Search in sources :

Example 6 with ServiceRegistry

use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.

the class ConnectionFactoryWriteAttributeHandler method revertUpdateToRuntime.

@Override
protected void revertUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName, final ModelNode valueToRestore, final ModelNode valueToRevert, final Void handback) throws OperationFailedException {
    ServiceRegistry registry = context.getServiceRegistry(true);
    final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
    ServiceController<?> service = registry.getService(serviceName);
    if (service != null && service.getState() == ServiceController.State.UP) {
        applyOperationToActiveMQService(context, getName(operation), attributeName, valueToRestore, service);
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Example 7 with ServiceRegistry

use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.

the class FederationDependencyProcessor method getFederationService.

private ServiceName getFederationService(DeploymentPhaseContext phaseContext) {
    DeploymentUnit deployment = phaseContext.getDeploymentUnit();
    ServiceRegistry serviceRegistry = phaseContext.getServiceRegistry();
    // We assume the mgmt ops that trigger IdentityProviderAddHandler or ServiceProviderAddHandler
    // run before the OperationStepHandler that triggers deploy. If not, that's a user mistake.
    // Since those handlers run first, we can count on MSC having services *registered* even
    // though we cannot count on them being *started*.
    ServiceController<?> service = serviceRegistry.getService(IdentityProviderService.createServiceName(deployment.getName()));
    if (service == null) {
        service = serviceRegistry.getService(ServiceProviderService.createServiceName(deployment.getName()));
    } else {
        IdentityProviderService identityProviderService = (IdentityProviderService) service.getService();
        IDPConfiguration idpType = identityProviderService.getValue().getConfiguration();
        if (idpType.isExternal()) {
            return null;
        }
    }
    if (service == null) {
        return null;
    }
    return service.getName();
}
Also used : IDPConfiguration(org.wildfly.extension.picketlink.federation.config.IDPConfiguration) IdentityProviderService(org.wildfly.extension.picketlink.federation.service.IdentityProviderService) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 8 with ServiceRegistry

use of org.jboss.msc.service.ServiceRegistry in project eap-additional-testsuite by jboss-set.

the class CurrentTopologyBean method getClusterMembers.

@Override
public Set<String> getClusterMembers(String cluster) {
    try {
        ServiceRegistry registry = currentServiceContainer();
        ServiceController<?> controller = registry.getService(ServiceName.JBOSS.append("infinispan", cluster));
        if (controller == null) {
            throw new IllegalStateException(String.format("Failed to locate service for cluster '%s'", cluster));
        }
        EmbeddedCacheManager manager = ServiceContainerHelper.getValue(controller, EmbeddedCacheManager.class);
        return this.getMembers(manager);
    } catch (StartException e) {
        throw new IllegalStateException(e);
    }
}
Also used : StartException(org.jboss.msc.service.StartException) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager)

Example 9 with ServiceRegistry

use of org.jboss.msc.service.ServiceRegistry in project wildfly-camel by wildfly-extras.

the class CamelContextRegistryService method start.

@Override
public void start(StartContext startContext) throws StartException {
    ContextCreateHandlerRegistry handlerRegistry = injectedHandlerRegistry.getValue();
    ServiceRegistry serviceRegistry = startContext.getController().getServiceContainer();
    contextRegistry = new CamelContextRegistryImpl(handlerRegistry, serviceRegistry, startContext.getChildTarget());
    // Register the service with gravia
    Runtime runtime = injectedRuntime.getValue();
    ModuleContext syscontext = runtime.getModuleContext();
    registration = syscontext.registerService(CamelContextRegistry.class, contextRegistry, null);
    for (final String name : subsystemState.getContextDefinitionNames()) {
        createCamelContext(name, subsystemState.getContextDefinition(name));
    }
}
Also used : Runtime(org.jboss.gravia.runtime.Runtime) ContextCreateHandlerRegistry(org.wildfly.extension.camel.ContextCreateHandlerRegistry) ModuleContext(org.jboss.gravia.runtime.ModuleContext) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) CamelContextRegistry(org.wildfly.extension.camel.CamelContextRegistry) MutableCamelContextRegistry(org.wildfly.extension.camel.service.CamelContextRegistryService.MutableCamelContextRegistry)

Example 10 with ServiceRegistry

