Search in sources :

Example 11 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 12 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)

Example 13 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 14 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 15 with Resource

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

the class PersistenceUnitServiceHandler method addManagementConsole.

/**
     * add to management console (if ManagementAdapter is supported for provider).
     * <p/>
     * full path to management data will be:
     * <p/>
     * /deployment=Deployment/subsystem=jpa/hibernate-persistence-unit=FullyAppQualifiedPath#PersistenceUnitName/cache=EntityClassName
     * <p/>
     * example of full path:
     * <p/>
     * /deployment=jpa_SecondLevelCacheTestCase.jar/subsystem=jpa/hibernate-persistence-unit=jpa_SecondLevelCacheTestCase.jar#mypc/
     * cache=org.jboss.as.test.integration.jpa.hibernate.Employee
     *  @param deploymentUnit
     * @param pu
     * @param adaptor
     * @param persistenceAdaptorRemoval
     */
private static void addManagementConsole(final DeploymentUnit deploymentUnit, final PersistenceUnitMetadata pu, final PersistenceProviderAdaptor adaptor, PersistenceAdaptorRemoval persistenceAdaptorRemoval) {
    ManagementAdaptor managementAdaptor = adaptor.getManagementAdaptor();
    // unit in management console.
    if (managementAdaptor != null && adaptor.doesScopedPersistenceUnitNameIdentifyCacheRegionName(pu)) {
        final String providerLabel = managementAdaptor.getIdentificationLabel();
        final String scopedPersistenceUnitName = pu.getScopedPersistenceUnitName();
        Resource providerResource = JPAService.createManagementStatisticsResource(managementAdaptor, scopedPersistenceUnitName, deploymentUnit);
        // Resource providerResource = managementAdaptor.createPersistenceUnitResource(scopedPersistenceUnitName, providerLabel);
        ModelNode perPuNode = providerResource.getModel();
        perPuNode.get(SCOPED_UNIT_NAME.getName()).set(pu.getScopedPersistenceUnitName());
        // TODO this is a temporary hack into internals until DeploymentUnit exposes a proper Resource-based API
        final Resource deploymentResource = deploymentUnit.getAttachment(DeploymentModelUtils.DEPLOYMENT_RESOURCE);
        Resource subsystemResource;
        synchronized (deploymentResource) {
            subsystemResource = getOrCreateResource(deploymentResource, PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "jpa"));
        }
        synchronized (subsystemResource) {
            subsystemResource.registerChild(PathElement.pathElement(providerLabel, scopedPersistenceUnitName), providerResource);
            // save the subsystemResource reference + path to scoped pu, so we can remove it during undeploy
            persistenceAdaptorRemoval.registerManagementConsoleChild(subsystemResource, PathElement.pathElement(providerLabel, scopedPersistenceUnitName));
        }
    }
}
Also used : ManagementAdaptor(org.jipijapa.plugin.spi.ManagementAdaptor) 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