@Test public void testSendShutdownEvent() throws Exception { AdapterRegistry adapterRegistry = (AdapterRegistry) AdapterRegistry .findInstance(new JunitBootstrapProperties(new Properties())); String adapterName = this.getClass().getSimpleName() + "." + getName(); Adapter adapter = createAdapter(adapterName, 2, 2); DefaultEventHandler evh = new DefaultEventHandler(); StaticMockEventProducer producer = new StaticMockEventProducer(Arrays.asList(new Class[] { AdapterShutdownEvent.class })); producer.getMessages().clear(); evh.setProducer(producer); adapter.setEventHandler(evh); String xml = DefaultMarshaller.getDefaultMarshaller().marshal(adapter); ObjectName objName = adapterRegistry.createAdapter(xml); assertEquals(1, adapterRegistry.getAdapters().size()); AdapterManagerMBean manager = JMX.newMBeanProxy(mBeanServer, objName, AdapterManagerMBean.class); manager.requestStart(); assertEquals(0, producer.messageCount()); AdapterRegistry.sendShutdownEvent(adapterRegistry.getAdapters()); waitForMessages(producer, 1); assertEquals(1, producer.messageCount()); AdapterRegistry.close(adapterRegistry.getAdapters()); producer.getMessages().clear(); }
public static void sendShutdownEvent(Set<ObjectName> adapterManagers) { for (ObjectName obj : adapterManagers) { AdapterManagerMBean mgr = JMX.newMBeanProxy(JmxHelper.findMBeanServer(), obj, AdapterManagerMBean.class); try { mgr.sendLifecycleEvent(EventFactory.create(AdapterShutdownEvent.class)); } catch (CoreException e) { log.warn("Failed to send ShutdownEvent for " + mgr.getUniqueId()); } } }
AdapterRegistry implements AdapterRegistryMBean { public static void sendShutdownEvent(Set<ObjectName> adapterManagers) { for (ObjectName obj : adapterManagers) { AdapterManagerMBean mgr = JMX.newMBeanProxy(JmxHelper.findMBeanServer(), obj, AdapterManagerMBean.class); try { mgr.sendLifecycleEvent(EventFactory.create(AdapterShutdownEvent.class)); } catch (CoreException e) { log.warn("Failed to send ShutdownEvent for " + mgr.getUniqueId()); } } } }
AdapterRegistry implements AdapterRegistryMBean { public static void sendShutdownEvent(Set<ObjectName> adapterManagers) { for (ObjectName obj : adapterManagers) { AdapterManagerMBean mgr = JMX.newMBeanProxy(JmxHelper.findMBeanServer(), obj, AdapterManagerMBean.class); try { mgr.sendLifecycleEvent(EventFactory.create(AdapterShutdownEvent.class)); } catch (CoreException e) { log.warn("Failed to send ShutdownEvent for " + mgr.getUniqueId()); } } } private  AdapterRegistry(); }
AdapterRegistry implements AdapterRegistryMBean { public static void sendShutdownEvent(Set<ObjectName> adapterManagers) { for (ObjectName obj : adapterManagers) { AdapterManagerMBean mgr = JMX.newMBeanProxy(JmxHelper.findMBeanServer(), obj, AdapterManagerMBean.class); try { mgr.sendLifecycleEvent(EventFactory.create(AdapterShutdownEvent.class)); } catch (CoreException e) { log.warn("Failed to send ShutdownEvent for " + mgr.getUniqueId()); } } } private  AdapterRegistry(); static AdapterRegistryMBean findInstance(Properties cfg); @Override ObjectName createObjectName(); @Override void registerMBean(); @Override void unregisterMBean(); @Override Set<ObjectName> getAdapters(); @Override URLString getConfigurationURL(ObjectName adapterName); @Override String getConfigurationURLString(ObjectName adapterName); @Override boolean removeConfigurationURL(ObjectName adapterName); @Override void putConfigurationURL(ObjectName adapterName, URLString configUrl); @Override void putConfigurationURL(ObjectName adapterName, String configUrl); @Override void persistAdapter(AdapterManagerMBean adapter, URLString url); @Override void persistAdapter(AdapterManagerMBean adapter, String url); @Override void persistAdapter(ObjectName adapter, URLString url); @Override void persistAdapter(ObjectName adapter, String url); @Override void persist(String data, URLString configUrl); @Override ObjectName createAdapter(URLString url); @Override ObjectName createAdapterFromUrl(String url); @Override ObjectName createAdapter(String xml); @Override void addAdapter(AdapterManagerMBean adapterManager); @Override void destroyAdapter(AdapterManagerMBean adapter); @Override void destroyAdapter(ObjectName adapterName); static void sendShutdownEvent(Set<ObjectName> adapterManagers); static void start(Set<ObjectName> adapterManagers); static void close(Set<ObjectName> adapterManagers); static void stop(Set<ObjectName> adapterManagers); static void unregister(Set<ObjectName> adapterManagers); @Override Properties getConfiguration(); @Override String getVersionControl(); @Override void reloadFromVersionControl(); @Override Set<ObjectName> reloadFromConfig(); @Override ObjectName reloadFromConfig(ObjectName obj); @Override ObjectName reloadFromVersionControl(ObjectName obj); @Override void addConfiguration(Properties cfg); @Override void validateConfig(String config); @Override String getClassDefinition(String className); @Override Set<ObjectName> getBuilders(); @Override ObjectName getBuilder(ObjectName p); @Override AdapterBuilderMBean getBuilderMBean(ObjectName p); @Override AdapterBuilderMBean getBuilder(Properties p); void addManagementComponentInfo(ManagementComponentInfo componentInfo); @Override List<ManagementComponentInfo> getManagementComponentInfo(); void setManagementComponentInfo(List<ManagementComponentInfo> managementComponentInfo); }
AdapterRegistry implements AdapterRegistryMBean { public static void sendShutdownEvent(Set<ObjectName> adapterManagers) { for (ObjectName obj : adapterManagers) { AdapterManagerMBean mgr = JMX.newMBeanProxy(JmxHelper.findMBeanServer(), obj, AdapterManagerMBean.class); try { mgr.sendLifecycleEvent(EventFactory.create(AdapterShutdownEvent.class)); } catch (CoreException e) { log.warn("Failed to send ShutdownEvent for " + mgr.getUniqueId()); } } } private  AdapterRegistry(); static AdapterRegistryMBean findInstance(Properties cfg); @Override ObjectName createObjectName(); @Override void registerMBean(); @Override void unregisterMBean(); @Override Set<ObjectName> getAdapters(); @Override URLString getConfigurationURL(ObjectName adapterName); @Override String getConfigurationURLString(ObjectName adapterName); @Override boolean removeConfigurationURL(ObjectName adapterName); @Override void putConfigurationURL(ObjectName adapterName, URLString configUrl); @Override void putConfigurationURL(ObjectName adapterName, String configUrl); @Override void persistAdapter(AdapterManagerMBean adapter, URLString url); @Override void persistAdapter(AdapterManagerMBean adapter, String url); @Override void persistAdapter(ObjectName adapter, URLString url); @Override void persistAdapter(ObjectName adapter, String url); @Override void persist(String data, URLString configUrl); @Override ObjectName createAdapter(URLString url); @Override ObjectName createAdapterFromUrl(String url); @Override ObjectName createAdapter(String xml); @Override void addAdapter(AdapterManagerMBean adapterManager); @Override void destroyAdapter(AdapterManagerMBean adapter); @Override void destroyAdapter(ObjectName adapterName); static void sendShutdownEvent(Set<ObjectName> adapterManagers); static void start(Set<ObjectName> adapterManagers); static void close(Set<ObjectName> adapterManagers); static void stop(Set<ObjectName> adapterManagers); static void unregister(Set<ObjectName> adapterManagers); @Override Properties getConfiguration(); @Override String getVersionControl(); @Override void reloadFromVersionControl(); @Override Set<ObjectName> reloadFromConfig(); @Override ObjectName reloadFromConfig(ObjectName obj); @Override ObjectName reloadFromVersionControl(ObjectName obj); @Override void addConfiguration(Properties cfg); @Override void validateConfig(String config); @Override String getClassDefinition(String className); @Override Set<ObjectName> getBuilders(); @Override ObjectName getBuilder(ObjectName p); @Override AdapterBuilderMBean getBuilderMBean(ObjectName p); @Override AdapterBuilderMBean getBuilder(Properties p); void addManagementComponentInfo(ManagementComponentInfo componentInfo); @Override List<ManagementComponentInfo> getManagementComponentInfo(); void setManagementComponentInfo(List<ManagementComponentInfo> managementComponentInfo);  }