Search in sources :

Example 36 with OperationStepHandler

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

the class DataSourceEnableDisable method execute.

public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
    // Log that this is deprecated
    ConnectorLogger.ROOT_LOGGER.legacyDisableEnableOperation(operation.get(OP).asString());
    // Just delegate to write-attribute.
    ModelNode writeAttributeOp = getWriteAttributeOperation(context.getCurrentAddress(), Constants.ENABLED.getName(), enabled);
    OperationStepHandler writeHandler = context.getResourceRegistration().getOperationHandler(PathAddress.EMPTY_ADDRESS, WRITE_ATTRIBUTE_OPERATION);
    // set the addFirst param to 'true' so the write-attribute runs before any other steps already registered;
    // i.e. in the logically equivalent spot in the sequence to this step
    context.addStep(writeAttributeOp, writeHandler, OperationContext.Stage.MODEL, true);
}
Also used : OperationStepHandler(org.jboss.as.controller.OperationStepHandler) ModelNode(org.jboss.dmr.ModelNode)

Example 37 with OperationStepHandler

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

the class GetInstalledDriverOperationHandler method execute.

@Override
public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException {
    validator.validate(operation);
    final String name = operation.require(DRIVER_NAME.getName()).asString();
    if (context.isNormalServer()) {
        context.addStep(new OperationStepHandler() {

            @Override
            public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException {
                ServiceController<?> sc = context.getServiceRegistry(false).getRequiredService(ConnectorServices.JDBC_DRIVER_REGISTRY_SERVICE);
                DriverRegistry driverRegistry = DriverRegistry.class.cast(sc.getValue());
                ModelNode result = new ModelNode();
                InstalledDriver driver = driverRegistry.getInstalledDriver(name);
                ModelNode driverNode = new ModelNode();
                driverNode.get(DRIVER_NAME.getName()).set(driver.getDriverName());
                if (driver.isFromDeployment()) {
                    driverNode.get(DEPLOYMENT_NAME.getName()).set(driver.getDriverName());
                    driverNode.get(DRIVER_MODULE_NAME.getName());
                    driverNode.get(MODULE_SLOT.getName());
                    driverNode.get(DRIVER_XA_DATASOURCE_CLASS_NAME.getName());
                } else {
                    driverNode.get(DEPLOYMENT_NAME.getName());
                    driverNode.get(DRIVER_MODULE_NAME.getName()).set(driver.getModuleName().getName());
                    driverNode.get(MODULE_SLOT.getName()).set(driver.getModuleName() != null ? driver.getModuleName().getSlot() : "");
                    driverNode.get(DRIVER_XA_DATASOURCE_CLASS_NAME.getName()).set(driver.getXaDataSourceClassName());
                }
                driverNode.get(DRIVER_CLASS_NAME.getName()).set(driver.getDriverClassName());
                driverNode.get(DRIVER_MAJOR_VERSION.getName()).set(driver.getMajorVersion());
                driverNode.get(DRIVER_MINOR_VERSION.getName()).set(driver.getMinorVersion());
                driverNode.get(JDBC_COMPLIANT.getName()).set(driver.isJdbcCompliant());
                result.add(driverNode);
                context.getResult().set(result);
            }
        }, OperationContext.Stage.RUNTIME);
    }
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) InstalledDriver(org.jboss.as.connector.services.driver.InstalledDriver) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) DriverRegistry(org.jboss.as.connector.services.driver.registry.DriverRegistry) OperationFailedException(org.jboss.as.controller.OperationFailedException) ServiceController(org.jboss.msc.service.ServiceController) ModelNode(org.jboss.dmr.ModelNode)

Example 38 with OperationStepHandler

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

the class IdentityStoreRemoveStepHandler method updateModel.

@Override
protected void updateModel(OperationContext context, ModelNode operation) throws OperationFailedException {
    checkIfLastIdentityStore(context);
    super.updateModel(context, operation);
    context.addStep(new OperationStepHandler() {

        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            PathAddress address = context.getCurrentAddress();
            String configurationName = address.getElement(address.size() - 2).getValue();
            String partitionManagerName = address.getElement(address.size() - 3).getValue();
            String identityStoreName = address.getLastElement().getValue();
            context.removeService(PartitionManagerService.createIdentityStoreServiceName(partitionManagerName, configurationName, identityStoreName));
            context.completeStep(OperationContext.ResultHandler.NOOP_RESULT_HANDLER);
        }
    }, OperationContext.Stage.RUNTIME);
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) PathAddress(org.jboss.as.controller.PathAddress) OperationFailedException(org.jboss.as.controller.OperationFailedException) ModelNode(org.jboss.dmr.ModelNode)

Example 39 with OperationStepHandler

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

the class TransactionSubsystemRootResourceDefinition method registerAttributes.

