Source Code Cross Referenced for JSR77_Util.java in  » EJB-Server-geronimo » plugins » org » apache » geronimo » console » configcreator » 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 » EJB Server geronimo » plugins » org.apache.geronimo.console.configcreator 
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.geronimo.console.configcreator;
017:
018:        import java.util.ArrayList;
019:        import java.util.Iterator;
020:        import java.util.List;
021:        import java.util.SortedSet;
022:
023:        import javax.management.MalformedObjectNameException;
024:        import javax.management.ObjectName;
025:        import javax.portlet.PortletRequest;
026:
027:        import org.apache.geronimo.console.util.PortletManager;
028:        import org.apache.geronimo.gbean.AbstractName;
029:        import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
030:        import org.apache.geronimo.kernel.repository.ListableRepository;
031:        import org.apache.geronimo.management.EJBModule;
032:        import org.apache.geronimo.management.J2EEResource;
033:        import org.apache.geronimo.management.geronimo.JCAAdminObject;
034:        import org.apache.geronimo.management.geronimo.JCAManagedConnectionFactory;
035:        import org.apache.geronimo.management.geronimo.ResourceAdapterModule;
036:        import org.apache.geronimo.management.geronimo.SecurityRealm;
037:
038:        /**
039:         * Util class for JSR-77 related functions
040:         * 
041:         * @version $Rev: 593590 $ $Date: 2007-11-09 08:53:02 -0800 (Fri, 09 Nov 2007) $
042:         */
043:        public class JSR77_Util {
044:
045:            public static class ReferredData {
046:                private String displayName;
047:
048:                private String patternName;
049:
050:                public ReferredData(String displayName, String patternName) {
051:                    this .displayName = displayName;
052:                    this .patternName = patternName;
053:                }
054:
055:                public String getDisplayName() {
056:                    return displayName;
057:                }
058:
059:                public void setDisplayName(String displayName) {
060:                    this .displayName = displayName;
061:                }
062:
063:                public String getPatternName() {
064:                    return patternName;
065:                }
066:
067:                public void setPatternName(String patternName) {
068:                    this .patternName = patternName;
069:                }
070:            }
071:
072:            protected static List getDeployedEJBs(PortletRequest request) {
073:                List ejbList = new ArrayList();
074:                EJBModule[] ejbModules = PortletManager.getManagementHelper(
075:                        request).getEJBModules(
076:                        PortletManager.getCurrentServer(request));
077:                for (int i = 0; ejbModules != null && i < ejbModules.length; i++) {
078:                    String[] ejbObjectNames = ejbModules[i].getEjbs();
079:                    for (int j = 0; j < ejbObjectNames.length; j++) {
080:                        try {
081:                            ObjectName objectName = ObjectName
082:                                    .getInstance(ejbObjectNames[j]);
083:                            String ejbName = objectName
084:                                    .getKeyProperty(NameFactory.J2EE_NAME);
085:                            String configurationName;
086:                            if ("null"
087:                                    .equalsIgnoreCase(objectName
088:                                            .getKeyProperty(NameFactory.J2EE_APPLICATION))) {
089:                                configurationName = objectName
090:                                        .getKeyProperty(NameFactory.EJB_MODULE)
091:                                        + "/";
092:                            } else {
093:                                configurationName = objectName
094:                                        .getKeyProperty(NameFactory.J2EE_APPLICATION)
095:                                        + "/"
096:                                        + objectName
097:                                                .getKeyProperty(NameFactory.EJB_MODULE);
098:                            }
099:                            ReferredData data = new ReferredData(ejbName + " ("
100:                                    + configurationName + ")",
101:                                    configurationName + "/" + ejbName);
102:                            ejbList.add(data);
103:                        } catch (MalformedObjectNameException e) {
104:                            // log.error(e.getMessage(), e);
105:                            e.printStackTrace();
106:                        } catch (NullPointerException e) {
107:                            // log.error(e.getMessage(), e);
108:                            e.printStackTrace();
109:                        }
110:                    }
111:                }
112:                return ejbList;
113:            }
114:
115:            protected static List getJMSConnectionFactories(
116:                    PortletRequest request) {
117:                // TODO this is a duplicate of the code from
118:                // org.apache.geronimo.console.jmsmanager.wizard.ListScreenHandler.populateExistingList()
119:                // TODO need to eliminate this duplicate code probably by putting it in a common place
120:                List connectionFactories = new ArrayList();
121:
122:                // Get the list of connection factories
123:                ResourceAdapterModule[] modules = PortletManager
124:                        .getOutboundRAModules(request, new String[] {
125:                                "javax.jms.ConnectionFactory",
126:                                "javax.jms.QueueConnectionFactory",
127:                                "javax.jms.TopicConnectionFactory", });
128:                try {
129:                    for (int i = 0; i < modules.length; i++) {
130:                        ResourceAdapterModule module = modules[i];
131:                        String configurationName = PortletManager
132:                                .getConfigurationFor(
133:                                        request,
134:                                        PortletManager.getNameFor(request,
135:                                                module)).toString()
136:                                + "/";
137:
138:                        JCAManagedConnectionFactory[] factories = PortletManager
139:                                .getOutboundFactoriesForRA(
140:                                        request,
141:                                        module,
142:                                        new String[] {
143:                                                "javax.jms.ConnectionFactory",
144:                                                "javax.jms.QueueConnectionFactory",
145:                                                "javax.jms.TopicConnectionFactory", });
146:                        for (int j = 0; j < factories.length; j++) {
147:                            JCAManagedConnectionFactory factory = factories[j];
148:                            String factoryName = ObjectName.getInstance(
149:                                    factory.getObjectName()).getKeyProperty(
150:                                    NameFactory.J2EE_NAME);
151:                            ReferredData data = new ReferredData(factoryName
152:                                    + " (" + configurationName + ")",
153:                                    configurationName + "/" + factoryName);
154:                            connectionFactories.add(data);
155:                        }
156:                    }
157:                } catch (MalformedObjectNameException e) {
158:                    // log.error(e.getMessage(), e);
159:                }
160:                return connectionFactories;
161:            }
162:
163:            protected static List getJMSDestinations(PortletRequest request) {
164:                // TODO this is a duplicate of the code from
165:                // org.apache.geronimo.console.jmsmanager.wizard.ListScreenHandler.populateExistingList()
166:                // TODO need to eliminate this duplicate code probably by putting it in a common place
167:                List jmsDestinations = new ArrayList();
168:
169:                // Get the list of connection factories
170:                ResourceAdapterModule[] modules = PortletManager
171:                        .getOutboundRAModules(request, new String[] {
172:                                "javax.jms.ConnectionFactory",
173:                                "javax.jms.QueueConnectionFactory",
174:                                "javax.jms.TopicConnectionFactory", });
175:                try {
176:                    for (int i = 0; i < modules.length; i++) {
177:                        ResourceAdapterModule module = modules[i];
178:                        String configurationName = PortletManager
179:                                .getConfigurationFor(
180:                                        request,
181:                                        PortletManager.getNameFor(request,
182:                                                module)).toString()
183:                                + "/";
184:
185:                        JCAAdminObject[] admins = PortletManager
186:                                .getAdminObjectsForRA(request, module,
187:                                        new String[] { "javax.jms.Queue",
188:                                                "javax.jms.Topic" });
189:                        for (int j = 0; j < admins.length; j++) {
190:                            JCAAdminObject admin = admins[j];
191:                            String destinationName = ObjectName.getInstance(
192:                                    admin.getObjectName()).getKeyProperty(
193:                                    NameFactory.J2EE_NAME);
194:                            ReferredData data = new ReferredData(
195:                                    destinationName + " (" + configurationName
196:                                            + ")", configurationName + "/"
197:                                            + destinationName);
198:                            jmsDestinations.add(data);
199:                        }
200:                    }
201:                } catch (MalformedObjectNameException e) {
202:                    // log.error(e.getMessage(), e);
203:                }
204:                return jmsDestinations;
205:            }
206:
207:            protected static List getJDBCConnectionPools(PortletRequest request) {
208:                // TODO this is a duplicate of the code from
209:                // org.apache.geronimo.console.databasemanager.wizard.DatabasePoolPortlet.populatePoolList()
210:                // TODO need to eliminate this duplicate code probably by putting it in a common place
211:                List list = new ArrayList();
212:                ResourceAdapterModule[] modules = PortletManager
213:                        .getOutboundRAModules(request, "javax.sql.DataSource");
214:                for (int i = 0; i < modules.length; i++) {
215:                    ResourceAdapterModule module = modules[i];
216:                    JCAManagedConnectionFactory[] databases = PortletManager
217:                            .getOutboundFactoriesForRA(request, module,
218:                                    "javax.sql.DataSource");
219:                    for (int j = 0; j < databases.length; j++) {
220:                        JCAManagedConnectionFactory db = databases[j];
221:                        AbstractName dbName = PortletManager
222:                                .getManagementHelper(request).getNameFor(db);
223:                        String poolName = (String) dbName.getName().get(
224:                                NameFactory.J2EE_NAME);
225:                        String configurationName = dbName.getArtifact()
226:                                .toString()
227:                                + "/";
228:                        ReferredData data = new ReferredData(poolName + " ("
229:                                + configurationName + ")", configurationName
230:                                + "/" + poolName);
231:                        list.add(data);
232:                    }
233:                }
234:                return list;
235:            }
236:
237:            protected static List getJavaMailSessions(PortletRequest request) {
238:                List mailSessionList = new ArrayList();
239:                J2EEResource[] j2eeResources = PortletManager
240:                        .getManagementHelper(request).getResources(
241:                                PortletManager.getCurrentServer(request));
242:                for (int i = 0; i < j2eeResources.length; i++) {
243:                    try {
244:                        ObjectName objectName = ObjectName
245:                                .getInstance(j2eeResources[i].getObjectName());
246:                        if (NameFactory.JAVA_MAIL_RESOURCE.equals(objectName
247:                                .getKeyProperty(NameFactory.J2EE_TYPE))) {
248:                            String mailSesssionName = objectName
249:                                    .getKeyProperty(NameFactory.J2EE_NAME);
250:                            String configurationName = objectName
251:                                    .getKeyProperty(NameFactory.SERVICE_MODULE)
252:                                    + "/";
253:                            ReferredData data = new ReferredData(
254:                                    mailSesssionName + " (" + configurationName
255:                                            + ")", configurationName + "/"
256:                                            + mailSesssionName);
257:                            mailSessionList.add(data);
258:                        }
259:                    } catch (MalformedObjectNameException e) {
260:                        // log.error(e.getMessage(), e);
261:                        e.printStackTrace();
262:                    } catch (NullPointerException e) {
263:                        // log.error(e.getMessage(), e);
264:                        e.printStackTrace();
265:                    }
266:                }
267:                return mailSessionList;
268:            }
269:
270:            protected static List getDeployedCredentialStores(
271:                    PortletRequest request) {
272:                List credentialStoreList = new ArrayList();
273:                Object[] objects = PortletManager
274:                        .getGBeansImplementing(
275:                                request,
276:                                org.apache.geronimo.security.credentialstore.CredentialStore.class);
277:                for (int i = 0; i < objects.length; i++) {
278:                    ObjectName objectName = PortletManager.getNameFor(request,
279:                            objects[i]).getObjectName();
280:                    String credentialStoreName = objectName
281:                            .getKeyProperty(NameFactory.J2EE_NAME);
282:                    String configurationName = objectName
283:                            .getKeyProperty(NameFactory.SERVICE_MODULE)
284:                            + "/";
285:                    ReferredData data = new ReferredData(credentialStoreName
286:                            + " (" + configurationName + ")", configurationName
287:                            + "/" + credentialStoreName);
288:                    credentialStoreList.add(data);
289:                }
290:                return credentialStoreList;
291:            }
292:
293:            protected static List getCommonLibs(PortletRequest request) {
294:                // TODO this is a duplicate of the code from
295:                // org.apache.geronimo.console.repository.RepositoryViewPortlet.doView()
296:                // TODO need to eliminate this duplicate code probably by putting it in a common place
297:                List list = new ArrayList();
298:                ListableRepository[] repos = PortletManager.getCurrentServer(
299:                        request).getRepositories();
300:                for (int i = 0; i < repos.length; i++) {
301:                    ListableRepository repo = repos[i];
302:                    final SortedSet artifacts = repo.list();
303:                    for (Iterator iterator = artifacts.iterator(); iterator
304:                            .hasNext();) {
305:                        String fileName = iterator.next().toString();
306:                        list.add(fileName);
307:                    }
308:                }
309:                return list;
310:            }
311:
312:            public static SecurityRealm[] getDeployedSecurityRealms(
313:                    PortletRequest request) {
314:                return PortletManager.getCurrentServer(request)
315:                        .getSecurityRealms();
316:            }
317:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.