Search in sources :

Example 51 with ServiceRegistry

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

the class TransportRemove method performRuntime.

@Override
protected void performRuntime(OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
    final ModelNode address = operation.require(OP_ADDR);
    final PathAddress pathAddress = PathAddress.pathAddress(address);
    String transportName = pathAddress.getLastElement().getValue();
    final ServiceRegistry serviceRegistry = context.getServiceRegistry(true);
    ServiceName serviceName = TeiidServiceNames.transportServiceName(transportName);
    final ServiceController<?> controller = serviceRegistry.getService(serviceName);
    if (controller != null) {
        TransportService transport = TransportService.class.cast(controller.getValue());
        if (transport.isLocal()) {
            final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(LocalServerConnection.jndiNameForRuntime(transportName));
            context.removeService(bindInfo.getBinderServiceName());
            // $NON-NLS-1$
            context.removeService(TeiidServiceNames.localTransportServiceName(transportName).append("reference-factory"));
        }
        context.removeService(serviceName);
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ModelNode(org.jboss.dmr.ModelNode) ContextNames(org.jboss.as.naming.deployment.ContextNames)

Example 52 with ServiceRegistry

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

the class TranslatorDeployer method undeploy.

@Override
public void undeploy(final DeploymentUnit context) {
    if (!TeiidAttachments.isTranslator(context)) {
        return;
    }
    VDBTranslatorMetaData metadata = context.getAttachment(TeiidAttachments.TRANSLATOR_METADATA);
    if (metadata == null) {
        return;
    }
    final ServiceRegistry registry = context.getServiceRegistry();
    final ServiceName serviceName = TeiidServiceNames.translatorServiceName(metadata.getName());
    final ServiceController<?> controller = registry.getService(serviceName);
    if (controller != null) {
        controller.setMode(Mode.REMOVE);
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) VDBTranslatorMetaData(org.teiid.adminapi.impl.VDBTranslatorMetaData)

Example 53 with ServiceRegistry

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

the class TranslatorRemove method performRuntime.

@Override
protected void performRuntime(OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
    final ModelNode address = operation.require(OP_ADDR);
    final PathAddress pathAddress = PathAddress.pathAddress(address);
    String translatorName = pathAddress.getLastElement().getValue();
    final ServiceRegistry registry = context.getServiceRegistry(true);
    final ServiceName serviceName = TeiidServiceNames.translatorServiceName(translatorName);
    final ServiceController<?> controller = registry.getService(serviceName);
    if (controller != null) {
        context.removeService(serviceName);
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ModelNode(org.jboss.dmr.ModelNode)

Example 54 with ServiceRegistry

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

the class EJBDefaultDistinctNameWriteHandler method updateDefaultDistinctName.

void updateDefaultDistinctName(final OperationContext context, final ModelNode model) throws OperationFailedException {
    final ModelNode defaultDistinctName = this.attributeDefinition.resolveModelAttribute(context, model);
    final ServiceRegistry registry = context.getServiceRegistry(true);
    final ServiceController<?> existingDefaultLocalEJBReceiverServiceController = registry.getService(DefaultDistinctNameService.SERVICE_NAME);
    DefaultDistinctNameService service = (DefaultDistinctNameService) existingDefaultLocalEJBReceiverServiceController.getValue();
    if (!defaultDistinctName.isDefined()) {
        service.setDefaultDistinctName(null);
    } else {
        service.setDefaultDistinctName(defaultDistinctName.asString());
    }
}
Also used : ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ModelNode(org.jboss.dmr.ModelNode)

Example 55 with ServiceRegistry

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

the class EnableGracefulTxnShutdownWriteHandler method applyModelToRuntime.

private void applyModelToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode model) throws OperationFailedException {
    String name = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
    ServiceRegistry registry = context.getServiceRegistry(true);
    EJBSuspendHandlerService service = (EJBSuspendHandlerService) registry.getRequiredService(EJBSuspendHandlerService.SERVICE_NAME).getValue();
    if (service != null && this.gracefulTxnShutdownAttribute.getName().equals(attributeName)) {
        boolean enableGracefulTxnShutdown = this.gracefulTxnShutdownAttribute.resolveModelAttribute(context, model).asBoolean();
        service.enableGracefulTxnShutdown(enableGracefulTxnShutdown);
    }
}
Also used : EJBSuspendHandlerService(org.jboss.as.ejb3.suspend.EJBSuspendHandlerService) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Aggregations

ServiceRegistry (org.jboss.msc.service.ServiceRegistry)74 ServiceName (org.jboss.msc.service.ServiceName)51 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 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 DivertConfiguration (org.apache.activemq.artemis.core.config.DivertConfiguration)2