Search in sources :

Example 1 with AdapterManagerMBean

use of com.adaptris.core.runtime.AdapterManagerMBean in project interlok by adaptris.

the class ShutdownHandlerTest method testRun.

@Test
public void testRun() throws Exception {
    String adapterName = nameGenerator.safeUUID();
    Adapter adapter = new Adapter();
    adapter.setUniqueId(adapterName);
    BootstrapProperties boot = bootstrapWithAdapter(adapter);
    AdapterManagerMBean mgmtBean = boot.getConfigManager().createAdapter();
    try {
        mgmtBean.requestStart();
        ShutdownHandler shutdown = new ShutdownHandler(boot);
        shutdown.run();
    } finally {
        unregisterQuietly(mgmtBean);
    }
}
Also used : AdapterManagerMBean(com.adaptris.core.runtime.AdapterManagerMBean) Adapter(com.adaptris.core.Adapter) Test(org.junit.Test)

Example 2 with AdapterManagerMBean

use of com.adaptris.core.runtime.AdapterManagerMBean in project interlok by adaptris.

the class ShutdownHandlerTest method testForceShutdown.

@Test
public void testForceShutdown() throws Exception {
    String adapterName = nameGenerator.safeUUID();
    Adapter adapter = new Adapter();
    adapter.setUniqueId(adapterName);
    BootstrapProperties boot = bootstrapWithAdapter(adapter);
    AdapterManagerMBean mgmtBean = boot.getConfigManager().createAdapter();
    try {
        mgmtBean.requestStart();
        HashSet<ObjectName> set = new HashSet(Arrays.asList(mgmtBean.createObjectName(), ObjectName.getInstance(JMX_ADAPTER_TYPE + ID_PREFIX + nameGenerator.safeUUID())));
        ShutdownHandler shutdown = new ShutdownHandler(boot);
        shutdown.forceShutdown(set);
    } finally {
        unregisterQuietly(mgmtBean);
    }
}
Also used : AdapterManagerMBean(com.adaptris.core.runtime.AdapterManagerMBean) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with AdapterManagerMBean

use of com.adaptris.core.runtime.AdapterManagerMBean in project interlok by adaptris.

the class UnifiedBootstrap method createAdapter.

public AdapterManagerMBean createAdapter() throws Exception {
    configurationUpdate();
    AdapterManagerMBean adapter = bootstrapProperties.getConfigManager().createAdapter(bootstrapProperties.findAdapterResource());
    log.info("Adapter created");
    return adapter;
}
Also used : AdapterManagerMBean(com.adaptris.core.runtime.AdapterManagerMBean)

Example 4 with AdapterManagerMBean

use of com.adaptris.core.runtime.AdapterManagerMBean in project interlok by adaptris.

the class UnifiedBootstrap method close.

public void close() throws Exception {
    AdapterRegistry.close(adapterRegistry.getAdapters());
    for (ObjectName objName : adapterRegistry.getAdapters()) {
        AdapterManagerMBean manager = JMX.newMBeanProxy(JmxHelper.findMBeanServer(bootstrapProperties), objName, AdapterManagerMBean.class);
        manager.unregisterMBean();
    }
    ManagementComponentFactory.closeCreated(bootstrapProperties, true);
}
Also used : AdapterManagerMBean(com.adaptris.core.runtime.AdapterManagerMBean) ObjectName(javax.management.ObjectName)

Example 5 with AdapterManagerMBean

use of com.adaptris.core.runtime.AdapterManagerMBean in project interlok by adaptris.

the class ShutdownHandlerTest method testShutdown.

@Test
public void testShutdown() throws Exception {
    String adapterName = nameGenerator.safeUUID();
    Adapter adapter = new Adapter();
    adapter.setUniqueId(adapterName);
    BootstrapProperties boot = bootstrapWithAdapter(adapter);
    AdapterManagerMBean mgmtBean = boot.getConfigManager().createAdapter();
    try {
        mgmtBean.requestStart();
        HashSet<ObjectName> set = new HashSet(Arrays.asList(mgmtBean.createObjectName(), ObjectName.getInstance(JMX_ADAPTER_TYPE + ID_PREFIX + nameGenerator.safeUUID())));
        ShutdownHandler shutdown = new ShutdownHandler(boot);
        shutdown.shutdown(set);
    } finally {
        unregisterQuietly(mgmtBean);
    }
}
Also used : AdapterManagerMBean(com.adaptris.core.runtime.AdapterManagerMBean) Adapter(com.adaptris.core.Adapter) ObjectName(javax.management.ObjectName) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

AdapterManagerMBean (com.adaptris.core.runtime.AdapterManagerMBean)6 ObjectName (javax.management.ObjectName)4 Adapter (com.adaptris.core.Adapter)3 Test (org.junit.Test)3 HashSet (java.util.HashSet)2 CoreException (com.adaptris.core.CoreException)1 TimeoutException (java.util.concurrent.TimeoutException)1