当前位置: 首页>>代码示例>>Java>>正文


Java ServiceController.getState方法代码示例

本文整理汇总了Java中org.jboss.msc.service.ServiceController.getState方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceController.getState方法的具体用法?Java ServiceController.getState怎么用?Java ServiceController.getState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.msc.service.ServiceController的用法示例。


在下文中一共展示了ServiceController.getState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:26,代码来源:CredentialStoreResourceDefinition.java

示例2: getModifiableSecurityRealm

import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:23,代码来源:ModifiableRealmDecorator.java

示例3: applyModelToRuntime

import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
private boolean applyModelToRuntime(OperationContext context, ModelNode operation, ModelNode fullModel) throws OperationFailedException {

        boolean reloadRequired = false;
        final String connectionName = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
        final ServiceName serviceName = LocalOutboundConnectionService.OUTBOUND_CONNECTION_BASE_SERVICE_NAME.append(connectionName);
        final ServiceRegistry registry = context.getServiceRegistry(true);
        ServiceController sc = registry.getService(serviceName);
        if (sc != null && sc.getState() == ServiceController.State.UP) {
                reloadRequired = true;
        } else {
            // Service isn't up so we can bounce it
            context.removeService(serviceName); // safe even if the service doesn't exist
            // install the service with new values
            LocalOutboundConnectionAdd.INSTANCE.installRuntimeService(context, operation, fullModel);
        }
        return reloadRequired;
    }
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:18,代码来源:LocalOutboundConnectionWriteHandler.java

示例4: applyModelToRuntime

import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
private boolean applyModelToRuntime(OperationContext context, ModelNode operation, ModelNode fullModel) throws OperationFailedException {

        boolean reloadRequired = false;
        final String connectionName = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
        final ServiceName serviceName = RemoteOutboundConnectionService.OUTBOUND_CONNECTION_BASE_SERVICE_NAME.append(connectionName);
        final ServiceRegistry registry = context.getServiceRegistry(true);
        ServiceController sc = registry.getService(serviceName);
        if (sc != null && sc.getState() == ServiceController.State.UP) {
            reloadRequired = true;
        } else {
            // Service isn't up so we can bounce it
            context.removeService(serviceName); // safe even if the service doesn't exist
            // install the service with new values
            RemoteOutboundConnectionAdd.INSTANCE.installRuntimeService(context, operation, fullModel);
        }

        return reloadRequired;
    }
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:19,代码来源:RemoteOutboundConnectionWriteHandler.java

示例5: applyModelToRuntime

import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
private void applyModelToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode fullModel) throws OperationFailedException {

        final String connectionName = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
        final ServiceName serviceName = GenericOutboundConnectionService.OUTBOUND_CONNECTION_BASE_SERVICE_NAME.append(connectionName);
        final ServiceRegistry registry = context.getServiceRegistry(true);
        ServiceController sc = registry.getService(serviceName);
        if (sc != null && sc.getState() == ServiceController.State.UP) {
            GenericOutboundConnectionService svc = GenericOutboundConnectionService.class.cast(sc.getValue());
            if (GenericOutboundConnectionResourceDefinition.URI.getName().equals(attributeName)) {
                svc.setDestination(GenericOutboundConnectionAdd.INSTANCE.getDestinationURI(context, fullModel));
            }
        } else {
            // Service isn't up so we can bounce it
            context.removeService(serviceName); // safe even if the service doesn't exist
            // install the service with new values
            GenericOutboundConnectionAdd.INSTANCE.installRuntimeService(context, operation, fullModel);
        }
    }
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:19,代码来源:GenericOutboundConnectionWriteHandler.java

示例6: execute

