ServiceName serviceName = ConnectorServices.registerDeployment(raName);
ResourceAdapterXmlDeploymentService service = new ResourceAdapterXmlDeploymentService(connectorXmlDescriptor,
raxml, module, deployment, serviceName);
ServiceBuilder builder = serviceTarget
.addService(serviceName, service)
.addDependency(ConnectorServices.IRONJACAMAR_MDR, MetadataRepository.class, service.getMdrInjector())
.addDependency(ConnectorServices.RA_REPOSISTORY_SERVICE, ResourceAdapterRepository.class,
service.getRaRepositoryInjector())
.addDependency(ConnectorServices.MANAGEMENT_REPOSISTORY_SERVICE, ManagementRepository.class,
service.getManagementRepositoryInjector())
.addDependency(ConnectorServices.RESOURCE_ADAPTER_REGISTRY_SERVICE,
ResourceAdapterDeploymentRegistry.class, service.getRegistryInjector())
.addDependency(ConnectorServices.TRANSACTION_INTEGRATION_SERVICE, TransactionIntegration.class,
service.getTxIntegrationInjector())
.addDependency(ConnectorServices.CONNECTOR_CONFIG_SERVICE, JcaSubsystemConfiguration.class,
service.getConfigInjector())
.addDependency(SubjectFactoryService.SERVICE_NAME, SubjectFactory.class,
service.getSubjectFactoryInjector())
.addDependency(ConnectorServices.CCM_SERVICE, CachedConnectionManager.class, service.getCcmInjector())
.addDependency(ConnectorServices.IDLE_REMOVER_SERVICE)
.addDependency(ConnectorServices.CONNECTION_VALIDATOR_SERVICE)
.addDependency(NamingService.SERVICE_NAME)
.addDependency(ConnectorServices.RESOURCE_ADAPTER_DEPLOYER_SERVICE_PREFIX.append(connectorXmlDescriptor.getDeploymentName()));
builder.addListener(new AbstractServiceListener<Object>() {
public void transition(final ServiceController<? extends Object> controller,
final ServiceController.Transition transition) {
switch (transition) {
case STARTING_to_UP: {
CommonDeployment deploymentMD = ((ResourceAdapterXmlDeploymentService) controller.getService()).getRaxmlDeployment();
if (deploymentMD.getConnectionManagers() != null && deploymentMD.getConnectionManagers()[0].getPool() != null) {
StatisticsPlugin poolStats = deploymentMD.getConnectionManagers()[0].getPool().getStatistics();
if (poolStats.getNames().size() != 0) {
DescriptionProvider statsResourceDescriptionProvider = new StatisticsDescriptionProvider(ResourceAdaptersSubsystemProviders.RESOURCE_NAME, "statistics", poolStats);
PathElement pe = PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, ResourceAdaptersExtension.SUBSYSTEM_NAME);
ManagementResourceRegistration overrideRegistration = registration;
//when you are in deploy you have a registration pointing to deployment=*
//when you are in re-deploy it points to specific deploymentUnit
if (registration.isAllowsOverride()) {
overrideRegistration = registration.registerOverrideModel(deploymentUnitName, new OverrideDescriptionProvider() {
@Override
public Map<String, ModelNode> getAttributeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
@Override
public Map<String, ModelNode> getChildTypeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
});
}
if (overrideRegistration.getSubModel(PathAddress.pathAddress(pe)) == null) {
ManagementResourceRegistration subRegistration = overrideRegistration.registerSubModel(pe, statsResourceDescriptionProvider);
for (String statName : poolStats.getNames()) {
subRegistration.registerMetric(statName, new PoolMetrics.ParametrizedPoolMetricsHandler(poolStats));
}
subRegistration.registerOperationHandler("clear-statistics", new ClearStatisticsHandler(poolStats), ResourceAdaptersSubsystemProviders.CLEAR_STATISTICS_DESC, false);
}
}
}
break;
}
case UP_to_STOP_REQUESTED: {
PathElement pe = PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, ResourceAdaptersExtension.SUBSYSTEM_NAME);
ManagementResourceRegistration overrideRegistration = registration.getOverrideModel(deploymentUnitName);
if (overrideRegistration.getSubModel(PathAddress.pathAddress(pe)) != null) {
overrideRegistration.unregisterSubModel(pe);
}
break;
}
}
}
});
builder.setInitialMode(Mode.ACTIVE).install();
}
}
} catch (Throwable t) {
throw new DeploymentUnitProcessingException(t);
}