Source Code Cross Referenced for WebServicesObjectName.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » ws » mbean » 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 » JOnAS 4.8.6 » org.objectweb.jonas.ws.mbean 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999 Bull S.A.
004:         * Contact: jonas-team@objectweb.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id$
023:         * --------------------------------------------------------------------------
024:         */package org.objectweb.jonas.ws.mbean;
025:
026:        import java.util.Hashtable;
027:        import java.util.Iterator;
028:
029:        import javax.management.MalformedObjectNameException;
030:        import javax.management.ObjectName;
031:
032:        import org.objectweb.jonas.jmx.JmxService;
033:        import org.objectweb.jonas.service.ServiceManager;
034:
035:        /**
036:         * ToolKit for WebServices Mbeans. It Helps to create ObjectNames for the
037:         * WebServices MBeans, simplify MBeans queries, ...
038:         *
039:         * @author Guillaume Sauthier
040:         */
041:        public class WebServicesObjectName {
042:
043:            /**
044:             * WebService type property
045:             */
046:            public static final String WEBSERVICE_TYPE = "WebService";
047:
048:            /**
049:             * WebServicePortComponent type property
050:             */
051:            public static final String PORTCOMPONENT_TYPE = "WebServicePortComponent";
052:
053:            /**
054:             * WebServiceHandler type property
055:             */
056:            public static final String HANDLER_TYPE = "WebServiceHandler";
057:
058:            /**
059:             * j2eeType for EJB modules
060:             */
061:            public static final String EJBMODULE = "EJBModule";
062:
063:            /**
064:             * j2eeType for Web modules
065:             */
066:            public static final String WEBMODULE = "WebModule";
067:
068:            /**
069:             * j2eeType for ear
070:             */
071:            public static final String J2EEAPPLICATION = "J2EEApplication";
072:
073:            /**
074:             * j2eeType for server instance
075:             */
076:            public static final String J2EESERVER = "J2EEServer";
077:
078:            /**
079:             * domain name
080:             */
081:            private static String domain = null;
082:
083:            /**
084:             * Default private Constructor for tool class
085:             */
086:            private WebServicesObjectName() {
087:            }
088:
089:            /**
090:             * @return Returns the domain name of the JOnAS server.
091:             *
092:             * TODO refactor this out (duplicated code from J2eeObjectName)
093:             */
094:            private static String getDomain() {
095:                if (domain == null) {
096:                    try {
097:                        domain = ((JmxService) ServiceManager.getInstance()
098:                                .getJmxService()).getDomainName();
099:                    } catch (Exception e) {
100:                        // should never occurs
101:                        domain = null;
102:                    }
103:                }
104:                return domain;
105:            }
106:
107:            /**
108:             * @param name
109:             *            base ObjectName
110:             * @return Returns a String that contains "inherited" properties from
111:             *         parent's ObjectName
112:             */
113:            private static String getInheritedPropertiesAsString(ObjectName name) {
114:                Hashtable table = (Hashtable) name.getKeyPropertyList().clone();
115:                // we remove some attributes from the ObjectName
116:                table.remove("j2eeType");
117:                table.remove("type");
118:                table.remove("subtype");
119:                table.remove("name");
120:                StringBuffer sb = new StringBuffer();
121:                for (Iterator i = table.keySet().iterator(); i.hasNext();) {
122:                    String key = (String) i.next();
123:                    sb.append(key + "=" + table.get(key) + ",");
124:                }
125:                if (sb.length() > 1) {
126:                    // remove the trailing comma
127:                    sb.setLength(sb.length() - 1);
128:                }
129:                return sb.toString();
130:            }
131:
132:            /**
133:             * @return ObjectName for Service
134:             * @param name
135:             *            Service id
136:             * @param parent
137:             *            parent name
138:             * @exception MalformedObjectNameException
139:             *                Could not create ObjectName with the given String
140:             */
141:            public static ObjectName service(String name, ObjectName parent)
142:                    throws MalformedObjectNameException {
143:                String parentModule = "";
144:                if (parent.getKeyProperty("j2eeType").equals(EJBMODULE)) {
145:                    parentModule = EJBMODULE + "="
146:                            + parent.getKeyProperty("name");
147:                } else {
148:                    parentModule = WEBMODULE + "="
149:                            + parent.getKeyProperty("name");
150:                }
151:                return ObjectName.getInstance(getDomain()
152:                        + ":type=WebService,name=" + name + "," + parentModule
153:                        + "," + getInheritedPropertiesAsString(parent));
154:            }
155:
156:            /**
157:             * @return ObjectName for PortComponent
158:             * @param name
159:             *            PortComponent id
160:             * @param parent
161:             *            parent name
162:             * @exception MalformedObjectNameException
163:             *                Could not create ObjectName with the given String
164:             */
165:            public static ObjectName portComponent(String name,
166:                    ObjectName parent) throws MalformedObjectNameException {
167:                String parentModule = "";
168:                if (parent.getKeyProperty("type").equals(WEBSERVICE_TYPE)) {
169:                    parentModule = WEBSERVICE_TYPE + "="
170:                            + parent.getKeyProperty("name");
171:                }
172:                return ObjectName.getInstance(getDomain() + ":type="
173:                        + PORTCOMPONENT_TYPE + ",name=" + name + ","
174:                        + parentModule + ","
175:                        + getInheritedPropertiesAsString(parent));
176:            }
177:
178:            /**
179:             * @return Returns the ObjectName for PortComponent
180:             * @param name PortComponent id
181:             * @param parent parent name
182:             * @exception MalformedObjectNameException
183:             *                Could not create ObjectName with the given String
184:             */
185:            public static ObjectName handler(String name, ObjectName parent)
186:                    throws MalformedObjectNameException {
187:                String parentModule = "";
188:                if (parent.getKeyProperty("type").equals(PORTCOMPONENT_TYPE)) {
189:                    parentModule = PORTCOMPONENT_TYPE + "="
190:                            + parent.getKeyProperty("name");
191:                }
192:                return ObjectName.getInstance(getDomain() + ":type="
193:                        + HANDLER_TYPE + ",name=" + name + "," + parentModule
194:                        + "," + getInheritedPropertiesAsString(parent));
195:            }
196:
197:            /**
198:             * @param parent parent ObjectName (J2EEApplication or J2EEModule subtype)
199:             * @param ejbName SSB name
200:             * @return Returns a Query ObjectName used to find a StatelessSessionBean
201:             *  coming from a particular J2EEApplication/J2EEModule
202:             */
203:            public static ObjectName getStatelessSessionBeanQuery(
204:                    ObjectName parent, String ejbName) {
205:                try {
206:                    StringBuffer sb = new StringBuffer(parent.getDomain());
207:                    sb.append(":j2eeType=StatelessSessionBean");
208:                    sb.append(",name=");
209:                    sb.append(ejbName);
210:                    sb.append(",J2EEApplication=");
211:                    if (parent.getKeyProperty("J2EEApplication") != null) {
212:                        // parent MBean maybe is not a J2EEApplication, but an EJBModule
213:                        sb.append(parent.getKeyProperty("J2EEApplication"));
214:                    } else {
215:                        sb.append(parent.getKeyProperty("name"));
216:                    }
217:                    sb.append(",J2EEServer=");
218:                    sb.append(parent.getKeyProperty("J2EEServer"));
219:                    sb.append(",*");
220:                    return new ObjectName(sb.toString());
221:                } catch (javax.management.MalformedObjectNameException e) {
222:                    // this should never occur
223:                    return null;
224:                }
225:            }
226:
227:            /**
228:             * @param parent parent J2EEApplication's ObjectName
229:             * @param servletName servlet name
230:             * @return Returns a Query ObjectName used to find a Servlet
231:             *  coming from a particular J2EEApplication
232:             */
233:            public static ObjectName getServletQuery(ObjectName parent,
234:                    String servletName) {
235:                try {
236:                    StringBuffer sb = new StringBuffer(parent.getDomain());
237:                    sb.append(":j2eeType=Servlet");
238:                    sb.append(",name=");
239:                    sb.append(servletName);
240:                    sb.append(",J2EEApplication=");
241:                    if (parent.getKeyProperty("J2EEApplication") != null) {
242:                        // parent MBean maybe is not a J2EEApplication, but an WebModule
243:                        sb.append(parent.getKeyProperty("J2EEApplication"));
244:                    } else {
245:                        sb.append(parent.getKeyProperty("name"));
246:                    }
247:                    sb.append(",J2EEServer=");
248:                    sb.append(parent.getKeyProperty("J2EEServer"));
249:                    sb.append(",*");
250:                    return new ObjectName(sb.toString());
251:                } catch (javax.management.MalformedObjectNameException e) {
252:                    // this should never occur
253:                    return null;
254:                }
255:            }
256:
257:            /**
258:             * @param ear parent J2EEApplication's ObjectName
259:             * @param key EJBModule name
260:             * @return Returns a Query ObjectName used to find an EJBModule
261:             *  coming from a particular J2EEApplication
262:             */
263:            public static ObjectName getEJBModule(ObjectName ear, String key) {
264:                try {
265:                    StringBuffer sb = new StringBuffer(ear.getDomain());
266:                    sb.append(":j2eeType=EJBModule");
267:                    sb.append(",name=");
268:                    sb.append(key);
269:                    sb.append(",J2EEApplication=");
270:                    sb.append(ear.getKeyProperty("name"));
271:                    sb.append(",J2EEServer=");
272:                    sb.append(ear.getKeyProperty("J2EEServer"));
273:                    sb.append(",*");
274:                    return new ObjectName(sb.toString());
275:                } catch (javax.management.MalformedObjectNameException e) {
276:                    // this should never occur
277:                    return null;
278:                }
279:            }
280:
281:            /**
282:             * @param ear parent J2EEApplication's ObjectName
283:             * @param key WebModule name
284:             * @return Returns a Query ObjectName used to find an WebModule
285:             *  coming from a particular J2EEApplication
286:             */
287:            public static ObjectName getWebModule(ObjectName ear, String key) {
288:                try {
289:                    StringBuffer sb = new StringBuffer(ear.getDomain());
290:                    sb.append(":j2eeType=WebModule");
291:                    sb.append(",name=");
292:                    sb.append(key);
293:                    sb.append(",J2EEApplication=");
294:                    sb.append(ear.getKeyProperty("name"));
295:                    sb.append(",J2EEServer=");
296:                    sb.append(ear.getKeyProperty("J2EEServer"));
297:                    sb.append(",*");
298:                    return new ObjectName(sb.toString());
299:                } catch (javax.management.MalformedObjectNameException e) {
300:                    // this should never occur
301:                    return null;
302:                }
303:            }
304:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.