Search in sources :

Example 1 with ReloadRequiredRemoveStepHandler

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

the class ModClusterRemoveCustomMetric method execute.

@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    PathAddress parent = PathAddress.pathAddress(ModClusterSubsystemResourceDefinition.PATH, ModClusterConfigResourceDefinition.PATH, DynamicLoadProviderDefinition.PATH);
    String clazz = CustomLoadMetricDefinition.CLASS.resolveModelAttribute(context, operation).asString();
    String name = getMetricName(context, clazz);
    if (name == null) {
        context.setRollbackOnly();
    } else {
        ModelNode targetOperation = Util.createRemoveOperation(parent.append(PathElement.pathElement(CustomLoadMetricDefinition.PATH.getKey(), name)));
        context.addStep(targetOperation, new ReloadRequiredRemoveStepHandler(), OperationContext.Stage.MODEL, true);
    }
    context.stepCompleted();
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ReloadRequiredRemoveStepHandler(org.jboss.as.controller.ReloadRequiredRemoveStepHandler) ModelNode(org.jboss.dmr.ModelNode)

Example 2 with ReloadRequiredRemoveStepHandler

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

the class ModClusterRemoveMetric method execute.

@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    PathAddress parent = PathAddress.pathAddress(ModClusterSubsystemResourceDefinition.PATH, ModClusterConfigResourceDefinition.PATH, DynamicLoadProviderDefinition.PATH);
    String type = LoadMetricDefinition.TYPE.resolveModelAttribute(context, operation).asString();
    String name = getMetricName(context, type);
    if (name == null) {
        context.setRollbackOnly();
    } else {
        ModelNode targetOperation = Util.createRemoveOperation(parent.append(PathElement.pathElement(LoadMetricDefinition.PATH.getKey(), name)));
        context.addStep(targetOperation, new ReloadRequiredRemoveStepHandler(), OperationContext.Stage.MODEL, true);
    }
    context.stepCompleted();
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) ReloadRequiredRemoveStepHandler(org.jboss.as.controller.ReloadRequiredRemoveStepHandler) ModelNode(org.jboss.dmr.ModelNode)

Example 3 with ReloadRequiredRemoveStepHandler

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

the class EeLegacySubsystemTestCase method createAdditionalInitialization.

@Override
protected AdditionalInitialization createAdditionalInitialization() {
    return new AdditionalInitialization() {

        @Override
        protected RunningMode getRunningMode() {
            return RunningMode.ADMIN_ONLY;
        }

        @Override
        protected void initializeExtraSubystemsAndModel(ExtensionRegistry extensionRegistry, Resource rootResource, ManagementResourceRegistration rootRegistration, RuntimeCapabilityRegistry capabilityRegistry) {
            if (!extensionAdded) {
                //extensionAdded = true;
                //bean validation depends on EE, so we can't use the real subsystem here
                final OperationDefinition removeExtension = new SimpleOperationDefinitionBuilder("remove", NonResolvingResourceDescriptionResolver.INSTANCE).build();
                final OperationDefinition addExtension = new SimpleOperationDefinitionBuilder("add", NonResolvingResourceDescriptionResolver.INSTANCE).addParameter(new SimpleAttributeDefinition("module", ModelType.STRING, false)).build();
                PathElement bvExtension = PathElement.pathElement(EXTENSION, "org.wildfly.extension.bean-validation");
                ManagementResourceRegistration extensionRegistration = rootRegistration.registerSubModel(new SimpleResourceDefinition(bvExtension, NonResolvingResourceDescriptionResolver.INSTANCE));
                extensionRegistration.registerReadOnlyAttribute(new SimpleAttributeDefinition("module", ModelType.STRING, false), new ReloadRequiredWriteAttributeHandler());
                extensionRegistration.registerOperationHandler(removeExtension, new ReloadRequiredRemoveStepHandler());
                extensionRegistration.registerOperationHandler(addExtension, new ReloadRequiredAddStepHandler(new SimpleAttributeDefinition("module", ModelType.STRING, false)));
                final OperationDefinition removeSubsystem = new SimpleOperationDefinitionBuilder("remove", NonResolvingResourceDescriptionResolver.INSTANCE).build();
                final OperationDefinition addSubsystem = new SimpleOperationDefinitionBuilder("add", NonResolvingResourceDescriptionResolver.INSTANCE).build();
                PathElement bvSubsystem = PathElement.pathElement(SUBSYSTEM, "bean-validation");
                ManagementResourceRegistration subsystemRegistration = rootRegistration.registerSubModel(new SimpleResourceDefinition(bvSubsystem, NonResolvingResourceDescriptionResolver.INSTANCE));
                subsystemRegistration.registerOperationHandler(removeSubsystem, new ReloadRequiredRemoveStepHandler());
                subsystemRegistration.registerOperationHandler(addSubsystem, new ReloadRequiredAddStepHandler());
            }
        }
    };
}
Also used : RuntimeCapabilityRegistry(org.jboss.as.controller.capability.registry.RuntimeCapabilityRegistry) SimpleOperationDefinitionBuilder(org.jboss.as.controller.SimpleOperationDefinitionBuilder) Resource(org.jboss.as.controller.registry.Resource) SimpleResourceDefinition(org.jboss.as.controller.SimpleResourceDefinition) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) AdditionalInitialization(org.jboss.as.subsystem.test.AdditionalInitialization) ReloadRequiredWriteAttributeHandler(org.jboss.as.controller.ReloadRequiredWriteAttributeHandler) ReloadRequiredAddStepHandler(org.jboss.as.controller.ReloadRequiredAddStepHandler) ExtensionRegistry(org.jboss.as.controller.extension.ExtensionRegistry) PathElement(org.jboss.as.controller.PathElement) ReloadRequiredRemoveStepHandler(org.jboss.as.controller.ReloadRequiredRemoveStepHandler) OperationDefinition(org.jboss.as.controller.OperationDefinition)

Aggregations

ReloadRequiredRemoveStepHandler (org.jboss.as.controller.ReloadRequiredRemoveStepHandler)3 PathAddress (org.jboss.as.controller.PathAddress)2 ModelNode (org.jboss.dmr.ModelNode)2 OperationDefinition (org.jboss.as.controller.OperationDefinition)1 PathElement (org.jboss.as.controller.PathElement)1 ReloadRequiredAddStepHandler (org.jboss.as.controller.ReloadRequiredAddStepHandler)1 ReloadRequiredWriteAttributeHandler (org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)1 SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)1 SimpleOperationDefinitionBuilder (org.jboss.as.controller.SimpleOperationDefinitionBuilder)1 SimpleResourceDefinition (org.jboss.as.controller.SimpleResourceDefinition)1 RuntimeCapabilityRegistry (org.jboss.as.controller.capability.registry.RuntimeCapabilityRegistry)1 ExtensionRegistry (org.jboss.as.controller.extension.ExtensionRegistry)1 ManagementResourceRegistration (org.jboss.as.controller.registry.ManagementResourceRegistration)1 Resource (org.jboss.as.controller.registry.Resource)1 AdditionalInitialization (org.jboss.as.subsystem.test.AdditionalInitialization)1