Search in sources :

Example 31 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class XaDataSourceDefinition method registerTransformers120.

static void registerTransformers120(ResourceTransformationDescriptionBuilder parentBuilder) {
    ResourceTransformationDescriptionBuilder builder = parentBuilder.addChildResource(PATH_XA_DATASOURCE);
    builder.getAttributeBuilder().setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(new ModelNode(false)), CONNECTABLE).setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(false, false, new ModelNode(true)), STATISTICS_ENABLED).setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(new ModelNode(true)), ENLISTMENT_TRACE).setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(new ModelNode(LEGACY_MCP)), MCP).setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(false, true, new ModelNode(false)), Constants.ELYTRON_ENABLED, Constants.RECOVERY_ELYTRON_ENABLED).setDiscard(DiscardAttributeChecker.UNDEFINED, Constants.AUTHENTICATION_CONTEXT, RECOVERY_AUTHENTICATION_CONTEXT, CREDENTIAL_REFERENCE, RECOVERY_CREDENTIAL_REFERENCE).addRejectCheck(RejectAttributeChecker.DEFINED, ENLISTMENT_TRACE).addRejectCheck(RejectAttributeChecker.DEFINED, MCP).addRejectCheck(new RejectAttributeChecker.DefaultRejectAttributeChecker() {

        @Override
        public String getRejectionLogMessage(Map<String, ModelNode> attributes) {
            return ConnectorLogger.ROOT_LOGGER.rejectAttributesMustBeTrue(attributes.keySet());
        }

        @Override
        protected boolean rejectAttribute(PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) {
            //This will not get called if it was discarded, so reject if it is undefined (default==false) or if defined and != 'true'
            return !attributeValue.isDefined() || !attributeValue.asString().equals("true");
        }
    }, STATISTICS_ENABLED).setDiscard(DiscardAttributeChecker.UNDEFINED, TRACKING).addRejectCheck(RejectAttributeChecker.DEFINED, TRACKING).addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, ENABLED).addRejectCheck(RejectAttributeChecker.DEFINED, Constants.ELYTRON_ENABLED, Constants.RECOVERY_ELYTRON_ENABLED, AUTHENTICATION_CONTEXT, RECOVERY_AUTHENTICATION_CONTEXT, CREDENTIAL_REFERENCE, RECOVERY_CREDENTIAL_REFERENCE).end().addOperationTransformationOverride(DATASOURCE_ENABLE.getName()).end().addOperationTransformationOverride(DATASOURCE_DISABLE.getName()).end();
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) ModelNode(org.jboss.dmr.ModelNode) DiscardAttributeChecker(org.jboss.as.controller.transform.description.DiscardAttributeChecker) Map(java.util.Map) TransformationContext(org.jboss.as.controller.transform.TransformationContext)

Example 32 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class XaDataSourceDefinition method registerTransformers130.

static void registerTransformers130(ResourceTransformationDescriptionBuilder parentBuilder) {
    ResourceTransformationDescriptionBuilder builder = parentBuilder.addChildResource(PATH_XA_DATASOURCE);
    builder.getAttributeBuilder().setDiscard(new DiscardAttributeChecker.DefaultDiscardAttributeChecker() {

        @Override
        protected boolean isValueDiscardable(PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) {
            return attributeValue.equals(new ModelNode(false));
        }
    }, TRACKING).setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(false, true, new ModelNode(false)), Constants.ELYTRON_ENABLED, Constants.RECOVERY_ELYTRON_ENABLED).setDiscard(DiscardAttributeChecker.UNDEFINED, Constants.AUTHENTICATION_CONTEXT, RECOVERY_AUTHENTICATION_CONTEXT, CREDENTIAL_REFERENCE, RECOVERY_CREDENTIAL_REFERENCE).addRejectCheck(RejectAttributeChecker.SIMPLE_EXPRESSIONS, ENABLED).addRejectCheck(RejectAttributeChecker.DEFINED, TRACKING).addRejectCheck(RejectAttributeChecker.DEFINED, Constants.ELYTRON_ENABLED, Constants.RECOVERY_ELYTRON_ENABLED, AUTHENTICATION_CONTEXT, RECOVERY_AUTHENTICATION_CONTEXT, CREDENTIAL_REFERENCE, RECOVERY_CREDENTIAL_REFERENCE).end();
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) ModelNode(org.jboss.dmr.ModelNode) DiscardAttributeChecker(org.jboss.as.controller.transform.description.DiscardAttributeChecker) TransformationContext(org.jboss.as.controller.transform.TransformationContext)

Example 33 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class EvictionMetricExecutor method execute.

@Override
public ModelNode execute(OperationContext context, Metric<Cache<?, ?>> metric) throws OperationFailedException {
    PathAddress cacheAddress = context.getCurrentAddress().getParent();
    String containerName = cacheAddress.getParent().getLastElement().getValue();
    String cacheName = cacheAddress.getLastElement().getValue();
    Cache<?, ?> cache = ServiceContainerHelper.findValue(context.getServiceRegistry(false), InfinispanCacheRequirement.CACHE.getServiceName(context, containerName, cacheName));
    return (cache != null) ? metric.execute(cache) : null;
}
Also used : PathAddress(org.jboss.as.controller.PathAddress)

