Search in sources :

Example 1 with DirectAdminObjectActivatorService

use of org.jboss.as.connector.services.resourceadapters.DirectAdminObjectActivatorService in project wildfly by wildfly.

the class AdministeredObjectDefinitionInjectionSource method getResourceValue.

public void getResourceValue(final ResolutionContext context, final ServiceBuilder<?> serviceBuilder, final DeploymentPhaseContext phaseContext, final Injector<ManagedReferenceFactory> injector) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    String raId = resourceAdapter;
    if (resourceAdapter.startsWith("#")) {
        raId = deploymentUnit.getParent().getName() + raId;
    }
    String deployerServiceName = raId;
    if (!raId.endsWith(".rar")) {
        deployerServiceName = deployerServiceName + ".rar";
        raId = deployerServiceName;
    }
    SUBSYSTEM_RA_LOGGER.debugf("@AdministeredObjectDefinition: %s for %s binding to %s ", className, resourceAdapter, jndiName);
    ContextNames.BindInfo bindInfo = ContextNames.bindInfoForEnvEntry(context.getApplicationName(), context.getModuleName(), context.getComponentName(), !context.isCompUsesModule(), jndiName);
    DirectAdminObjectActivatorService service = new DirectAdminObjectActivatorService(jndiName, className, resourceAdapter, raId, properties, module, bindInfo);
    ServiceName serviceName = DirectAdminObjectActivatorService.SERVICE_NAME_BASE.append(jndiName);
    final ServiceBuilder sb = phaseContext.getServiceTarget().addService(serviceName, service);
    sb.addDependency(ConnectorServices.IRONJACAMAR_MDR, AS7MetadataRepository.class, service.getMdrInjector());
    sb.requires(ConnectorServices.RESOURCE_ADAPTER_DEPLOYER_SERVICE_PREFIX.append(deployerServiceName));
    sb.setInitialMode(ServiceController.Mode.ACTIVE).install();
    serviceBuilder.addDependency(AdminObjectReferenceFactoryService.SERVICE_NAME_BASE.append(bindInfo.getBinderServiceName()), ManagedReferenceFactory.class, injector);
    serviceBuilder.addListener(new LifecycleListener() {

        private volatile boolean bound;

        public void handleEvent(final ServiceController<?> controller, final LifecycleEvent event) {
            switch(event) {
                case UP:
                    {
                        DEPLOYMENT_CONNECTOR_LOGGER.adminObjectAnnotation(jndiName);
                        bound = true;
                        break;
                    }
                case DOWN:
                    {
                        if (bound) {
                            DEPLOYMENT_CONNECTOR_LOGGER.unboundJca("AdminObject", jndiName);
                        }
                        break;
                    }
                case REMOVED:
                    {
                        DEPLOYMENT_CONNECTOR_LOGGER.debugf("Removed JCA AdminObject [%s]", jndiName);
                    }
            }
        }
    });
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) DirectAdminObjectActivatorService(org.jboss.as.connector.services.resourceadapters.DirectAdminObjectActivatorService) LifecycleEvent(org.jboss.msc.service.LifecycleEvent) LifecycleListener(org.jboss.msc.service.LifecycleListener) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) ContextNames(org.jboss.as.naming.deployment.ContextNames) ServiceBuilder(org.jboss.msc.service.ServiceBuilder)

Aggregations

DirectAdminObjectActivatorService (org.jboss.as.connector.services.resourceadapters.DirectAdminObjectActivatorService)1 ContextNames (org.jboss.as.naming.deployment.ContextNames)1 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 Module (org.jboss.modules.Module)1 LifecycleEvent (org.jboss.msc.service.LifecycleEvent)1 LifecycleListener (org.jboss.msc.service.LifecycleListener)1 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)1 ServiceName (org.jboss.msc.service.ServiceName)1