CommonDeployment deploymentMD = getDeploymentMetadata(controller);
if (deploymentMD.getConnectionManagers() != null) {
for (ConnectionManager cm : deploymentMD.getConnectionManagers()) {
if (cm.getPool() != null) {
StatisticsPlugin poolStats = cm.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);
PathElement peStats = PathElement.pathElement(Constants.STATISTICS_NAME, Constants.STATISTICS_NAME);
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 {
subRegistration = overrideRegistration.registerSubModel(new SimpleResourceDefinition(pe, new SubSystemExtensionDescriptionProvider(ResourceAdaptersSubsystemProviders.RESOURCE_NAME, "deployment-subsystem")));
} 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 {
statsRegistration = subRegistration.registerSubModel(new SimpleResourceDefinition(peStats, new StatisticsElementDescriptionProvider(ResourceAdaptersSubsystemProviders.RESOURCE_NAME, "statistics")));
} 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);
}
if (statsRegistration.getSubModel(PathAddress.pathAddress(peCD)) == null) {
ManagementResourceRegistration cdSubRegistration = statsRegistration.registerSubModel(peCD, statsResourceDescriptionProvider);
final Resource cdResource = new IronJacamarResource.IronJacamarRuntimeResource();
if (!statisticsResource.hasChild(peCD))
statisticsResource.registerChild(peCD, cdResource);
for (String statName : poolStats.getNames()) {
cdSubRegistration.registerMetric(statName, new PoolMetrics.ParametrizedPoolMetricsHandler(poolStats));
}
cdSubRegistration.registerOperationHandler("clear-statistics", new ClearStatisticsHandler(poolStats), ResourceAdaptersSubsystemProviders.CLEAR_STATISTICS_DESC, false);
}