Search in sources :

Example 1 with DefaultResourceAdapterService

use of org.jboss.as.ejb3.component.messagedriven.DefaultResourceAdapterService in project wildfly by wildfly.

the class DefaultResourceAdapterWriteHandler method updateDefaultAdapterService.

void updateDefaultAdapterService(final OperationContext context, final ModelNode model) throws OperationFailedException {
    final ModelNode adapterNameNode = EJB3SubsystemRootResourceDefinition.DEFAULT_RESOURCE_ADAPTER_NAME.resolveModelAttribute(context, model);
    final String adapterName = adapterNameNode.isDefined() ? adapterNameNode.asString() : null;
    final ServiceRegistry serviceRegistry = context.getServiceRegistry(true);
    ServiceController<DefaultResourceAdapterService> existingDefaultRANameService = (ServiceController<DefaultResourceAdapterService>) serviceRegistry.getService(DefaultResourceAdapterService.DEFAULT_RA_NAME_SERVICE_NAME);
    // if a default RA name service is already installed then just update the resource adapter name
    if (existingDefaultRANameService != null) {
        existingDefaultRANameService.getValue().setResourceAdapterName(adapterName);
    } else if (adapterName != null) {
        // create a new one and install
        final DefaultResourceAdapterService defaultResourceAdapterService = new DefaultResourceAdapterService(adapterName);
        ServiceController<?> newController = context.getServiceTarget().addService(DefaultResourceAdapterService.DEFAULT_RA_NAME_SERVICE_NAME, defaultResourceAdapterService).install();
    }
}
Also used : DefaultResourceAdapterService(org.jboss.as.ejb3.component.messagedriven.DefaultResourceAdapterService) ServiceController(org.jboss.msc.service.ServiceController) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

DefaultResourceAdapterService (org.jboss.as.ejb3.component.messagedriven.DefaultResourceAdapterService)1 ModelNode (org.jboss.dmr.ModelNode)1 ServiceController (org.jboss.msc.service.ServiceController)1 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)1