use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class MessagingXmlInstallDeploymentUnitProcessor method getOrCreate.
static Resource getOrCreate(final Resource parent, final PathAddress address) {
Resource current = parent;
for (final PathElement element : address) {
synchronized (current) {
if (current.hasChild(element)) {
current = current.requireChild(element);
} else {
final Resource resource = Resource.Factory.create();
current.registerChild(element, resource);
current = resource;
}
}
}
return current;
}
use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class SecurityRoleAttributeHandler method applyUpdateToRuntime.
@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode newValue, ModelNode currentValue, HandbackHolder<Set<Role>> handbackHolder) throws OperationFailedException {
final ActiveMQServer server = getActiveMQServer(context, operation);
if (server != null) {
final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
final String match = address.getElement(address.size() - 2).getValue();
final String roleName = address.getLastElement().getValue();
final Set<Role> newRoles = new HashSet<Role>();
final Set<Role> roles = server.getSecurityRepository().getMatch(match);
handbackHolder.setHandback(roles);
for (final Role role : roles) {
if (!roleName.equals(role.getName())) {
newRoles.add(role);
}
}
final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
final ModelNode subModel = resource.getModel();
final Role updatedRole = SecurityRoleDefinition.transform(context, roleName, subModel);
newRoles.add(updatedRole);
server.getSecurityRepository().addMatch(match, newRoles);
}
return false;
}
use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class NotEmptyResourceValidationStepHandler method validateChildren.
protected void validateChildren(OperationContext context, ModelNode operation) throws OperationFailedException {
Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
PathAddress pathAddress = PathAddress.pathAddress(operation.get(OP_ADDR));
if (resource.getChildTypes().isEmpty()) {
throw ROOT_LOGGER.emptyResource(pathAddress.getLastElement().toString());
}
}
use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class DefaultRemoveStepHandler method updateModel.
@Override
protected void updateModel(OperationContext context, ModelNode operation) throws OperationFailedException {
super.updateModel(context, operation);
PathAddress partitionManagerAddress = getParentAddress(PathAddress.pathAddress(operation.require(OP_ADDR)));
Resource partitionManagerResource = context.readResourceFromRoot(partitionManagerAddress);
ModelNode parentModel = Resource.Tools.readModel(partitionManagerResource);
PartitionManagerAddHandler.INSTANCE.validateModel(context, partitionManagerAddress.getLastElement().getValue(), parentModel);
}
use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class IDMConfigWriteAttributeHandler method execute.
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
context.addStep(new OperationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
final PathAddress address = getParentAddress(PathAddress.pathAddress(operation.require(OP_ADDR)));
Resource resource = context.readResourceFromRoot(address);
final ModelNode parentModel = Resource.Tools.readModel(resource);
PartitionManagerAddHandler.INSTANCE.validateModel(context, address.getLastElement().getValue(), parentModel);
context.stepCompleted();
}
}, OperationContext.Stage.MODEL);
super.execute(context, operation);
}
Aggregations