@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    // Register all attributes except of the mutual ones
    Set<AttributeDefinition> attributesWithoutMutuals = new HashSet<>(Arrays.asList(attributes));
    attributesWithoutMutuals.remove(USE_JOURNAL_STORE);
    attributesWithoutMutuals.remove(USE_JDBC_STORE);
    attributesWithoutMutuals.remove(STATISTICS_ENABLED);
    attributesWithoutMutuals.remove(DEFAULT_TIMEOUT);
    // Remove these as it also needs special write handler
    attributesWithoutMutuals.remove(JDBC_STORE_DATASOURCE);
    attributesWithoutMutuals.remove(PROCESS_ID_UUID);
    attributesWithoutMutuals.remove(PROCESS_ID_SOCKET_BINDING);
    attributesWithoutMutuals.remove(PROCESS_ID_SOCKET_MAX_PORTS);
    OperationStepHandler writeHandler = new ReloadRequiredWriteAttributeHandler(attributesWithoutMutuals);
    for (final AttributeDefinition def : attributesWithoutMutuals) {
        resourceRegistration.registerReadWriteAttribute(def, null, writeHandler);
    }
    // Register mutual object store attributes
    OperationStepHandler mutualWriteHandler = new ObjectStoreMutualWriteHandler(USE_JOURNAL_STORE, USE_JDBC_STORE);
    resourceRegistration.registerReadWriteAttribute(USE_JOURNAL_STORE, null, mutualWriteHandler);
    resourceRegistration.registerReadWriteAttribute(USE_JDBC_STORE, null, mutualWriteHandler);
    //Register default-timeout attribute
    resourceRegistration.registerReadWriteAttribute(DEFAULT_TIMEOUT, null, new DefaultTimeoutHandler(DEFAULT_TIMEOUT));
    // Register jdbc-store-datasource attribute
    resourceRegistration.registerReadWriteAttribute(JDBC_STORE_DATASOURCE, null, new JdbcStoreDatasourceWriteHandler(JDBC_STORE_DATASOURCE));
    // Register mutual object store attributes
    OperationStepHandler mutualProcessIdWriteHandler = new ProcessIdWriteHandler(PROCESS_ID_UUID, PROCESS_ID_SOCKET_BINDING, PROCESS_ID_SOCKET_MAX_PORTS);
    resourceRegistration.registerReadWriteAttribute(PROCESS_ID_UUID, null, mutualProcessIdWriteHandler);
    resourceRegistration.registerReadWriteAttribute(PROCESS_ID_SOCKET_BINDING, null, mutualProcessIdWriteHandler);
    resourceRegistration.registerReadWriteAttribute(PROCESS_ID_SOCKET_MAX_PORTS, null, mutualProcessIdWriteHandler);
    //Register statistics-enabled attribute
    resourceRegistration.registerReadWriteAttribute(STATISTICS_ENABLED, null, new StatisticsEnabledHandler(STATISTICS_ENABLED));
    AliasedHandler esh = new AliasedHandler(STATISTICS_ENABLED.getName());
    resourceRegistration.registerReadWriteAttribute(ENABLE_STATISTICS, esh, esh);
    AliasedHandler hsh = new AliasedHandler(USE_JOURNAL_STORE.getName());
    resourceRegistration.registerReadWriteAttribute(USE_HORNETQ_STORE, hsh, hsh);
    AliasedHandler hseh = new AliasedHandler(JOURNAL_STORE_ENABLE_ASYNC_IO.getName());
    resourceRegistration.registerReadWriteAttribute(HORNETQ_STORE_ENABLE_ASYNC_IO, hseh, hseh);
    if (registerRuntimeOnly) {
        TxStatsHandler.INSTANCE.registerMetrics(resourceRegistration);
    }
}
Also used : OperationStepHandler(org.jboss.as.controller.OperationStepHandler) AttributeDefinition(org.jboss.as.controller.AttributeDefinition) SimpleAttributeDefinition(org.jboss.as.controller.SimpleAttributeDefinition) ReloadRequiredWriteAttributeHandler(org.jboss.as.controller.ReloadRequiredWriteAttributeHandler) HashSet(java.util.HashSet)

Example 40 with OperationStepHandler

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

the class LogStoreParticipantDeleteHandler method refreshParticipant.

void refreshParticipant(OperationContext context) {
    final ModelNode operation = Util.createEmptyOperation("refresh-log-store", context.getCurrentAddress().getParent().getParent());
    context.addStep(operation, new OperationStepHandler() {

        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            probeHandler.execute(context, operation);
        }
    }, OperationContext.Stage.MODEL);
}
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)

Aggregations

OperationStepHandler (org.jboss.as.controller.OperationStepHandler)48 ModelNode (org.jboss.dmr.ModelNode)39 OperationContext (org.jboss.as.controller.OperationContext)37 OperationFailedException (org.jboss.as.controller.OperationFailedException)31 PathAddress (org.jboss.as.controller.PathAddress)18 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)12 Resource (org.jboss.as.controller.registry.Resource)11 PathElement (org.jboss.as.controller.PathElement)8 SimpleAttributeDefinition (org.jboss.as.controller.SimpleAttributeDefinition)8 ManagementResourceRegistration (org.jboss.as.controller.registry.ManagementResourceRegistration)7 ServiceController (org.jboss.msc.service.ServiceController)7 ServiceName (org.jboss.msc.service.ServiceName)7 Map (java.util.Map)5 ArrayList (java.util.ArrayList)4 ResourceServiceHandler (org.jboss.as.clustering.controller.ResourceServiceHandler)4 ReloadRequiredWriteAttributeHandler (org.jboss.as.controller.ReloadRequiredWriteAttributeHandler)4 Collection (java.util.Collection)3 LinkedHashMap (java.util.LinkedHashMap)3 List (java.util.List)3 ResourceDescriptor (org.jboss.as.clustering.controller.ResourceDescriptor)3