Search in sources :

Example 21 with ReloadRequiredWriteAttributeHandler

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

the class XaDataSourceDefinition method registerAttributes.

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    if (deployed) {
        for (final SimpleAttributeDefinition attribute : XA_DATASOURCE_ATTRIBUTE) {
            SimpleAttributeDefinition runtimeAttribute = new SimpleAttributeDefinitionBuilder(attribute).setFlags(AttributeAccess.Flag.STORAGE_RUNTIME).build();
            resourceRegistration.registerReadOnlyAttribute(runtimeAttribute, XMLXaDataSourceRuntimeHandler.INSTANCE);
        }
        for (final PropertiesAttributeDefinition attribute : XA_DATASOURCE_PROPERTIES_ATTRIBUTES) {
            PropertiesAttributeDefinition runtimeAttribute = new PropertiesAttributeDefinition.Builder(attribute).setFlags(AttributeAccess.Flag.STORAGE_RUNTIME).build();
            resourceRegistration.registerReadOnlyAttribute(runtimeAttribute, XMLXaDataSourceRuntimeHandler.INSTANCE);
        }
    } else {
        ReloadRequiredWriteAttributeHandler reloadRequiredWriteHandler = new ReloadRequiredWriteAttributeHandler(XA_DATASOURCE_ATTRIBUTE);
        for (final SimpleAttributeDefinition attribute : XA_DATASOURCE_ATTRIBUTE) {
            if (PoolConfigurationRWHandler.ATTRIBUTES.contains(attribute.getName())) {
                resourceRegistration.registerReadWriteAttribute(attribute, PoolConfigurationRWHandler.PoolConfigurationReadHandler.INSTANCE, PoolConfigurationRWHandler.LocalAndXaDataSourcePoolConfigurationWriteHandler.INSTANCE);
            } else if (attribute.getName().equals(ENLISTMENT_TRACE.getName())) {
                resourceRegistration.registerReadWriteAttribute(attribute, null, new EnlistmentTraceAttributeWriteHandler());
            } else {
                resourceRegistration.registerReadWriteAttribute(attribute, null, reloadRequiredWriteHandler);
            }
        }
        ReloadRequiredWriteAttributeHandler reloadRequiredPropertiesWriteHandler = new ReloadRequiredWriteAttributeHandler(XA_DATASOURCE_PROPERTIES_ATTRIBUTES);
        for (final PropertiesAttributeDefinition attribute : XA_DATASOURCE_PROPERTIES_ATTRIBUTES) {
            if (PoolConfigurationRWHandler.ATTRIBUTES.contains(attribute.getName())) {
                resourceRegistration.registerReadWriteAttribute(attribute, PoolConfigurationRWHandler.PoolConfigurationReadHandler.INSTANCE, PoolConfigurationRWHandler.LocalAndXaDataSourcePoolConfigurationWriteHandler.INSTANCE);
            } else {
                resourceRegistration.registerReadWriteAttribute(attribute, null, reloadRequiredPropertiesWriteHandler);
            }
        }
    }
}
Also used : PropertiesAttributeDefinition(org.jboss.as.controller.PropertiesAttributeDefinition) SimpleAttributeDefinitionBuilder(org.jboss.as.controller.SimpleAttributeDefinitionBuilder) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) SimpleAttributeDefinitionBuilder(org.jboss.as.controller.SimpleAttributeDefinitionBuilder) ReloadRequiredWriteAttributeHandler(org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)

Example 22 with ReloadRequiredWriteAttributeHandler

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

the class JcaCachedConnectionManagerDefinition method registerAttributes.

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    super.registerAttributes(resourceRegistration);
    for (final CcmParameters parameter : CcmParameters.values()) {
        if (parameter != CcmParameters.INSTALL) {
            resourceRegistration.registerReadWriteAttribute(parameter.getAttribute(), null, JcaCachedConnectionManagerWriteHandler.INSTANCE);
        } else {
            AttributeDefinition ad = parameter.getAttribute();
            resourceRegistration.registerReadWriteAttribute(ad, null, new ReloadRequiredWriteAttributeHandler(ad));
        }
    }
}
Also used : SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) ReloadRequiredWriteAttributeHandler(org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)

Example 23 with ReloadRequiredWriteAttributeHandler

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

the class BatchSubsystemDefinition method registerAttributes.

