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);
}
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);
}
}
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);
}
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);
}
}
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);
}
Aggregations