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


001:        package org.objectweb.celtix.bus.management;
002:
003:        import java.util.Iterator;
004:        import java.util.LinkedList;
005:        import java.util.List;
006:        import java.util.logging.Level;
007:        import java.util.logging.Logger;
008:
009:        import javax.management.MBeanServer;
010:
011:        import org.objectweb.celtix.Bus;
012:        import org.objectweb.celtix.BusEvent;
013:        import org.objectweb.celtix.BusEventListener;
014:        import org.objectweb.celtix.BusException;
015:        import org.objectweb.celtix.bus.busimpl.CeltixBus;
016:        import org.objectweb.celtix.bus.busimpl.CeltixBusInstrumentation;
017:        import org.objectweb.celtix.bus.busimpl.ComponentCreatedEvent;
018:        import org.objectweb.celtix.bus.busimpl.ComponentRemovedEvent;
019:
020:        import org.objectweb.celtix.bus.instrumentation.InstrumentationPolicyType;
021:        import org.objectweb.celtix.bus.instrumentation.MBServerPolicyType;
022:        import org.objectweb.celtix.bus.jaxws.EndpointImpl;
023:        import org.objectweb.celtix.bus.jaxws.EndpointInstrumentation;
024:        import org.objectweb.celtix.bus.management.jmx.JMXManagedComponentManager;
025:        import org.objectweb.celtix.bus.transports.http.HTTPClientTransport;
026:        import org.objectweb.celtix.bus.transports.http.HTTPClientTransportInstrumentation;
027:        import org.objectweb.celtix.bus.transports.http.HTTPServerTransportInstrumentation;
028:        import org.objectweb.celtix.bus.transports.http.JettyHTTPServerTransport;
029:        import org.objectweb.celtix.bus.transports.jms.JMSClientTransport;
030:        import org.objectweb.celtix.bus.transports.jms.JMSClientTransportInstrumentation;
031:        import org.objectweb.celtix.bus.transports.jms.JMSServerTransport;
032:        import org.objectweb.celtix.bus.transports.jms.JMSServerTransportInstrumentation;
033:        import org.objectweb.celtix.bus.workqueue.WorkQueueInstrumentation;
034:        import org.objectweb.celtix.bus.workqueue.WorkQueueManagerImpl;
035:        import org.objectweb.celtix.bus.wsdl.WSDLManagerImpl;
036:        import org.objectweb.celtix.bus.wsdl.WSDLManagerInstrumentation;
037:        import org.objectweb.celtix.common.logging.LogUtils;
038:        import org.objectweb.celtix.configuration.Configuration;
039:        import org.objectweb.celtix.configuration.ConfigurationBuilder;
040:        import org.objectweb.celtix.configuration.ConfigurationBuilderFactory;
041:        import org.objectweb.celtix.management.Instrumentation;
042:        import org.objectweb.celtix.management.InstrumentationManager;
043:
044:        /** The basic manager information center for common management model
045:         *  Instrumentation components will be registed to InstrumenationManager.
046:         *  The Instrumentation mananger will send event to notifier the management 
047:         *  layer to expose the managed component. 
048:         *  Instrumentation manager also provider a qurey interface for the instrumentation.
049:         *  The JMX layer could query the detail information for instrumentation.
050:         */
051:        public class InstrumentationManagerImpl implements 
052:                InstrumentationManager, BusEventListener {
053:            static final Logger LOG = LogUtils
054:                    .getL7dLogger(InstrumentationManagerImpl.class);
055:            static final String INSTRUMENTATION_CONFIGURATION_URI = "http://celtix.objectweb.org/bus/instrumentation/instrumentation-config";
056:            static final String INSTRUMENTATION_CONFIGURATION_ID = "Instrumentation";
057:            private Bus bus;
058:            private List<Instrumentation> instrumentations;
059:            private JMXManagedComponentManager jmxManagedComponentManager;
060:            private ComponentEventFilter componentEventFilter;
061:            private boolean instrumentationEnabled;
062:            private boolean jmxEnabled;
063:
064:            public InstrumentationManagerImpl(Bus b) throws BusException {
065:                InstrumentationPolicyType instrumentation = null;
066:                MBServerPolicyType mbserver = null;
067:
068:                bus = b;
069:
070:                Configuration itConfiguration = getConfiguration(bus
071:                        .getConfiguration());
072:
073:                instrumentation = (InstrumentationPolicyType) itConfiguration
074:                        .getObject("InstrumentationControl");
075:
076:                if (instrumentation == null) {
077:                    instrumentation = new InstrumentationPolicyType();
078:                }
079:
080:                mbserver = (MBServerPolicyType) itConfiguration
081:                        .getObject("MBServer");
082:
083:                if (mbserver == null) {
084:                    mbserver = new MBServerPolicyType();
085:                }
086:
087:                instrumentationEnabled = instrumentation
088:                        .isInstrumentationEnabled();
089:                jmxEnabled = instrumentation.isJMXEnabled();
090:
091:                if (LOG.isLoggable(Level.INFO)) {
092:                    LOG.info("Setting up InstrumentationManager for BUS");
093:                }
094:
095:                // get the configuration
096:                if (instrumentationEnabled) {
097:                    instrumentations = new LinkedList<Instrumentation>();
098:                    componentEventFilter = new ComponentEventFilter();
099:                    bus.addListener((BusEventListener) this ,
100:                            componentEventFilter);
101:                }
102:
103:                jmxManagedComponentManager = new JMXManagedComponentManager(bus);
104:
105:                if (jmxEnabled) {
106:
107:                    jmxManagedComponentManager.init(mbserver);
108:
109:                    bus.addListener(
110:                            (BusEventListener) jmxManagedComponentManager,
111:                            jmxManagedComponentManager
112:                                    .getManagementEventFilter());
113:                }
114:
115:            }
116:
117:            private Configuration getConfiguration(Configuration configuration) {
118:
119:                ConfigurationBuilder cb = ConfigurationBuilderFactory
120:                        .getBuilder(null);
121:
122:                Configuration itCfg = cb.getConfiguration(
123:                        INSTRUMENTATION_CONFIGURATION_URI,
124:                        INSTRUMENTATION_CONFIGURATION_ID, configuration);
125:                if (null == itCfg) {
126:                    itCfg = cb.buildConfiguration(
127:                            INSTRUMENTATION_CONFIGURATION_URI,
128:                            INSTRUMENTATION_CONFIGURATION_ID, configuration);
129:                }
130:                return itCfg;
131:            }
132:
133:            public void shutdown() {
134:                if (LOG.isLoggable(Level.INFO)) {
135:                    LOG.info("Shutdown InstrumentationManager ");
136:                }
137:                if (instrumentationEnabled) {
138:                    try {
139:                        bus.removeListener((BusEventListener) this );
140:                    } catch (BusException ex) {
141:                        LOG
142:                                .log(Level.SEVERE,
143:                                        "REMOVE_LISTENER_FAILURE_MSG", ex);
144:                    }
145:                }
146:
147:                if (jmxManagedComponentManager != null && jmxEnabled) {
148:                    try {
149:                        bus
150:                                .removeListener((BusEventListener) jmxManagedComponentManager);
151:                    } catch (BusException ex) {
152:                        LOG
153:                                .log(Level.SEVERE,
154:                                        "REMOVE_LISTENER_FAILURE_MSG", ex);
155:                    }
156:                    jmxManagedComponentManager.shutdown();
157:                }
158:            }
159:
160:            public void register(Instrumentation it) {
161:                if (it == null) {
162:                    // can't find the right instrumentation ,just return
163:                    return;
164:                } else {
165:                    instrumentations.add(it);
166:                    //create the instrumentation creation event        
167:                    bus.sendEvent(new InstrumentationCreatedEvent(it));
168:                }
169:            }
170:
171:            public void unregister(Object component) {
172:                for (Iterator<Instrumentation> i = instrumentations.iterator(); i
173:                        .hasNext();) {
174:                    Instrumentation it = i.next();
175:                    if (it.getComponent() == component) {
176:                        i.remove();
177:                        if (it != null) {
178:                            //create the instrumentation remove event           
179:                            bus.sendEvent(new InstrumentationRemovedEvent(it));
180:                        }
181:                    }
182:                }
183:            }
184:
185:            // get the instance and create the right component
186:            public void processEvent(BusEvent e) throws BusException {
187:                Instrumentation it;
188:                if (e.getID().equals(
189:                        ComponentCreatedEvent.COMPONENT_CREATED_EVENT)) {
190:                    it = createInstrumentation(e.getSource());
191:                    if (LOG.isLoggable(Level.INFO)) {
192:                        LOG.info("Instrumentation register "
193:                                + e.getSource().getClass().getName());
194:                    }
195:                    register(it);
196:
197:                } else if (e.getID().equals(
198:                        ComponentRemovedEvent.COMPONENT_REMOVED_EVENT)) {
199:                    if (LOG.isLoggable(Level.INFO)) {
200:                        LOG.info("Instrumentation unregister "
201:                                + e.getSource().getClass().getName());
202:                    }
203:                    unregister(e.getSource());
204:                }
205:            }
206:
207:            private Instrumentation createInstrumentation(Object component) {
208:                Instrumentation it = null;
209:                // if the componenet implements the instrumentation interface, 
210:                // just return the object itself
211:
212:                if (Instrumentation.class
213:                        .isAssignableFrom(component.getClass())) {
214:                    it = (Instrumentation) component;
215:                    return it;
216:                }
217:
218:                if (CeltixBus.class.isAssignableFrom(component.getClass())) {
219:                    it = new CeltixBusInstrumentation((CeltixBus) component);
220:                }
221:                if (WSDLManagerImpl.class
222:                        .isAssignableFrom(component.getClass())) {
223:                    it = new WSDLManagerInstrumentation(
224:                            (WSDLManagerImpl) component);
225:                }
226:                if (WorkQueueManagerImpl.class.isAssignableFrom(component
227:                        .getClass())) {
228:                    it = new WorkQueueInstrumentation(
229:                            (WorkQueueManagerImpl) component);
230:                }
231:                if (HTTPClientTransport.class.isAssignableFrom(component
232:                        .getClass())) {
233:                    it = new HTTPClientTransportInstrumentation(
234:                            (HTTPClientTransport) component);
235:                }
236:                if (JettyHTTPServerTransport.class.isAssignableFrom(component
237:                        .getClass())) {
238:                    it = new HTTPServerTransportInstrumentation(
239:                            (JettyHTTPServerTransport) component);
240:                }
241:                if (JMSServerTransport.class.isAssignableFrom(component
242:                        .getClass())) {
243:                    it = new JMSServerTransportInstrumentation(
244:                            (JMSServerTransport) component);
245:                }
246:                if (JMSClientTransport.class.isAssignableFrom(component
247:                        .getClass())) {
248:                    it = new JMSClientTransportInstrumentation(
249:                            (JMSClientTransport) component);
250:                }
251:                if (EndpointImpl.class.isAssignableFrom(component.getClass())) {
252:                    it = new EndpointInstrumentation((EndpointImpl) component);
253:                }
254:
255:                return it;
256:            }
257:
258:            public List<Instrumentation> getAllInstrumentation() {
259:                // TODO need to add more qurey interface
260:                return instrumentations;
261:            }
262:
263:            public MBeanServer getMBeanServer() {
264:                return jmxManagedComponentManager.getMBeanServer();
265:            }
266:
267:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.