Source Code Cross Referenced for DeploymentListBean.java in  » J2EE » openejb3 » org » apache » openejb » webadmin » main » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » openejb3 » org.apache.openejb.webadmin.main 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */package org.apache.openejb.webadmin.main;
017:
018:        import java.io.IOException;
019:        import java.io.PrintWriter;
020:        import java.util.Arrays;
021:        import java.util.HashMap;
022:        import java.util.List;
023:
024:        import org.apache.openejb.DeploymentInfo;
025:        import org.apache.openejb.OpenEJB;
026:        import org.apache.openejb.core.CoreDeploymentInfo;
027:        import org.apache.openejb.spi.ContainerSystem;
028:        import org.apache.openejb.loader.SystemInstance;
029:        import org.apache.openejb.webadmin.HttpRequest;
030:        import org.apache.openejb.webadmin.HttpResponse;
031:        import org.apache.openejb.webadmin.WebAdminBean;
032:        import org.apache.openejb.webadmin.HttpHome;
033:        import org.apache.openejb.assembler.classic.EjbReferenceInfo;
034:        import org.apache.openejb.assembler.classic.EnterpriseBeanInfo;
035:        import org.apache.openejb.assembler.classic.EnvEntryInfo;
036:        import org.apache.openejb.assembler.classic.JndiEncInfo;
037:        import org.apache.openejb.assembler.classic.ResourceReferenceInfo;
038:        import org.apache.openejb.assembler.classic.OpenEjbConfiguration;
039:        import org.apache.openejb.assembler.classic.AppInfo;
040:        import org.apache.openejb.assembler.classic.EjbJarInfo;
041:        import org.apache.openejb.assembler.classic.EjbLocalReferenceInfo;
042:        import org.apache.openejb.assembler.classic.ResourceEnvReferenceInfo;
043:        import org.apache.openejb.assembler.classic.PersistenceUnitReferenceInfo;
044:        import org.apache.openejb.assembler.classic.PersistenceContextReferenceInfo;
045:        import org.apache.openejb.assembler.classic.ServiceReferenceInfo;
046:        import org.apache.openejb.util.StringUtilities;
047:
048:        import javax.ejb.Stateless;
049:        import javax.ejb.RemoteHome;
050:
051:        /**
052:         * A bean which lists all deployed beans.
053:         * 
054:         * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
055:         * @author <a href="mailto:tim_urberg@yahoo.com">Tim Urberg</a>
056:         */
057:        @Stateless(name="Webadmin/DeploymentList")
058:        @RemoteHome(HttpHome.class)
059:        public class DeploymentListBean extends WebAdminBean {
060:            private HashMap deploymentIdIndex;
061:            private HashMap containerIdIndex;
062:
063:            /** Creates a new instance of DeploymentListBean */
064:            public void ejbCreate() {
065:                this .section = "DeploymentList";
066:            }
067:
068:            /** called after all content is written to the browser
069:             * @param request the http request
070:             * @param response the http response
071:             * @throws IOException if an exception is thrown
072:             *
073:             */
074:            public void postProcess(HttpRequest request, HttpResponse response)
075:                    throws IOException {
076:            }
077:
078:            /** called before any content is written to the browser
079:             * @param request the http request
080:             * @param response the http response
081:             * @throws IOException if an exception is thrown
082:             *
083:             */
084:            public void preProcess(HttpRequest request, HttpResponse response)
085:                    throws IOException {
086:                createIndexes();
087:            }
088:
089:            /** writes the main body content to the broswer.  This content is inside a <code>&lt;p&gt;</code> block
090:             *
091:             *
092:             * @param body the output to write to
093:             * @exception IOException if an exception is thrown
094:             *
095:             */
096:            public void writeBody(PrintWriter body) throws IOException {
097:                String id = request.getQueryParameter("id");
098:                if (id != null) {
099:                    showDeployment(body, id);
100:                } else {
101:                    printDeployments(body);
102:                }
103:            }
104:
105:            private void createIndexes() {
106:                deploymentIdIndex = new HashMap();
107:                containerIdIndex = new HashMap();
108:                OpenEjbConfiguration configuration = SystemInstance.get()
109:                        .getComponent(OpenEjbConfiguration.class);
110:                for (AppInfo appInfo : configuration.containerSystem.applications) {
111:                    for (EjbJarInfo ejbJarInfo : appInfo.ejbJars) {
112:                        for (EnterpriseBeanInfo bean : ejbJarInfo.enterpriseBeans) {
113:                            deploymentIdIndex.put(bean.ejbDeploymentId, bean);
114:                        }
115:                    }
116:                }
117:            }
118:
119:            private void showDeployment(PrintWriter body, String id)
120:                    throws IOException {
121:                EnterpriseBeanInfo bean = getBeanInfo(id);
122:
123:                // TODO:0: Inform the user the id is bad
124:                if (bean == null)
125:                    return;
126:
127:                // Assuming things are good        
128:                body = response.getPrintWriter();
129:
130:                body.println("<h2>General</h2><br>");
131:                body.println("<table width=\"100%\" border=\"1\">");
132:                body.println("<tr bgcolor=\"#5A5CB8\">");
133:                body
134:                        .println("<td><font face=\"arial\" color=\"white\">ID</font></td>");
135:                body
136:                        .println("<td><font color=\"white\">" + id
137:                                + "</font></td>");
138:                body.println("</tr>");
139:
140:                SystemInstance system = SystemInstance.get();
141:                ContainerSystem containerSystem = system
142:                        .getComponent(ContainerSystem.class);
143:
144:                CoreDeploymentInfo di = (CoreDeploymentInfo) containerSystem
145:                        .getDeploymentInfo(id);
146:
147:                printRow("Name", bean.ejbName, body);
148:                printRow(
149:                        "Description",
150:                        StringUtilities
151:                                .replaceNullOrBlankStringWithNonBreakingSpace(bean.description),
152:                        body);
153:
154:                String type = null;
155:
156:                switch (di.getComponentType()) {
157:                case CMP_ENTITY:
158:                    type = "EntityBean with Container-Managed Persistence";
159:                    break;
160:                case BMP_ENTITY:
161:                    type = "EntityBean with Bean-Managed Persistence";
162:                    break;
163:                case STATEFUL:
164:                    type = "Stateful SessionBean";
165:                    break;
166:                case STATELESS:
167:                    type = "Stateless SessionBean";
168:                    break;
169:                default:
170:                    type = "Unkown Bean Type";
171:                    break;
172:                }
173:
174:                printRow("Bean Type", type, body);
175:                printRow("Bean Class", bean.ejbClass, body);
176:                printRow("Home Interface", bean.home, body);
177:                printRow("Remote Interface", bean.remote, body);
178:                printRow("Jar location", bean.codebase, body);
179:
180:                //String container = URLEncoder.encode("" + di.getContainer().getContainerID());
181:                String container = (String) di.getContainer().getContainerID();
182:                printRow("Deployed in", container, body);
183:
184:                body.println("</table>");
185:
186:                JndiEncInfo enc = bean.jndiEnc;
187:
188:                body.println("<h2>JNDI Environment Details</h2><br>");
189:                body.println("<table width=\"100%\" border=\"1\">");
190:                body.println("<tr bgcolor=\"#5A5CB8\">");
191:                body
192:                        .println("<td><font face=\"arial\" color=\"white\">JNDI Name</font></td>");
193:                body
194:                        .println("<td><font face=\"arial\" color=\"white\">Value</font></td>");
195:                body
196:                        .println("<td><font face=\"arial\" color=\"white\">Type</font></td>");
197:                body.println("</tr>");
198:
199:                for (EnvEntryInfo info : enc.envEntries) {
200:                    printRow(info.name, info.value, info.type, body);
201:                }
202:
203:                for (EjbLocalReferenceInfo info : enc.ejbLocalReferences) {
204:                    printRow(info.referenceName, info.ejbDeploymentId,
205:                            info.homeType, body);
206:                }
207:
208:                for (EjbReferenceInfo info : enc.ejbReferences) {
209:                    printRow(info.referenceName, info.ejbDeploymentId,
210:                            info.homeType, body);
211:                }
212:
213:                for (ResourceReferenceInfo info : enc.resourceRefs) {
214:                    printRow(info.referenceName, info.resourceID,
215:                            info.referenceType, body);
216:                }
217:
218:                for (ResourceEnvReferenceInfo info : enc.resourceEnvRefs) {
219:                    printRow(info.resourceEnvRefName, info.resourceID,
220:                            info.resourceEnvRefType, body);
221:                }
222:
223:                for (PersistenceUnitReferenceInfo info : enc.persistenceUnitRefs) {
224:                    printRow(info.referenceName, info.persistenceUnitName, "",
225:                            body);
226:                }
227:
228:                for (PersistenceContextReferenceInfo info : enc.persistenceContextRefs) {
229:                    printRow(info.referenceName, info.persistenceUnitName, "",
230:                            body);
231:                }
232:
233:                for (ServiceReferenceInfo info : enc.serviceRefs) {
234:                    printRow(info.referenceName, "<not-supported>", "", body);
235:                }
236:
237:                body.println("</table>");
238:            }
239:
240:            private EnterpriseBeanInfo getBeanInfo(String id) {
241:                return (EnterpriseBeanInfo) deploymentIdIndex.get(id);
242:            }
243:
244:            private void printDeployments(PrintWriter out) throws IOException {
245:                SystemInstance system = SystemInstance.get();
246:                ContainerSystem containerSystem = system
247:                        .getComponent(ContainerSystem.class);
248:
249:                DeploymentInfo[] deployments = containerSystem.deployments();
250:                String[] deploymentString = new String[deployments.length];
251:                out.println("<table width=\"100%\" border=\"1\">");
252:                out.println("<tr bgcolor=\"#5A5CB8\">");
253:                out
254:                        .println("<td><font color=\"white\">Deployment ID</font></td>");
255:                out.println("</tr>");
256:
257:                if (deployments.length > 0) {
258:                    for (int i = 0; i < deployments.length; i++) {
259:                        deploymentString[i] = (String) deployments[i]
260:                                .getDeploymentID();
261:                    }
262:                    Arrays.sort(deploymentString);
263:
264:                    for (int i = 0; i < deploymentString.length; i++) {
265:                        if (i % 2 == 1) {
266:                            out.println("<tr bgcolor=\"#c9c5fe\">");
267:                        } else {
268:                            out.println("<tr>");
269:                        }
270:
271:                        out.print("<td><span class=\"bodyBlack\">");
272:                        out.print("<a href=\"DeploymentList?id="
273:                                + deploymentString[i] + "\">");
274:                        out.print(deploymentString[i]);
275:                        out.print("</a>");
276:                        out.println("</span></td></tr>");
277:                    }
278:                }
279:                out.println("</table>");
280:            }
281:
282:            /** Write the TITLE of the HTML document.  This is the part
283:             * that goes into the <code>&lt;head&gt;&lt;title&gt;
284:             * &lt;/title&gt;&lt;/head&gt;</code> tags
285:             *
286:             * @param body the output to write to
287:             * @exception IOException of an exception is thrown
288:             *
289:             */
290:            public void writeHtmlTitle(PrintWriter body) throws IOException {
291:                body.println(HTML_TITLE);
292:            }
293:
294:            /** Write the title of the page.  This is displayed right
295:             * above the main block of content.
296:             *
297:             * @param body the output to write to
298:             * @exception IOException if an exception is thrown
299:             *
300:             */
301:            public void writePageTitle(PrintWriter body) throws IOException {
302:                body.println("EnterpriseBean Details");
303:            }
304:
305:            /** Write the sub items for this bean in the left navigation bar of
306:             * the page.  This should look somthing like the one below:
307:             *
308:             *      <code>
309:             *      &lt;tr&gt;
310:             *       &lt;td valign="top" align="left"&gt;
311:             *        &lt;a href="system?show=deployments"&gt;&lt;span class="subMenuOff"&gt;
312:             *        &nbsp;&nbsp;&nbsp;Deployments
313:             *        &lt;/span&gt;
314:             *        &lt;/a&gt;&lt;/td&gt;
315:             *      &lt;/tr&gt;
316:             *      </code>
317:             *
318:             * Alternately, the bean can use the method formatSubMenuItem(..) which
319:             * will create HTML like the one above
320:             *
321:             * @param body the output to write to
322:             * @exception IOException if an exception is thrown
323:             *
324:             */
325:            public void writeSubMenuItems(PrintWriter body) throws IOException {
326:            }
327:
328:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.