Search in sources :

Example 86 with ModelNode

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

the class EJB3Subsystem50Parser method parseProfile.

protected void parseProfile(final XMLExtendedStreamReader reader, List<ModelNode> operations) throws XMLStreamException {
    final int count = reader.getAttributeCount();
    String profileName = null;
    final EJBClientContext.Builder builder = new EJBClientContext.Builder();
    final ModelNode operation = Util.createAddOperation();
    for (int i = 0; i < count; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final EJB3SubsystemXMLAttribute attribute = EJB3SubsystemXMLAttribute.forName(reader.getAttributeLocalName(i));
        switch(attribute) {
            case NAME:
                profileName = value;
                break;
            case EXCLUDE_LOCAL_RECEIVER:
                RemotingProfileResourceDefinition.EXCLUDE_LOCAL_RECEIVER.parseAndSetParameter(value, operation, reader);
                break;
            case LOCAL_RECEIVER_PASS_BY_VALUE:
                RemotingProfileResourceDefinition.LOCAL_RECEIVER_PASS_BY_VALUE.parseAndSetParameter(value, operation, reader);
                break;
            default:
                throw unexpectedAttribute(reader, i);
        }
    }
    if (profileName == null) {
        throw missingRequired(reader, Collections.singleton(EJB3SubsystemXMLAttribute.NAME.getLocalName()));
    }
    final PathAddress address = SUBSYSTEM_PATH.append(EJB3SubsystemModel.REMOTING_PROFILE, profileName);
    operation.get(OP_ADDR).set(address.toModelNode());
    operations.add(operation);
    while (reader.hasNext() && reader.nextTag() != XMLStreamConstants.END_ELEMENT) {
        switch(EJB3SubsystemXMLElement.forName(reader.getLocalName())) {
            case STATIC_EJB_DISCOVERY:
                final ModelNode staticEjb = parseStaticEjbDiscoveryType(reader);
                operation.get(StaticEJBDiscoveryDefinition.STATIC_EJB_DISCOVERY).set(staticEjb);
                break;
            case REMOTING_EJB_RECEIVER:
                {
                    parseRemotingReceiver(reader, address, operations);
                    break;
                }
            default:
                {
                    throw unexpectedElement(reader);
                }
        }
    }
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) EJBClientContext(org.jboss.ejb.client.EJBClientContext) ModelNode(org.jboss.dmr.ModelNode)

Example 87 with ModelNode

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

the class EJB3SubsystemAdd method populateModel.

@Override
protected void populateModel(final OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
    ModelNode model = resource.getModel();
    for (AttributeDefinition attr : EJB3SubsystemRootResourceDefinition.ATTRIBUTES) {
        attr.validateAndSet(operation, model);
    }
    // WFLY-5520 deal with legacy default-clustered-sfsb-cache
    ModelNode defClustered = DEFAULT_CLUSTERED_SFSB_CACHE.validateOperation(operation);
    if (defClustered.isDefined()) {
        boolean setDefaultSfsbCache = true;
        // Assume this is a legacy script and try and adapt the params to the new attributes
        if (model.hasDefined(DEFAULT_SFSB_CACHE)) {
            if (model.hasDefined(DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE)) {
                // are the same, meaning default-clustered-sfsb-cache is redundant
                if (!defClustered.equals(model.get(DEFAULT_SFSB_CACHE))) {
                    // No good. Log or fail
                    if (context.getRunningMode() == RunningMode.ADMIN_ONLY) {
                        EjbLogger.ROOT_LOGGER.logInconsistentAttributeNotSupported(DEFAULT_CLUSTERED_SFSB_CACHE.getName(), DEFAULT_SFSB_CACHE);
                        // don't overwrite default-sfsb-cache
                        setDefaultSfsbCache = false;
                    } else {
                        throw EjbLogger.ROOT_LOGGER.inconsistentAttributeNotSupported(DEFAULT_CLUSTERED_SFSB_CACHE.getName(), DEFAULT_SFSB_CACHE);
                    }
                }
            } else {
                // The old attributes were defined; new one wasn't so, move the old default-sfsb-cache to default-passivation-disabled
                model.get(DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE).set(model.get(DEFAULT_SFSB_CACHE));
            }
        }
        if (setDefaultSfsbCache) {
            model.get(DEFAULT_SFSB_CACHE).set(defClustered);
            EjbLogger.ROOT_LOGGER.remappingCacheAttributes(context.getCurrentAddress().toCLIStyleString(), defClustered, model.get(DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE));
        }
    }
}
Also used : AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelNode(org.jboss.dmr.ModelNode)

Example 88 with ModelNode

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

the class EJB3SubsystemDefaultCacheWriteHandler method applyUpdateToRuntime.

@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> handbackHolder) throws OperationFailedException {
    final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel();
    updateCacheService(context, model);
    return false;
}
Also used : ModelNode(org.jboss.dmr.ModelNode)

Example 89 with ModelNode

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

the class EJB3SubsystemDefaultCacheWriteHandler method updateCacheService.

void updateCacheService(final OperationContext context, final ModelNode model) throws OperationFailedException {
    ModelNode cacheName = this.attribute.resolveModelAttribute(context, model);
    ServiceRegistry registry = context.getServiceRegistry(true);
    if (registry.getService(this.serviceName) != null) {
        context.removeService(this.serviceName);
    }
    if (cacheName.isDefined()) {
        this.installValueService(context, this.serviceName, CacheFactoryBuilder.class, CacheFactoryBuilderService.getServiceName(cacheName.asString()));
    }
}
Also used : ServiceRegistry(org.jboss.msc.service.ServiceRegistry) ModelNode(org.jboss.dmr.ModelNode)

Example 90 with ModelNode

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

the class EJB3SubsystemDefaultEntityBeanOptimisticLockingWriteHandler method applyUpdateToRuntime.

@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> handbackHolder) throws OperationFailedException {
    final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel();
    updateOptimisticLocking(context, model);
    return false;
}
Also used : ModelNode(org.jboss.dmr.ModelNode)

Aggregations

ModelNode (org.jboss.dmr.ModelNode)1634 PathAddress (org.jboss.as.controller.PathAddress)351 Test (org.junit.Test)344 KernelServices (org.jboss.as.subsystem.test.KernelServices)102 Property (org.jboss.dmr.Property)92 OperationFailedException (org.jboss.as.controller.OperationFailedException)89 OperationContext (org.jboss.as.controller.OperationContext)68 ParseUtils.unexpectedElement (org.jboss.as.controller.parsing.ParseUtils.unexpectedElement)68 ArrayList (java.util.ArrayList)58 Resource (org.jboss.as.controller.registry.Resource)54 PathElement (org.jboss.as.controller.PathElement)53 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)52 ParseUtils.requireNoNamespaceAttribute (org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute)50 IOException (java.io.IOException)49 ServiceName (org.jboss.msc.service.ServiceName)49 ResourceTransformationDescriptionBuilder (org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)47 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)44 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)42 OperationBuilder (org.jboss.as.controller.client.OperationBuilder)42 Map (java.util.Map)38