use of org.jboss.msc.service.ServiceRegistry in project wildfly by wildfly.

the class EEJndiViewExtension method execute.

public void execute(final JndiViewExtensionContext context) throws OperationFailedException {
    final ModelNode applicationsNode = context.getResult().get("applications");
    final ServiceRegistry serviceRegistry = context.getOperationContext().getServiceRegistry(false);
    final Set<Resource.ResourceEntry> deploymentResource = context.getOperationContext().readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).getChildren(DEPLOYMENT);
    for (final Resource.ResourceEntry entry : deploymentResource) {
        final ServiceController<?> deploymentUnitServiceController = serviceRegistry.getService(ServiceName.JBOSS.append("deployment", "unit", entry.getName()));
        if (deploymentUnitServiceController != null) {
            final ModelNode deploymentNode = applicationsNode.get(entry.getName());
            final DeploymentUnit deploymentUnit = DeploymentUnit.class.cast(deploymentUnitServiceController.getValue());
            final String appName = cleanName(deploymentUnit.getName());
            final ServiceName appContextName = ContextNames.contextServiceNameOfApplication(appName);
            final ServiceController<?> appContextController = serviceRegistry.getService(appContextName);
            if (appContextController != null) {
                final NamingStore appStore = NamingStore.class.cast(appContextController.getValue());
                try {
                    context.addEntries(deploymentNode.get("java:app"), new NamingContext(appStore, null));
                } catch (NamingException e) {
                    throw new OperationFailedException(e, new ModelNode().set(EeLogger.ROOT_LOGGER.failedToRead("java:app", appName)));
                }
            }
            if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
                final List<ResourceRoot> roots = deploymentUnit.getAttachmentList(org.jboss.as.server.deployment.Attachments.RESOURCE_ROOTS);
                if (roots != null)
                    for (ResourceRoot root : roots) {
                        if (SubDeploymentMarker.isSubDeployment(root)) {
                            final ResourceRoot parentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
                            final String relativePath = root.getRoot().getPathNameRelativeTo(parentRoot.getRoot());
                            final ServiceName subDeploymentServiceName = Services.deploymentUnitName(deploymentUnit.getName(), relativePath);
                            final ServiceController<?> subDeploymentController = serviceRegistry.getService(subDeploymentServiceName);
                            if (subDeploymentController != null) {
                                final DeploymentUnit subDeploymentUnit = DeploymentUnit.class.cast(subDeploymentController.getValue());
                                handleModule(context, subDeploymentUnit, deploymentNode.get("modules"), serviceRegistry);
                            }
                        }
                    }
            } else {
                handleModule(context, deploymentUnit, deploymentNode.get("modules"), serviceRegistry);
            }
        }
    }
}
Also used : NamingStore(org.jboss.as.naming.NamingStore) Resource(org.jboss.as.controller.registry.Resource) OperationFailedException(org.jboss.as.controller.OperationFailedException) NamingContext(org.jboss.as.naming.NamingContext) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) ServiceName(org.jboss.msc.service.ServiceName) NamingException(javax.naming.NamingException) ServiceController(org.jboss.msc.service.ServiceController) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ModelNode(org.jboss.dmr.ModelNode) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

ServiceRegistry (org.jboss.msc.service.ServiceRegistry)75 ServiceName (org.jboss.msc.service.ServiceName)52 ModelNode (org.jboss.dmr.ModelNode)22 PathAddress (org.jboss.as.controller.PathAddress)15 ServiceTarget (org.jboss.msc.service.ServiceTarget)15 OperationFailedException (org.jboss.as.controller.OperationFailedException)13 ServiceController (org.jboss.msc.service.ServiceController)12 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)8 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)8 OperationContext (org.jboss.as.controller.OperationContext)6 Resource (org.jboss.as.controller.registry.Resource)6 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)5 Activation (org.jboss.jca.common.api.metadata.resourceadapter.Activation)5 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)4 PathElement (org.jboss.as.controller.PathElement)4 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)3 DefaultAccessTimeoutService (org.jboss.as.ejb3.component.DefaultAccessTimeoutService)3 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)3 ArrayList (java.util.ArrayList)2 BridgeConfiguration (org.apache.activemq.artemis.core.config.BridgeConfiguration)2