Source Code Cross Referenced for ServicemixJmxClient.java in  » ESB » cbesb-1.2 » com » bostechcorp » cbesb » console » jmxclient » 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 » cbesb 1.2 » com.bostechcorp.cbesb.console.jmxclient 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.bostechcorp.cbesb.console.jmxclient;
002:
003:        import java.io.FileInputStream;
004:        import java.io.FileNotFoundException;
005:        import java.io.IOException;
006:        import java.io.InputStream;
007:        import java.net.MalformedURLException;
008:        import java.util.HashMap;
009:        import java.util.Map;
010:        import java.util.Properties;
011:        import java.util.Set;
012:        import java.util.Vector;
013:
014:        import javax.management.MalformedObjectNameException;
015:        import javax.management.ObjectName;
016:        import javax.management.remote.JMXConnector;
017:        import javax.management.remote.JMXConnectorFactory;
018:        import javax.management.remote.JMXServiceURL;
019:
020:        import org.apache.servicemix.jbi.framework.ComponentStatsMBean;
021:
022:        import com.bostechcorp.cbesb.common.i18n.CoreMessageConstants;
023:        import com.bostechcorp.cbesb.common.i18n.Messages;
024:        import com.bostechcorp.cbesb.common.util.EsbPathHelper;
025:        import com.bostechcorp.cbesb.console.common.ServerSideException;
026:
027:        //import com.bostechcorp.cbesb.runtime.ccsl.lib.ChainbuilderEsbExtension;
028:        //import com.bostechcorp.cbesb.runtime.ccsl.lib.ChainbuilderEsbExtensionMBean;
029:
030:        public class ServicemixJmxClient extends BaseJmxClient {
031:            public static final String JMX_PROPERTY_FILE_NAME = "jmx.properties";
032:            public static final String JMX_SERVICE_URL = "JMXServiceURL";
033:            public static final String JMX_USER = "user";
034:            public static final String JMX_PASSWORD = "password";
035:
036:            private Properties properties;
037:
038:            /*
039:             * The constructor will establish an MBeanServer connection if it is
040:             * successful.
041:             */
042:            public ServicemixJmxClient() throws Exception {
043:                properties = getJmxPropertiesFromFile();
044:                init("0", properties.getProperty(JMX_USER), properties
045:                        .getProperty(JMX_PASSWORD));
046:            }
047:
048:            /*
049:             * Gets lists of Binding Components, Service Engines and Shared Libraries currently installed
050:             * (non-Javadoc)
051:             * @see com.bostechcorp.cbesb.console.jmxclient.BaseJmxClient#getSharedLibraryNames()
052:             */
053:            @SuppressWarnings("unchecked")
054:            public String[] getSharedLibraryNames() throws ServerSideException {
055:                Set<ObjectName> allObjNames;
056:                try {
057:                    allObjNames = getServerConnection().queryNames(null, null);
058:                } catch (IOException e) {
059:                    throw new ServerSideException((Messages
060:                            .get(CoreMessageConstants.NO_JMX_SERVER_ERROR)), e);
061:                }
062:                Vector<String> slNameVec = new Vector<String>();
063:                for (ObjectName name : allObjNames) {
064:                    String strName = name.toString();
065:                    if (strName
066:                            .matches("org.apache.servicemix:.*Type=SharedLibrary.*"))
067:                        slNameVec.add(name.getKeyProperty("Name"));
068:                }
069:                return slNameVec.toArray(new String[0]);
070:            }
071:
072:            protected ObjectName getAdminServiceMbeanName()
073:                    throws MalformedObjectNameException {
074:                return new ObjectName(
075:                        "org.apache.servicemix:ContainerName=ServiceMix,Type=SystemService,Name=ManagementContext");
076:            }
077:
078:            protected ObjectName getDeploymentServiceMbeanName()
079:                    throws MalformedObjectNameException {
080:                return new ObjectName(
081:                        "org.apache.servicemix:ContainerName=ServiceMix,Type=SystemService,Name=DeploymentService");
082:            }
083:
084:            protected ObjectName getInstallationServiceMbeanName()
085:                    throws MalformedObjectNameException {
086:                return new ObjectName(
087:                        "org.apache.servicemix:ContainerName=ServiceMix,Type=SystemService,Name=InstallationService");
088:            }
089:
090:            protected ObjectName getRegistryMbeanName()
091:                    throws MalformedObjectNameException {
092:                return new ObjectName(
093:                        "org.apache.servicemix:ContainerName=ServiceMix,Type=SystemService,Name=Registry");
094:            }
095:
096:            protected ObjectName getInstallerMbeanName(String componentName)
097:                    throws MalformedObjectNameException {
098:                //		org.apache.servicemix:ContainerName=ServiceMix,Type=Component,Name=ChainBuilderESB-SE-Sequencing,SubType=Installer				
099:                return new ObjectName(
100:                        "org.apache.servicemix:ContainerName=ServiceMix,Type=Component,Name="
101:                                + componentName + ",SubType=Installer");
102:            }
103:
104:            public ObjectName getLifeCycleMbeanName(String componentName)
105:                    throws MalformedObjectNameException {
106:                return new ObjectName(
107:                        "org.apache.servicemix:ContainerName=ServiceMix,Type=Component,Name="
108:                                + componentName + ",SubType=LifeCycle");
109:            }
110:
111:            public ObjectName getLifeCycleExtensionMbeanName(
112:                    String componentName) throws MalformedObjectNameException {
113:                return new ObjectName(
114:                        "org.apache.servicemix:ContainerName=ServiceMix,Type=Component,Name="
115:                                + componentName + ",SubType=LifeCycleExtension");
116:            }
117:
118:            protected ObjectName getServiceUnitLifeCycleMbeanName(
119:                    String serviceUintName, String componentName)
120:                    throws MalformedObjectNameException {
121:                return new ObjectName(
122:                        "org.apache.servicemix:ContainerName=ServiceMix,Type=ServiceUnit,Name="
123:                                + serviceUintName + ",SubType=" + componentName);
124:            }
125:
126:            protected ObjectName getSharedLibraryMbeanName(String libName)
127:                    throws MalformedObjectNameException {
128:                return new ObjectName(
129:                        "org.apache.servicemix:ContainerName=ServiceMix,Type=SharedLibrary,Name="
130:                                + libName);
131:            }
132:
133:            protected ObjectName getSharedLibraryInstallerMbeanName(
134:                    String libName) throws MalformedObjectNameException {
135:                //		org.apache.servicemix:ContainerName=ServiceMix,Type=Component,Name=ChainBuilderESB-SE-Sequencing,SubType=Installer				
136:                return new ObjectName(
137:                        "org.apache.servicemix:ContainerName=ServiceMix,Type=SharedLibrary,Name="
138:                                + libName + ",SubType=Installer");
139:            }
140:
141:            public JMXServiceURL getServiceUrl() throws MalformedURLException {
142:                //JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + "localhost" + ":" + port + "/jmxrmi");
143:                JMXServiceURL url = new JMXServiceURL(properties
144:                        .getProperty(JMX_SERVICE_URL));
145:                return url;
146:            }
147:
148:            public JMXConnector getJmxConnector(JMXServiceURL url)
149:                    throws ServerSideException {
150:                log.info("Connecting to JBI Container at: " + url);
151:                Map<String, String[]> m = new HashMap<String, String[]>();
152:                String[] credInfo = new String[] { user, password };
153:                m.put("jmx.remote.credentials", credInfo);
154:                try {
155:                    return JMXConnectorFactory.connect(url, m);
156:                } catch (IOException e) {
157:                    throw new ServerSideException(Messages
158:                            .get(CoreMessageConstants.NO_JMX_SERVER_ERROR), e);
159:                }
160:            }
161:
162:            /**
163:             * Reads the JMX properties from jmx.properties File 
164:             * @return
165:             * @throws FileNotFoundException
166:             * @throws IOException
167:             */
168:            public static Properties getJmxPropertiesFromFile()
169:                    throws FileNotFoundException, IOException {
170:                Properties result = new Properties();
171:                InputStream inStream;
172:                try {
173:                    inStream = new FileInputStream(EsbPathHelper
174:                            .getCbesbHomeDir()
175:                            + "/runtime/console/config/"
176:                            + JMX_PROPERTY_FILE_NAME);
177:                } catch (FileNotFoundException e) {
178:                    inStream = ServicemixJmxClient.class.getClassLoader()
179:                            .getResourceAsStream(JMX_PROPERTY_FILE_NAME);
180:                    if (inStream == null) {
181:                        //if the classloader also does not find the resource then 
182:                        //the file really does not exist; throw the caught exception. 
183:                        //actually the file will always exist in source it should exist 
184:                        throw e;
185:                    }
186:                }
187:                result.load(inStream);
188:                return result;
189:            }
190:
191:            /**
192:             * @return the properties
193:             */
194:            public Properties getProperties() {
195:                return properties;
196:            }
197:
198:            /**
199:             * @param properties the properties to set
200:             */
201:            public void setProperties(Properties properties) {
202:                this.properties = properties;
203:            }
204:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.