use of org.jboss.as.controller.PropertiesAttributeDefinition in project wildfly by wildfly.
the class JcaDistributedWorkManagerWriteHandler method applyUpdateToRuntime.
@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode resolvedValue, ModelNode currentValue, HandbackHolder<JcaSubsystemConfiguration> jcaSubsystemConfigurationHandbackHolder) throws OperationFailedException {
final ModelNode address = operation.require(OP_ADDR);
final String name = PathAddress.pathAddress(address).getLastElement().getValue();
Object wm = context.getServiceRegistry(true).getService(ConnectorServices.WORKMANAGER_SERVICE.append(name)).getValue();
if (wm == null || !(wm instanceof NamedDistributedWorkManager)) {
throw ConnectorLogger.ROOT_LOGGER.failedToFindDistributedWorkManager(name);
}
NamedDistributedWorkManager namedDistributedWorkManager = (NamedDistributedWorkManager) wm;
Injection injector = new Injection();
if (attributeName.equals(JcaDistributedWorkManagerDefinition.DWmParameters.POLICY.getAttribute().getName())) {
switch(JcaDistributedWorkManagerDefinition.PolicyValue.valueOf(resolvedValue.asString())) {
case NEVER:
{
namedDistributedWorkManager.setPolicy(new Never());
break;
}
case ALWAYS:
{
namedDistributedWorkManager.setPolicy(new Always());
break;
}
case WATERMARK:
{
namedDistributedWorkManager.setPolicy(new WaterMark());
break;
}
default:
{
throw ROOT_LOGGER.unsupportedPolicy(resolvedValue.asString());
}
}
} else if (attributeName.equals(JcaDistributedWorkManagerDefinition.DWmParameters.SELECTOR.getAttribute().getName())) {
switch(JcaDistributedWorkManagerDefinition.SelectorValue.valueOf(resolvedValue.asString())) {
case FIRST_AVAILABLE:
{
namedDistributedWorkManager.setSelector(new FirstAvailable());
break;
}
case MAX_FREE_THREADS:
{
namedDistributedWorkManager.setSelector(new MaxFreeThreads());
break;
}
case PING_TIME:
{
namedDistributedWorkManager.setSelector(new PingTime());
break;
}
default:
{
throw ROOT_LOGGER.unsupportedSelector(resolvedValue.asString());
}
}
} else if (attributeName.equals(JcaDistributedWorkManagerDefinition.DWmParameters.POLICY_OPTIONS.getAttribute().getName()) && namedDistributedWorkManager.getPolicy() != null) {
for (Map.Entry<String, String> entry : ((PropertiesAttributeDefinition) JcaDistributedWorkManagerDefinition.DWmParameters.POLICY_OPTIONS.getAttribute()).unwrap(context, operation).entrySet()) {
try {
injector.inject(namedDistributedWorkManager.getPolicy(), entry.getKey(), entry.getValue());
} catch (Exception e) {
ROOT_LOGGER.unsupportedPolicyOption(entry.getKey());
}
}
} else if (attributeName.equals(JcaDistributedWorkManagerDefinition.DWmParameters.SELECTOR_OPTIONS.getAttribute().getName())) {
for (Map.Entry<String, String> entry : ((PropertiesAttributeDefinition) JcaDistributedWorkManagerDefinition.DWmParameters.SELECTOR_OPTIONS.getAttribute()).unwrap(context, operation).entrySet()) {
try {
injector.inject(namedDistributedWorkManager.getSelector(), entry.getKey(), entry.getValue());
} catch (Exception e) {
ROOT_LOGGER.unsupportedSelectorOption(entry.getKey());
}
}
}
return false;
}
use of org.jboss.as.controller.PropertiesAttributeDefinition 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);
}
}
}
}
use of org.jboss.as.controller.PropertiesAttributeDefinition 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);
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 {
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);
}
}
}
}
use of org.jboss.as.controller.PropertiesAttributeDefinition in project wildfly by wildfly.
the class IIOPSubsystemAdd method getResourceProperties.
private void getResourceProperties(final Properties properties, PersistentResourceDefinition resource, OperationContext context, ModelNode model) throws OperationFailedException {
for (AttributeDefinition attrDefinition : resource.getAttributes()) {
if (attrDefinition instanceof PropertiesAttributeDefinition) {
PropertiesAttributeDefinition pad = (PropertiesAttributeDefinition) attrDefinition;
ModelNode resolvedModelAttribute = attrDefinition.resolveModelAttribute(context, model);
if (resolvedModelAttribute.isDefined()) {
for (final Property prop : resolvedModelAttribute.asPropertyList()) {
properties.setProperty(prop.getName(), prop.getValue().asString());
}
}
continue;
}
ModelNode resolvedModelAttribute = attrDefinition.resolveModelAttribute(context, model);
//FIXME
if (resolvedModelAttribute.isDefined()) {
String name = attrDefinition.getName();
String value = resolvedModelAttribute.asString();
String openjdkProperty = PropertiesMap.PROPS_MAP.get(name);
if (openjdkProperty != null) {
name = openjdkProperty;
}
properties.setProperty(name, value);
}
}
}
Aggregations