use of org.jboss.as.controller.descriptions.ResourceDescriptionResolver in project wildfly by wildfly.
the class ModClusterConfigResourceDefinition method registerOperations.
@Override
public void registerOperations(ManagementResourceRegistration resourceRegistration) {
super.registerOperations(resourceRegistration);
final ResourceDescriptionResolver rootResolver = getResourceDescriptionResolver();
final OperationDefinition addMetricDef = new SimpleOperationDefinitionBuilder(CommonAttributes.ADD_METRIC, rootResolver).setParameters(LoadMetricDefinition.ATTRIBUTES).setRuntimeOnly().build();
final OperationDefinition addCustomDef = new SimpleOperationDefinitionBuilder(CommonAttributes.ADD_CUSTOM_METRIC, rootResolver).setParameters(CustomLoadMetricDefinition.ATTRIBUTES).setRuntimeOnly().build();
final OperationDefinition removeMetricDef = new SimpleOperationDefinitionBuilder(CommonAttributes.REMOVE_METRIC, rootResolver).setParameters(LoadMetricDefinition.TYPE).setRuntimeOnly().build();
final OperationDefinition removeCustomDef = new SimpleOperationDefinitionBuilder(CommonAttributes.REMOVE_CUSTOM_METRIC, rootResolver).setParameters(CustomLoadMetricDefinition.CLASS).setRuntimeOnly().build();
resourceRegistration.registerOperationHandler(addMetricDef, ModClusterAddMetric.INSTANCE);
resourceRegistration.registerOperationHandler(addCustomDef, ModClusterAddCustomMetric.INSTANCE);
resourceRegistration.registerOperationHandler(removeMetricDef, ModClusterRemoveMetric.INSTANCE);
resourceRegistration.registerOperationHandler(removeCustomDef, ModClusterRemoveCustomMetric.INSTANCE);
}
use of org.jboss.as.controller.descriptions.ResourceDescriptionResolver in project wildfly by wildfly.
the class ModClusterSubsystemResourceDefinition method registerRuntimeOperations.
public void registerRuntimeOperations(ManagementResourceRegistration registration) {
final ResourceDescriptionResolver rootResolver = getResourceDescriptionResolver();
registration.registerOperationHandler(ModClusterListProxies.getDefinition(rootResolver), ModClusterListProxies.INSTANCE);
registration.registerOperationHandler(ModClusterGetProxyInfo.getDefinition(rootResolver), ModClusterGetProxyInfo.INSTANCE);
registration.registerOperationHandler(ModClusterGetProxyConfiguration.getDefinition(rootResolver), ModClusterGetProxyConfiguration.INSTANCE);
// add/remove a proxy from the proxy-list (it is not persisted operation).
registration.registerOperationHandler(ModClusterAddProxy.getDefinition(rootResolver), ModClusterAddProxy.INSTANCE);
registration.registerOperationHandler(ModClusterRemoveProxy.getDefinition(rootResolver), ModClusterRemoveProxy.INSTANCE);
// node related operations.
registration.registerOperationHandler(ModClusterRefresh.getDefinition(rootResolver), ModClusterRefresh.INSTANCE);
registration.registerOperationHandler(ModClusterReset.getDefinition(rootResolver), ModClusterReset.INSTANCE);
// node (all contexts) related operations.
registration.registerOperationHandler(ModClusterEnable.getDefinition(rootResolver), ModClusterEnable.INSTANCE);
registration.registerOperationHandler(ModClusterDisable.getDefinition(rootResolver), ModClusterDisable.INSTANCE);
registration.registerOperationHandler(ModClusterStop.getDefinition(rootResolver), ModClusterStop.INSTANCE);
// Context related operations.
registration.registerOperationHandler(ModClusterEnableContext.getDefinition(rootResolver), ModClusterEnableContext.INSTANCE);
registration.registerOperationHandler(ModClusterDisableContext.getDefinition(rootResolver), ModClusterDisableContext.INSTANCE);
registration.registerOperationHandler(ModClusterStopContext.getDefinition(rootResolver), ModClusterStopContext.INSTANCE);
}
use of org.jboss.as.controller.descriptions.ResourceDescriptionResolver in project wildfly by wildfly.
the class JPAService method createManagementStatisticsResource.
/**
* Create single instance of management statistics resource per managementAdaptor version.
*
* ManagementAccess
*
* The persistence provider and jipijapa adapters will be in the same classloader,
* either a static module or included directly in the application. Those are the two supported use
* cases for management of deployment persistence units also.
*
* From a management point of view, the requirements are:
* 1. show management statistics for static persistence provider modules and applications that have
* their own persistence provider module.
*
* 2. persistence provider adapters will provide a unique key that identifies the management version of supported
* management statistics/operations. For example, Hibernate 3.x might be 1.0, Hibernate 4.1/4.2 might
* be version 2.0 and Hibernate 4.3 could be 2.0 also as long as its compatible (same stats) with 4.1/4.2.
* Eventually, a Hibernate (later version) change in statistics is likely to happen, the management version
* will be incremented.
*
*
* @param managementAdaptor the management adaptor that will provide statistics
* @param scopedPersistenceUnitName name of the persistence unit
* @param deploymentUnit deployment unit for the deployment requesting a resource
* @return the management resource
*/
public static Resource createManagementStatisticsResource(final ManagementAdaptor managementAdaptor, final String scopedPersistenceUnitName, final DeploymentUnit deploymentUnit) {
synchronized (existingResourceDescriptionResolver) {
final EntityManagerFactoryLookup entityManagerFactoryLookup = new EntityManagerFactoryLookup();
final Statistics statistics = managementAdaptor.getStatistics();
if (false == existingResourceDescriptionResolver.contains(managementAdaptor.getVersion())) {
// setup statistics (this used to be part of JPA subsystem startup)
ResourceDescriptionResolver resourceDescriptionResolver = new StandardResourceDescriptionResolver(statistics.getResourceBundleKeyPrefix(), statistics.getResourceBundleName(), statistics.getClass().getClassLoader()) {
private ResourceDescriptionResolver fallback = JPAExtension.getResourceDescriptionResolver();
//add a fallback in case provider doesn't have all properties properly defined
@Override
public String getResourceAttributeDescription(String attributeName, Locale locale, ResourceBundle bundle) {
if (bundle.containsKey(getBundleKey(attributeName))) {
return super.getResourceAttributeDescription(attributeName, locale, bundle);
} else {
return fallback.getResourceAttributeDescription(attributeName, locale, fallback.getResourceBundle(locale));
}
}
};
PathElement subsystemPE = PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, JPAExtension.SUBSYSTEM_NAME);
ManagementResourceRegistration deploymentResourceRegistration = deploymentUnit.getAttachment(DeploymentModelUtils.MUTABLE_REGISTRATION_ATTACHMENT);
ManagementResourceRegistration deploymentSubsystemRegistration = deploymentResourceRegistration.getSubModel(PathAddress.pathAddress(subsystemPE));
ManagementResourceRegistration subdeploymentSubsystemRegistration = deploymentResourceRegistration.getSubModel(PathAddress.pathAddress(PathElement.pathElement(ModelDescriptionConstants.SUBDEPLOYMENT), subsystemPE));
ManagementResourceRegistration providerResource = deploymentSubsystemRegistration.registerSubModel(new ManagementResourceDefinition(PathElement.pathElement(managementAdaptor.getIdentificationLabel()), resourceDescriptionResolver, statistics, entityManagerFactoryLookup));
providerResource.registerReadOnlyAttribute(PersistenceUnitServiceHandler.SCOPED_UNIT_NAME, null);
providerResource = subdeploymentSubsystemRegistration.registerSubModel(new ManagementResourceDefinition(PathElement.pathElement(managementAdaptor.getIdentificationLabel()), resourceDescriptionResolver, statistics, entityManagerFactoryLookup));
providerResource.registerReadOnlyAttribute(PersistenceUnitServiceHandler.SCOPED_UNIT_NAME, null);
existingResourceDescriptionResolver.add(managementAdaptor.getVersion());
}
// create (per deployment) dynamic Resource implementation that can reflect the deployment specific names (e.g. jpa entity classname/Hibernate region name)
return new DynamicManagementStatisticsResource(statistics, scopedPersistenceUnitName, managementAdaptor.getIdentificationLabel(), entityManagerFactoryLookup);
}
}
use of org.jboss.as.controller.descriptions.ResourceDescriptionResolver in project wildfly by wildfly.
the class ManagementResourceDefinition method registerChildren.
@Override
public void registerChildren(ManagementResourceRegistration resourceRegistration) {
super.registerChildren(resourceRegistration);
for (final String sublevelChildName : statistics.getChildrenNames()) {
Statistics sublevelStatistics = statistics.getChild(sublevelChildName);
ResourceDescriptionResolver sublevelResourceDescriptionResolver = new StandardResourceDescriptionResolver(sublevelChildName, sublevelStatistics.getResourceBundleName(), sublevelStatistics.getClass().getClassLoader());
resourceRegistration.registerSubModel(new ManagementResourceDefinition(PathElement.pathElement(sublevelChildName), sublevelResourceDescriptionResolver, sublevelStatistics, entityManagerFactoryLookup));
}
}
Aggregations