ManagementComponentFactory { public static List<ManagementComponentInfo> create(final BootstrapProperties p) throws Exception { if (!INSTANCE.getManagementComponents().containsKey(p)) { List<ManagementComponentInfo> manCompInfo = INSTANCE.createComponents(p); INSTANCE.getManagementComponents().put(p,manCompInfo ); } return INSTANCE.getManagementComponents().get(p); } private  ManagementComponentFactory(); static List<ManagementComponentInfo> create(final BootstrapProperties p); static void initCreated(BootstrapProperties bootstrapProperties); static void startCreated(BootstrapProperties bootstrapProperties); static void stopCreated(BootstrapProperties bootstrapProperties, boolean reverseOrder); static void closeCreated(BootstrapProperties bootstrapProperties, boolean reverseOrder);  }
@Test public void testCreateJsr160Component() throws Exception { final BootstrapProperties p = new BootstrapProperties(); final int port = PortManager.nextUnusedPort(5555); try { p.setProperty(Constants.CFG_KEY_MANAGEMENT_COMPONENT, "jmx"); p.setProperty(Constants.CFG_KEY_JMX_SERVICE_URL_KEY, "service:jmx:jmxmp: final List<ManagementComponentInfo> list = ManagementComponentFactory.create(p); assertEquals(1, list.size()); testLifecycle(list, p, false); } finally { PortManager.release(port); } }
@Test public void testCreateJettyComponent() throws Exception { final BootstrapProperties p = new BootstrapProperties(); final int port = PortManager.nextUnusedPort(5555); try { p.setProperty(Constants.CFG_KEY_MANAGEMENT_COMPONENT, "jetty"); p.setProperty(ServerBuilder.WEB_SERVER_PORT_CFG_KEY, String.valueOf(port)); final List<ManagementComponentInfo> list = ManagementComponentFactory.create(p); assertEquals(1, list.size()); testLifecycle(list, p, true); } finally { PortManager.release(port); } }
@Test public void testCreateMultipleComponents() throws Exception { final BootstrapProperties p = new BootstrapProperties(); final int port = PortManager.nextUnusedPort(8080); try { p.setProperty(Constants.CFG_KEY_MANAGEMENT_COMPONENT, DummyManagementComponent.class.getCanonicalName() + ":" + "jmx"); final List<ManagementComponentInfo> list = ManagementComponentFactory.create(p); assertEquals(2, list.size()); assertEquals(DummyManagementComponent.class.getName(), list.get(0).getClassName()); assertEquals(DummyManagementComponent.class.getCanonicalName(), list.get(0).getName()); assertEquals(ClosedState.getInstance(), list.get(0).getState()); testLifecycle(list, p, false); } finally { PortManager.release(port); } }
@Test public void testCreateComponentDoNotErrorOnLifecycleFail() throws Exception { final BootstrapProperties p = new BootstrapProperties(); final int port = PortManager.nextUnusedPort(8080); try { p.setProperty(Constants.CFG_KEY_MANAGEMENT_COMPONENT, AlwaysFailDummyManagementComponent.class.getCanonicalName()); final List<ManagementComponentInfo> list = ManagementComponentFactory.create(p); testLifecycle(list, p, false); } finally { PortManager.release(port); } }