Example 34 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class BinaryTableResourceDefinition method buildTransformation.

@SuppressWarnings("deprecation")
static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
    ResourceTransformationDescriptionBuilder builder = parent.addChildResource(PATH);
    if (InfinispanModel.VERSION_4_0_0.requiresTransformation(version)) {
        OperationTransformer addTransformer = new OperationTransformer() {

            @Override
            public ModelNode transformOperation(ModelNode operation) {
                PathAddress storeAddress = Operations.getPathAddress(operation).getParent();
                ModelNode value = new ModelNode();
                for (Class<? extends org.jboss.as.clustering.controller.Attribute> attributeClass : Arrays.asList(Attribute.class, TableResourceDefinition.Attribute.class, TableResourceDefinition.ColumnAttribute.class)) {
                    for (org.jboss.as.clustering.controller.Attribute attribute : attributeClass.getEnumConstants()) {
                        String name = attribute.getName();
                        if (operation.hasDefined(name)) {
                            value.get(name).set(operation.get(name));
                        }
                    }
                }
                return value.isDefined() ? Operations.createWriteAttributeOperation(storeAddress, BinaryKeyedJDBCStoreResourceDefinition.DeprecatedAttribute.TABLE, value) : Operations.createUndefineAttributeOperation(storeAddress, BinaryKeyedJDBCStoreResourceDefinition.DeprecatedAttribute.TABLE);
            }
        };
        builder.addRawOperationTransformationOverride(ModelDescriptionConstants.ADD, new SimpleOperationTransformer(addTransformer));
        OperationTransformer removeTransformer = new OperationTransformer() {

            @Override
            public ModelNode transformOperation(ModelNode operation) {
                PathAddress storeAddress = Operations.getPathAddress(operation).getParent();
                return Operations.createUndefineAttributeOperation(storeAddress, BinaryKeyedJDBCStoreResourceDefinition.DeprecatedAttribute.TABLE);
            }
        };
        builder.addRawOperationTransformationOverride(ModelDescriptionConstants.REMOVE, new SimpleOperationTransformer(removeTransformer));
    }
}
Also used : SimpleOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleOperationTransformer) OperationTransformer(org.jboss.as.clustering.controller.transform.OperationTransformer) PathAddress(org.jboss.as.controller.PathAddress) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) SimpleOperationTransformer(org.jboss.as.clustering.controller.transform.SimpleOperationTransformer) ModelNode(org.jboss.dmr.ModelNode)

Example 35 with PathAddress

use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.

the class StoreMetricExecutor method execute.

@Override
public ModelNode execute(OperationContext context, Metric<ActivationInterceptor> metric) throws OperationFailedException {
    PathAddress cacheAddress = context.getCurrentAddress().getParent();
    String containerName = cacheAddress.getParent().getLastElement().getValue();
    String cacheName = cacheAddress.getLastElement().getValue();
    Cache<?, ?> cache = ServiceContainerHelper.findValue(context.getServiceRegistry(false), InfinispanCacheRequirement.CACHE.getServiceName(context, containerName, cacheName));
    if (cache != null) {
        ActivationInterceptor interceptor = CacheMetric.findInterceptor(cache, ActivationInterceptor.class);
        if (interceptor != null) {
            return metric.execute(interceptor);
        }
    }
    return null;
}
Also used : ActivationInterceptor(org.infinispan.interceptors.ActivationInterceptor) PathAddress(org.jboss.as.controller.PathAddress)

Aggregations

PathAddress (org.jboss.as.controller.PathAddress)644 ModelNode (org.jboss.dmr.ModelNode)492 Resource (org.jboss.as.controller.registry.Resource)70 Test (org.junit.Test)66 PathElement (org.jboss.as.controller.PathElement)63 KernelServices (org.jboss.as.subsystem.test.KernelServices)51 ServiceName (org.jboss.msc.service.ServiceName)51 OperationFailedException (org.jboss.as.controller.OperationFailedException)43 ParseUtils.requireNoNamespaceAttribute (org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute)35 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)35 FailedOperationTransformationConfig (org.jboss.as.model.test.FailedOperationTransformationConfig)34 KernelServicesBuilder (org.jboss.as.subsystem.test.KernelServicesBuilder)33 ServiceTarget (org.jboss.msc.service.ServiceTarget)32 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)31 Map (java.util.Map)30 ParseUtils.unexpectedElement (org.jboss.as.controller.parsing.ParseUtils.unexpectedElement)29 IOException (java.io.IOException)28 ResourceTransformationDescriptionBuilder (org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)26 ArrayList (java.util.ArrayList)25 OperationContext (org.jboss.as.controller.OperationContext)23