use of org.jboss.as.controller.ReloadRequiredWriteAttributeHandler in project wildfly by wildfly.
the class AbstractDataSourceDefinition method registerAttributes.
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
ReloadRequiredWriteAttributeHandler handler = new ReloadRequiredWriteAttributeHandler(getAttributes());
for (AttributeDefinition attributeDefinition : getAttributes()) {
OperationStepHandler writeHandler = handler;
if (attributeDefinition == STATISTICS_ENABLED_ATTRIBUTE) {
writeHandler = AbstractDataSourceOperations.STATISTICS_ENABLED_WRITE_OPERATION;
}
if (attributeDefinition == CONNECTION_FACTORY_ATTRIBUTE) {
writeHandler = AbstractDataSourceOperations.CONNECTION_FACTORY_WRITE_OPERATION;
}
if (attributeDefinition == CONNECTION_POOL_ATTRIBUTE) {
writeHandler = AbstractDataSourceOperations.CONNECTION_POOL_WRITE_OPERATION;
}
if (attributeDefinition == CREDENTIAL_REFERENCE) {
writeHandler = AbstractDataSourceOperations.CREDENTIAL_REFERENCE_WRITE_OPERATION;
}
resourceRegistration.registerReadWriteAttribute(attributeDefinition, null, writeHandler);
}
// Runtime attributes
if (resourceRegistration.getProcessType().isServer()) {
resourceRegistration.registerReadOnlyAttribute(STATISTICS, AbstractDataSourceOperations.STATISTICS_GET_OPERATION);
}
}
use of org.jboss.as.controller.ReloadRequiredWriteAttributeHandler in project wildfly by wildfly.
the class ProxyConfigurationResourceDefinition method register.
@SuppressWarnings("deprecation")
@Override
public ManagementResourceRegistration register(ManagementResourceRegistration parent) {
ManagementResourceRegistration registration = parent.registerSubModel(this);
ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(EnumSet.complementOf(EnumSet.of(Attribute.SSL_CONTEXT))).addExtraParameters(Attribute.SSL_CONTEXT).addAttributeTranslation(DeprecatedAttribute.SIMPLE_LOAD_PROVIDER, SIMPLE_LOAD_PROVIDER_TRANSLATION).addAlias(DeprecatedAttribute.CONNECTOR, Attribute.LISTENER).addRequiredSingletonChildren(SimpleLoadProviderResourceDefinition.PATH).addCapabilities(Capability.class);
registration.registerReadWriteAttribute(Attribute.SSL_CONTEXT.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 {
if (model.hasChild(SSLResourceDefinition.PATH)) {
throw new OperationFailedException(ROOT_LOGGER.bothElytronAndLegacySslContextDefined());
}
}
}, OperationContext.Stage.MODEL);
}
});
parent.registerAlias(LEGACY_PATH, new AliasEntry(registration) {
@Override
public PathAddress convertToTargetAddress(PathAddress aliasAddress, AliasContext aliasContext) {
PathAddress rebuiltAddress = PathAddress.EMPTY_ADDRESS;
for (PathElement pathElement : aliasAddress) {
if (pathElement.equals(LEGACY_PATH)) {
try {
if (aliasContext.readResourceFromRoot(rebuiltAddress, false).hasChildren(ProxyConfigurationResourceDefinition.WILDCARD_PATH.getKey())) {
Set<Resource.ResourceEntry> children = aliasContext.readResourceFromRoot(rebuiltAddress, false).getChildren(ProxyConfigurationResourceDefinition.WILDCARD_PATH.getKey());
if (children.size() > 1 && !Operations.getOperationName(aliasContext.getOperation()).equals(AliasContext.RECURSIVE_GLOBAL_OP)) {
throw new IllegalStateException(ModClusterLogger.ROOT_LOGGER.legacyOperationsWithMultipleProxies());
}
PathAddress proxyPath = PathAddress.pathAddress(ProxyConfigurationResourceDefinition.pathElement(children.iterator().next().getName()));
rebuiltAddress = rebuiltAddress.append(proxyPath);
} else {
// handle :add
rebuiltAddress = rebuiltAddress.append(ProxyConfigurationResourceDefinition.pathElement("default"));
}
} catch (Resource.NoSuchResourceException ignore) {
// handle recursive-global-op
rebuiltAddress = rebuiltAddress.append(ProxyConfigurationResourceDefinition.WILDCARD_PATH);
}
} else {
rebuiltAddress = rebuiltAddress.append(pathElement);
}
}
return rebuiltAddress;
}
});
if (registration.isRuntimeOnlyRegistrationValid()) {
new OperationHandler<>(new ProxyOperationExecutor(this.executors), ProxyOperation.class).register(registration);
}
new ReloadRequiredResourceRegistration(descriptor).register(registration);
new LegacyMetricOperationsRegistration().register(registration);
new SimpleLoadProviderResourceDefinition().register(registration);
new DynamicLoadProviderResourceDefinition().register(registration);
new SSLResourceDefinition().register(registration);
return registration;
}
use of org.jboss.as.controller.ReloadRequiredWriteAttributeHandler in project wildfly by wildfly.
the class SecuritySubsystemRootResourceDefinition method registerAttributes.
@Override
public void registerAttributes(final ManagementResourceRegistration resourceRegistration) {
resourceRegistration.registerReadWriteAttribute(DEEP_COPY_SUBJECT_MODE, null, new ReloadRequiredWriteAttributeHandler(DEEP_COPY_SUBJECT_MODE));
resourceRegistration.registerReadWriteAttribute(INITIALIZE_JACC, null, new ReloadRequiredWriteAttributeHandler(INITIALIZE_JACC) {
@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<Void> voidHandback) throws OperationFailedException {
// As the PolicyConfigurationFactory is a singleton, once it's initialized any changes will require a restart
CapabilityServiceSupport capabilitySupport = context.getCapabilityServiceSupport();
final boolean elytronJacc = capabilitySupport.hasCapability("org.wildfly.security.jacc-policy");
if (resolvedValue.asBoolean() == true && elytronJacc) {
throw SecurityLogger.ROOT_LOGGER.unableToEnableJaccSupport();
}
return super.applyUpdateToRuntime(context, operation, attributeName, resolvedValue, currentValue, voidHandback);
}
@Override
protected void recordCapabilitiesAndRequirements(OperationContext context, AttributeDefinition attributeDefinition, ModelNode newValue, ModelNode oldValue) {
super.recordCapabilitiesAndRequirements(context, attributeDefinition, newValue, oldValue);
boolean shouldRegister = resolveValue(context, attributeDefinition, newValue);
boolean registered = resolveValue(context, attributeDefinition, oldValue);
if (!shouldRegister) {
context.deregisterCapability(JACC_CAPABILITY.getName());
}
if (!registered && shouldRegister) {
context.registerCapability(JACC_CAPABILITY);
// do not register the JACC_CAPABILITY_TOMBSTONE at this point - it will be registered on restart
}
}
private boolean resolveValue(OperationContext context, AttributeDefinition attributeDefinition, ModelNode node) {
try {
return attributeDefinition.resolveValue(context, node).asBoolean();
} catch (OperationFailedException e) {
throw new IllegalStateException(e);
}
}
});
}
use of org.jboss.as.controller.ReloadRequiredWriteAttributeHandler 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);
}
if (resourceRegistration.getProcessType().isServer()) {
resourceRegistration.registerReadOnlyAttribute(REFERENCING_DEPLOYMENTS, new ReferencingDeploymentsHandler());
}
}
use of org.jboss.as.controller.ReloadRequiredWriteAttributeHandler in project wildfly by wildfly.
the class BridgeDefinition method registerAttributes.
@Override
public void registerAttributes(ManagementResourceRegistration registry) {
ReloadRequiredWriteAttributeHandler reloadRequiredWriteAttributeHandler = new ReloadRequiredWriteAttributeHandler(ATTRIBUTES);
CredentialReferenceWriteAttributeHandler credentialReferenceWriteAttributeHandler = new CredentialReferenceWriteAttributeHandler(CREDENTIAL_REFERENCE);
for (AttributeDefinition attr : ATTRIBUTES) {
if (!attr.getFlags().contains(AttributeAccess.Flag.STORAGE_RUNTIME)) {
if (attr.equals(CREDENTIAL_REFERENCE)) {
registry.registerReadWriteAttribute(attr, null, credentialReferenceWriteAttributeHandler);
} else {
registry.registerReadWriteAttribute(attr, null, reloadRequiredWriteAttributeHandler);
}
}
}
BridgeControlHandler.INSTANCE.registerAttributes(registry);
}
Aggregations