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