import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    List<ServiceName> failures = new ArrayList<>();
    ServiceRegistry registry = context.getServiceRegistry(false);
    for (ServiceName serviceName : requiredServices) {
        try {
            ServiceController<?> controller = registry.getService(serviceName);
            if (controller == null || State.UP != controller.getState()) {
                failures.add(serviceName);
            }
        } catch (ServiceNotFoundException ex) {
            failures.add(serviceName);
        }
    }
    if (!failures.isEmpty()) {
        Boolean attachment = context.getAttachment(MANAGEMENT_INTERFACE_KEY);
        if (attachment == null || !context.getAttachment(MANAGEMENT_INTERFACE_KEY)) {
            context.attach(MANAGEMENT_INTERFACE_KEY, false);
            context.addStep(new VerifyInstallationStep(), OperationContext.Stage.VERIFY);
        }
    } else {
        context.attach(MANAGEMENT_INTERFACE_KEY, true);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:25,代码来源:ManagementInterfaceAddStepHandler.java

示例7: testBadAdd

import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
@Test
public void testBadAdd() throws Exception {
    ServiceController<?> pathManagerService = getContainer().getRequiredService(PATH_MANAGER_SVC);
    PathManager pathManager = (PathManager) pathManagerService.getValue();

    PerformChangeCallback allCallback1 = new PerformChangeCallback(pathManager, "add1", Event.ADDED, Event.REMOVED, Event.UPDATED);

    ModelNode operation = createOperation(ADD);
    operation.get(OP_ADDR).add(PATH, "add1");
    operation.get(PATH).set("123");
    operation.get(RELATIVE_TO).set("bad");
    executeForFailure(operation);

    try {
        ServiceController<?> svc = getContainer().getRequiredService(AbstractPathService.pathNameOf("add1"));
        if (svc.getState() == State.UP) {
            Assert.fail("Should not managed to install service");
        }
    } catch (Exception expected) {
    }

    allCallback1.checkEvent(Event.ADDED, "add1", "123", "bad");
    allCallback1.checkEvent(Event.REMOVED, "add1", "123", "bad");
    allCallback1.checkDone();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:26,代码来源:PathsTestCase.java

示例8: applyUpdateToRuntime

import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
@Override
protected boolean applyUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName, final ModelNode resolvedValue,
                                       final ModelNode currentValue, final HandbackHolder<RollbackInfo> handbackHolder) throws OperationFailedException {

    final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
    final PathElement element = address.getLastElement();
    final String bindingName = element.getValue();
    final ModelNode bindingModel = context.readResource(PathAddress.EMPTY_ADDRESS).getModel();
    final ServiceName serviceName = SOCKET_BINDING_CAPABILITY.getCapabilityServiceName(bindingName, SocketBinding.class);
    final ServiceController<?> controller = context.getServiceRegistry(true).getRequiredService(serviceName);
    final SocketBinding binding = controller.getState() == ServiceController.State.UP ? SocketBinding.class.cast(controller.getValue()) : null;
    final boolean bound = binding != null && binding.isBound();
    if (binding == null) {
        // existing is not started, so can't update it. Instead reinstall the service
        handleBindingReinstall(context, bindingName, bindingModel, serviceName);
    } else if (bound) {
        // Cannot edit bound sockets
        return true;
    } else {
        handleRuntimeChange(context, operation, attributeName, resolvedValue, binding);
    }
    handbackHolder.setHandback(new RollbackInfo(bindingName, bindingModel, binding));
    return requiresRestart();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:25,代码来源:AbstractBindingWriteHandler.java

示例9: executeRuntimeStep

import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
    ServiceName providerLoaderName = context.getCapabilityServiceName(PROVIDERS_CAPABILITY, context.getCurrentAddressValue(), Provider[].class);
    ServiceController<Provider[]> serviceContainer = getRequiredService(context.getServiceRegistry(false), providerLoaderName, Provider[].class);
    if (serviceContainer.getState() != State.UP) {
        return;
    }

    populateProviders(context.getResult(), serviceContainer.getValue());
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:11,代码来源:ProviderDefinitions.java

示例10: getXnioWorker

import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
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();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:9,代码来源:WorkerResourceDefinition.java

示例11: getSSLContext

import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
/**
 * Get the {@link SSLContext} represented by this {@link Resource} or {@code null} if it is not currently available.
 *
 * @return The {@link SSLContext} represented by this {@link Resource} or {@code null} if it is not currently available.
 */
static SSLContext getSSLContext(ServiceController<SSLContext> sslContextServiceController) {
    if (sslContextServiceController == null || sslContextServiceController.getState() != State.UP) {
        return null;
    } else {
        return sslContextServiceController.getValue();
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:13,代码来源:SSLContextResource.java

示例12: getSaslServerAvailableMechanisms

import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
private static String[] getSaslServerAvailableMechanisms(OperationContext context) {
    RuntimeCapability<Void> runtimeCapability = SASL_SERVER_FACTORY_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue());
    ServiceName saslServerFactoryName = runtimeCapability.getCapabilityServiceName(SaslServerFactory.class);

    ServiceController<SaslServerFactory> serviceContainer = getRequiredService(context.getServiceRegistry(false), saslServerFactoryName, SaslServerFactory.class);
    if (serviceContainer.getState() != State.UP) {
        return null;
    }
    return serviceContainer.getValue().getMechanismNames(Collections.emptyMap());
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:11,代码来源:SaslServerDefinitions.java

示例13: getAvailableHttpMechanisms

import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
private static String[] getAvailableHttpMechanisms(OperationContext context) {
    RuntimeCapability<Void> runtimeCapability = HTTP_AUTHENTICATION_FACTORY_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue());
    ServiceName securityDomainHttpConfigurationName = runtimeCapability.getCapabilityServiceName(HttpAuthenticationFactory.class);

    ServiceController<HttpAuthenticationFactory> serviceContainer = getRequiredService(context.getServiceRegistry(false), securityDomainHttpConfigurationName, HttpAuthenticationFactory.class);
    if (serviceContainer.getState() != State.UP) {
        return null;
    }

    Collection<String> mechanismNames = serviceContainer.getValue().getMechanismNames();
    return  mechanismNames.toArray(new String[mechanismNames.size()]);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:13,代码来源:AuthenticationFactoryDefinitions.java

示例14: getAvailableSaslMechanisms

import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
private static String[] getAvailableSaslMechanisms(OperationContext context) {
    RuntimeCapability<Void> runtimeCapability = SASL_AUTHENTICATION_FACTORY_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue());
    ServiceName securityDomainSaslConfigurationName = runtimeCapability.getCapabilityServiceName(SaslAuthenticationFactory.class);

    ServiceController<SaslAuthenticationFactory> serviceContainer = getRequiredService(context.getServiceRegistry(false), securityDomainSaslConfigurationName, SaslAuthenticationFactory.class);
    if (serviceContainer.getState() != State.UP) {
        return null;
    }

    Collection<String> mechanismNames = serviceContainer.getValue().getMechanismNames();
    return  mechanismNames.toArray(new String[mechanismNames.size()]);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:13,代码来源:AuthenticationFactoryDefinitions.java

示例15: executeRuntimeStep

import org.jboss.msc.service.ServiceController; //导入方法依赖的package包/类
@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
    ServiceName keyStoreName = KEY_STORE_UTIL.serviceName(operation);

    ServiceController<KeyStore> serviceContainer = getRequiredService(context.getServiceRegistry(writeAccess), keyStoreName, KeyStore.class);
    State serviceState;
    if ((serviceState = serviceContainer.getState()) != State.UP) {
        if (serviceMustBeUp) {
            throw ROOT_LOGGER.requiredServiceNotUp(keyStoreName, serviceState);
        }
        return;
    }

    performRuntime(context.getResult(), context, operation, (KeyStoreService) serviceContainer.getService());
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:16,代码来源:KeyStoreDefinition.java


注:本文中的org.jboss.msc.service.ServiceController.getState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。