Search in sources :

Example 36 with ServiceRegistry

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

the class BridgeAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) 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) {
        // The original subsystem initialization is complete; use the control object to create the divert
        if (service.getState() != ServiceController.State.UP) {
            throw MessagingLogger.ROOT_LOGGER.invalidServiceState(serviceName, ServiceController.State.UP, service.getState());
        }
        final String name = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
        BridgeConfiguration bridgeConfig = createBridgeConfiguration(context, name, model);
        // noinspection RedundantClassCall
        ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
        createBridge(bridgeConfig, server);
    }
// else the initial subsystem install is not complete; MessagingSubsystemAdd will add a
// handler that calls addBridgeConfigs
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ServiceName(org.jboss.msc.service.ServiceName) BridgeConfiguration(org.apache.activemq.artemis.core.config.BridgeConfiguration) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Example 37 with ServiceRegistry

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

the class DivertAdd method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) 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) {
        // The original subsystem initialization is complete; use the control object to create the divert
        if (service.getState() != ServiceController.State.UP) {
            throw MessagingLogger.ROOT_LOGGER.invalidServiceState(serviceName, ServiceController.State.UP, service.getState());
        }
        final String name = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
        DivertConfiguration divertConfiguration = createDivertConfiguration(context, name, model);
        ActiveMQServerControl serverControl = ActiveMQServer.class.cast(service.getValue()).getActiveMQServerControl();
        createDivert(name, divertConfiguration, serverControl);
    }
// else the initial subsystem install is not complete; MessagingSubsystemAdd will add a
// handler that calls addDivertConfigs
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ActiveMQServerControl(org.apache.activemq.artemis.api.core.management.ActiveMQServerControl) ServiceName(org.jboss.msc.service.ServiceName) DivertConfiguration(org.apache.activemq.artemis.core.config.DivertConfiguration) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Example 38 with ServiceRegistry

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

the class DivertRemove method performRuntime.

@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    final String name = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
    final ServiceRegistry registry = context.getServiceRegistry(true);
    final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
    final ServiceController<?> service = registry.getService(serviceName);
    if (service != null && service.getState() == ServiceController.State.UP) {
        ActiveMQServer server = ActiveMQServer.class.cast(service.getValue());
        try {
            server.getActiveMQServerControl().destroyDivert(name);
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            // TODO should this be an OFE instead?
            throw new RuntimeException(e);
        }
    }
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ServiceName(org.jboss.msc.service.ServiceName) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) OperationFailedException(org.jboss.as.controller.OperationFailedException)

Example 39 with ServiceRegistry

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

the class HandlerAdd method performRuntime.

@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
    // modify the runtime if we're booting, otherwise set reload required and leave the runtime unchanged
    if (context.isBooting()) {
        final PathAddress address = context.getCurrentAddress();
        final PathElement confElem = address.getElement(address.size() - 3);
        final String configType = confElem.getKey();
        final String configName = confElem.getValue();
        final String handlerChainType = address.getElement(address.size() - 2).getKey();
        final String handlerChainId = address.getElement(address.size() - 2).getValue();
        final String handlerName = address.getElement(address.size() - 1).getValue();
        final String handlerClass = Attributes.CLASS.resolveModelAttribute(context, model).asString();
        final ServiceTarget target = context.getServiceTarget();
        final ServiceName configServiceName = getConfigServiceName(configType, configName);
        final ServiceRegistry registry = context.getServiceRegistry(false);
        if (registry.getService(configServiceName) == null) {
            throw WSLogger.ROOT_LOGGER.missingConfig(configName);
        }
        final ServiceName handlerChainServiceName = getHandlerChainServiceName(configServiceName, handlerChainType, handlerChainId);
        if (registry.getService(handlerChainServiceName) == null) {
            throw WSLogger.ROOT_LOGGER.missingHandlerChain(configName, handlerChainType, handlerChainId);
        }
        final ServiceName handlerServiceName = getHandlerServiceName(handlerChainServiceName, handlerName);
        final ServiceBuilder<?> handlerServiceBuilder = target.addService(handlerServiceName);
        final Consumer<UnifiedHandlerMetaData> handlerConsumer = handlerServiceBuilder.provides(handlerServiceName);
        handlerServiceBuilder.setInstance(new HandlerService(handlerName, handlerClass, counter.incrementAndGet(), handlerConsumer));
        handlerServiceBuilder.install();
    } else {
        context.reloadRequired();
    }
}
Also used : PathElement(org.jboss.as.controller.PathElement) PackageUtils.getHandlerServiceName(org.jboss.as.webservices.dmr.PackageUtils.getHandlerServiceName) PackageUtils.getConfigServiceName(org.jboss.as.webservices.dmr.PackageUtils.getConfigServiceName) PackageUtils.getHandlerChainServiceName(org.jboss.as.webservices.dmr.PackageUtils.getHandlerChainServiceName) ServiceName(org.jboss.msc.service.ServiceName) HandlerService(org.jboss.as.webservices.service.HandlerService) UnifiedHandlerMetaData(org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData) PathAddress(org.jboss.as.controller.PathAddress) ServiceTarget(org.jboss.msc.service.ServiceTarget) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Example 40 with ServiceRegistry

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

the class WeldDeploymentCleanupProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final DeploymentUnit parent = Utils.getRootDeploymentUnit(deploymentUnit);
    final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
    final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
    // obtain service names
    ServiceName weldStartCompletionServiceName = parent.getServiceName().append(WeldStartCompletionService.SERVICE_NAME);
    ServiceName weldBootstrapServiceName = parent.getServiceName().append(WeldBootstrapService.SERVICE_NAME);
    ServiceName weldStartServiceName = parent.getServiceName().append(WeldStartService.SERVICE_NAME);
    // if it is not Weld deployment, we skip it
    if (!WeldDeploymentMarker.isPartOfWeldDeployment(deploymentUnit)) {
        return;
    }
    // only register this on top level deployments
    if (deploymentUnit.getParent() != null) {
        return;
    }
    // add dependency on our WeldBootstrapService and WeldStartService to ensure this goes after them
    ServiceBuilder<?> weldStartCompletionServiceBuilder = serviceTarget.addService(weldStartCompletionServiceName);
    final Supplier<WeldBootstrapService> bootstrapSupplier = weldStartCompletionServiceBuilder.requires(weldBootstrapServiceName);
    weldStartCompletionServiceBuilder.requires(weldStartServiceName);
    // require component start services from top level deployment
    for (ServiceName componentStartSN : getComponentStartServiceNames(deploymentUnit)) {
        weldStartCompletionServiceBuilder.requires(componentStartSN);
    }
    // require component start services from sub-deployments
    final List<DeploymentUnit> subDeployments = deploymentUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS);
    for (DeploymentUnit sub : subDeployments) {
        ServiceRegistry registry = sub.getServiceRegistry();
        List<ServiceName> componentStartServiceNames = getComponentStartServiceNames(sub);
        for (ServiceName componentStartSN : componentStartServiceNames) {
            weldStartCompletionServiceBuilder.requires(componentStartSN);
        }
    }
    weldStartCompletionServiceBuilder.setInstance(new WeldStartCompletionService(bootstrapSupplier, WeldDeploymentProcessor.getSetupActions(deploymentUnit), module.getClassLoader()));
    weldStartCompletionServiceBuilder.install();
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) WeldStartCompletionService(org.jboss.as.weld.WeldStartCompletionService) ServiceTarget(org.jboss.msc.service.ServiceTarget) WeldBootstrapService(org.jboss.as.weld.WeldBootstrapService) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) Module(org.jboss.modules.Module) 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