Source Code Cross Referenced for ObjectNameManager.java in  » J2EE » spring-framework-2.5 » org » springframework » jmx » support » 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 » spring framework 2.5 » org.springframework.jmx.support 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002-2007 the original author or authors.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package org.springframework.jmx.support;
018:
019:        import java.util.Hashtable;
020:
021:        import javax.management.MalformedObjectNameException;
022:        import javax.management.ObjectName;
023:
024:        import org.springframework.util.ClassUtils;
025:
026:        /**
027:         * Helper class for the creation of {@link javax.management.ObjectName} instances.
028:         *
029:         * <p><code>ObjectName</code> instances will be cached on JMX 1.2,
030:         * whereas they will be recreated for each request on JMX 1.0.
031:         *
032:         * @author Rob Harrop
033:         * @author Juergen Hoeller
034:         * @since 1.2
035:         * @see javax.management.ObjectName#getInstance(String)
036:         */
037:        public class ObjectNameManager {
038:
039:            // Determine whether the JMX 1.2 <code>ObjectName.getInstance</code> method is available.
040:            private static final boolean getInstanceAvailable = ClassUtils
041:                    .hasMethod(ObjectName.class, "getInstance",
042:                            new Class[] { String.class });
043:
044:            /**
045:             * Retrieve the <code>ObjectName</code> instance corresponding to the supplied name.
046:             * @param objectName the <code>ObjectName</code> in <code>ObjectName</code> or
047:             * <code>String</code> format
048:             * @return the <code>ObjectName</code> instance
049:             * @throws MalformedObjectNameException in case of an invalid object name specification
050:             * @see ObjectName#ObjectName(String)
051:             * @see ObjectName#getInstance(String)
052:             */
053:            public static ObjectName getInstance(Object objectName)
054:                    throws MalformedObjectNameException {
055:                if (objectName instanceof  ObjectName) {
056:                    return (ObjectName) objectName;
057:                }
058:                if (!(objectName instanceof  String)) {
059:                    throw new MalformedObjectNameException(
060:                            "Invalid ObjectName value type ["
061:                                    + objectName.getClass().getName()
062:                                    + "]: only ObjectName and String supported.");
063:                }
064:                return getInstance((String) objectName);
065:            }
066:
067:            /**
068:             * Retrieve the <code>ObjectName</code> instance corresponding to the supplied name.
069:             * @param objectName the <code>ObjectName</code> in <code>String</code> format
070:             * @return the <code>ObjectName</code> instance
071:             * @throws MalformedObjectNameException in case of an invalid object name specification
072:             * @see ObjectName#ObjectName(String)
073:             * @see ObjectName#getInstance(String)
074:             */
075:            public static ObjectName getInstance(String objectName)
076:                    throws MalformedObjectNameException {
077:                if (getInstanceAvailable) {
078:                    return ObjectName.getInstance(objectName);
079:                } else {
080:                    return new ObjectName(objectName);
081:                }
082:            }
083:
084:            /**
085:             * Retrieve an <code>ObjectName</code> instance for the specified domain and a
086:             * single property with the supplied key and value.
087:             * @param domainName the domain name for the <code>ObjectName</code>
088:             * @param key the key for the single property in the <code>ObjectName</code>
089:             * @param value the value for the single property in the <code>ObjectName</code>
090:             * @return the <code>ObjectName</code> instance
091:             * @throws MalformedObjectNameException in case of an invalid object name specification
092:             * @see ObjectName#ObjectName(String, String, String)
093:             * @see ObjectName#getInstance(String, String, String)
094:             */
095:            public static ObjectName getInstance(String domainName, String key,
096:                    String value) throws MalformedObjectNameException {
097:
098:                if (getInstanceAvailable) {
099:                    return ObjectName.getInstance(domainName, key, value);
100:                } else {
101:                    return new ObjectName(domainName, key, value);
102:                }
103:            }
104:
105:            /**
106:             * Retrieve an <code>ObjectName</code> instance with the specified domain name
107:             * and the supplied key/name properties.
108:             * @param domainName the domain name for the <code>ObjectName</code>
109:             * @param properties the properties for the <code>ObjectName</code>
110:             * @return the <code>ObjectName</code> instance
111:             * @throws MalformedObjectNameException in case of an invalid object name specification
112:             * @see ObjectName#ObjectName(String, java.util.Hashtable)
113:             * @see ObjectName#getInstance(String, java.util.Hashtable)
114:             */
115:            public static ObjectName getInstance(String domainName,
116:                    Hashtable properties) throws MalformedObjectNameException {
117:
118:                if (getInstanceAvailable) {
119:                    return ObjectName.getInstance(domainName, properties);
120:                } else {
121:                    return new ObjectName(domainName, properties);
122:                }
123:            }
124:
125:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.