Source Code Cross Referenced for JMXConnectionProperties.java in  » ESB » open-esb » com » sun » jbi » ui » client » 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.ui.client 
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:         * @(#)JMXConnectionProperties.java
025:         * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026:         *
027:         * END_HEADER - DO NOT EDIT
028:         */
029:        package com.sun.jbi.ui.client;
030:
031:        import com.sun.jbi.ui.common.ToolsLogManager;
032:        import com.sun.jbi.ui.common.Util;
033:
034:        import java.io.IOException;
035:
036:        import java.text.MessageFormat;
037:
038:        import java.util.Properties;
039:        import java.util.logging.Level;
040:
041:        /**
042:         * This class manages the JMX Connection properties
043:         *
044:         * @author Sun Microsystems, Inc.
045:         */
046:        public class JMXConnectionProperties {
047:            /**
048:             * property name
049:             */
050:            public static final String USERNAME_PROP = "com.sun.jbi.tools.remote.jmx.username";
051:
052:            /**
053:             * property name
054:             */
055:            public static final String PASSWORD_PROP = "com.sun.jbi.tools.remote.jmx.password";
056:
057:            /**
058:             * property name
059:             */
060:            public static final String HOST_PROP = "com.sun.jbi.tools.remote.jmx.host";
061:
062:            /**
063:             * property name
064:             */
065:            public static final String PORT_PROP = "com.sun.jbi.tools.remote.jmx.port";
066:
067:            /**
068:             * property name
069:             */
070:            public static final String URL_PROP = "com.sun.jbi.tools.remote.jmx.url";
071:
072:            /**
073:             * property name
074:             */
075:            public static final String CONNECTION_FACTORY_PROP = "com.sun.jbi.tools.jmx.connection.factory";
076:
077:            /**
078:             * signleton
079:             */
080:            private static JMXConnectionProperties sConnProps;
081:
082:            /**
083:             * defaults
084:             */
085:            private static Properties sDefProps;
086:
087:            /**
088:             * Creates a new instance of JMXConnectionProps
089:             */
090:            private JMXConnectionProperties() {
091:                // don't allow others to create instance
092:            }
093:
094:            /**
095:             * loads default props
096:             *
097:             * @return Default Properties
098:             */
099:            private Properties getDefaultProperties() {
100:                if (sDefProps == null) {
101:                    try {
102:                        sDefProps = new Properties();
103:                        sDefProps.load(this .getClass().getResourceAsStream(
104:                                "JMXConnection.properties"));
105:                    } catch (IOException ex) {
106:                        Util.logDebug(ToolsLogManager.getClientLogger(), ex);
107:                    }
108:                }
109:
110:                return sDefProps;
111:            }
112:
113:            /**
114:             * gets the property value. Search order is first system props and then
115:             * defults
116:             *
117:             * @param property Property to look for
118:             *
119:             * @return Property value
120:             */
121:            private String getProperty(String property) {
122:                // Search order
123:                // System setup
124:                // default
125:                String defValue = getDefaultProperties().getProperty(property);
126:                String value = System.getProperty(property, defValue);
127:
128:                return value;
129:            }
130:
131:            /**
132:             * create instance if not created
133:             *
134:             * @return object
135:             */
136:            public static JMXConnectionProperties getInstance() {
137:                if (sConnProps == null) {
138:                    sConnProps = new JMXConnectionProperties();
139:                }
140:
141:                return sConnProps;
142:            }
143:
144:            /**
145:             * username
146:             *
147:             * @return username
148:             */
149:            public String getDefaultUserName() {
150:                String value = getProperty(USERNAME_PROP);
151:
152:                return value;
153:            }
154:
155:            /**
156:             * password
157:             *
158:             * @return password
159:             */
160:            public String getDefaultPassword() {
161:                String value = getProperty(PASSWORD_PROP);
162:
163:                return value;
164:            }
165:
166:            /**
167:             * con factory
168:             *
169:             * @return connection factory
170:             */
171:            public String getDefaultConnectionFactory() {
172:                String value = getProperty(CONNECTION_FACTORY_PROP);
173:
174:                return value;
175:            }
176:
177:            /**
178:             * host
179:             *
180:             * @return host
181:             */
182:            public String getHost() {
183:                String value = getProperty(HOST_PROP);
184:
185:                return value;
186:            }
187:
188:            /**
189:             * port
190:             *
191:             * @return port
192:             */
193:            public String getPort() {
194:                String value = getProperty(PORT_PROP);
195:
196:                return value;
197:            }
198:
199:            /**
200:             * returns url format
201:             *
202:             * @return url format
203:             */
204:            public String getURLFormat() {
205:                String value = getProperty(URL_PROP);
206:
207:                return value;
208:            }
209:
210:            /**
211:             * constructs the jmx url
212:             *
213:             * @return url
214:             */
215:            public String getConnectionURL() {
216:                return getConnectionURL(null, null, null);
217:            }
218:
219:            /**
220:             * constructs the jmx url. any or all params can be null.
221:             *
222:             * @param aHost host
223:             * @param aPort port
224:             *
225:             * @return url
226:             */
227:            public String getConnectionURL(String aHost, String aPort) {
228:                return getConnectionURL(null, aHost, aPort);
229:            }
230:
231:            /**
232:             * constructs the jmx url. any or all params can be null.
233:             *
234:             * @param aUrl url format
235:             * @param aHost host
236:             * @param aPort port
237:             *
238:             * @return url
239:             */
240:            public String getConnectionURL(String aUrl, String aHost,
241:                    String aPort) {
242:                String urlFormat = null;
243:                String host = null;
244:                String port = null;
245:
246:                if (aHost == null) {
247:                    host = getHost();
248:                } else {
249:                    host = aHost;
250:                }
251:
252:                if (aPort == null) {
253:                    port = getPort();
254:                } else {
255:                    port = aPort;
256:                }
257:
258:                if (aUrl == null) {
259:                    urlFormat = getURLFormat();
260:                } else {
261:                    urlFormat = aUrl;
262:                }
263:
264:                String[] args = { host, port };
265:                String url = null;
266:
267:                try {
268:                    MessageFormat mf = new MessageFormat(urlFormat);
269:                    url = mf.format(args);
270:                } catch (Exception ex) {
271:                    Util.logDebug(ToolsLogManager.getClientLogger(), ex);
272:                }
273:
274:                return url;
275:            }
276:
277:            /**
278:             * creates the Properties object that contains the name/value pair of the
279:             * connection properties from the user input. Adds onlu non null values
280:             * passed to the properties object. if user want to use the system
281:             * defaults, they should pass null for the corresponding property.
282:             *
283:             * @param url url
284:             * @param host host
285:             * @param port port
286:             * @param username username
287:             * @param password password
288:             *
289:             * @return Property map.
290:             */
291:            public static Properties getJMXConnectionPropertyMap(String url,
292:                    String host, String port, String username, String password) {
293:                Properties props = new Properties();
294:
295:                if (username != null) {
296:                    props.setProperty(JMXConnectionProperties.USERNAME_PROP,
297:                            username);
298:                }
299:
300:                if (password != null) {
301:                    props.setProperty(JMXConnectionProperties.PASSWORD_PROP,
302:                            password);
303:                }
304:
305:                if (host != null) {
306:                    props.setProperty(JMXConnectionProperties.HOST_PROP, host);
307:                }
308:
309:                if (port != null) {
310:                    props.setProperty(JMXConnectionProperties.PORT_PROP, port);
311:                }
312:
313:                if (url != null) {
314:                    props.setProperty(JMXConnectionProperties.URL_PROP, url);
315:                }
316:
317:                return props;
318:            }
319:
320:            /**
321:             *
322:             *
323:             * @param confac  
324:             * @param provprops  
325:             * @param url  
326:             * @param host  
327:             * @param port  
328:             * @param username  
329:             * @param password  
330:             *
331:             * @return  
332:             */
333:            public static Properties getJMXConnectionPropertyMap(String confac,
334:                    Properties provprops, String url, String host, String port,
335:                    String username, String password) {
336:                Properties props = getJMXConnectionPropertyMap(url, host, port,
337:                        username, password);
338:
339:                if (provprops != null) {
340:                    try {
341:                        props.putAll(provprops);
342:                    } catch (Exception e) {
343:                        ;
344:                    }
345:                }
346:
347:                if (confac != null) {
348:                    props.put(CONNECTION_FACTORY_PROP, confac);
349:                }
350:
351:                return props;
352:            }
353:
354:            /**
355:             *
356:             *
357:             * @param provprops  
358:             * @param url  
359:             * @param host  
360:             * @param port  
361:             * @param username  
362:             * @param password  
363:             *
364:             * @return  
365:             */
366:            public static Properties getJMXConnectionPropertyMap(
367:                    Properties provprops, String url, String host, String port,
368:                    String username, String password) {
369:                Properties props = getJMXConnectionPropertyMap(url, host, port,
370:                        username, password);
371:
372:                if (provprops != null) {
373:                    try {
374:                        props.putAll(provprops);
375:                    } catch (Exception e) {
376:                        ;
377:                    }
378:                }
379:
380:                return props;
381:            }
382:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.