use of org.jboss.as.controller.registry.AliasEntry in project wildfly by wildfly.
the class TransportResourceDefinition method register.
@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parent) {
ManagementResourceRegistration registration = super.register(parent);
new WriteAttributeStepHandler(new WriteThreadingAttributeStepHandlerDescriptor()) {
@Override
protected void validateUpdatedModel(OperationContext context, Resource model) throws OperationFailedException {
// Add a new step to validate instead of doing it directly in this method.
// This allows a composite op to change both attributes and then the
// validation occurs after both have done their work.
context.addStep(new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
ModelNode conf = context.readResource(PathAddress.EMPTY_ADDRESS).getModel();
// TODO doesn't cover the admin-only modes
if (context.getProcessType().isServer()) {
for (ThreadingAttribute attribute : EnumSet.allOf(ThreadingAttribute.class)) {
if (conf.hasDefined(attribute.getName())) {
// That is not supported.
throw new OperationFailedException(JGroupsLogger.ROOT_LOGGER.threadsAttributesUsedInRuntime());
}
}
}
}
}, OperationContext.Stage.MODEL);
}
}.register(registration);
if (registration.getPathAddress().getLastElement().isWildcard()) {
for (ThreadPoolResourceDefinition pool : EnumSet.allOf(ThreadPoolResourceDefinition.class)) {
pool.register(registration);
}
parent.registerAlias(LEGACY_PATH, new AliasEntry(registration) {
@Override
public PathAddress convertToTargetAddress(PathAddress aliasAddress, AliasContext aliasContext) {
PathAddress target = this.getTargetAddress();
List<PathElement> result = new ArrayList<>(aliasAddress.size());
for (int i = 0; i < aliasAddress.size(); ++i) {
PathElement element = aliasAddress.getElement(i);
if (i == target.size() - 1) {
final ModelNode operation = aliasContext.getOperation();
final String stackName;
if (ModelDescriptionConstants.ADD.equals(Operations.getName(operation)) && operation.hasDefined("type")) {
stackName = operation.get("type").asString();
} else {
Resource root = null;
try {
root = aliasContext.readResourceFromRoot(PathAddress.pathAddress(result));
} catch (Resource.NoSuchResourceException ignored) {
}
if (root == null) {
stackName = "*";
} else {
Set<String> names = root.getChildrenNames("transport");
if (names.size() > 1) {
throw new AssertionError("There should be at most one child");
} else if (names.size() == 0) {
stackName = "*";
} else {
stackName = names.iterator().next();
}
}
}
result.add(PathElement.pathElement("transport", stackName));
} else if (i < target.size()) {
PathElement targetElement = target.getElement(i);
result.add(targetElement.isWildcard() ? PathElement.pathElement(targetElement.getKey(), element.getValue()) : targetElement);
} else {
result.add(element);
}
}
return PathAddress.pathAddress(result);
}
});
}
return registration;
}
use of org.jboss.as.controller.registry.AliasEntry 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.registry.AliasEntry in project wildfly by wildfly.
the class FilterDefinitions method registerChildren.
@Override
public void registerChildren(ManagementResourceRegistration resourceRegistration) {
super.registerChildren(resourceRegistration);
PathElement targetPe = RequestLimitHandler.INSTANCE.getPathElement();
AliasEntry aliasEntry = new AliasEntry(resourceRegistration.getSubModel(PathAddress.pathAddress(targetPe))) {
@Override
public PathAddress convertToTargetAddress(PathAddress aliasAddress, AliasContext aliasContext) {
PathElement pe = aliasAddress.getLastElement();
return aliasAddress.getParent().append(PathElement.pathElement(targetPe.getKey(), pe.getValue()));
}
};
resourceRegistration.registerAlias(PathElement.pathElement("connection-limit"), aliasEntry);
}
use of org.jboss.as.controller.registry.AliasEntry in project wildfly by wildfly.
the class ACLResourceDefinition method registerChildren.
@Override
public void registerChildren(ManagementResourceRegistration resourceRegistration) {
super.registerChildren(resourceRegistration);
ManagementResourceRegistration moduleReg = resourceRegistration.registerSubModel(new LoginModuleResourceDefinition(Constants.ACL_MODULE));
// https://issues.jboss.org/browse/WFLY-2474 acl-module was wrongly called login-module in 7.2.0
resourceRegistration.registerAlias(PathElement.pathElement(Constants.LOGIN_MODULE), new AliasEntry(moduleReg) {
@Override
public PathAddress convertToTargetAddress(PathAddress address, AliasContext aliasContext) {
PathElement element = address.getLastElement();
element = PathElement.pathElement(Constants.ACL_MODULE, element.getValue());
return address.subAddress(0, address.size() - 1).append(element);
}
});
}
Aggregations