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);
}
}
}
});
}
Aggregations