Search in sources :

Example 41 with ServiceRegistry

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

the class QueueAdd method performRuntime.

@Override
@SuppressWarnings("unchecked")
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    ServiceRegistry registry = context.getServiceRegistry(true);
    final ServiceName serviceName = MessagingServices.getActiveMQServiceName(context.getCurrentAddress());
    ServiceController<?> serverService = registry.getService(serviceName);
    if (serverService != null) {
        final String queueName = context.getCurrentAddressValue();
        final CoreQueueConfiguration queueConfiguration = ConfigurationHelper.createCoreQueueConfiguration(context, queueName, model);
        final ServiceName queueServiceName = MessagingServices.getQueueBaseServiceName(serviceName).append(queueName);
        final ServiceBuilder sb = context.getServiceTarget().addService(queueServiceName);
        sb.requires(ActiveMQActivationService.getServiceName(serviceName));
        Supplier<ActiveMQServer> serverSupplier = sb.requires(serviceName);
        final QueueService service = new QueueService(serverSupplier, queueConfiguration, false, true);
        sb.setInitialMode(Mode.PASSIVE);
        sb.setInstance(service);
        sb.install();
    }
// else the initial subsystem install is not complete; MessagingSubsystemAdd will add a
// handler that calls addQueueConfigs
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ServiceName(org.jboss.msc.service.ServiceName) CoreQueueConfiguration(org.apache.activemq.artemis.core.config.CoreQueueConfiguration) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ServiceBuilder(org.jboss.msc.service.ServiceBuilder)

Example 42 with ServiceRegistry

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

the class EndpointPublisherImpl method doPublish.

/**
 * Publish the webapp for the WS deployment unit
 *
 * @param target
 * @param unit
 * @return
 * @throws Exception
 */
protected Context doPublish(ServiceTarget target, DeploymentUnit unit) throws Exception {
    final Deployment deployment = unit.getAttachment(WSAttachmentKeys.DEPLOYMENT_KEY);
    final List<Endpoint> endpoints = deployment.getService().getEndpoints();
    // otherwise we need to explicitly wait for the endpoint services to be started before creating the webapp.
    if (!runningInService) {
        final ServiceRegistry registry = unit.getServiceRegistry();
        final CountDownLatch latch = new CountDownLatch(endpoints.size());
        final LifecycleListener listener = new LifecycleListener() {

            @Override
            public void handleEvent(final ServiceController<?> controller, final LifecycleEvent event) {
                if (event == LifecycleEvent.UP) {
                    latch.countDown();
                    controller.removeListener(this);
                }
            }
        };
        ServiceName serviceName;
        for (Endpoint ep : endpoints) {
            serviceName = EndpointService.getServiceName(unit, ep.getShortName());
            registry.getRequiredService(serviceName).addListener(listener);
        }
        latch.await();
    }
    // TODO simplify and use findChild later in destroy()/stopWebApp()
    deployment.addAttachment(WebDeploymentController.class, startWebApp(host, unit));
    return new Context(unit.getAttachment(WSAttachmentKeys.JBOSSWEB_METADATA_KEY).getContextRoot(), endpoints);
}
Also used : Context(org.jboss.wsf.spi.publish.Context) Endpoint(org.jboss.wsf.spi.deployment.Endpoint) ServiceName(org.jboss.msc.service.ServiceName) Deployment(org.jboss.wsf.spi.deployment.Deployment) LifecycleEvent(org.jboss.msc.service.LifecycleEvent) ServiceController(org.jboss.msc.service.ServiceController) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) LifecycleListener(org.jboss.msc.service.LifecycleListener) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 43 with ServiceRegistry

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

the class TransactionExtension method getMBeanServer.

static MBeanServer getMBeanServer(OperationContext context) {
    final ServiceRegistry serviceRegistry = context.getServiceRegistry(false);
    final ServiceController<?> serviceController = serviceRegistry.getService(MBEAN_SERVER_SERVICE_NAME);
    if (serviceController == null) {
        throw TransactionLogger.ROOT_LOGGER.jmxSubsystemNotInstalled();
    }
    return (MBeanServer) serviceController.getValue();
}
Also used : ServiceRegistry(org.jboss.msc.service.ServiceRegistry) MBeanServer(javax.management.MBeanServer)

Example 44 with ServiceRegistry

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

the class ConnectionFactoryWriteAttributeHandler method applyUpdateToRuntime.

@Override
protected boolean applyUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName, final ModelNode newValue, final ModelNode currentValue, final HandbackHolder<Void> handbackHolder) throws OperationFailedException {
    AttributeDefinition attr = getAttributeDefinition(attributeName);
    if (attr.getFlags().contains(AttributeAccess.Flag.RESTART_ALL_SERVICES)) {
        // Restart required
        return true;
    }
    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 service isn't installed, so the work done in the Stage.MODEL part is all there is to it
        return false;
    } else if (service.getState() != ServiceController.State.UP) {
        // No, don't barf; just let the update apply to the model and put the server in a reload-required state
        return true;
    } else {
        if (!ActiveMQActivationService.isActiveMQServerActive(context, operation)) {
            return false;
        }
        // Actually apply the update
        applyOperationToActiveMQService(context, getName(operation), attributeName, newValue, service);
        return false;
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Example 45 with ServiceRegistry

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

the class StackOperationExecutor method execute.

@Override
public ModelNode execute(OperationContext context, Operation<ChannelFactory> operation) throws OperationFailedException {
    String stackName = context.getCurrentAddressValue();
    ServiceRegistry registry = context.getServiceRegistry(false);
    ServiceName serviceName = JGroupsRequirement.CHANNEL_FACTORY.getServiceName(context, stackName);
    try {
        ServiceController<ChannelFactory> controller = ServiceContainerHelper.getService(registry, serviceName);
        ServiceController.Mode mode = controller.getMode();
        controller.setMode(ServiceController.Mode.ACTIVE);
        try {
            return operation.execute(controller.awaitValue());
        } finally {
            controller.setMode(mode);
        }
    } catch (InterruptedException e) {
        throw new OperationFailedException(e.getLocalizedMessage(), e);
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) OperationFailedException(org.jboss.as.controller.OperationFailedException) ServiceController(org.jboss.msc.service.ServiceController) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ChannelFactory(org.wildfly.clustering.jgroups.spi.ChannelFactory)

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