1 package org.objectweb.celtix.bus.busimpl; 2 3 4 import java.util.Map ; 5 6 import org.objectweb.celtix.Bus; 7 import org.objectweb.celtix.BusEvent; 8 import org.objectweb.celtix.BusEventCache; 9 import org.objectweb.celtix.BusEventFilter; 10 import org.objectweb.celtix.BusEventListener; 11 import org.objectweb.celtix.BusException; 12 import org.objectweb.celtix.bindings.BindingManager; 13 import org.objectweb.celtix.bus.bindings.BindingManagerImpl; 14 import org.objectweb.celtix.bus.configuration.ConfigurationEvent; 15 import org.objectweb.celtix.bus.configuration.ConfigurationEventFilter; 16 import org.objectweb.celtix.bus.jaxws.EndpointRegistryImpl; 17 import org.objectweb.celtix.bus.management.InstrumentationManagerImpl; 18 import org.objectweb.celtix.bus.resource.ResourceManagerImpl; 19 import org.objectweb.celtix.bus.transports.TransportFactoryManagerImpl; 20 import org.objectweb.celtix.bus.workqueue.WorkQueueManagerImpl; 21 import org.objectweb.celtix.bus.wsdl.WSDLManagerImpl; 22 import org.objectweb.celtix.buslifecycle.BusLifeCycleManager; 23 import org.objectweb.celtix.configuration.Configuration; 24 import org.objectweb.celtix.jaxws.EndpointRegistry; 25 import org.objectweb.celtix.management.InstrumentationManager; 26 import org.objectweb.celtix.plugins.PluginManager; 27 import org.objectweb.celtix.resource.ResourceManager; 28 import org.objectweb.celtix.transports.TransportFactoryManager; 29 import org.objectweb.celtix.workqueue.WorkQueueManager; 30 import org.objectweb.celtix.wsdl.WSDLManager; 31 32 33 public class CeltixBus extends Bus implements BusEventListener { 34 35 public static final String CELTIX_WSDLMANAGER = "celtix.WSDLManager"; 36 public static final String CELTIX_TRANSPORTFACTORYMANAGER = "celtix.TRANSPORTFACTORYMANAGER"; 37 38 private Configuration configuration; 39 private BindingManager bindingManager; 40 private Object clientRegistry; 41 private EndpointRegistryImpl endpointRegistry; 42 private TransportFactoryManager transportFactoryManager; 43 private WSDLManager wsdlManager; 44 private PluginManager pluginManager; 45 private CeltixBusLifeCycleManager lifeCycleManager; 46 private WorkQueueManager workQueueManager; 47 private ResourceManager resourceManager; 48 private InstrumentationManager instrumentationManager; 49 private BusEventCache eventCache; 50 private BusEventProcessor eventProcessor; 51 private String busID; 52 private boolean servicesMonitoring; 53 54 55 60 public void initialize(String [] args, Map <String , Object > properties) 61 throws BusException { 62 63 64 lifeCycleManager = new CeltixBusLifeCycleManager(); 65 66 eventCache = new BusEventCacheImpl(this); 68 eventProcessor = new BusEventProcessor(this, eventCache); 70 71 configuration = new BusConfigurationBuilder().build(args, properties); 72 ConfigurationEventFilter configurationEventFilter = new ConfigurationEventFilter(); 74 addListener((BusEventListener)this, configurationEventFilter); 75 76 busID = (String )configuration.getId(); 77 servicesMonitoring = configuration.getBoolean("servicesMonitoring"); 78 79 instrumentationManager = new InstrumentationManagerImpl(this); 80 81 if (properties.get(CELTIX_WSDLMANAGER) != null) { 82 wsdlManager = (WSDLManager)properties.get(CELTIX_WSDLMANAGER); 83 } else { 84 wsdlManager = new WSDLManagerImpl(this); 85 } 86 87 if (properties.get(CELTIX_TRANSPORTFACTORYMANAGER) != null) { 88 transportFactoryManager = (TransportFactoryManager)properties.get(CELTIX_TRANSPORTFACTORYMANAGER); 89 } else { 90 transportFactoryManager = new TransportFactoryManagerImpl(this); 91 } 92 93 bindingManager = new BindingManagerImpl(this); 94 workQueueManager = new WorkQueueManagerImpl(this); 95 resourceManager = new ResourceManagerImpl(this); 96 97 100 endpointRegistry = new EndpointRegistryImpl(this); 101 102 Bus.setCurrent(this); 103 104 lifeCycleManager.initComplete(); 105 this.sendEvent(new ComponentCreatedEvent(this)); 107 } 108 109 119 public static synchronized Bus init(String [] args) 120 throws BusException { 121 return null; 122 } 123 124 131 public void shutdown(boolean wait) throws BusException { 132 lifeCycleManager.preShutdown(); 134 135 137 endpointRegistry.shutdown(); 138 139 transportFactoryManager.shutdown(); 140 bindingManager.shutdown(); 141 wsdlManager.shutdown(); 142 this.sendEvent(new ComponentRemovedEvent(this)); 143 148 workQueueManager.shutdown(wait); 149 instrumentationManager.shutdown(); 150 lifeCycleManager.postShutdown(); 151 super.removeByID(getBusID()); 152 } 153 154 157 @Override 158 public void run() { 159 workQueueManager.run(); 160 } 161 162 167 public Configuration getConfiguration() { 168 return configuration; 169 } 170 171 176 public BindingManager getBindingManager() { 177 return bindingManager; 178 } 179 180 185 public TransportFactoryManager getTransportFactoryManager() { 186 return transportFactoryManager; 187 } 188 189 194 public Object getClientRegistry() { 195 return clientRegistry; 196 } 197 198 199 public WSDLManager getWSDLManager() { 200 return wsdlManager; 201 } 202 203 206 @Override 207 public PluginManager getPluginManager() { 208 return pluginManager; 209 } 210 211 216 public EndpointRegistry getEndpointRegistry() { 217 return endpointRegistry; 218 } 219 220 223 @Override 224 public BusLifeCycleManager getLifeCycleManager() { 225 return lifeCycleManager; 226 } 227 228 231 @Override 232 public WorkQueueManager getWorkQueueManager() { 233 return workQueueManager; 234 } 235 236 237 240 @Override 241 public ResourceManager getResourceManager() { 242 return resourceManager; 243 } 244 245 @Override 246 public InstrumentationManager getInstrumentationManager() { 247 return instrumentationManager; 248 } 249 250 @Override 251 public void sendEvent(BusEvent event) { 252 eventProcessor.processEvent(event); 253 } 254 255 @Override 256 public void addListener(BusEventListener l, BusEventFilter filter) throws BusException { 257 eventProcessor.addListener(l, filter); 258 } 259 260 @Override 261 public void removeListener(BusEventListener l) throws BusException { 262 eventProcessor.removeListener(l); 263 } 264 265 @Override 266 public BusEventCache getEventCache() { 267 return eventCache; 268 } 269 270 @Override 271 public String getBusID() { 272 return busID; 273 } 274 275 public boolean isServicesMonitoring() { 276 return servicesMonitoring; 277 } 278 279 public void setServicesMonitoring(boolean pServicesMonitoring) { 280 servicesMonitoring = pServicesMonitoring; 281 } 282 283 public void processEvent(BusEvent e) throws BusException { 286 if (e.getID().equals(ConfigurationEvent.RECONFIGURED)) { 287 String configName = (String )e.getSource(); 288 293 reConfigure(configName); 294 } 295 } 296 297 private void reConfigure(String configName) { 298 if ("servicesMonitoring".equals(configName)) { 299 servicesMonitoring = configuration.getBoolean("servicesMonitoring"); 300 } 301 302 } 303 } 304 | Popular Tags |