Java Code Examples for org.jboss.msc.service.ServiceController#getValue()
The following examples show how to use
org.jboss.msc.service.ServiceController#getValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JBossSubsystemXMLTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testInstallSubsystemXmlPlatformPlugins() throws Exception { String subsystemXml = FileUtils.readFile(SUBSYSTEM_WITH_PROCESS_ENGINES_ELEMENT_ONLY); KernelServices services = createKernelServicesBuilder(null) .setSubsystemXml(subsystemXml) .build(); ServiceContainer container = services.getContainer(); ServiceController<?> serviceController = container.getService(PLATFORM_BPM_PLATFORM_PLUGINS_SERVICE_NAME); assertNotNull(serviceController); Object platformPlugins = serviceController.getValue(); assertNotNull(platformPlugins); assertTrue(platformPlugins instanceof BpmPlatformPlugins); List<BpmPlatformPlugin> plugins = ((BpmPlatformPlugins) platformPlugins).getPlugins(); assertEquals(1, plugins.size()); assertTrue(plugins.get(0) instanceof ExampleBpmPlatformPlugin); }
Example 2
Source File: ModifiableRealmDecorator.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
/** * Try to obtain a {@link ModifiableSecurityRealm} based on the given {@link OperationContext}. * * @param context the current context * @return the current security realm * @throws OperationFailedException if any error occurs obtaining the reference to the security realm. */ static ModifiableSecurityRealm getModifiableSecurityRealm(OperationContext context) throws OperationFailedException { ServiceRegistry serviceRegistry = context.getServiceRegistry(true); PathAddress currentAddress = context.getCurrentAddress(); RuntimeCapability<Void> runtimeCapability = MODIFIABLE_SECURITY_REALM_RUNTIME_CAPABILITY.fromBaseCapability(currentAddress.getLastElement().getValue()); ServiceName realmName = runtimeCapability.getCapabilityServiceName(); ServiceController<ModifiableSecurityRealm> serviceController = getRequiredService(serviceRegistry, realmName, ModifiableSecurityRealm.class); if ( serviceController.getState() != ServiceController.State.UP ){ try { serviceController.awaitValue(500, TimeUnit.MILLISECONDS); } catch (IllegalStateException | InterruptedException | TimeoutException e) { throw ROOT_LOGGER.requiredServiceNotUp(serviceController.getName(), serviceController.getState()); } } return serviceController.getValue(); }
Example 3
Source File: EmbeddedHostControllerFactory.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private synchronized void establishModelControllerClient(ControlledProcessState.State state, boolean storeState) { ModelControllerClient newClient = null; if (state != ControlledProcessState.State.STOPPING && state != ControlledProcessState.State.STOPPED && serviceContainer != null) { ModelControllerClientFactory clientFactory; try { @SuppressWarnings("unchecked") final ServiceController clientFactorySvc = serviceContainer.getService(DomainModelControllerService.CLIENT_FACTORY_SERVICE_NAME); clientFactory = (ModelControllerClientFactory) clientFactorySvc.getValue(); } catch (RuntimeException e) { // Either NPE because clientFactorySvc was not installed, or ISE from getValue because not UP clientFactory = null; } if (clientFactory != null) { newClient = clientFactory.createSuperUserClient(executorService, true); } } modelControllerClient = newClient; if (storeState || currentProcessState == null) { currentProcessState = state; } }
Example 4
Source File: EmbeddedStandaloneServerFactory.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private synchronized void establishModelControllerClient(ControlledProcessState.State state, boolean storeState) { ModelControllerClient newClient = null; if (state != ControlledProcessState.State.STOPPING && state != ControlledProcessState.State.STOPPED && serviceContainer != null) { ModelControllerClientFactory clientFactory; try { @SuppressWarnings("unchecked") final ServiceController clientFactorySvc = serviceContainer.getService(ServerService.JBOSS_SERVER_CLIENT_FACTORY); clientFactory = (ModelControllerClientFactory) clientFactorySvc.getValue(); } catch (RuntimeException e) { // Either NPE because clientFactorySvc was not installed, or ISE from getValue because not UP clientFactory = null; } if (clientFactory != null) { newClient = clientFactory.createSuperUserClient(executorService, true); } } modelControllerClient = newClient; if (storeState || currentProcessState == null) { currentProcessState = state; } }
Example 5
Source File: PathsTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Test public void testCannotRemoveDependentService() throws Exception { testAddPath(); ServiceController<?> pathManagerService = getContainer().getRequiredService(PATH_MANAGER_SVC); PathManager pathManager = (PathManager) pathManagerService.getValue(); PerformChangeCallback allCallback1 = new PerformChangeCallback(pathManager, "add2", Event.ADDED, Event.REMOVED, Event.UPDATED); PerformChangeCallback allCallback2 = new PerformChangeCallback(pathManager, "add2", Event.ADDED, Event.REMOVED, Event.UPDATED); checkServiceAndPathEntry("add1", "xyz", null); checkServiceAndPathEntry("add2", "123", "add1"); ModelNode operation = createOperation(REMOVE); operation.get(OP_ADDR).add(PATH, "add1"); executeForFailure(operation); allCallback1.checkDone(); allCallback2.checkDone(); checkServiceAndPathEntry("add1", "xyz", null); checkServiceAndPathEntry("add2", "123", "add1"); }
Example 6
Source File: SpringContextBindingDependenciesEarTest.java From wildfly-camel with Apache License 2.0 | 6 votes |
@Test public void testCamelSpringDeploymentWaitsForJndiBindings() { CamelContext camelctx = contextRegistry.getCamelContext("jndi-binding-spring-context"); Assert.assertNotNull("Expected jndi-binding-spring-context to not be null", camelctx); Assert.assertEquals(ServiceStatus.Started, camelctx.getStatus()); BindInfo bindInfo = bindInfoFor("java:/spring/binding/test"); ServiceName serviceName = bindInfo.getBinderServiceName(); ServiceController<?> controller = serviceContainer.getService(serviceName); Assert.assertNotNull("Expected controller to not be null", controller); ManagedReferenceFactory referenceFactory = (ManagedReferenceFactory) controller.getValue(); DelayedBinderService binderService = (DelayedBinderService) referenceFactory.getReference().getInstance(); // Make sure the DelayedBinderService did sleep Assert.assertTrue("Expected DelayedBinderService.getSleepStart() to be > 0", binderService.getSleepStart() > 0); // Verify that the camel context waited for the binding service to finish starting CamelContextStartupEventNotifier notifier = (CamelContextStartupEventNotifier) camelctx.getRegistry().lookupByName("contextStartupEventNotifier"); long startupDelay = notifier.getStartupTime() - binderService.getSleepStart(); Assert.assertTrue(startupDelay >= binderService.getSleepDelay()); }
Example 7
Source File: ModuleExtensionNameProcessor.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** {@inheritDoc} */ public void undeploy(final DeploymentUnit deploymentUnit) { final ExtensionInfo extensionInfo = deploymentUnit.getAttachment(Attachments.EXTENSION_INFORMATION); if (extensionInfo == null) { return; } // we need to remove the extension on undeploy final ServiceController<?> extensionIndexController = deploymentUnit.getServiceRegistry().getRequiredService( Services.JBOSS_DEPLOYMENT_EXTENSION_INDEX); final ExtensionIndex extensionIndexService = (ExtensionIndex) extensionIndexController.getValue(); final ModuleIdentifier moduleIdentifier = deploymentUnit.getAttachment(Attachments.MODULE_IDENTIFIER); extensionIndexService.removeDeployedExtension(extensionInfo.getName(), moduleIdentifier); }
Example 8
Source File: TransactionsArquillianTest.java From thorntail with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Test public void testPorts() throws Exception { ServiceController<SocketBinding> statusManagerService = (ServiceController<SocketBinding>) registry.getService(ServiceName.parse("org.wildfly.network.socket-binding.txn-status-manager")); SocketBinding statusManager = statusManagerService.getValue(); assertEquals(9876, statusManager.getAbsolutePort()); ServiceController<SocketBinding> recoveryService = (ServiceController<SocketBinding>) registry.getService(ServiceName.parse("org.wildfly.network.socket-binding.txn-recovery-environment")); SocketBinding recovery = recoveryService.getValue(); assertEquals(4567, recovery.getAbsolutePort()); }
Example 9
Source File: BootstrapListener.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public void logAdminConsole() { ServiceController<?> controller = serviceContainer.getService(UndertowHttpManagementService.SERVICE_NAME); if (controller != null) { HttpManagement mgmt = (HttpManagement)controller.getValue(); boolean hasHttp = mgmt.getHttpNetworkInterfaceBinding() != null; boolean hasHttps = mgmt.getHttpsNetworkInterfaceBinding() != null; if (hasHttp && hasHttps) { ServerLogger.AS_ROOT_LOGGER.logHttpAndHttpsManagement(NetworkUtils.formatIPAddressForURI(mgmt.getHttpNetworkInterfaceBinding().getAddress()), mgmt.getHttpPort(), NetworkUtils.formatIPAddressForURI(mgmt.getHttpsNetworkInterfaceBinding().getAddress()), mgmt.getHttpsPort()); if (mgmt.hasConsole()) { ServerLogger.AS_ROOT_LOGGER.logHttpAndHttpsConsole(NetworkUtils.formatIPAddressForURI(mgmt.getHttpNetworkInterfaceBinding().getAddress()), mgmt.getHttpPort(), NetworkUtils.formatIPAddressForURI(mgmt.getHttpsNetworkInterfaceBinding().getAddress()), mgmt.getHttpsPort()); } else { ServerLogger.AS_ROOT_LOGGER.logNoConsole(); } } else if (hasHttp) { ServerLogger.AS_ROOT_LOGGER.logHttpManagement(NetworkUtils.formatIPAddressForURI(mgmt.getHttpNetworkInterfaceBinding().getAddress()), mgmt.getHttpPort()); if (mgmt.hasConsole()) { ServerLogger.AS_ROOT_LOGGER.logHttpConsole(NetworkUtils.formatIPAddressForURI(mgmt.getHttpNetworkInterfaceBinding().getAddress()), mgmt.getHttpPort()); } else { ServerLogger.AS_ROOT_LOGGER.logNoConsole(); } } else if (hasHttps) { ServerLogger.AS_ROOT_LOGGER.logHttpsManagement(NetworkUtils.formatIPAddressForURI(mgmt.getHttpsNetworkInterfaceBinding().getAddress()), mgmt.getHttpsPort()); if (mgmt.hasConsole()) { ServerLogger.AS_ROOT_LOGGER.logHttpsConsole(NetworkUtils.formatIPAddressForURI(mgmt.getHttpsNetworkInterfaceBinding().getAddress()), mgmt.getHttpsPort()); } else { ServerLogger.AS_ROOT_LOGGER.logNoConsole(); } } else { ServerLogger.AS_ROOT_LOGGER.logNoHttpManagement(); ServerLogger.AS_ROOT_LOGGER.logNoConsole(); } } }
Example 10
Source File: MscRuntimeContainerDelegate.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected ProcessEngine getProcessEngineService(ServiceName processEngineServiceName) { try { ServiceController<ProcessEngine> serviceController = getProcessEngineServiceController(processEngineServiceName); return serviceController.getValue(); } catch (ServiceNotFoundException e) { return null; } }
Example 11
Source File: MscRuntimeContainerDelegate.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") protected MscManagedProcessApplication getManagedProcessApplication(String name) { ServiceController<MscManagedProcessApplication> serviceController = (ServiceController<MscManagedProcessApplication>) serviceContainer .getService(ServiceNames.forManagedProcessApplication(name)); if (serviceController != null) { return serviceController.getValue(); } else { return null; } }
Example 12
Source File: OtherServicesSubsystemTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Test that a port offset of 0 works correctly. */ @Test public void testPortOffsetZero() throws Exception { ((OtherServicesSubsystemExtension)getMainExtension()).setAddHandler(SubsystemAddWithSocketBindingUserService.INSTANCE); //Parse the subsystem xml and install into the controller String subsystemXml = "<subsystem xmlns=\"" + SimpleSubsystemExtension.NAMESPACE + "\">" + "</subsystem>"; KernelServices services = createKernelServicesBuilder(new PortOffsetZeroInit()) .setSubsystemXml(subsystemXml) .build(); //Read the whole model and make sure it looks as expected ModelNode model = services.readWholeModel(); Assert.assertTrue(model.get(SUBSYSTEM).hasDefined(OtherServicesSubsystemExtension.SUBSYSTEM_NAME)); ModelNode group = model.require(SOCKET_BINDING_GROUP).require(ControllerInitializer.SOCKET_BINDING_GROUP_NAME); Assert.assertEquals(8000, group.require(PORT_OFFSET).asInt()); ModelNode bindings = group.require(SOCKET_BINDING); Assert.assertEquals(1, bindings.asList().size()); Assert.assertEquals(0, group.require(SOCKET_BINDING).require("test2").require(PORT).asInt()); ServiceController<?> controller = services.getContainer().getService(SocketBindingUserService.NAME); Assert.assertNotNull(controller); SocketBindingUserService service = (SocketBindingUserService)controller.getValue(); SocketBinding socketBinding = service.socketBindingValue.getValue(); Assert.assertEquals(8000, socketBinding.getSocketBindings().getPortOffset()); Assert.assertFalse("fixed port", socketBinding.isFixedPort()); Assert.assertEquals(0, socketBinding.getPort()); // Port 0 must not be affected by port-offset Assert.assertEquals(0, socketBinding.getSocketAddress().getPort()); }
Example 13
Source File: CamelUndertowHostService.java From wildfly-camel with Apache License 2.0 | 5 votes |
private static CamelEndpointDeploymentSchedulerService lookupDeploymentSchedulerService(ClassLoader classLoader) { final ServiceName serviceName = CamelEndpointDeploymentSchedulerService .deploymentSchedulerServiceName(classLoader); ServiceController<?> serviceController = CurrentServiceContainer.getServiceContainer() .getRequiredService(serviceName); return (CamelEndpointDeploymentSchedulerService) serviceController.getValue(); }
Example 14
Source File: WorkerResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static XnioWorker getXnioWorker(ServiceRegistry serviceRegistry, String name) { ServiceName serviceName = IO_WORKER_RUNTIME_CAPABILITY.getCapabilityServiceName(name, XnioWorker.class); ServiceController<XnioWorker> controller = (ServiceController<XnioWorker>) serviceRegistry.getService(serviceName); if (controller == null || controller.getState() != ServiceController.State.UP) { return null; } return controller.getValue(); }
Example 15
Source File: PathsTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Test public void testPathManagerRemoveNotifications() throws Exception { testAddPath(); ServiceController<?> pathManagerService = getContainer().getRequiredService(PATH_MANAGER_SVC); PathManager pathManager = (PathManager) pathManagerService.getValue(); PerformChangeCallback allCallback1 = new PerformChangeCallback(pathManager, "add1", Event.ADDED, Event.REMOVED, Event.UPDATED); PerformChangeCallback addCallback1 = new PerformChangeCallback(pathManager, "add1", Event.ADDED); PerformChangeCallback changeCallback1 = new PerformChangeCallback(pathManager, "add1", Event.UPDATED); PerformChangeCallback removeCallback1 = new PerformChangeCallback(pathManager, "add1", Event.REMOVED); PerformChangeCallback allCallback2 = new PerformChangeCallback(pathManager, "add2", Event.ADDED, Event.REMOVED, Event.UPDATED); //Test callbacks for 2 ModelNode operation = createOperation(REMOVE); operation.get(OP_ADDR).add(PATH, "add2"); executeForResult(operation); allCallback1.checkDone(); addCallback1.checkDone(); changeCallback1.checkDone(); removeCallback1.checkDone(); allCallback2.checkEvent(Event.REMOVED, "add2", "123", "add1"); allCallback2.checkDone(); //Test callbacks for 1 operation = createOperation(REMOVE); operation.get(OP_ADDR).add(PATH, "add1"); executeForResult(operation); allCallback1.checkEvent(Event.REMOVED, "add1", "xyz", null); allCallback1.checkDone(); addCallback1.checkDone(); changeCallback1.checkDone(); removeCallback1.checkEvent(Event.REMOVED, "add1", "xyz", null); removeCallback1.checkDone(); allCallback2.checkDone(); //Test that the removed callbacks don't get triggered allCallback1.remove(); addCallback1.remove(); changeCallback1.remove(); removeCallback1.remove(); allCallback2.remove(); testAddPath(); operation = createOperation(REMOVE); operation.get(OP_ADDR).add(PATH, "add2"); executeForResult(operation); operation = createOperation(REMOVE); operation.get(OP_ADDR).add(PATH, "add1"); executeForResult(operation); allCallback1.checkDone(); addCallback1.checkDone(); changeCallback1.checkDone(); removeCallback1.checkDone(); allCallback2.checkDone(); }
Example 16
Source File: PathsTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Test public void testPathManagerChangeNotifications() throws Exception { testAddPath(); ServiceController<?> pathManagerService = getContainer().getRequiredService(PATH_MANAGER_SVC); PathManager pathManager = (PathManager) pathManagerService.getValue(); ModelNode operation = createOperation(ADD); operation.get(OP_ADDR).add(PATH, "add3"); operation.get(PATH).set("xyz"); executeForResult(operation); PerformChangeCallback allCallback1 = new PerformChangeCallback(pathManager, "add1", Event.ADDED, Event.REMOVED, Event.UPDATED); PerformChangeCallback allCallback2 = new PerformChangeCallback(pathManager, "add2", Event.ADDED, Event.REMOVED, Event.UPDATED); PerformChangeCallback addCallback2 = new PerformChangeCallback(pathManager, "add2", Event.ADDED); PerformChangeCallback changeCallback2 = new PerformChangeCallback(pathManager, "add2", Event.UPDATED); PerformChangeCallback removeCallback2 = new PerformChangeCallback(pathManager, "add2", Event.REMOVED); //Test callbacks for 2 relative to absolute operation = createOperation(WRITE_ATTRIBUTE_OPERATION); operation.get(OP_ADDR).add(PATH, "add2"); operation.get(NAME).set(RELATIVE_TO); operation.get(VALUE).set("add3"); executeForResult(operation); allCallback1.checkDone(); allCallback2.checkEvent(Event.UPDATED, "add2", "123", "add3"); allCallback2.checkDone(); addCallback2.checkDone(); changeCallback2.checkEvent(Event.UPDATED, "add2", "123", "add3"); changeCallback2.checkDone(); removeCallback2.checkDone(); operation = createOperation(WRITE_ATTRIBUTE_OPERATION); operation.get(OP_ADDR).add(PATH, "add2"); operation.get(NAME).set(RELATIVE_TO); operation.get(VALUE).set(new ModelNode()); executeForResult(operation); allCallback1.checkDone(); allCallback2.checkEvent(Event.UPDATED, "add2", "123", null); allCallback2.checkDone(); addCallback2.checkDone(); changeCallback2.checkEvent(Event.UPDATED, "add2", "123", null); changeCallback2.checkDone(); removeCallback2.checkDone(); operation = createOperation(WRITE_ATTRIBUTE_OPERATION); operation.get(OP_ADDR).add(PATH, "add2"); operation.get(NAME).set(PATH); operation.get(VALUE).set("abc"); executeForResult(operation); allCallback1.checkDone(); allCallback2.checkEvent(Event.UPDATED, "add2", "abc", null); allCallback2.checkDone(); addCallback2.checkDone(); changeCallback2.checkEvent(Event.UPDATED, "add2", "abc", null); changeCallback2.checkDone(); removeCallback2.checkDone(); //Test callbacks for 2 relative to absolute operation = createOperation(WRITE_ATTRIBUTE_OPERATION); operation.get(OP_ADDR).add(PATH, "add2"); operation.get(NAME).set(RELATIVE_TO); operation.get(VALUE).set("add1"); executeForResult(operation); allCallback1.checkDone(); allCallback2.checkEvent(Event.UPDATED, "add2", "abc", "add1"); allCallback2.checkDone(); addCallback2.checkDone(); changeCallback2.checkEvent(Event.UPDATED, "add2", "abc", "add1"); changeCallback2.checkDone(); removeCallback2.checkDone(); }
Example 17
Source File: ProcessApplicationDeploymentProcessor.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") protected ProcessEngine getProcessEngineForArchive(ServiceName serviceName, ServiceRegistry serviceRegistry) { ServiceController<ProcessEngine> processEngineServiceController = (ServiceController<ProcessEngine>) serviceRegistry.getRequiredService(serviceName); return processEngineServiceController.getValue(); }
Example 18
Source File: JmxRbacTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private MBeanServer getMBeanServer() throws Exception { ServiceController controller = getContainer().getRequiredService(MBeanServerService.SERVICE_NAME); return (PluggableMBeanServer)controller.getValue(); }
Example 19
Source File: ServiceLocator.java From wildfly-camel with Apache License 2.0 | 4 votes |
public static <T extends Object> T getRequiredService(ServiceName serviceName, Class<T> type) { ServiceController<?> serviceController = serviceContainer.getRequiredService(serviceName); T service = (T) serviceController.getValue(); return service; }
Example 20
Source File: JMXSubsystemRootResource.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private void setPluggableMBeanServerCoreSensitivity(OperationContext context, boolean sensitivity) { ServiceController<?> controller = context.getServiceRegistry(false).getRequiredService(MBeanServerService.SERVICE_NAME); PluggableMBeanServerImpl server = (PluggableMBeanServerImpl)controller.getValue(); server.setNonFacadeMBeansSensitive(sensitivity); }