use of org.jboss.as.controller.ResourceBuilder 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.ResourceBuilder 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.ResourceBuilder 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.ResourceBuilder in project wildfly by wildfly.
the class WSExtension method initialize.
@Override
public void initialize(final ExtensionContext context) {
final boolean registerRuntimeOnly = context.isRuntimeOnlyRegistrationValid();
final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, CURRENT_MODEL_VERSION);
subsystem.registerXMLElementWriter(WSSubsystemWriter.getInstance());
// ws subsystem
ResourceBuilder propertyResource = ResourceBuilder.Factory.create(PROPERTY_PATH, getResourceDescriptionResolver(Constants.PROPERTY)).setAddOperation(PropertyAdd.INSTANCE).setRemoveOperation(ReloadRequiredRemoveStepHandler.INSTANCE).addReadWriteAttribute(Attributes.VALUE, null, new ReloadRequiredWriteAttributeHandler(Attributes.VALUE));
ResourceBuilder handlerBuilder = ResourceBuilder.Factory.create(HANDLER_PATH, getResourceDescriptionResolver(HANDLER)).setAddOperation(HandlerAdd.INSTANCE).setRemoveOperation(ReloadRequiredRemoveStepHandler.INSTANCE).addReadWriteAttribute(Attributes.CLASS, null, new ReloadRequiredWriteAttributeHandler(Attributes.CLASS));
ResourceBuilder preHandler = ResourceBuilder.Factory.create(PRE_HANDLER_CHAIN_PATH, getResourceDescriptionResolver(Constants.PRE_HANDLER_CHAIN)).setAddOperation(HandlerChainAdd.INSTANCE).setRemoveOperation(ReloadRequiredRemoveStepHandler.INSTANCE).addReadWriteAttribute(Attributes.PROTOCOL_BINDINGS, null, new ReloadRequiredWriteAttributeHandler(Attributes.PROTOCOL_BINDINGS)).pushChild(handlerBuilder).pop();
ResourceBuilder postHandler = ResourceBuilder.Factory.create(POST_HANDLER_CHAIN_PATH, getResourceDescriptionResolver(Constants.POST_HANDLER_CHAIN)).setAddOperation(HandlerChainAdd.INSTANCE).setRemoveOperation(ReloadRequiredRemoveStepHandler.INSTANCE).addReadWriteAttribute(Attributes.PROTOCOL_BINDINGS, null, new ReloadRequiredWriteAttributeHandler(Attributes.PROTOCOL_BINDINGS)).pushChild(handlerBuilder).pop();
ResourceDefinition epConfigsDef = ResourceBuilder.Factory.create(ENDPOINT_CONFIG_PATH, getResourceDescriptionResolver(ENDPOINT_CONFIG)).setAddOperation(EndpointConfigAdd.INSTANCE).setRemoveOperation(ReloadRequiredRemoveStepHandler.INSTANCE).pushChild(propertyResource).pop().pushChild(preHandler).pop().pushChild(postHandler).pop().build();
ResourceDefinition clConfigsDef = ResourceBuilder.Factory.create(CLIENT_CONFIG_PATH, getResourceDescriptionResolver(CLIENT_CONFIG)).setAddOperation(ClientConfigAdd.INSTANCE).setRemoveOperation(ReloadRequiredRemoveStepHandler.INSTANCE).pushChild(propertyResource).pop().pushChild(preHandler).pop().pushChild(postHandler).pop().build();
ResourceDefinition subsystemResource = ResourceBuilder.Factory.createSubsystemRoot(SUBSYSTEM_PATH, getResourceDescriptionResolver(), WSSubsystemAdd.INSTANCE, WSSubsystemRemove.INSTANCE).addReadWriteAttribute(Attributes.WSDL_HOST, null, new WSServerConfigAttributeHandler(Attributes.WSDL_HOST)).addReadWriteAttribute(Attributes.WSDL_PORT, null, new WSServerConfigAttributeHandler(Attributes.WSDL_PORT)).addReadWriteAttribute(Attributes.WSDL_SECURE_PORT, null, new WSServerConfigAttributeHandler(Attributes.WSDL_SECURE_PORT)).addReadWriteAttribute(Attributes.WSDL_URI_SCHEME, null, new WSServerConfigAttributeHandler(Attributes.WSDL_URI_SCHEME)).addReadWriteAttribute(Attributes.WSDL_PATH_REWRITE_RULE, null, new WSServerConfigAttributeHandler(Attributes.WSDL_PATH_REWRITE_RULE)).addReadWriteAttribute(Attributes.MODIFY_WSDL_ADDRESS, null, new WSServerConfigAttributeHandler(Attributes.MODIFY_WSDL_ADDRESS)).addReadWriteAttribute(Attributes.STATISTICS_ENABLED, null, new WSServerConfigAttributeHandler(Attributes.STATISTICS_ENABLED)).build();
ManagementResourceRegistration subsystemRegistration = subsystem.registerSubsystemModel(subsystemResource);
subsystemRegistration.registerSubModel(epConfigsDef);
subsystemRegistration.registerSubModel(clConfigsDef);
if (registerRuntimeOnly) {
subsystem.registerDeploymentModel(ResourceBuilder.Factory.create(SUBSYSTEM_PATH, getResourceDescriptionResolver("deployment")).pushChild(ENDPOINT_PATH).addMetrics(WSEndpointMetrics.INSTANCE, WSEndpointMetrics.ATTRIBUTES).addReadOnlyAttribute(ENDPOINT_CLASS).addReadOnlyAttribute(ENDPOINT_CONTEXT).addReadOnlyAttribute(ENDPOINT_NAME).addReadOnlyAttribute(ENDPOINT_TYPE).addReadOnlyAttribute(ENDPOINT_WSDL).build());
}
if (context.isRegisterTransformers()) {
registerTransformers1_2_0(subsystem);
registerTransformers2_0_0(subsystem);
}
}
use of org.jboss.as.controller.ResourceBuilder in project wildfly by wildfly.
the class ProtocolResourceRegistrationHandler method createProtocolResourceDefinition.
private ResourceDefinition createProtocolResourceDefinition(String protocolName, Class<? extends Protocol> protocolClass) {
SimpleResourceDescriptionResolver resolver = new SimpleResourceDescriptionResolver(protocolName, protocolClass.getSimpleName());
ResourceBuilder builder = ResourceBuilder.Factory.create(ProtocolResourceDefinition.pathElement(protocolName), resolver).setRuntime();
ProtocolMetricsHandler handler = new ProtocolMetricsHandler(this);
for (Map.Entry<String, Attribute> entry : ProtocolMetricsHandler.findProtocolAttributes(protocolClass).entrySet()) {
String name = entry.getKey();
Attribute attribute = entry.getValue();
FieldType type = FieldType.valueOf(attribute.getType());
resolver.addDescription(name, attribute.getDescription());
builder.addMetric(new SimpleAttributeDefinitionBuilder(name, type.getModelType(), true).setStorageRuntime().build(), handler);
}
return builder.build();
}
Aggregations