CommonDeployment deploymentMD = getDeploymentMetadata(controller);
if (deploymentMD.getConnectionManagers() != null) {
for (ConnectionManager cm : deploymentMD.getConnectionManagers()) {
if (cm.getPool() != null) {
StatisticsPlugin poolStats = cm.getPool().getStatistics();
poolStats.setEnabled(false);
final ServiceController<?> bootstrapContextController = controller.getServiceContainer().getService(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append(bootstrapCtx));
WorkManager wm = null;
if (bootstrapContextController != null) {
wm = (WorkManager) ((CloneableBootstrapContext) bootstrapContextController.getValue()).getWorkManager();
}
if ((wm != null && wm.getStatistics() != null) || poolStats.getNames().size() != 0) {
PathElement pe = PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, ResourceAdaptersExtension.SUBSYSTEM_NAME);
PathElement peStats = PathElement.pathElement(Constants.STATISTICS_NAME, Constants.STATISTICS_NAME);
PathElement peRa = PathElement.pathElement(Constants.RESOURCEADAPTER_NAME, raName);
PathElement peWm = PathElement.pathElement(Constants.WORKMANAGER_NAME, wm.getName());
PathElement peDistributedWm = PathElement.pathElement(Constants.DISTRIBUTED_WORKMANAGER_NAME, wm.getName());
PathElement peCD = PathElement.pathElement(Constants.CONNECTIONDEFINITIONS_NAME, cm.getJndiName());
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
synchronized (this) {
if (registration.isAllowsOverride()) {
if (registration.getOverrideModel(deploymentUnitName) != null) {
overrideRegistration = registration.getOverrideModel(deploymentUnitName);
} else {
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();
}
});
}
}
ManagementResourceRegistration subRegistration;
try {
ResourceBuilder resourceBuilder = ResourceBuilder.Factory.create(pe,
new StandardResourceDescriptionResolver(Constants.STATISTICS_NAME, CommonAttributes.RESOURCE_NAME, CommonAttributes.class.getClassLoader()));
subRegistration = overrideRegistration.registerSubModel(resourceBuilder.build());
} catch (IllegalArgumentException iae) {
subRegistration = overrideRegistration.getSubModel(PathAddress.pathAddress(pe));
}
Resource subsystemResource;
if (!deploymentResource.hasChild(pe)) {
subsystemResource = new IronJacamarResource.IronJacamarRuntimeResource();
deploymentResource.registerChild(pe, subsystemResource);
} else {
subsystemResource = deploymentResource.getChild(pe);
}
ManagementResourceRegistration statsRegistration;
try {
ResourceBuilder resourceBuilder = ResourceBuilder.Factory.create(peStats,
new StandardResourceDescriptionResolver(Constants.STATISTICS_NAME, CommonAttributes.RESOURCE_NAME, CommonAttributes.class.getClassLoader()));
statsRegistration = subRegistration.registerSubModel(resourceBuilder.build());
} catch (IllegalArgumentException iae) {
statsRegistration = subRegistration.getSubModel(PathAddress.pathAddress(peStats));
}
Resource statisticsResource;
if (!subsystemResource.hasChild(peStats)) {
statisticsResource = new IronJacamarResource.IronJacamarRuntimeResource();
subsystemResource.registerChild(peStats, statisticsResource);
} else {
statisticsResource = subsystemResource.getChild(peStats);
}
ManagementResourceRegistration raRegistration;
try {
ResourceBuilder resourceBuilder = ResourceBuilder.Factory.create(peRa,
new StandardResourceDescriptionResolver(Constants.STATISTICS_NAME, CommonAttributes.RESOURCE_NAME, CommonAttributes.class.getClassLoader()));
raRegistration = statsRegistration.registerSubModel(resourceBuilder.build());
} catch (IllegalArgumentException iae) {
raRegistration = statsRegistration.getSubModel(PathAddress.pathAddress(peRa));
}
Resource raResource;
if (!statisticsResource.hasChild(peRa)) {
raResource = new IronJacamarResource.IronJacamarRuntimeResource();
statisticsResource.registerChild(peRa, raResource);
} else {
raResource = statisticsResource.getChild(peRa);
}
if (deploymentMD.getConnector() != null && deploymentMD.getConnector().getResourceAdapter() != null && deploymentMD.getConnector().getResourceAdapter().getStatistics() != null) {
StatisticsPlugin raStats = deploymentMD.getConnector().getResourceAdapter().getStatistics();
raStats.setEnabled(false);
PoolMetrics.ParametrizedPoolMetricsHandler handler = new PoolMetrics.ParametrizedPoolMetricsHandler(raStats);
for (AttributeDefinition attribute : StatisticsResourceDefinition.getAttributesFromPlugin(raStats)){
raRegistration.registerMetric(attribute, handler);
}
//adding enable/disable for pool stats