use of org.jboss.as.controller.PathElement in project wildfly by wildfly.
the class ProxyConfigurationResourceDefinition method register.
@SuppressWarnings("deprecation")
@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parent) {
ManagementResourceRegistration registration = parent.registerSubModel(this);
ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(EnumSet.complementOf(EnumSet.of(Attribute.SSL_CONTEXT))).addExtraParameters(Attribute.SSL_CONTEXT).addAttributeTranslation(DeprecatedAttribute.SIMPLE_LOAD_PROVIDER, SIMPLE_LOAD_PROVIDER_TRANSLATION).addAlias(DeprecatedAttribute.CONNECTOR, Attribute.LISTENER).addRequiredSingletonChildren(SimpleLoadProviderResourceDefinition.PATH).addCapabilities(Capability.class);
registration.registerReadWriteAttribute(Attribute.SSL_CONTEXT.getDefinition(), null, new ReloadRequiredWriteAttributeHandler() {
@Override
protected void validateUpdatedModel(OperationContext context, Resource model) {
context.addStep(new OperationStepHandler() {
@Override
public void execute(OperationContext ctx, ModelNode op) throws OperationFailedException {
if (model.hasChild(SSLResourceDefinition.PATH)) {
throw new OperationFailedException(ROOT_LOGGER.bothElytronAndLegacySslContextDefined());
}
}
}, OperationContext.Stage.MODEL);
}
});
parent.registerAlias(LEGACY_PATH, new AliasEntry(registration) {
@Override
public PathAddress convertToTargetAddress(PathAddress aliasAddress, AliasContext aliasContext) {
PathAddress rebuiltAddress = PathAddress.EMPTY_ADDRESS;
for (PathElement pathElement : aliasAddress) {
if (pathElement.equals(LEGACY_PATH)) {
try {
if (aliasContext.readResourceFromRoot(rebuiltAddress, false).hasChildren(ProxyConfigurationResourceDefinition.WILDCARD_PATH.getKey())) {
Set<Resource.ResourceEntry> children = aliasContext.readResourceFromRoot(rebuiltAddress, false).getChildren(ProxyConfigurationResourceDefinition.WILDCARD_PATH.getKey());
if (children.size() > 1 && !Operations.getOperationName(aliasContext.getOperation()).equals(AliasContext.RECURSIVE_GLOBAL_OP)) {
throw new IllegalStateException(ModClusterLogger.ROOT_LOGGER.legacyOperationsWithMultipleProxies());
}
PathAddress proxyPath = PathAddress.pathAddress(ProxyConfigurationResourceDefinition.pathElement(children.iterator().next().getName()));
rebuiltAddress = rebuiltAddress.append(proxyPath);
} else {
// handle :add
rebuiltAddress = rebuiltAddress.append(ProxyConfigurationResourceDefinition.pathElement("default"));
}
} catch (Resource.NoSuchResourceException ignore) {
// handle recursive-global-op
rebuiltAddress = rebuiltAddress.append(ProxyConfigurationResourceDefinition.WILDCARD_PATH);
}
} else {
rebuiltAddress = rebuiltAddress.append(pathElement);
}
}
return rebuiltAddress;
}
});
if (registration.isRuntimeOnlyRegistrationValid()) {
new OperationHandler<>(new ProxyOperationExecutor(this.executors), ProxyOperation.class).register(registration);
}
new ReloadRequiredResourceRegistration(descriptor).register(registration);
new LegacyMetricOperationsRegistration().register(registration);
new SimpleLoadProviderResourceDefinition().register(registration);
new DynamicLoadProviderResourceDefinition().register(registration);
new SSLResourceDefinition().register(registration);
return registration;
}
use of org.jboss.as.controller.PathElement in project wildfly by wildfly.
the class SecuritySubsystemParser_2_0 method parseElytronRealm.
protected void parseElytronRealm(final XMLExtendedStreamReader reader, final List<ModelNode> operations, final PathAddress subsystemPath) throws XMLStreamException {
final ModelNode elytronRealmAddOperation = Util.createAddOperation();
PathElement elytronRealmPath = null;
final EnumSet<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.LEGACY_JAAS_CONFIG);
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
requireNoNamespaceAttribute(reader, i);
final String value = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
required.remove(attribute);
switch(attribute) {
case NAME:
{
if (value == null || value.length() == 0) {
throw invalidAttributeValue(reader, i);
}
elytronRealmPath = PathElement.pathElement(ELYTRON_REALM, value);
break;
}
case LEGACY_JAAS_CONFIG:
{
LEGACY_JAAS_CONFIG.parseAndSetParameter(value, elytronRealmAddOperation, reader);
break;
}
case APPLY_ROLE_MAPPERS:
{
APPLY_ROLE_MAPPERS.parseAndSetParameter(value, elytronRealmAddOperation, reader);
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
if (!required.isEmpty()) {
throw missingRequired(reader, required);
}
elytronRealmAddOperation.get(OP_ADDR).set(subsystemPath.append(elytronRealmPath).toModelNode());
operations.add(elytronRealmAddOperation);
requireNoContent(reader);
}
use of org.jboss.as.controller.PathElement in project wildfly by wildfly.
the class SecuritySubsystemParser_2_0 method parseTLSEntity.
protected void parseTLSEntity(final XMLExtendedStreamReader reader, final List<ModelNode> operations, final PathAddress subsystemPath, final String tlsEntityName) throws XMLStreamException {
final ModelNode elytronTLSEntityAddOperation = Util.createAddOperation();
PathElement elytronTLSEntityPath = null;
final EnumSet<Attribute> required = EnumSet.of(Attribute.NAME, Attribute.LEGACY_JSSE_CONFIG);
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
requireNoNamespaceAttribute(reader, i);
final String value = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
required.remove(attribute);
switch(attribute) {
case NAME:
{
if (value == null || value.length() == 0) {
throw invalidAttributeValue(reader, i);
}
elytronTLSEntityPath = PathElement.pathElement(tlsEntityName, value);
break;
}
case LEGACY_JSSE_CONFIG:
{
LEGACY_JSSE_CONFIG.parseAndSetParameter(value, elytronTLSEntityAddOperation, reader);
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
if (!required.isEmpty()) {
throw missingRequired(reader, required);
}
elytronTLSEntityAddOperation.get(OP_ADDR).set(subsystemPath.append(elytronTLSEntityPath).toModelNode());
operations.add(elytronTLSEntityAddOperation);
requireNoContent(reader);
}
use of org.jboss.as.controller.PathElement in project wildfly by wildfly.
the class IronJacamarActivationResourceService method start.
@Override
public void start(StartContext context) throws StartException {
final CommonDeployment deploymentMD = deployment.getValue().getDeployment();
final String deploymentName = deploymentMD.getDeploymentName();
ROOT_LOGGER.debugf("Starting IronJacamarActivationResourceService %s", deploymentName);
try {
Connector connector = deploymentMD.getConnector();
if (connector != null && connector.getResourceAdapter() != null) {
final OverrideDescriptionProvider OD_PROVIDER = new OverrideDescriptionProvider() {
@Override
public Map<String, ModelNode> getAttributeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
@Override
public Map<String, ModelNode> getChildTypeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
};
final PathElement EXTENDED_STATS = PathElement.pathElement(Constants.STATISTICS_NAME, "extended");
final PathAddress EXTENDED_STATS_ADDR = PathAddress.pathAddress(EXTENDED_STATS);
final PathAddress CON_DEF_ADDR = PathAddress.EMPTY_ADDRESS.append(Constants.CONNECTIONDEFINITIONS_NAME);
ManagementResourceRegistration raRegistration = registration.getSubModel(RA_ADDRESS).registerOverrideModel(deploymentName, OD_PROVIDER);
ResourceBuilder resourceBuilder = ResourceBuilder.Factory.create(EXTENDED_STATS, new StandardResourceDescriptionResolver(Constants.STATISTICS_NAME + "." + Constants.WORKMANAGER_NAME, CommonAttributes.RESOURCE_NAME, CommonAttributes.class.getClassLoader()));
ManagementResourceRegistration raStatsSubRegistration = raRegistration.registerSubModel(resourceBuilder.build());
StatisticsPlugin raStats = connector.getResourceAdapter().getStatistics();
if (raStats != null) {
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));
}
List<ConnectionFactory> connectionFactories = connector.getConnectionFactories();
if (connectionFactories != null) {
for (ConnectionFactory cf : connectionFactories) {
ManagedConnectionFactory mcf = cf.getManagedConnectionFactory();
StatisticsPlugin extendStats = mcf == null ? null : mcf.getStatistics();
if (extendStats != null) {
extendStats.setEnabled(statsEnabled);
if (!extendStats.getNames().isEmpty()) {
ManagementResourceRegistration cdRegistration = raRegistration.getSubModel(CON_DEF_ADDR);
ManagementResourceRegistration overrideCdRegistration = cdRegistration.registerOverrideModel(cf.getJndiName(), OD_PROVIDER);
if (overrideCdRegistration.getSubModel(EXTENDED_STATS_ADDR) == null) {
overrideCdRegistration.registerSubModel(new StatisticsResourceDefinition(EXTENDED_STATS, CommonAttributes.RESOURCE_NAME, extendStats));
}
}
}
}
}
ConnectionManager[] connectionManagers = deploymentMD.getConnectionManagers();
if (connectionManagers != null) {
PathElement POOL_STATS = PathElement.pathElement(Constants.STATISTICS_NAME, "pool");
PathAddress POOL_STATS_ADDR = PathAddress.pathAddress(POOL_STATS);
for (ConnectionManager cm : connectionManagers) {
if (cm.getPool() != null) {
StatisticsPlugin poolStats = cm.getPool().getStatistics();
poolStats.setEnabled(statsEnabled);
if (!poolStats.getNames().isEmpty()) {
ManagementResourceRegistration cdRegistration = raRegistration.getSubModel(CON_DEF_ADDR);
ManagementResourceRegistration overrideCdRegistration = cdRegistration.registerOverrideModel(cm.getJndiName(), OD_PROVIDER);
if (overrideCdRegistration.getSubModel(POOL_STATS_ADDR) == null) {
overrideCdRegistration.registerSubModel(new StatisticsResourceDefinition(POOL_STATS, CommonAttributes.RESOURCE_NAME, poolStats));
}
}
}
}
}
List<AdminObject> adminObjects = connector.getAdminObjects();
if (adminObjects != null) {
PathAddress AO_ADDR = PathAddress.EMPTY_ADDRESS.append(Constants.ADMIN_OBJECTS_NAME);
for (AdminObject ao : adminObjects) {
StatisticsPlugin extendStats = ao.getStatistics();
if (extendStats != null) {
extendStats.setEnabled(statsEnabled);
if (!extendStats.getNames().isEmpty()) {
ManagementResourceRegistration cdRegistration = raRegistration.getSubModel(AO_ADDR);
ManagementResourceRegistration overrideCdRegistration = cdRegistration.registerOverrideModel(ao.getJndiName(), OD_PROVIDER);
if (overrideCdRegistration.getSubModel(EXTENDED_STATS_ADDR) == null) {
overrideCdRegistration.registerSubModel(new StatisticsResourceDefinition(EXTENDED_STATS, 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.PathElement in project wildfly by wildfly.
the class ConnectionDefinitionStatisticsService method stop.
@Override
public void stop(StopContext context) {
PathElement peCD = PathElement.pathElement(Constants.STATISTICS_NAME, "pool");
if (overrideRegistration.getSubModel(PathAddress.pathAddress(peCD)) != null) {
overrideRegistration.unregisterSubModel(peCD);
}
PathElement peExtended = PathElement.pathElement(Constants.STATISTICS_NAME, "extended");
if (overrideRegistration.getSubModel(PathAddress.pathAddress(peExtended)) != null) {
overrideRegistration.unregisterSubModel(peExtended);
}
}
Aggregations