本文整理汇总了Java中org.jboss.msc.service.ServiceController.getService方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceController.getService方法的具体用法?Java ServiceController.getService怎么用?Java ServiceController.getService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.msc.service.ServiceController
的用法示例。
在下文中一共展示了ServiceController.getService方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getModifiableKeyStore
import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
/**
* Try to obtain a modifiable {@link KeyStore} based on the given {@link OperationContext}.
*
* @param context the current context
* @return the modifiable KeyStore
* @throws OperationFailedException if any error occurs while obtaining.
*/
static KeyStore getModifiableKeyStore(OperationContext context) throws OperationFailedException {
ServiceRegistry serviceRegistry = context.getServiceRegistry(true);
PathAddress currentAddress = context.getCurrentAddress();
RuntimeCapability<Void> runtimeCapability = KEY_STORE_RUNTIME_CAPABILITY.fromBaseCapability(currentAddress.getLastElement().getValue());
ServiceName serviceName = runtimeCapability.getCapabilityServiceName();
ServiceController<KeyStore> serviceContainer = getRequiredService(serviceRegistry, serviceName, KeyStore.class);
ServiceController.State serviceState = serviceContainer.getState();
if (serviceState != ServiceController.State.UP) {
throw ROOT_LOGGER.requiredServiceNotUp(serviceName, serviceState);
}
ModifiableKeyStoreService service = (ModifiableKeyStoreService) serviceContainer.getService();
return service.getModifiableValue();
}
示例2: executeRuntimeStep
import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
ServiceName credentialStoreServiceName = CREDENTIAL_STORE_UTIL.serviceName(operation);
ServiceController<?> credentialStoreServiceController = context.getServiceRegistry(writeAccess).getRequiredService(credentialStoreServiceName);
State serviceState;
if ((serviceState = credentialStoreServiceController.getState()) != State.UP) {
if (serviceMustBeUp) {
try {
// give it another chance to wait at most 500 mill-seconds
credentialStoreServiceController.awaitValue(500, TimeUnit.MILLISECONDS);
} catch (InterruptedException | IllegalStateException | TimeoutException e) {
throw ROOT_LOGGER.requiredServiceNotUp(credentialStoreServiceName, credentialStoreServiceController.getState());
}
}
serviceState = credentialStoreServiceController.getState();
if (serviceState != State.UP) {
if (serviceMustBeUp) {
throw ROOT_LOGGER.requiredServiceNotUp(credentialStoreServiceName, serviceState);
}
return;
}
}
CredentialStoreService service = (CredentialStoreService) credentialStoreServiceController.getService();
performRuntime(context.getResult(), context, operation, service);
}
示例3: applyOperation
import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
@Override
protected void applyOperation(final OperationContext context, ModelNode model, String attributeName,
ServiceController<?> service, boolean forRollback) throws OperationFailedException {
final QueuelessThreadPoolService pool = (QueuelessThreadPoolService) service.getService();
if (PoolAttributeDefinitions.KEEPALIVE_TIME.getName().equals(attributeName)) {
TimeUnit defaultUnit = pool.getKeepAliveUnit();
final TimeSpec spec = getTimeSpec(context, model, defaultUnit);
pool.setKeepAlive(spec);
} else if(PoolAttributeDefinitions.MAX_THREADS.getName().equals(attributeName)) {
pool.setMaxThreads(PoolAttributeDefinitions.MAX_THREADS.resolveModelAttribute(context, model).asInt());
} else if (!forRollback) {
// Programming bug. Throw a RuntimeException, not OFE, as this is not a client error
throw ThreadsLogger.ROOT_LOGGER.unsupportedQueuelessThreadPoolAttribute(attributeName);
}
}
示例4: applyOperation
import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
@Override
protected void applyOperation(final OperationContext context, ModelNode model, String attributeName,
ServiceController<?> service, boolean forRollback) throws OperationFailedException {
final UnboundedQueueThreadPoolService pool = (UnboundedQueueThreadPoolService) service.getService();
if (PoolAttributeDefinitions.KEEPALIVE_TIME.getName().equals(attributeName)) {
TimeUnit defaultUnit = pool.getKeepAliveUnit();
final TimeSpec spec = getTimeSpec(context, model, defaultUnit);
pool.setKeepAlive(spec);
} else if(PoolAttributeDefinitions.MAX_THREADS.getName().equals(attributeName)) {
pool.setMaxThreads(PoolAttributeDefinitions.MAX_THREADS.resolveModelAttribute(context, model).asInt());
} else if (!forRollback) {
// Programming bug. Throw a RuntimeException, not OFE, as this is not a client error
throw ThreadsLogger.ROOT_LOGGER.unsupportedUnboundedQueueThreadPoolAttribute(attributeName);
}
}
示例5: activate
import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
public void activate(ServiceActivatorContext serviceActivatorContext) throws ServiceRegistryException {
ServiceTarget target = serviceActivatorContext.getServiceTarget();
ServiceController argsController = serviceActivatorContext.getServiceRegistry().getService(ServiceName.of("wildfly", "swarm", "main-args"));
ValueService<String[]> argsService = (ValueService<String[]>) argsController.getService();
String[] args = argsService.getValue();
log.infof("Args available to services: %s\n", Arrays.asList(args));
ScannerService service = new ScannerService(args);
ServiceName serviceName = ServiceName.parse("org.jboss.rhiot.beacon.swarm.ScannerService");
target.addService(serviceName, service)
.install();
}
示例6: getService
import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
private static SecurityPropertyService getService(OperationContext context) {
ServiceRegistry serviceRegistry = context.getServiceRegistry(true);
ServiceController<?> service = serviceRegistry.getService(SecurityPropertyService.SERVICE_NAME);
if (service != null) {
Object serviceImplementation = service.getService();
if (serviceImplementation != null && serviceImplementation instanceof SecurityPropertyService) {
return (SecurityPropertyService) serviceImplementation;
}
}
// Again should not be reachable.
throw new IllegalStateException("Requires service not available or wrong type.");
}
示例7: uninstallSecurityPropertyService
import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
private static SecurityPropertyService uninstallSecurityPropertyService(OperationContext context) {
ServiceRegistry serviceRegistry = context.getServiceRegistry(true);
ServiceController<?> service = serviceRegistry.getService(SecurityPropertyService.SERVICE_NAME);
if (service != null) {
Object serviceImplementation = service.getService();
context.removeService(service);
if (serviceImplementation != null && serviceImplementation instanceof SecurityPropertyService) {
return (SecurityPropertyService) serviceImplementation;
}
}
return null;
}
示例8: testRuntime
import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
/**
* Tests that the outbound connections configured in the remoting subsytem are processed and services
* are created for them
*
* @throws Exception
*/
@Test
public void testRuntime() throws Exception {
KernelServices services = createKernelServicesBuilder(createRuntimeAdditionalInitialization())
.setSubsystemXml(getSubsystemXml())
.build();
ServiceController<Endpoint> endPointServiceController = (ServiceController<Endpoint>) services.getContainer().getRequiredService(RemotingServices.SUBSYSTEM_ENDPOINT);
endPointServiceController.setMode(ServiceController.Mode.ACTIVE);
Endpoint endpointService = endPointServiceController.getValue();
assertNotNull("Endpoint service was null", endpointService);
assertNotNull(endpointService.getName());
ServiceName connectorServiceName = RemotingServices.serverServiceName("remoting-connector");
ServiceController<?> remotingConnectorController = services.getContainer().getRequiredService(connectorServiceName);
remotingConnectorController.setMode(ServiceController.Mode.ACTIVE);
assertNotNull("Connector was null", remotingConnectorController);
InjectedSocketBindingStreamServerService remotingConnector = (InjectedSocketBindingStreamServerService) remotingConnectorController.getService();
assertEquals("remote", remotingConnector.getEndpointInjector().getValue().getName());
ServiceController<?> httpConnectorController = services.getContainer().getRequiredService(RemotingHttpUpgradeService.UPGRADE_SERVICE_NAME.append("http-connector"));
assertNotNull("Http connector was null", httpConnectorController);
httpConnectorController.setMode(ServiceController.Mode.ACTIVE);
InjectedSocketBindingStreamServerService httpConnector = (InjectedSocketBindingStreamServerService) remotingConnectorController.getService();
assertEquals("remote", httpConnector.getEndpointInjector().getValue().getName());
}
示例9: getExistingScanner
import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
private FileSystemDeploymentService getExistingScanner(OperationContext context, ModelNode operation) throws OperationFailedException {
final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
final String name = address.getLastElement().getValue();
ServiceController<?> serviceController = context.getServiceRegistry(true).getService(DeploymentScannerService.getServiceName(name));
if(serviceController != null && serviceController.getState() == ServiceController.State.UP) {
DeploymentScannerService service = (DeploymentScannerService) serviceController.getService();
return (FileSystemDeploymentService) service.getValue();
}
return null;
}
示例10: executeRuntimeStep
import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
final String attributeName = operation.require(ModelDescriptionConstants.NAME).asString();
if (context.getRunningMode() == RunningMode.NORMAL) {
ServiceController<?> serviceController = getService(context, operation);
final Service<?> service = serviceController.getService();
setResult(context, attributeName, service);
}
context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER);
}
示例11: applyOperation
import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
@Override
protected void applyOperation(final OperationContext context, ModelNode model, String attributeName,
ServiceController<?> service, boolean forRollback) throws OperationFailedException {
final BoundedQueueThreadPoolService pool = (BoundedQueueThreadPoolService) service.getService();
if (PoolAttributeDefinitions.KEEPALIVE_TIME.getName().equals(attributeName)) {
TimeUnit defaultUnit = pool.getKeepAliveUnit();
final TimeSpec spec = getTimeSpec(context, model, defaultUnit);
pool.setKeepAlive(spec);
} else if(PoolAttributeDefinitions.MAX_THREADS.getName().equals(attributeName)) {
pool.setMaxThreads(PoolAttributeDefinitions.MAX_THREADS.resolveModelAttribute(context, model).asInt());
} else if(PoolAttributeDefinitions.CORE_THREADS.getName().equals(attributeName)) {
int coreCount;
ModelNode coreNode = PoolAttributeDefinitions.CORE_THREADS.resolveModelAttribute(context, model);
if (coreNode.isDefined()) {
coreCount = coreNode.asInt();
} else {
// Core is same as max
coreCount = PoolAttributeDefinitions.MAX_THREADS.resolveModelAttribute(context, model).asInt();
}
pool.setCoreThreads(coreCount);
} else if(PoolAttributeDefinitions.QUEUE_LENGTH.getName().equals(attributeName)) {
if (forRollback) {
context.revertReloadRequired();
} else {
context.reloadRequired();
}
} else if (PoolAttributeDefinitions.ALLOW_CORE_TIMEOUT.getName().equals(attributeName)) {
pool.setAllowCoreTimeout(PoolAttributeDefinitions.ALLOW_CORE_TIMEOUT.resolveModelAttribute(context, model).asBoolean());
} else if (!forRollback) {
// Programming bug. Throw a RuntimeException, not OFE, as this is not a client error
throw ThreadsLogger.ROOT_LOGGER.unsupportedBoundedQueueThreadPoolAttribute(attributeName);
}
}
示例12: getWorkerService
import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
static WorkerService getWorkerService(final OperationContext context) {
final ServiceRegistry serviceRegistry = context.getServiceRegistry(false);
final String workerName = context.getCurrentAddress().getParent().getLastElement().getValue();
final ServiceName workerServiceName = WorkerResourceDefinition.IO_WORKER_RUNTIME_CAPABILITY.getCapabilityServiceName(workerName, XnioWorker.class);
final ServiceController<?> workerServiceController = serviceRegistry.getRequiredService(workerServiceName);
return (WorkerService) workerServiceController.getService();
}