Source Code Cross Referenced for JMXManagedComponentManager.java in  » ESB » celtix-1.0 » org » objectweb » celtix » bus » management » 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 » celtix 1.0 » org.objectweb.celtix.bus.management.jmx 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.objectweb.celtix.bus.management.jmx;
002:
003:        import java.io.IOException;
004:        import java.util.logging.Level;
005:        import java.util.logging.Logger;
006:
007:        import javax.management.InstanceAlreadyExistsException;
008:        import javax.management.InstanceNotFoundException;
009:        import javax.management.JMException;
010:        import javax.management.MBeanException;
011:        import javax.management.MBeanRegistrationException;
012:        import javax.management.MBeanServer;
013:        import javax.management.MBeanServerFactory;
014:
015:        import javax.management.NotCompliantMBeanException;
016:        import javax.management.ObjectName;
017:        import javax.management.ReflectionException;
018:        import javax.management.modelmbean.InvalidTargetObjectTypeException;
019:        import javax.management.modelmbean.ModelMBeanInfo;
020:        import javax.management.modelmbean.RequiredModelMBean;
021:
022:        import org.objectweb.celtix.Bus;
023:        import org.objectweb.celtix.BusEvent;
024:        import org.objectweb.celtix.BusException;
025:        import org.objectweb.celtix.bus.instrumentation.MBServerPolicyType;
026:        import org.objectweb.celtix.bus.management.InstrumentationEventFilter;
027:        import org.objectweb.celtix.bus.management.InstrumentationEventListener;
028:        import org.objectweb.celtix.bus.management.jmx.export.runtime.ModelMBeanAssembler;
029:        import org.objectweb.celtix.common.logging.LogUtils;
030:        import org.objectweb.celtix.management.Instrumentation;
031:
032:        /***
033:         * The manager class for the JMXManagedComponent which host the JMXManagedComponent
034:         * It implemenated the ManagementEventListener for the managed component register and unregister
035:         */
036:
037:        public class JMXManagedComponentManager implements 
038:                InstrumentationEventListener {
039:            private static final Logger LOG = LogUtils
040:                    .getL7dLogger(JMXManagedComponentManager.class);
041:
042:            private boolean platformMBeanServer;
043:            private InstrumentationEventFilter meFilter;
044:            private ModelMBeanAssembler mbAssembler;
045:            private MBServerConnectorFactory mcf;
046:            private Bus bus;
047:            private String busID;
048:            private MBeanServer mbs;
049:
050:            public JMXManagedComponentManager(Bus b) {
051:                bus = b;
052:                busID = bus.getBusID();
053:                meFilter = new InstrumentationEventFilter();
054:                mbAssembler = new ModelMBeanAssembler();
055:
056:            }
057:
058:            public void init(MBServerPolicyType mbpt) {
059:                // get the init information from configuration
060:
061:                if (LOG.isLoggable(Level.INFO)) {
062:                    LOG.info("Setting up MBeanServer ");
063:                }
064:
065:                mbs = MBeanServerFactory
066:                        .createMBeanServer(JMXUtils.DOMAIN_STRING);
067:                mcf = MBServerConnectorFactory.getInstance();
068:                mcf.setMBeanServer(mbs);
069:                mcf.setThreaded(mbpt.getJMXConnector().isThreaded());
070:                mcf.setDaemon(mbpt.getJMXConnector().isDaemon());
071:                mcf.setServiceUrl(mbpt.getJMXConnector().getJMXServiceURL());
072:                try {
073:                    mcf.createConnector();
074:                } catch (IOException ex) {
075:                    LOG.log(Level.SEVERE, "START_CONNECTOR_FAILURE_MSG",
076:                            new Object[] { ex });
077:                }
078:
079:            }
080:
081:            public MBeanServer getMBeanServer() {
082:                return mbs;
083:            }
084:
085:            public void shutdown() {
086:                if (!platformMBeanServer) {
087:                    try {
088:                        mcf.destroy();
089:                    } catch (IOException ex) {
090:                        LOG.log(Level.SEVERE, "STOP_CONNECTOR_FAILURE_MSG",
091:                                new Object[] { ex });
092:                    }
093:                }
094:            }
095:
096:            public InstrumentationEventFilter getManagementEventFilter() {
097:                return meFilter;
098:            }
099:
100:            public void registerMBean(Object object, ObjectName name) {
101:                try {
102:                    onRegister(name);
103:                    mbs.registerMBean(object, name);
104:                } catch (InstanceAlreadyExistsException e) {
105:                    //LOG.log(Level.SEVERE, "REGISTER_FAILURE_MSG", new Object[]{name, e});
106:                    //regist the new object instance
107:                    try {
108:                        mbs.unregisterMBean(name);
109:                        mbs.registerMBean(object, name);
110:                    } catch (Exception e1) {
111:                        LOG.log(Level.SEVERE, "REGISTER_FAILURE_MSG",
112:                                new Object[] { name, e1 });
113:                    }
114:                } catch (MBeanRegistrationException e) {
115:                    LOG.log(Level.SEVERE, "REGISTER_FAILURE_MSG", new Object[] {
116:                            name, e });
117:                } catch (NotCompliantMBeanException e) {
118:                    LOG.log(Level.SEVERE, "REGISTER_FAILURE_MSG", new Object[] {
119:                            name, e });
120:                }
121:            }
122:
123:            public void unregisterMBean(ObjectName name) {
124:
125:                try {
126:                    onUnregister(name);
127:                    mbs.unregisterMBean(name);
128:                } catch (JMException e) {
129:                    LOG.log(Level.SEVERE, "UNREGISTER_FAILURE_MSG",
130:                            new Object[] { name, e });
131:                }
132:            }
133:
134:            protected void onRegister(ObjectName objectName) {
135:
136:            }
137:
138:            protected void onUnregister(ObjectName objectName) {
139:                if (LOG.isLoggable(Level.INFO)) {
140:                    LOG
141:                            .info("unregistered the object to MBserver"
142:                                    + objectName);
143:                }
144:            }
145:
146:            // find out the related JMX managed component do register and unregister things   
147:
148:            public void processEvent(BusEvent event) throws BusException {
149:                if (meFilter.isEventEnabled(event)) {
150:                    Instrumentation instrumentation = (Instrumentation) event
151:                            .getSource();
152:
153:                    if (meFilter.isCreateEvent(event)) {
154:
155:                        ModelMBeanInfo mbi = mbAssembler
156:                                .getModelMbeanInfo(instrumentation.getClass());
157:
158:                        if (mbi != null) {
159:                            RequiredModelMBean rtMBean;
160:                            try {
161:
162:                                rtMBean = (RequiredModelMBean) mbs
163:                                        .instantiate("javax.management.modelmbean.RequiredModelMBean");
164:
165:                                rtMBean.setModelMBeanInfo(mbi);
166:
167:                                rtMBean.setManagedResource(instrumentation,
168:                                        "ObjectReference");
169:
170:                                registerMBean(
171:                                        rtMBean,
172:                                        JMXUtils
173:                                                .getObjectName(
174:                                                        instrumentation
175:                                                                .getInstrumentationName(),
176:                                                        instrumentation
177:                                                                .getUniqueInstrumentationName(),
178:                                                        busID));
179:
180:                                if (LOG.isLoggable(Level.INFO)) {
181:                                    LOG
182:                                            .info("registered the object to MBserver "
183:                                                    + instrumentation
184:                                                            .getUniqueInstrumentationName());
185:                                }
186:
187:                            } catch (ReflectionException e) {
188:                                LOG.log(Level.SEVERE,
189:                                        "INSTANTIANTE_FAILURE_MSG",
190:                                        new Object[] { e });
191:                            } catch (MBeanException e) {
192:                                LOG.log(Level.SEVERE, "MBEAN_FAILURE_MSG",
193:                                        new Object[] { e });
194:                            } catch (InstanceNotFoundException e) {
195:                                LOG.log(Level.SEVERE,
196:                                        "SET_MANAGED_RESOURCE_FAILURE_MSG",
197:                                        new Object[] { e });
198:                            } catch (InvalidTargetObjectTypeException e) {
199:                                LOG.log(Level.SEVERE,
200:                                        "SET_MANAGED_RESOURCE_FAILURE_MSG",
201:                                        new Object[] { e });
202:                            }
203:                        } else {
204:                            LOG.log(Level.SEVERE,
205:                                    "GET_MANAGED_INFORMATION_FAILURE_MSG",
206:                                    new Object[] { instrumentation
207:                                            .getInstrumentationName() });
208:                        }
209:                    }
210:
211:                    if (meFilter.isRemovedEvent(event)) {
212:                        // unregist the component and distroy it.
213:                        ObjectName name;
214:                        name = JMXUtils.getObjectName(instrumentation
215:                                .getInstrumentationName(), instrumentation
216:                                .getUniqueInstrumentationName(), busID);
217:                        unregisterMBean(name);
218:                        if (LOG.isLoggable(Level.INFO)) {
219:                            LOG.info("unregistered the object to MBserver"
220:                                    + instrumentation
221:                                            .getUniqueInstrumentationName());
222:                        }
223:
224:                    }
225:                }
226:            }
227:
228:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.