Search in sources :

Example 1 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class BatchSubsystemParser method writeContent.

@Override
public void writeContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException {
    context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
    final ModelNode model = context.getModelNode();
    BatchSubsystemDefinition.JOB_REPOSITORY_TYPE.marshallAsElement(model, writer);
    // Write the thread pool
    if (model.hasDefined(BatchConstants.THREAD_POOL)) {
        final List<Property> threadPools = model.get(BatchConstants.THREAD_POOL).asPropertyList();
        for (Property threadPool : threadPools) {
            threadsParser.writeUnboundedQueueThreadPool(writer, threadPool, Element.THREAD_POOL.getLocalName(), false);
        }
    }
    // Write out the thread factory
    if (model.hasDefined(BatchConstants.THREAD_FACTORY)) {
        final List<Property> threadFactories = model.get(BatchConstants.THREAD_FACTORY).asPropertyList();
        for (Property threadFactory : threadFactories) {
            threadsParser.writeThreadFactory(writer, threadFactory);
        }
    }
    writer.writeEndElement();
}
Also used : ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 2 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class LegacyPropertyAddOperationTransformer method transformOperation.

@Override
public ModelNode transformOperation(ModelNode operation) {
    if (operation.hasDefined(PROPERTIES)) {
        final ModelNode addOp = operation.clone();
        final ModelNode properties = addOp.remove(PROPERTIES);
        final ModelNode composite = new ModelNode();
        composite.get(OP).set(COMPOSITE);
        composite.get(OP_ADDR).setEmptyList();
        composite.get(STEPS).add(addOp);
        // Handle odd jgroups-specific legacy case, where :add operation for the protocol is :add-protocol on the parent
        PathAddress propertyAddress = Operations.getName(addOp).equals("add-protocol") ? Operations.getPathAddress(addOp).append("protocol", addOp.get("type").asString()) : Operations.getPathAddress(addOp);
        for (final Property property : properties.asPropertyList()) {
            String key = property.getName();
            ModelNode value = property.getValue();
            ModelNode propAddOp = Util.createAddOperation(propertyAddress.append(PathElement.pathElement(PROPERTY, key)));
            propAddOp.get(VALUE).set(value);
            composite.get(STEPS).add(propAddOp);
        }
        return composite;
    }
    return operation;
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 3 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class LegacyPropertyResourceTransformer method transformPropertiesToChildrenResources.

public static void transformPropertiesToChildrenResources(ModelNode properties, PathAddress address, ResourceTransformationContext parentContext) {
    if (properties.isDefined()) {
        for (final Property property : properties.asPropertyList()) {
            String key = property.getName();
            ModelNode value = property.getValue();
            Resource propertyResource = Resource.Factory.create();
            propertyResource.getModel().get(VALUE).set(value);
            PathAddress absoluteAddress = address.append(PROPERTY, key);
            parentContext.addTransformedResourceFromRoot(absoluteAddress, propertyResource);
        }
    }
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) Resource(org.jboss.as.controller.registry.Resource) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 4 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class BackupsBuilder method configure.

@Override
public Builder<SitesConfiguration> configure(OperationContext context, ModelNode model) throws OperationFailedException {
    this.backups.clear();
    if (model.hasDefined(BackupResourceDefinition.WILDCARD_PATH.getKey())) {
        SitesConfigurationBuilder builder = new ConfigurationBuilder().sites();
        for (Property property : model.get(BackupResourceDefinition.WILDCARD_PATH.getKey()).asPropertyList()) {
            String siteName = property.getName();
            ModelNode backup = property.getValue();
            BackupConfigurationBuilder backupBuilder = builder.addBackup();
            backupBuilder.site(siteName).enabled(ENABLED.resolveModelAttribute(context, backup).asBoolean()).backupFailurePolicy(ModelNodes.asEnum(FAILURE_POLICY.resolveModelAttribute(context, backup), BackupFailurePolicy.class)).replicationTimeout(TIMEOUT.resolveModelAttribute(context, backup).asLong()).strategy(ModelNodes.asEnum(STRATEGY.resolveModelAttribute(context, backup), BackupStrategy.class)).takeOffline().afterFailures(AFTER_FAILURES.resolveModelAttribute(context, backup).asInt()).minTimeToWait(MIN_WAIT.resolveModelAttribute(context, backup).asLong());
            this.backups.put(siteName, backupBuilder.create());
        }
    }
    return this;
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) SitesConfigurationBuilder(org.infinispan.configuration.cache.SitesConfigurationBuilder) BackupConfigurationBuilder(org.infinispan.configuration.cache.BackupConfigurationBuilder) SitesConfigurationBuilder(org.infinispan.configuration.cache.SitesConfigurationBuilder) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property) BackupConfigurationBuilder(org.infinispan.configuration.cache.BackupConfigurationBuilder)

Example 5 with Property

use of org.jboss.dmr.Property in project wildfly by wildfly.

the class CmpSubsystem10Parser method writeContent.

public void writeContent(final XMLExtendedStreamWriter writer, final SubsystemMarshallingContext context) throws XMLStreamException {
    context.startSubsystemElement(Namespace.CURRENT.getUriString(), false);
    final ModelNode model = context.getModelNode();
    if (model.hasDefined(UUID_KEY_GENERATOR) || model.hasDefined(HILO_KEY_GENERATOR)) {
        writer.writeStartElement(Element.KEY_GENERATORS.getLocalName());
        if (model.hasDefined(UUID_KEY_GENERATOR)) {
            for (Property keyGen : model.get(UUID_KEY_GENERATOR).asPropertyList()) {
                final String name = keyGen.getName();
                final ModelNode keyGenModel = keyGen.getValue();
                writeUuid(writer, name, keyGenModel);
            }
        }
        if (model.hasDefined(HILO_KEY_GENERATOR)) {
            for (Property keyGen : model.get(HILO_KEY_GENERATOR).asPropertyList()) {
                final String name = keyGen.getName();
                final ModelNode keyGenModel = keyGen.getValue();
                writeHilo(writer, name, keyGenModel);
            }
        }
        writer.writeEndElement();
    }
    writer.writeEndElement();
}
Also used : ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Aggregations

Property (org.jboss.dmr.Property)179 ModelNode (org.jboss.dmr.ModelNode)144 HashMap (java.util.HashMap)19 Test (org.junit.Test)19 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)12 PathAddress (org.jboss.as.controller.PathAddress)11 ArrayList (java.util.ArrayList)10 ValueExpression (org.jboss.dmr.ValueExpression)10 ModelType (org.jboss.dmr.ModelType)9 Map (java.util.Map)8 HashSet (java.util.HashSet)7 ArrayDeque (java.util.ArrayDeque)6 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)6 OperationFailedException (org.jboss.as.controller.OperationFailedException)6 SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)6 Properties (java.util.Properties)5 LoginModuleControlFlag (javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag)4 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)4 HttpResponse (org.apache.http.HttpResponse)3 HttpGet (org.apache.http.client.methods.HttpGet)3