Source Code Cross Referenced for JMXConnectorSourceImpl.java in  » ESB » open-esb » com » sun » jbi » util » jmx » 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 » ESB » open esb » com.sun.jbi.util.jmx 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * BEGIN_HEADER - DO NOT EDIT
003:         *
004:         * The contents of this file are subject to the terms
005:         * of the Common Development and Distribution License
006:         * (the "License").  You may not use this file except
007:         * in compliance with the License.
008:         *
009:         * You can obtain a copy of the license at
010:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011:         * See the License for the specific language governing
012:         * permissions and limitations under the License.
013:         *
014:         * When distributing Covered Code, include this CDDL
015:         * HEADER in each file and include the License file at
016:         * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017:         * If applicable add the following below this CDDL HEADER,
018:         * with the fields enclosed by brackets "[]" replaced with
019:         * your own identifying information: Portions Copyright
020:         * [year] [name of copyright owner]
021:         */
022:
023:        /*
024:         * @(#)JMXConnectorSourceImpl.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        /**
030:         *  JMXConnectorSourceImpl.java
031:         *
032:         *  SUN PROPRIETARY/CONFIDENTIAL.
033:         *  This software is the proprietary information of Sun Microsystems, Inc.
034:         *  Use is subject to license terms.
035:         *
036:         *  Created on June 13, 2005, 12:02 PM
037:         */package com.sun.jbi.util.jmx;
038:
039:        import java.io.File;
040:
041:        import com.sun.jbi.util.StringTranslator;
042:        import javax.management.remote.JMXConnector;
043:        import javax.management.remote.JMXConnectorFactory;
044:        import javax.management.remote.JMXServiceURL;
045:
046:        import java.util.Map;
047:
048:        /**
049:         * This class is to be used by jbi components / services to get a JMX Client Connector.
050:         * This is a wrapper around the JMXConnectorFactory and allows one to connect to 
051:         * a Connector Server, which may have proprietary extensions for Security. The 
052:         * corresponding client Connector Source would be made available through this interface.
053:         *
054:         * @author Sun Microsystems, Inc.
055:         */
056:        public class JMXConnectorSourceImpl implements  JMXConnectorSource {
057:
058:            /** Username. */
059:            private String mUser;
060:
061:            /** Password. */
062:            private String mPwd;
063:
064:            /** JMXServiceURL. */
065:            private JMXServiceURL mJmxServiceUrl;
066:
067:            /** JMXCOnnector. */
068:            private JMXConnector mJmxConnector;
069:
070:            /** JMX Creds. */
071:            private static final String CREDENTIALS_KEY = "jmx.remote.credentials";
072:
073:            /** NULL_OBJ Key. */
074:            private static final String NULL_OBJECT = "NULL_OBJECT";
075:
076:            /** 
077:             * Ctor. 
078:             */
079:            public JMXConnectorSourceImpl() {
080:                mJmxConnector = null;
081:                mJmxServiceUrl = null;
082:                mPwd = null;
083:                mUser = null;
084:            }
085:
086:            /**
087:             * @param username is the username to be used for the Connection.
088:             * @param password is the user password.
089:             */
090:            public void setCredentials(String username, String password) {
091:                mUser = username;
092:                mPwd = password;
093:            }
094:
095:            /**
096:             * This operation is not supported by this implementation of the Connector source and
097:             * is a no-op.
098:             *
099:             * @param secureFlag indicates whether the connection is to be secured (ex. use SSL)
100:             */
101:            public void setIsSecure(boolean secureFlag) {
102:                // -- no-op
103:            }
104:
105:            /**
106:             * This operation is not supported by this implementation of the Connector source
107:             * and is a no-op.
108:             *
109:             * @param truststore path to the JKS truststore file.
110:             * @param type is the type of the Keystore ( JKS, JCEKS etc)
111:             * @param passwd - the truststore password
112:             */
113:            public void setTrustStore(File truststore, String type,
114:                    char[] passwd) {
115:                // -- no-op
116:            }
117:
118:            /**
119:             * @param jmxServiceURL - JMX Service URL
120:             */
121:            public void setJMXServiceURL(JMXServiceURL jmxServiceURL) {
122:                mJmxServiceUrl = jmxServiceURL;
123:            }
124:
125:            /**
126:             * If the JMX Connector Server's host and port cannot be identified from the 
127:             * JMX Service URL or if the JMXServiceURL is not set, then this is the process
128:             * of indicating this information. This is a no-op in this implementation.
129:             *
130:             * @param host - hostname
131:             * @param port - port
132:             */
133:            public void setHostAndPort(String host, int port) {
134:                // -- no-op
135:            }
136:
137:            /**
138:             * If the connection has already been created, return the existing 
139:             * JMXConnector unless 'forceNew' is true or the connection is currently null.
140:             *
141:             * @param forceNew - create a new connection
142:             * @param environment - a set of attributes to determine how the connection is made. 
143:             * This parameter can be null. Keys in this map must be Strings. The appropriate type 
144:             * of each associated value depends on the attribute. The contents of environment are 
145:             * not changed by this call
146:             * @return the JMX Connector.
147:             * @throws java.io.IOException if a connection cannot be established.
148:             */
149:            public javax.management.remote.JMXConnector getJMXConnector(
150:                    boolean forceNew, Map environment)
151:                    throws java.io.IOException {
152:                StringTranslator translator = new StringTranslator(
153:                        "com.sun.jbi.util", null);
154:                if (mJmxServiceUrl == null) {
155:                    throw new java.io.IOException(translator.getString(
156:                            NULL_OBJECT, "JMXServiceURL"));
157:                }
158:
159:                if ((mUser == null) || (mPwd == null)) {
160:                    throw new java.io.IOException(translator.getString(
161:                            NULL_OBJECT, "Username/Password"));
162:                }
163:
164:                if ((mJmxConnector == null) || (forceNew)) {
165:                    // -- Create a new connection.
166:
167:                    java.util.HashMap env = new java.util.HashMap();
168:                    if (environment != null) {
169:                        env.putAll(environment);
170:                    }
171:
172:                    if (!env.containsKey(CREDENTIALS_KEY)) {
173:                        String[] credentials = new String[] { mUser, mPwd };
174:                        env.put(CREDENTIALS_KEY, credentials);
175:                    }
176:
177:                    mJmxConnector = JMXConnectorFactory.connect(mJmxServiceUrl,
178:                            env);
179:                }
180:
181:                return mJmxConnector;
182:
183:            }
184:
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.