Search in sources :

Example 51 with Resource

use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.

the class IdentityConfigurationRemoveStepHandler method updateModel.

@Override
protected void updateModel(OperationContext context, ModelNode operation) throws OperationFailedException {
    PathAddress partitionManagerAddress = getParentAddress(context.getCurrentAddress());
    Resource partitionManagerResource = context.readResourceFromRoot(partitionManagerAddress);
    checkIfLastConfiguration(partitionManagerResource);
    ModelNode originalParentModel = Resource.Tools.readModel(partitionManagerResource);
    super.updateModel(context, operation);
    context.addStep(new OperationStepHandler() {

        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            PartitionManagerRemoveHandler.INSTANCE.removeIdentityStoreServices(context, originalParentModel, partitionManagerAddress.getLastElement().getValue(), context.getCurrentAddressValue());
            context.completeStep(OperationContext.ResultHandler.NOOP_RESULT_HANDLER);
        }
    }, OperationContext.Stage.RUNTIME);
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) PathAddress(org.jboss.as.controller.PathAddress) Resource(org.jboss.as.controller.registry.Resource) OperationFailedException(org.jboss.as.controller.OperationFailedException) ModelNode(org.jboss.dmr.ModelNode)

Example 52 with Resource

use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.

the class IdentityStoreRemoveStepHandler method checkIfLastIdentityStore.

private void checkIfLastIdentityStore(OperationContext context) throws OperationFailedException {
    PathAddress parentAddress = Util.getParentAddressByKey(context.getCurrentAddress(), ModelElement.IDENTITY_CONFIGURATION.getName());
    Resource resource = context.readResourceFromRoot(parentAddress);
    if (resource.getChildTypes().size() == 1) {
        throw ROOT_LOGGER.idmNoIdentityStoreProvided(parentAddress.getLastElement().getValue());
    }
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) Resource(org.jboss.as.controller.registry.Resource)

Example 53 with Resource

use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.

the class PackageUtils method getServiceNameDependencies.

static List<ServiceName> getServiceNameDependencies(final OperationContext context, final ServiceName baseServiceName, final PathAddress address, final String childType) {
    final List<ServiceName> childrenServiceNames = new LinkedList<ServiceName>();
    final Resource resource = context.readResourceFromRoot(address);
    final ServiceName sn = baseServiceName.append(childType);
    for (ResourceEntry re : resource.getChildren(childType)) {
        childrenServiceNames.add(sn.append(re.getName()));
    }
    return childrenServiceNames;
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ResourceEntry(org.jboss.as.controller.registry.Resource.ResourceEntry) Resource(org.jboss.as.controller.registry.Resource) LinkedList(java.util.LinkedList)

Example 54 with Resource

use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.

the class WSSubsystemAdd method getServerConfigDependencies.

/**
     * Process the model to figure out the name of the services the server config service has to depend on
     *
     */
private static List<ServiceName> getServerConfigDependencies(OperationContext context, boolean appclient) {
    final List<ServiceName> serviceNames = new ArrayList<ServiceName>();
    final Resource subsystemResource = context.readResourceFromRoot(PathAddress.pathAddress(WSExtension.SUBSYSTEM_PATH));
    readConfigServiceNames(serviceNames, subsystemResource, Constants.CLIENT_CONFIG);
    readConfigServiceNames(serviceNames, subsystemResource, Constants.ENDPOINT_CONFIG);
    if (!appclient) {
        serviceNames.add(CommonWebServer.SERVICE_NAME);
    }
    return serviceNames;
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ArrayList(java.util.ArrayList) Resource(org.jboss.as.controller.registry.Resource)

Example 55 with Resource

use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.

the class ManagementHelper method checkNoOtherSibling.

static OperationStepHandler checkNoOtherSibling(final String childType) {
    return new OperationStepHandler() {

        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            PathAddress parentAddress = context.getCurrentAddress().getParent();
            Resource parent = context.readResourceFromRoot(parentAddress, false);
            Set<String> children = parent.getChildrenNames(childType);
            if (children.size() > 1) {
                throw MessagingLogger.ROOT_LOGGER.onlyOneChildIsAllowed(childType, children);
            }
        }
    };
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) PathAddress(org.jboss.as.controller.PathAddress) 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