}
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
OperationStepHandler readHandler = new PoolStatisticsRuntimeAttributeReadHandler(raStats);
OperationStepHandler writeHandler = new PoolStatisticsRuntimeAttributeWriteHandler(raStats);
raRegistration.registerReadWriteAttribute(org.jboss.as.connector.subsystems.common.pool.Constants.POOL_STATISTICS_ENABLED, readHandler, writeHandler);
}
if (poolStats.getNames().size() != 0 && raRegistration.getSubModel(PathAddress.pathAddress(peCD)) == null) {
ManagementResourceRegistration cdSubRegistration = raRegistration.registerSubModel(new StatisticsResourceDefinition(peCD, CommonAttributes.RESOURCE_NAME, poolStats));
final Resource cdResource = new IronJacamarResource.IronJacamarRuntimeResource();
if (!raResource.hasChild(peCD))
raResource.registerChild(peCD, cdResource);
}
if (wm.getStatistics() != null) {
if (wm instanceof DistributedWorkManager && ((DistributedWorkManager)wm).getDistributedStatistics() != null && raRegistration.getSubModel(PathAddress.pathAddress(peDistributedWm)) == null) {
ResourceBuilder resourceBuilder = ResourceBuilder.Factory.create(peDistributedWm,
new StandardResourceDescriptionResolver(Constants.STATISTICS_NAME + "." + Constants.WORKMANAGER_NAME, CommonAttributes.RESOURCE_NAME, CommonAttributes.class.getClassLoader()));
ManagementResourceRegistration dwmSubRegistration = raRegistration.registerSubModel(resourceBuilder.build());
final Resource dwmResource = new IronJacamarResource.IronJacamarRuntimeResource();
if (!raResource.hasChild(peDistributedWm))
raResource.registerChild(peDistributedWm, dwmResource);
OperationStepHandler metricsHandler = new WorkManagerRuntimeAttributeReadHandler(wm, ((DistributedWorkManager)wm).getDistributedStatistics(), false);
for (SimpleAttributeDefinition metric : Constants.WORKMANAGER_METRICS) {
dwmSubRegistration.registerMetric(metric, metricsHandler);
}
OperationStepHandler readHandler = new WorkManagerRuntimeAttributeReadHandler(wm, ((DistributedWorkManager)wm).getDistributedStatistics(), true);
OperationStepHandler writeHandler = new WorkManagerRuntimeAttributeWriteHandler(wm, true, Constants.DISTRIBUTED_WORKMANAGER_RW_ATTRIBUTES);
for (SimpleAttributeDefinition attribute : Constants.DISTRIBUTED_WORKMANAGER_RW_ATTRIBUTES) {
dwmSubRegistration.registerReadWriteAttribute(attribute, readHandler, writeHandler);
}
dwmSubRegistration.registerOperationHandler(ClearWorkManagerStatisticsHandler.DEFINITION, new ClearWorkManagerStatisticsHandler(wm));
}
if (raRegistration.getSubModel(PathAddress.pathAddress(peWm)) == null) {
ResourceBuilder resourceBuilder = ResourceBuilder.Factory.create(peWm,
new StandardResourceDescriptionResolver(Constants.STATISTICS_NAME + "." + Constants.WORKMANAGER_NAME, CommonAttributes.RESOURCE_NAME, CommonAttributes.class.getClassLoader()));
ManagementResourceRegistration wmSubRegistration = raRegistration.registerSubModel(resourceBuilder.build());
final Resource wmResource = new IronJacamarResource.IronJacamarRuntimeResource();
if (!raResource.hasChild(peWm))
raResource.registerChild(peWm, wmResource);