use of org.jboss.as.controller.SimpleAttributeDefinition 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.SimpleAttributeDefinition in project wildfly by wildfly.
the class XaDataSourcePropertyDefinition method registerAttributes.
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
if (deployed) {
SimpleAttributeDefinition runtimeAttribute = new SimpleAttributeDefinitionBuilder(Constants.XADATASOURCE_PROPERTY_VALUE).setFlags(AttributeAccess.Flag.STORAGE_RUNTIME).build();
resourceRegistration.registerReadOnlyAttribute(runtimeAttribute, XMLXaDataSourceRuntimeHandler.INSTANCE);
} else {
resourceRegistration.registerReadOnlyAttribute(Constants.XADATASOURCE_PROPERTY_VALUE, null);
}
}
use of org.jboss.as.controller.SimpleAttributeDefinition in project wildfly by wildfly.
the class JacORBSubsystemParser method parseSecurityConfig_1_0.
/**
* <p>
* Parses the {@code security} section of the JacORB subsystem configuration according to the XSD version 1.0.
* </p>
*
* @param reader the {@code XMLExtendedStreamReader} used to read the configuration XML.
* @param node the {@code ModelNode} that will hold the parsed security configuration.
* @throws javax.xml.stream.XMLStreamException
* if an error occurs while parsing the XML.
*/
private void parseSecurityConfig_1_0(XMLExtendedStreamReader reader, ModelNode node) throws XMLStreamException {
// parse all security attributes.
EnumSet<Attribute> expectedAttributes = EnumSet.of(Attribute.SECURITY_SUPPORT_SSL, Attribute.SECURITY_ADD_COMPONENT_INTERCEPTOR, Attribute.SECURITY_CLIENT_SUPPORTS, Attribute.SECURITY_CLIENT_REQUIRES, Attribute.SECURITY_SERVER_SUPPORTS, Attribute.SECURITY_SERVER_REQUIRES, Attribute.SECURITY_USE_DOMAIN_SF, Attribute.SECURITY_USE_DOMAIN_SSF);
EnumSet<Attribute> parsedAttributes = EnumSet.noneOf(Attribute.class);
for (int i = 0; i < reader.getAttributeCount(); i++) {
requireNoNamespaceAttribute(reader, i);
String attrValue = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
// check for unexpected attributes.
if (!expectedAttributes.contains(attribute))
throw unexpectedAttribute(reader, i);
// check for duplicate attributes.
if (!parsedAttributes.add(attribute)) {
throw duplicateAttribute(reader, attribute.getLocalName());
}
switch(attribute) {
// check the attributes that need to be converted from int to string.
case SECURITY_CLIENT_SUPPORTS:
case SECURITY_CLIENT_REQUIRES:
case SECURITY_SERVER_SUPPORTS:
case SECURITY_SERVER_REQUIRES:
SSLConfigValue value = SSLConfigValue.fromValue(attrValue);
if (value == null)
throw JacORBLogger.ROOT_LOGGER.invalidSSLConfig(attrValue, reader.getLocation());
attrValue = value.toString();
default:
SimpleAttributeDefinition definition = ((SimpleAttributeDefinition) JacORBSubsystemDefinitions.valueOf(attribute.getLocalName()));
// a null definition represents an attribute that has been deprecated and is no longer used.
if (definition != null)
definition.parseAndSetParameter(attrValue, node, reader);
}
}
// the security element doesn't have child elements.
requireNoContent(reader);
}
use of org.jboss.as.controller.SimpleAttributeDefinition in project wildfly by wildfly.
the class MessagingSubsystemParser method processHornetQServer.
protected void processHornetQServer(final XMLExtendedStreamReader reader, final ModelNode subsystemAddress, final List<ModelNode> list, Namespace namespace) throws XMLStreamException {
String hqServerName = null;
String elementName = null;
if (namespace == Namespace.MESSAGING_1_0) {
// We're parsing the 1.0 xsd's <subsystem> element
requireNoAttributes(reader);
elementName = ModelDescriptionConstants.SUBSYSTEM;
} else {
final int count = reader.getAttributeCount();
if (count > 0) {
requireSingleAttribute(reader, Attribute.NAME.getLocalName());
hqServerName = reader.getAttributeValue(0).trim();
}
elementName = HORNETQ_SERVER;
}
if (hqServerName == null || hqServerName.length() == 0) {
hqServerName = DEFAULT;
}
final ModelNode address = subsystemAddress.clone();
address.add(HORNETQ_SERVER, hqServerName);
address.protect();
final ModelNode operation = new ModelNode();
operation.get(OP).set(ADD);
operation.get(OP_ADDR).set(address);
list.add(operation);
EnumSet<Element> seen = EnumSet.noneOf(Element.class);
// Handle elements
String localName = null;
do {
reader.nextTag();
localName = reader.getLocalName();
final Element element = Element.forName(reader.getLocalName());
if (!seen.add(element)) {
throw ParseUtils.duplicateNamedElement(reader, element.getLocalName());
}
switch(element) {
case ACCEPTORS:
processAcceptors(reader, address, list);
break;
case ADDRESS_SETTINGS:
processAddressSettings(reader, address, list);
break;
case BINDINGS_DIRECTORY:
parseDirectory(reader, CommonAttributes.BINDINGS_DIRECTORY, address, list);
break;
case BRIDGES:
processBridges(reader, address, list);
break;
case BROADCAST_GROUPS:
processBroadcastGroups(reader, address, list);
break;
case CLUSTER_CONNECTIONS:
processClusterConnections(reader, address, list);
break;
case CONNECTORS:
processConnectors(reader, address, list);
break;
case CONNECTOR_SERVICES:
processConnectorServices(reader, address, list);
break;
case DISCOVERY_GROUPS:
processDiscoveryGroups(reader, address, list);
break;
case DIVERTS:
parseDiverts(reader, address, list);
break;
case FILE_DEPLOYMENT_ENABLED:
// This isn't an element in the xsd as there is no filesystem support in AS
unhandledElement(reader, element);
break;
case GROUPING_HANDLER:
processGroupingHandler(reader, address, list);
break;
case JOURNAL_DIRECTORY:
parseDirectory(reader, CommonAttributes.JOURNAL_DIRECTORY, address, list);
break;
case LARGE_MESSAGES_DIRECTORY:
parseDirectory(reader, CommonAttributes.LARGE_MESSAGES_DIRECTORY, address, list);
break;
case LIVE_CONNECTOR_REF:
{
MessagingLogger.ROOT_LOGGER.deprecatedXMLElement(element.toString());
skipElementText(reader);
break;
}
case PAGING_DIRECTORY:
parseDirectory(reader, CommonAttributes.PAGING_DIRECTORY, address, list);
break;
case REMOTING_INTERCEPTORS:
processRemotingInterceptors(reader, operation);
break;
case SECURITY_DOMAIN:
handleElementText(reader, element, null, operation);
break;
case SECURITY_SETTINGS:
{
// process security settings
processSecuritySettings(reader, address, list);
break;
}
case CORE_QUEUES:
{
parseQueues(reader, address, list);
break;
}
case CONNECTION_FACTORIES:
{
processConnectionFactories(reader, address, list);
break;
}
case JMS_DESTINATIONS:
{
processJmsDestinations(reader, address, list);
break;
}
case SCHEDULED_THREAD_POOL_MAX_SIZE:
case THREAD_POOL_MAX_SIZE:
{
// Use the "server" variant
handleElementText(reader, element, "server", operation);
break;
}
case MESSAGE_COUNTER_ENABLED:
{
MessagingLogger.ROOT_LOGGER.deprecatedXMLElement(element.toString(), Element.STATISTICS_ENABLED.toString());
handleElementText(reader, element, operation);
break;
}
case HORNETQ_SERVER:
// The end of the hornetq-server element
if (namespace == Namespace.MESSAGING_1_0) {
throw unexpectedEndElement(reader);
}
break;
case SUBSYSTEM:
// The end of the subsystem element
if (namespace != Namespace.MESSAGING_1_0) {
throw unexpectedEndElement(reader);
}
break;
case CLUSTERED:
// log that the attribute is deprecated but handle it anyway
MessagingLogger.ROOT_LOGGER.deprecatedXMLElement(element.toString());
default:
if (SIMPLE_ROOT_RESOURCE_ELEMENTS.contains(element)) {
AttributeDefinition attributeDefinition = element.getDefinition();
if (attributeDefinition instanceof SimpleAttributeDefinition) {
handleElementText(reader, element, operation);
} else {
// These should be handled in specific case blocks above, e.g. case REMOTING_INTERCEPTORS:
handleComplexConfigurationAttribute(reader, element, operation);
}
} else {
handleUnknownConfigurationAttribute(reader, element, operation);
}
}
} while (reader.hasNext() && localName.equals(elementName) == false);
}
use of org.jboss.as.controller.SimpleAttributeDefinition in project wildfly by wildfly.
the class PooledConnectionFactoryDefinition method copy.
private static AttributeDefinition copy(AttributeDefinition attribute, AttributeAccess.Flag flag) {
AbstractAttributeDefinitionBuilder builder;
if (attribute instanceof SimpleListAttributeDefinition) {
builder = new SimpleListAttributeDefinition.Builder((SimpleListAttributeDefinition) attribute);
// TODO remove once WFCORE-95 is fixed
((SimpleListAttributeDefinition.Builder) builder).setListValidator(attribute.getValidator());
} else if (attribute instanceof SimpleMapAttributeDefinition) {
builder = new SimpleMapAttributeDefinition.Builder((SimpleMapAttributeDefinition) attribute);
} else if (attribute instanceof PrimitiveListAttributeDefinition) {
builder = new PrimitiveListAttributeDefinition.Builder((PrimitiveListAttributeDefinition) attribute);
// TODO remove once WFCORE-95 is fixed
((PrimitiveListAttributeDefinition.Builder) builder).setListValidator(attribute.getValidator());
} else {
builder = new SimpleAttributeDefinitionBuilder((SimpleAttributeDefinition) attribute);
}
builder.setFlags(flag);
return builder.build();
}
Aggregations