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 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
if (registration.isAllowsOverride()) {
overrideRegistration = registration.registerOverrideModel(deploymentUnit.getName(), 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 = overrideRegistration.getSubModel(PathAddress.pathAddress(pe));
if (subRegistration == null) {
subRegistration = overrideRegistration.registerSubModel(pe, new SubSystemExtensionDescriptionProvider(ResourceAdaptersSubsystemProviders.RESOURCE_NAME, "statistics"));
}
if (subRegistration.getSubModel(PathAddress.pathAddress(peCD)) == null) {
ManagementResourceRegistration cdSubRegistration = subRegistration.registerSubModel(peCD, statsResourceDescriptionProvider);
for (String statName : poolStats.getNames()) {
cdSubRegistration.registerMetric(statName, new PoolMetrics.ParametrizedPoolMetricsHandler(poolStats));
}
cdSubRegistration.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(deploymentUnit.getName());
if (overrideRegistration.getSubModel(PathAddress.pathAddress(pe)) != null) {
overrideRegistration.unregisterSubModel(pe);
}
break;