Source Code Cross Referenced for WebLogicMBeanServerFactoryBean.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:
023:        import org.springframework.beans.factory.FactoryBean;
024:        import org.springframework.beans.factory.InitializingBean;
025:        import org.springframework.jmx.MBeanServerNotFoundException;
026:
027:        /**
028:         * FactoryBean that obtains a specified WebLogic {@link javax.management.MBeanServer}
029:         * reference through WebLogic's proprietary <code>Helper</code> /
030:         * <code>MBeanHome</code> API, which is available on WebLogic 6.1 and higher.
031:         *
032:         * <p>Exposes the <code>MBeanServer</code> for bean references.
033:         * This FactoryBean is a direct alternative to {@link MBeanServerFactoryBean},
034:         * which uses standard JMX 1.2 API to access the platform's MBeanServer.
035:         *
036:         * <p>Note: There is also a {@link WebLogicJndiMBeanServerFactoryBean} for
037:         * accessing the WebLogic <code>MBeanServer</code> instance through a WebLogic
038:         * <code>MBeanHome</code> obtained via a JNDI lookup, typical a local one.
039:         *
040:         * <p><b>NOTE: This class is only intended for use with WebLogic up to 8.1.</b>
041:         * On WebLogic 9.x, simply obtain the MBeanServer directly from the JNDI location
042:         * "java:comp/env/jmx/runtime", for example through the following configuration:
043:         *
044:         * <pre>
045:         * &lt;bean class="org.springframework.jndi.JndiObjectFactoryBean"&gt;
046:         *   &lt;property name="jndiName" value="java:comp/env/jmx/runtime"/&gt;
047:         * &lt;/bean&gt;</pre>
048:         *
049:         * @author Rob Harrop
050:         * @author Juergen Hoeller
051:         * @since 1.2
052:         * @see weblogic.management.Helper#getMBeanHome(String, String, String, String)
053:         * @see weblogic.management.MBeanHome#getMBeanServer()
054:         * @see javax.management.MBeanServer
055:         * @see MBeanServerFactoryBean
056:         * @see WebLogicJndiMBeanServerFactoryBean
057:         */
058:        public class WebLogicMBeanServerFactoryBean implements  FactoryBean,
059:                InitializingBean {
060:
061:            private static final String WEBLOGIC_JMX_HELPER_CLASS = "weblogic.management.Helper";
062:
063:            private static final String GET_MBEAN_HOME_METHOD = "getMBeanHome";
064:
065:            private static final String GET_MBEAN_SERVER_METHOD = "getMBeanServer";
066:
067:            private String username = "weblogic";
068:
069:            private String password = "weblogic";
070:
071:            private String serverUrl = "t3://localhost:7001";
072:
073:            private String serverName = "server";
074:
075:            private MBeanServer mbeanServer;
076:
077:            /**
078:             * Set the username to use for retrieving the WebLogic MBeanServer.
079:             * Default is "weblogic".
080:             */
081:            public void setUsername(String username) {
082:                this .username = username;
083:            }
084:
085:            /**
086:             * Set the password to use for retrieving the WebLogic MBeanServer.
087:             * Default is "weblogic".
088:             */
089:            public void setPassword(String password) {
090:                this .password = password;
091:            }
092:
093:            /**
094:             * Set the server URL to use for retrieving the WebLogic MBeanServer.
095:             * Default is "t3://localhost:7001".
096:             */
097:            public void setServerUrl(String serverUrl) {
098:                this .serverUrl = serverUrl;
099:            }
100:
101:            /**
102:             * Set the server name to use for retrieving the WebLogic MBeanServer.
103:             * Default is "server".
104:             */
105:            public void setServerName(String serverName) {
106:                this .serverName = serverName;
107:            }
108:
109:            public void afterPropertiesSet()
110:                    throws MBeanServerNotFoundException {
111:                try {
112:                    /*
113:                     * MBeanHome mbeanHome = Helper.getMBeanHome(this.username, this.password, this.serverUrl, this.serverName);
114:                     */
115:                    Class helperClass = getClass().getClassLoader().loadClass(
116:                            WEBLOGIC_JMX_HELPER_CLASS);
117:                    Class[] argTypes = new Class[] { String.class,
118:                            String.class, String.class, String.class };
119:                    Object[] args = new Object[] { this .username,
120:                            this .password, this .serverUrl, this .serverName };
121:                    Object mbeanHome = helperClass.getMethod(
122:                            GET_MBEAN_HOME_METHOD, argTypes).invoke(null, args);
123:
124:                    /*
125:                     * this.mbeanServer = mbeanHome.getMBeanServer();
126:                     */
127:                    this .mbeanServer = (MBeanServer) mbeanHome.getClass()
128:                            .getMethod(GET_MBEAN_SERVER_METHOD, null).invoke(
129:                                    mbeanHome, null);
130:                } catch (ClassNotFoundException ex) {
131:                    throw new MBeanServerNotFoundException(
132:                            "Could not find WebLogic's JMX Helper class", ex);
133:                } catch (InvocationTargetException ex) {
134:                    throw new MBeanServerNotFoundException(
135:                            "WebLogic's JMX Helper.getMBeanHome/getMBeanServer method failed",
136:                            ex.getTargetException());
137:                } catch (Exception ex) {
138:                    throw new MBeanServerNotFoundException(
139:                            "Could not access WebLogic's JMX Helper.getMBeanHome/getMBeanServer method",
140:                            ex);
141:                }
142:            }
143:
144:            public Object getObject() {
145:                return this .mbeanServer;
146:            }
147:
148:            public Class getObjectType() {
149:                return (this .mbeanServer != null ? this .mbeanServer.getClass()
150:                        : MBeanServer.class);
151:            }
152:
153:            public boolean isSingleton() {
154:                return true;
155:            }
156:
157:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.