use of org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver in project wildfly by wildfly.
the class ProtocolResourceRegistrationHandler method execute.
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
OverrideDescriptionProvider provider = new OverrideDescriptionProvider() {
@Override
public Map<String, ModelNode> getAttributeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
@Override
public Map<String, ModelNode> getChildTypeOverrideDescriptions(Locale locale) {
StandardResourceDescriptionResolver resolver = new JGroupsResourceDescriptionResolver();
String description = resolver.getChildTypeDescription(ProtocolResourceDefinition.WILDCARD_PATH.getKey(), locale, resolver.getResourceBundle(locale));
ModelNode result = new ModelNode();
result.get(ModelDescriptionConstants.DESCRIPTION).set(description);
return Collections.singletonMap(ProtocolResourceDefinition.WILDCARD_PATH.getKey(), result);
}
};
Resource resource = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS);
String stack = STACK.resolveModelAttribute(context, resource.getModel()).asString();
ManagementResourceRegistration registration = context.getResourceRegistrationForUpdate().registerOverrideModel(context.getCurrentAddressValue(), provider);
PathAddress stackAddress = context.getCurrentAddress().getParent().append(StackResourceDefinition.pathElement(stack));
Resource stackResource = context.readResourceFromRoot(stackAddress, false);
for (String name : stackResource.getChildrenNames(TransportResourceDefinition.WILDCARD_PATH.getKey())) {
PathAddress transportAddress = stackAddress.append(TransportResourceDefinition.pathElement(name));
ModelNode transport = context.readResourceFromRoot(transportAddress, false).getModel();
String moduleName = MODULE.resolveModelAttribute(context, transport).asString();
Class<? extends Protocol> transportClass = findProtocolClass(context, name, moduleName);
registration.registerSubModel(this.createProtocolResourceDefinition(name, transportClass));
resource.registerChild(ProtocolResourceDefinition.pathElement(name), PlaceholderResource.INSTANCE);
}
for (String name : stackResource.getChildrenNames(ProtocolResourceDefinition.WILDCARD_PATH.getKey())) {
Resource protocolResource = context.readResourceFromRoot(stackAddress.append(ProtocolResourceDefinition.pathElement(name)), false);
String moduleName = MODULE.resolveModelAttribute(context, protocolResource.getModel()).asString();
Class<? extends Protocol> protocolClass = findProtocolClass(context, name, moduleName);
registration.registerSubModel(this.createProtocolResourceDefinition(name, protocolClass));
resource.registerChild(ProtocolResourceDefinition.pathElement(name), PlaceholderResource.INSTANCE);
}
if (stackResource.hasChild(RelayResourceDefinition.PATH)) {
registration.registerSubModel(this.createProtocolResourceDefinition(RelayConfiguration.PROTOCOL_NAME, RELAY2.class));
resource.registerChild(ProtocolResourceDefinition.pathElement(RelayConfiguration.PROTOCOL_NAME), PlaceholderResource.INSTANCE);
}
}
use of org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver in project wildfly by wildfly.
the class DistributedWorkManagerStatisticsService method start.
@Override
public void start(StartContext context) throws StartException {
synchronized (this) {
DistributedWorkManager dwm = distributedWorkManager.getValue();
dwm.setDistributedStatisticsEnabled(statsEnabled);
if (dwm.getDistributedStatistics() != null) {
PathElement peDistributedWm = PathElement.pathElement(Constants.STATISTICS_NAME, "distributed");
ResourceBuilder resourceBuilder = ResourceBuilder.Factory.create(peDistributedWm, new StandardResourceDescriptionResolver(Constants.STATISTICS_NAME + "." + Constants.WORKMANAGER_NAME, CommonAttributes.RESOURCE_NAME, CommonAttributes.class.getClassLoader()));
ManagementResourceRegistration dwmSubRegistration = overrideRegistration.registerSubModel(resourceBuilder.build());
OperationStepHandler metricHandler = new WorkManagerRuntimeAttributeReadHandler(dwm, dwm.getDistributedStatistics(), false);
for (SimpleAttributeDefinition metric : Constants.WORKMANAGER_METRICS) {
dwmSubRegistration.registerMetric(metric, metricHandler);
}
OperationStepHandler readHandler = new WorkManagerRuntimeAttributeReadHandler(dwm, dwm.getDistributedStatistics(), false);
OperationStepHandler writeHandler = new WorkManagerRuntimeAttributeWriteHandler(dwm, false, Constants.DISTRIBUTED_WORKMANAGER_RW_ATTRIBUTES);
for (SimpleAttributeDefinition attribute : Constants.DISTRIBUTED_WORKMANAGER_RW_ATTRIBUTES) {
dwmSubRegistration.registerReadWriteAttribute(attribute, readHandler, writeHandler);
}
dwmSubRegistration.registerOperationHandler(ClearWorkManagerStatisticsHandler.DEFINITION, new ClearWorkManagerStatisticsHandler(dwm));
}
}
}
use of org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver in project wildfly by wildfly.
the class WorkManagerStatisticsService method start.
@Override
public void start(StartContext context) throws StartException {
synchronized (this) {
WorkManager wm = workManager.getValue();
wm.setStatisticsEnabled(statsEnabled);
if (wm.getStatistics() != null) {
PathElement peLocaldWm = PathElement.pathElement(Constants.STATISTICS_NAME, "local");
ResourceBuilder resourceBuilder = ResourceBuilder.Factory.create(peLocaldWm, new StandardResourceDescriptionResolver(Constants.STATISTICS_NAME + "." + Constants.WORKMANAGER_NAME, CommonAttributes.RESOURCE_NAME, CommonAttributes.class.getClassLoader()));
ManagementResourceRegistration wmSubRegistration = overrideRegistration.registerSubModel(resourceBuilder.build());
OperationStepHandler metricHandler = new WorkManagerRuntimeAttributeReadHandler(wm, wm.getStatistics(), false);
for (SimpleAttributeDefinition metric : Constants.WORKMANAGER_METRICS) {
wmSubRegistration.registerMetric(metric, metricHandler);
}
OperationStepHandler readHandler = new WorkManagerRuntimeAttributeReadHandler(wm, wm.getStatistics(), false);
OperationStepHandler writeHandler = new WorkManagerRuntimeAttributeWriteHandler(wm, false, Constants.WORKMANAGER_RW_ATTRIBUTES);
for (SimpleAttributeDefinition attribute : Constants.WORKMANAGER_RW_ATTRIBUTES) {
wmSubRegistration.registerReadWriteAttribute(attribute, readHandler, writeHandler);
}
wmSubRegistration.registerOperationHandler(ClearWorkManagerStatisticsHandler.DEFINITION, new ClearWorkManagerStatisticsHandler(wm));
}
}
}
use of org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver in project wildfly by wildfly.
the class IronJacamarActivationResourceService method start.
@Override
public void start(StartContext context) throws StartException {
ManagementResourceRegistration subRegistration;
final CommonDeployment deploymentMD = deployment.getValue().getDeployment();
ROOT_LOGGER.debugf("Starting IronJacamarActivationResourceService %s", deploymentMD.getDeploymentName());
try {
ResourceBuilder resourceBuilder = ResourceBuilder.Factory.create(SUBSYSTEM_PATH_ELEMENT, new StandardResourceDescriptionResolver(Constants.STATISTICS_NAME, CommonAttributes.RESOURCE_NAME, CommonAttributes.class.getClassLoader()));
subRegistration = registration.registerSubModel(resourceBuilder.build());
} catch (IllegalArgumentException iae) {
subRegistration = registration.getSubModel(PathAddress.pathAddress(SUBSYSTEM_PATH_ELEMENT));
}
ManagementResourceRegistration ijRegistration;
try {
ijRegistration = subRegistration.registerSubModel(new IronJacamarResourceDefinition());
} catch (IllegalArgumentException iae) {
ijRegistration = subRegistration.getSubModel(PathAddress.pathAddress(Constants.IRONJACAMAR_NAME, Constants.IRONJACAMAR_NAME));
}
try {
if (deploymentResource != null) {
PathElement peLocalStats = PathElement.pathElement(Constants.STATISTICS_NAME, "extended");
if (deploymentMD.getConnector() != null && deploymentMD.getConnector().getResourceAdapter() != null) {
ManagementResourceRegistration raRegistration = ijRegistration.getSubModel(PathAddress.EMPTY_ADDRESS.append(PathElement.pathElement(Constants.RESOURCEADAPTER_NAME))).registerOverrideModel(deploymentMD.getDeploymentName(), new OverrideDescriptionProvider() {
@Override
public Map<String, ModelNode> getAttributeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
@Override
public Map<String, ModelNode> getChildTypeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
});
ResourceBuilder resourceBuilder = ResourceBuilder.Factory.create(peLocalStats, new StandardResourceDescriptionResolver(Constants.STATISTICS_NAME + "." + Constants.WORKMANAGER_NAME, CommonAttributes.RESOURCE_NAME, CommonAttributes.class.getClassLoader()));
ManagementResourceRegistration raStatsSubRegistration = raRegistration.registerSubModel(resourceBuilder.build());
if (deploymentMD.getConnector().getResourceAdapter().getStatistics() != null) {
StatisticsPlugin raStats = deploymentMD.getConnector().getResourceAdapter().getStatistics();
raStats.setEnabled(statsEnabled);
PoolMetrics.ParametrizedPoolMetricsHandler handler = new PoolMetrics.ParametrizedPoolMetricsHandler(raStats);
for (AttributeDefinition attribute : StatisticsResourceDefinition.getAttributesFromPlugin(raStats)) {
raStatsSubRegistration.registerMetric(attribute, handler);
}
raStatsSubRegistration.registerOperationHandler(ClearStatisticsHandler.DEFINITION, new ClearStatisticsHandler(raStats));
}
if (deploymentMD.getConnector() != null && deploymentMD.getConnector().getConnectionFactories() != null) {
for (ConnectionFactory cf : deploymentMD.getConnector().getConnectionFactories()) {
if (cf.getManagedConnectionFactory() != null && cf.getManagedConnectionFactory().getStatistics() != null) {
PathElement peCD = PathElement.pathElement(Constants.CONNECTIONDEFINITIONS_NAME, cf.getJndiName());
PathElement peCdStats = PathElement.pathElement(Constants.STATISTICS_NAME, "extended");
StatisticsPlugin extendStats = cf.getManagedConnectionFactory().getStatistics();
extendStats.setEnabled(statsEnabled);
if (extendStats.getNames().size() != 0) {
if (extendStats.getNames().size() != 0) {
ManagementResourceRegistration cdRegistration = raRegistration.getSubModel(PathAddress.pathAddress(peCD));
ManagementResourceRegistration overrideCdRegistration = cdRegistration.registerOverrideModel(cf.getJndiName(), new OverrideDescriptionProvider() {
@Override
public Map<String, ModelNode> getAttributeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
@Override
public Map<String, ModelNode> getChildTypeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
});
if (extendStats.getNames().size() != 0 && overrideCdRegistration.getSubModel(PathAddress.pathAddress(peCdStats)) == null) {
overrideCdRegistration.registerSubModel(new StatisticsResourceDefinition(peCdStats, CommonAttributes.RESOURCE_NAME, extendStats));
}
}
}
}
}
}
if (deploymentMD.getConnectionManagers() != null) {
for (ConnectionManager cm : deploymentMD.getConnectionManagers()) {
if (cm.getPool() != null) {
PathElement peCD = PathElement.pathElement(Constants.CONNECTIONDEFINITIONS_NAME, cm.getJndiName());
PathElement peCdStats = PathElement.pathElement(Constants.STATISTICS_NAME, "pool");
StatisticsPlugin poolStats = cm.getPool().getStatistics();
poolStats.setEnabled(statsEnabled);
if (poolStats.getNames().size() != 0) {
ManagementResourceRegistration cdRegistration = raRegistration.getSubModel(PathAddress.pathAddress(peCD));
ManagementResourceRegistration overrideCdRegistration = cdRegistration.registerOverrideModel(cm.getJndiName(), new OverrideDescriptionProvider() {
@Override
public Map<String, ModelNode> getAttributeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
@Override
public Map<String, ModelNode> getChildTypeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
});
if (poolStats.getNames().size() != 0 && overrideCdRegistration.getSubModel(PathAddress.pathAddress(peCdStats)) == null) {
overrideCdRegistration.registerSubModel(new StatisticsResourceDefinition(peCdStats, CommonAttributes.RESOURCE_NAME, poolStats));
}
}
}
}
}
if (deploymentMD.getConnector() != null && deploymentMD.getConnector().getAdminObjects() != null) {
for (AdminObject ao : deploymentMD.getConnector().getAdminObjects()) {
if (ao.getStatistics() != null) {
PathElement peCD = PathElement.pathElement(Constants.ADMIN_OBJECTS_NAME, ao.getJndiName());
PathElement peCdStats = PathElement.pathElement(Constants.STATISTICS_NAME, "extended");
StatisticsPlugin extendStats = ao.getStatistics();
extendStats.setEnabled(statsEnabled);
if (extendStats.getNames().size() != 0) {
if (extendStats.getNames().size() != 0) {
ManagementResourceRegistration cdRegistration = raRegistration.getSubModel(PathAddress.pathAddress(peCD));
ManagementResourceRegistration overrideCdRegistration = cdRegistration.registerOverrideModel(ao.getJndiName(), new OverrideDescriptionProvider() {
@Override
public Map<String, ModelNode> getAttributeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
@Override
public Map<String, ModelNode> getChildTypeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
});
if (extendStats.getNames().size() != 0 && overrideCdRegistration.getSubModel(PathAddress.pathAddress(peCdStats)) == null) {
overrideCdRegistration.registerSubModel(new StatisticsResourceDefinition(peCdStats, CommonAttributes.RESOURCE_NAME, extendStats));
}
}
}
}
}
}
}
}
} catch (IllegalArgumentException e) {
//ignore it, already restered
}
Resource subsystemResource;
if (!deploymentResource.hasChild(SUBSYSTEM_PATH_ELEMENT)) {
subsystemResource = new IronJacamarResource.IronJacamarRuntimeResource();
deploymentResource.registerChild(SUBSYSTEM_PATH_ELEMENT, subsystemResource);
} else {
subsystemResource = deploymentResource.getChild(SUBSYSTEM_PATH_ELEMENT);
}
IronJacamarResourceCreator.INSTANCE.execute(subsystemResource, mdr.getValue(), deployment.getValue().getRaName());
}
use of org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver 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);
}
}
Aggregations