@Override
public void registerAttributes(final ManagementResourceRegistration resourceRegistration) {
    super.registerAttributes(resourceRegistration);
    final OperationStepHandler writeHandler = new ReloadRequiredWriteAttributeHandler(DEFAULT_JOB_REPOSITORY, DEFAULT_THREAD_POOL, SECURITY_DOMAIN);
    resourceRegistration.registerReadWriteAttribute(DEFAULT_JOB_REPOSITORY, null, writeHandler);
    resourceRegistration.registerReadWriteAttribute(DEFAULT_THREAD_POOL, null, writeHandler);
    resourceRegistration.registerReadWriteAttribute(SECURITY_DOMAIN, null, writeHandler);
    resourceRegistration.registerReadWriteAttribute(RESTART_JOBS_ON_RESUME, null, new AbstractWriteAttributeHandler<Boolean>(RESTART_JOBS_ON_RESUME) {

        @Override
        protected boolean applyUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName, final ModelNode resolvedValue, final ModelNode currentValue, final HandbackHolder<Boolean> handbackHolder) throws OperationFailedException {
            setValue(context, resolvedValue);
            return false;
        }

        @Override
        protected void revertUpdateToRuntime(final OperationContext context, final ModelNode operation, final String attributeName, final ModelNode valueToRestore, final ModelNode valueToRevert, final Boolean handback) throws OperationFailedException {
            setValue(context, valueToRestore);
        }

        private void setValue(final OperationContext context, final ModelNode value) {
            final BatchConfigurationService service = (BatchConfigurationService) context.getServiceRegistry(true).getService(context.getCapabilityServiceName(Capabilities.BATCH_CONFIGURATION_CAPABILITY.getName(), BatchConfiguration.class)).getService();
            service.setRestartOnResume(value.asBoolean());
        }
    });
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) OperationFailedException(org.jboss.as.controller.OperationFailedException) ModelNode(org.jboss.dmr.ModelNode) ReloadRequiredWriteAttributeHandler(org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)

Example 24 with ReloadRequiredWriteAttributeHandler

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

the class DataSourceDefinition method registerAttributes.

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    if (deployed) {
        for (final SimpleAttributeDefinition attribute : DATASOURCE_ATTRIBUTE) {
            SimpleAttributeDefinition runtimeAttribute = new SimpleAttributeDefinitionBuilder(attribute).setFlags(AttributeAccess.Flag.STORAGE_RUNTIME).build();
            resourceRegistration.registerReadOnlyAttribute(runtimeAttribute, XMLDataSourceRuntimeHandler.INSTANCE);
        }
        for (final PropertiesAttributeDefinition attribute : DATASOURCE_PROPERTIES_ATTRIBUTES) {
            PropertiesAttributeDefinition runtimeAttribute = new PropertiesAttributeDefinition.Builder(attribute).setFlags(AttributeAccess.Flag.STORAGE_RUNTIME).build();
            resourceRegistration.registerReadOnlyAttribute(runtimeAttribute, XMLDataSourceRuntimeHandler.INSTANCE);
        }
    } else {
        ReloadRequiredWriteAttributeHandler reloadRequiredWriteAttributeHandler = new ReloadRequiredWriteAttributeHandler(DATASOURCE_ATTRIBUTE);
        CredentialReferenceWriteAttributeHandler credentialReferenceWriteAttributeHandler = new CredentialReferenceWriteAttributeHandler(CREDENTIAL_REFERENCE, RECOVERY_CREDENTIAL_REFERENCE);
        for (final SimpleAttributeDefinition attribute : DATASOURCE_ATTRIBUTE) {
            if (PoolConfigurationRWHandler.ATTRIBUTES.contains(attribute.getName())) {
                resourceRegistration.registerReadWriteAttribute(attribute, PoolConfigurationRWHandler.PoolConfigurationReadHandler.INSTANCE, PoolConfigurationRWHandler.LocalAndXaDataSourcePoolConfigurationWriteHandler.INSTANCE);
            } else if (attribute.getName().equals(ENLISTMENT_TRACE.getName())) {
                resourceRegistration.registerReadWriteAttribute(attribute, null, new EnlistmentTraceAttributeWriteHandler());
            } else if (attribute.getName().equals(CREDENTIAL_REFERENCE.getName()) || attribute.getName().equals(RECOVERY_CREDENTIAL_REFERENCE.getName())) {
                resourceRegistration.registerReadWriteAttribute(attribute, null, credentialReferenceWriteAttributeHandler);
            } else {
                resourceRegistration.registerReadWriteAttribute(attribute, null, reloadRequiredWriteAttributeHandler);
            }
        }
        ReloadRequiredWriteAttributeHandler reloadRequiredPropertiesWriteHandler = new ReloadRequiredWriteAttributeHandler(DATASOURCE_PROPERTIES_ATTRIBUTES);
        for (final PropertiesAttributeDefinition attribute : DATASOURCE_PROPERTIES_ATTRIBUTES) {
            if (PoolConfigurationRWHandler.ATTRIBUTES.contains(attribute.getName())) {
                resourceRegistration.registerReadWriteAttribute(attribute, PoolConfigurationRWHandler.PoolConfigurationReadHandler.INSTANCE, PoolConfigurationRWHandler.LocalAndXaDataSourcePoolConfigurationWriteHandler.INSTANCE);
            } else {
                resourceRegistration.registerReadWriteAttribute(attribute, null, reloadRequiredPropertiesWriteHandler);
            }
        }
    }
}
Also used : PropertiesAttributeDefinition(org.jboss.as.controller.PropertiesAttributeDefinition) CredentialReferenceWriteAttributeHandler(org.jboss.as.controller.security.CredentialReferenceWriteAttributeHandler) SimpleAttributeDefinitionBuilder(org.jboss.as.controller.SimpleAttributeDefinitionBuilder) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) SimpleAttributeDefinitionBuilder(org.jboss.as.controller.SimpleAttributeDefinitionBuilder) ReloadRequiredWriteAttributeHandler(org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)

