Search in sources :

Example 46 with Resource

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;
}
Also used : PathElement(org.jboss.as.controller.PathElement) Resource(org.jboss.as.controller.registry.Resource)

Example 47 with Resource

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;
}
Also used : Role(org.apache.activemq.artemis.core.security.Role) ActiveMQActivationService.getActiveMQServer(org.wildfly.extension.messaging.activemq.ActiveMQActivationService.getActiveMQServer) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) PathAddress(org.jboss.as.controller.PathAddress) Resource(org.jboss.as.controller.registry.Resource) ModelNode(org.jboss.dmr.ModelNode) HashSet(java.util.HashSet)

Example 48 with Resource

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());
    }
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) Resource(org.jboss.as.controller.registry.Resource)

Example 49 with Resource

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);
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) Resource(org.jboss.as.controller.registry.Resource) ModelNode(org.jboss.dmr.ModelNode)

Example 50 with Resource

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);
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) PathAddress(org.jboss.as.controller.PathAddress) OperationFailedException(org.jboss.as.controller.OperationFailedException) Resource(org.jboss.as.controller.registry.Resource) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

Resource (org.jboss.as.controller.registry.Resource)93 PathAddress (org.jboss.as.controller.PathAddress)52 ModelNode (org.jboss.dmr.ModelNode)52 PathElement (org.jboss.as.controller.PathElement)25 OperationFailedException (org.jboss.as.controller.OperationFailedException)24 OperationContext (org.jboss.as.controller.OperationContext)15 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)12 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)11 Map (java.util.Map)10 ServiceName (org.jboss.msc.service.ServiceName)10 ServiceTarget (org.jboss.msc.service.ServiceTarget)10 ManagementResourceRegistration (org.jboss.as.controller.registry.ManagementResourceRegistration)9 ResourceTransformationContext (org.jboss.as.controller.transform.ResourceTransformationContext)6 ResourceTransformer (org.jboss.as.controller.transform.ResourceTransformer)6 ResourceTransformationDescriptionBuilder (org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)6 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)6 ObjectName (javax.management.ObjectName)5 Activation (org.jboss.jca.common.api.metadata.resourceadapter.Activation)5 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)5 ArrayList (java.util.ArrayList)4