Source Code Cross Referenced for WebLogicJndiMBeanServerFactoryBean.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.lang.reflect.InvocationTargetException;
020:
021:        import javax.management.MBeanServer;
022:        import javax.naming.NamingException;
023:
024:        import org.springframework.beans.factory.FactoryBean;
025:        import org.springframework.beans.factory.InitializingBean;
026:        import org.springframework.jmx.MBeanServerNotFoundException;
027:        import org.springframework.jndi.JndiLocatorSupport;
028:
029:        /**
030:         * FactoryBean that obtains a specified WebLogic {@link javax.management.MBeanServer}
031:         * reference through a WebLogic <code>MBeanHome</code> obtained via a JNDI lookup.
032:         * By default, the server's local <code>MBeanHome</code> will be obtained.
033:         *
034:         * <p>Exposes the <code>MBeanServer</code> for bean references.
035:         * This FactoryBean is a direct alternative to {@link MBeanServerFactoryBean},
036:         * which uses standard JMX 1.2 API to access the platform's MBeanServer.
037:         *
038:         * <p>Note: There is also a more general {@link WebLogicMBeanServerFactoryBean}
039:         * for accessing any specified WebLogic <code>MBeanServer</code>,
040:         * potentially a remote one.
041:         *
042:         * <p><b>NOTE: This class is only intended for use with WebLogic 8.1.</b>
043:         * On WebLogic 9.x, simply obtain the MBeanServer directly from the JNDI location
044:         * "java:comp/env/jmx/runtime", for example through the following configuration:
045:         *
046:         * <pre>
047:         * &lt;bean class="org.springframework.jndi.JndiObjectFactoryBean"&gt;
048:         *   &lt;property name="jndiName" value="java:comp/env/jmx/runtime"/&gt;
049:         * &lt;/bean&gt;</pre>
050:         *
051:         * @author Rob Harrop
052:         * @author Juergen Hoeller
053:         * @since 1.2.6
054:         * @see weblogic.management.MBeanHome#LOCAL_JNDI_NAME
055:         * @see weblogic.management.MBeanHome#getMBeanServer()
056:         * @see javax.management.MBeanServer
057:         * @see MBeanServerFactoryBean
058:         * @see WebLogicMBeanServerFactoryBean
059:         */
060:        public class WebLogicJndiMBeanServerFactoryBean extends
061:                JndiLocatorSupport implements  FactoryBean, InitializingBean {
062:
063:            private static final String WEBLOGIC_MBEAN_HOME_CLASS = "weblogic.management.MBeanHome";
064:
065:            private static final String LOCAL_JNDI_NAME_FIELD = "LOCAL_JNDI_NAME";
066:
067:            private static final String GET_MBEAN_SERVER_METHOD = "getMBeanServer";
068:
069:            private String mbeanHomeName;
070:
071:            private MBeanServer mbeanServer;
072:
073:            /**
074:             * Specify the JNDI name of the WebLogic MBeanHome object to use
075:             * for creating the JMX MBeanServer reference.
076:             * <p>Default is <code>MBeanHome.LOCAL_JNDI_NAME</code>
077:             * @see weblogic.management.MBeanHome#LOCAL_JNDI_NAME
078:             */
079:            public void setMbeanHomeName(String mbeanHomeName) {
080:                this .mbeanHomeName = mbeanHomeName;
081:            }
082:
083:            public void afterPropertiesSet()
084:                    throws MBeanServerNotFoundException {
085:                try {
086:                    String jndiName = this .mbeanHomeName;
087:                    if (jndiName == null) {
088:                        /*
089:                         * jndiName = MBeanHome.LOCAL_JNDI_NAME;
090:                         */
091:                        Class mbeanHomeClass = getClass().getClassLoader()
092:                                .loadClass(WEBLOGIC_MBEAN_HOME_CLASS);
093:                        jndiName = (String) mbeanHomeClass.getField(
094:                                LOCAL_JNDI_NAME_FIELD).get(null);
095:                    }
096:                    Object mbeanHome = lookup(jndiName);
097:
098:                    /*
099:                     * this.mbeanServer = mbeanHome.getMBeanServer();
100:                     */
101:                    this .mbeanServer = (MBeanServer) mbeanHome.getClass()
102:                            .getMethod(GET_MBEAN_SERVER_METHOD, null).invoke(
103:                                    mbeanHome, null);
104:                } catch (NamingException ex) {
105:                    throw new MBeanServerNotFoundException(
106:                            "Could not find WebLogic's MBeanHome object in JNDI",
107:                            ex);
108:                } catch (ClassNotFoundException ex) {
109:                    throw new MBeanServerNotFoundException(
110:                            "Could not find WebLogic's MBeanHome class", ex);
111:                } catch (InvocationTargetException ex) {
112:                    throw new MBeanServerNotFoundException(
113:                            "WebLogic's MBeanHome.getMBeanServer method failed",
114:                            ex.getTargetException());
115:                } catch (Exception ex) {
116:                    throw new MBeanServerNotFoundException(
117:                            "Could not access WebLogic's MBeanHome/getMBeanServer method",
118:                            ex);
119:                }
120:            }
121:
122:            public Object getObject() {
123:                return this .mbeanServer;
124:            }
125:
126:            public Class getObjectType() {
127:                return (this .mbeanServer != null ? this .mbeanServer.getClass()
128:                        : MBeanServer.class);
129:            }
130:
131:            public boolean isSingleton() {
132:                return true;
133:            }
134:
135:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.