Example 25 with ReloadRequiredWriteAttributeHandler

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

the class SSLResourceDefinition method register.

@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parent) {
    ManagementResourceRegistration registration = parent.registerSubModel(this);
    ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addExtraParameters(Attribute.class);
    for (Attribute attribute : Attribute.values()) {
        registration.registerReadWriteAttribute(attribute.getDefinition(), null, new ReloadRequiredWriteAttributeHandler() {

            @Override
            protected void validateUpdatedModel(OperationContext context, Resource model) {
                context.addStep(new OperationStepHandler() {

                    @Override
                    public void execute(OperationContext ctx, ModelNode op) throws OperationFailedException {
                        final ModelNode conf = ctx.readResourceFromRoot(ctx.getCurrentAddress().getParent(), false).getModel();
                        if (conf.hasDefined(ProxyConfigurationResourceDefinition.Attribute.SSL_CONTEXT.getName())) {
                            throw new OperationFailedException(ROOT_LOGGER.bothElytronAndLegacySslContextDefined());
                        }
                    }
                }, OperationContext.Stage.MODEL);
            }
        });
    }
    new ReloadRequiredResourceRegistration(descriptor).register(registration);
    return registration;
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) Resource(org.jboss.as.controller.registry.Resource) OperationFailedException(org.jboss.as.controller.OperationFailedException) ReloadRequiredResourceRegistration(org.jboss.as.clustering.controller.ReloadRequiredResourceRegistration) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) ModelNode(org.jboss.dmr.ModelNode) ReloadRequiredWriteAttributeHandler(org.jboss.as.controller.ReloadRequiredWriteAttributeHandler) ResourceDescriptor(org.jboss.as.clustering.controller.ResourceDescriptor)

Aggregations

ReloadRequiredWriteAttributeHandler (org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)30 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)14 SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)14 OperationContext (org.jboss.as.controller.OperationContext)8 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)8 ModelNode (org.jboss.dmr.ModelNode)8 OperationFailedException (org.jboss.as.controller.OperationFailedException)7 StringListAttributeDefinition (org.jboss.as.controller.StringListAttributeDefinition)6 PropertiesAttributeDefinition (org.jboss.as.controller.PropertiesAttributeDefinition)5 CredentialReferenceWriteAttributeHandler (org.jboss.as.controller.security.CredentialReferenceWriteAttributeHandler)4 ObjectTypeAttributeDefinition (org.jboss.as.controller.ObjectTypeAttributeDefinition)3 PrimitiveListAttributeDefinition (org.jboss.as.controller.PrimitiveListAttributeDefinition)3 ReloadRequiredResourceRegistration (org.jboss.as.clustering.controller.ReloadRequiredResourceRegistration)2 ResourceDescriptor (org.jboss.as.clustering.controller.ResourceDescriptor)2 SimpleAttributeDefinitionBuilder (org.jboss.as.controller.SimpleAttributeDefinitionBuilder)2 ManagementResourceRegistration (org.jboss.as.controller.registry.ManagementResourceRegistration)2 Resource (org.jboss.as.controller.registry.Resource)2 EnumSet (java.util.EnumSet)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1