Search in sources :

Example 11 with AttributeDefinition

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

the class CachedConnectionManagerRemove method execute.

@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    // This is an odd case where we do not actually do a remove; we just reset state to
    // what it would be following parsing if the xml element does not exist.
    // See discussion on PR with fix for WFLY-2640 .
    ModelNode model = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS).getModel();
    for (JcaCachedConnectionManagerDefinition.CcmParameters param : JcaCachedConnectionManagerDefinition.CcmParameters.values()) {
        AttributeDefinition ad = param.getAttribute();
        if (param == INSTALL || param == DEBUG || param == ERROR || param == IGNORE_UNKNOWN_CONNECTIONS) {
            model.get(ad.getName()).clear();
        } else {
            // Someone added a new param since wFLY-2640/WFLY-8141 and did not account for it above
            throw new IllegalStateException();
        }
    }
    // At the time of WFLY-2640 there were no capabilities associated with this resource,
    // but if anyone adds one, part of the task is to deal with deregistration.
    // So here's an assert to ensure that is considered
    Set<RuntimeCapability> capabilitySet = context.getResourceRegistration().getCapabilities();
    assert capabilitySet.isEmpty();
    if (context.isDefaultRequiresRuntime()) {
        context.addStep(new OperationStepHandler() {

            @Override
            public void execute(OperationContext operationContext, ModelNode modelNode) throws OperationFailedException {
                context.reloadRequired();
                context.completeStep(new OperationContext.RollbackHandler() {

                    @Override
                    public void handleRollback(OperationContext operationContext, ModelNode modelNode) {
                        context.revertReloadRequired();
                    }
                });
            }
        }, OperationContext.Stage.RUNTIME);
    }
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) RuntimeCapability(org.jboss.as.controller.capability.RuntimeCapability) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) OperationFailedException(org.jboss.as.controller.OperationFailedException) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ModelNode(org.jboss.dmr.ModelNode)

Example 12 with AttributeDefinition

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

the class ApplicationSecurityDomainDefinition method registerAttributes.

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    knownApplicationSecurityDomains.clear();
    ReloadRequiredWriteAttributeHandler handler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES);
    for (AttributeDefinition attribute : ATTRIBUTES) {
        resourceRegistration.registerReadWriteAttribute(attribute, null, handler);
    }
    resourceRegistration.registerReadOnlyAttribute(REFERENCING_DEPLOYMENTS, new ReferencingDeploymentsHandler());
}
Also used : StringListAttributeDefinition(org.jboss.as.controller.StringListAttributeDefinition) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) ReloadRequiredWriteAttributeHandler(org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)

Example 13 with AttributeDefinition

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

the class JacORBSubsystemAdd method getConfigurationProperties.

@Override
protected Properties getConfigurationProperties(OperationContext context, ModelNode model) throws OperationFailedException {
    Properties props = new Properties();
    // get the configuration properties from the attribute definitions.
    for (AttributeDefinition attrDefinition : JacORBSubsystemDefinitions.SUBSYSTEM_ATTRIBUTES) {
        if (JacORBSubsystemDefinitions.ON_OFF_ATTRIBUTES_TO_REJECT.contains(attrDefinition) || JacORBSubsystemDefinitions.ATTRIBUTES_TO_REJECT.contains(attrDefinition)) {
            continue;
        }
        ModelNode resolvedModelAttribute = attrDefinition.resolveModelAttribute(context, model);
        if (resolvedModelAttribute.isDefined()) {
            String name = attrDefinition.getName();
            String value = resolvedModelAttribute.asString();
            String openjdkProperty = PropertiesMap.PROPS_MAP.get(name);
            if (openjdkProperty != null) {
                name = openjdkProperty;
            }
            props.setProperty(name, value);
        }
    }
    // check if the node contains a list of generic properties.
    if (model.hasDefined(JacORBSubsystemConstants.PROPERTIES)) {
        ModelNode propertiesNode = model.get(JacORBSubsystemConstants.PROPERTIES);
        for (Property property : propertiesNode.asPropertyList()) {
            String name = property.getName();
            ModelNode value = property.getValue();
            props.setProperty(name, value.asString());
        }
    }
    return props;
}
Also used : AttributeDefinition(org.jboss.as.controller.AttributeDefinition) Properties(java.util.Properties) ModelNode(org.jboss.dmr.ModelNode) Property(org.jboss.dmr.Property)

Example 14 with AttributeDefinition

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

the class ActiveMQServerControlWriteHandler method applyUpdateToRuntime.

@Override
protected boolean applyUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName, final ModelNode newValue, final ModelNode currentValue, final HandbackHolder<Void> handbackHolder) throws OperationFailedException {
    AttributeDefinition attr = getAttributeDefinition(attributeName);
    if (attr.getFlags().contains(AttributeAccess.Flag.RESTART_ALL_SERVICES)) {
        // Restart required
        return true;
    } else {
        ServiceRegistry registry = context.getServiceRegistry(true);
        final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(OP_ADDR)));
        ServiceController<?> service = registry.getService(serviceName);
        if (service == null) {
            // The service isn't installed, so the work done in the Stage.MODEL part is all there is to it
            return false;
        } else if (service.getState() != ServiceController.State.UP) {
            // No, don't barf; just let the update apply to the model and put the server in a reload-required state
            return true;
        } else {
            if (!ActiveMQActivationService.isActiveMQServerActive(context, operation)) {
                return false;
            }
            applyOperationToActiveMQService(operation, attributeName, newValue, service);
            return false;
        }
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Example 15 with AttributeDefinition

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

the class ActiveMQServerControlWriteHandler method revertUpdateToRuntime.

@Override
protected void revertUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName, final ModelNode valueToRestore, final ModelNode valueToRevert, final Void handback) throws OperationFailedException {
    AttributeDefinition attr = getAttributeDefinition(attributeName);
    if (!attr.getFlags().contains(AttributeAccess.Flag.RESTART_ALL_SERVICES)) {
        ServiceRegistry registry = context.getServiceRegistry(true);
        final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(OP_ADDR)));
        ServiceController<?> service = registry.getService(serviceName);
        if (service != null && service.getState() == ServiceController.State.UP) {
            applyOperationToActiveMQService(operation, attributeName, valueToRestore, service);
        }
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Aggregations

AttributeDefinition (org.jboss.as.controller.AttributeDefinition)79 ModelNode (org.jboss.dmr.ModelNode)43 SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)33 OperationContext (org.jboss.as.controller.OperationContext)16 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)12 PathAddress (org.jboss.as.controller.PathAddress)12 Resource (org.jboss.as.controller.registry.Resource)11 Property (org.jboss.dmr.Property)11 ReloadRequiredWriteAttributeHandler (org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)10 OperationFailedException (org.jboss.as.controller.OperationFailedException)8 AbstractAddStepHandler (org.jboss.as.controller.AbstractAddStepHandler)7 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 PathElement (org.jboss.as.controller.PathElement)5 PrimitiveListAttributeDefinition (org.jboss.as.controller.PrimitiveListAttributeDefinition)5 PropertiesAttributeDefinition (org.jboss.as.controller.PropertiesAttributeDefinition)5 StringListAttributeDefinition (org.jboss.as.controller.StringListAttributeDefinition)5 SecurityDomainContext (org.jboss.as.security.plugins.SecurityDomainContext)5 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)5 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)5