use of org.jboss.as.controller.AttributeDefinition 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.AttributeDefinition in project wildfly by wildfly.
the class HornetQServerResourceDefinition method registerAttributes.
@Override
public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
OperationStepHandler writeHandler = new ModelOnlyWriteAttributeHandler(CommonAttributes.SIMPLE_ROOT_RESOURCE_ATTRIBUTES);
for (AttributeDefinition ad : CommonAttributes.SIMPLE_ROOT_RESOURCE_ATTRIBUTES) {
if (ad.getName().equals(CLUSTERED.getName())) {
resourceRegistration.registerReadWriteAttribute(CLUSTERED, ClusteredAttributeHandlers.READ_HANDLER, ClusteredAttributeHandlers.WRITE_HANDLER);
} else if (ad.getName().equals(MESSAGE_COUNTER_ENABLED.getName())) {
MessageCounterEnabledHandler handler = new MessageCounterEnabledHandler();
resourceRegistration.registerReadWriteAttribute(MESSAGE_COUNTER_ENABLED, handler, handler);
} else {
resourceRegistration.registerReadWriteAttribute(ad, null, writeHandler);
}
}
// handle deprecate attributes
resourceRegistration.registerReadWriteAttribute(CommonAttributes.LIVE_CONNECTOR_REF, null, DeprecatedAttributeWriteHandler.INSTANCE);
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class MessagingXMLWriter method writeClusterConnections.
private static void writeClusterConnections(XMLExtendedStreamWriter writer, ModelNode node) throws XMLStreamException {
if (!node.isDefined()) {
return;
}
List<Property> properties = node.asPropertyList();
if (!properties.isEmpty()) {
writer.writeStartElement(Element.CLUSTER_CONNECTIONS.getLocalName());
for (final Property property : node.asPropertyList()) {
writer.writeStartElement(Element.CLUSTER_CONNECTION.getLocalName());
writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
final ModelNode cluster = property.getValue();
for (AttributeDefinition attribute : ClusterConnectionDefinition.ATTRIBUTES) {
if (attribute == ClusterConnectionDefinition.ALLOW_DIRECT_CONNECTIONS_ONLY) {
// we nest it in static-connectors
continue;
}
if (attribute == CONNECTOR_REFS) {
if (attribute.isMarshallable(cluster)) {
writer.writeStartElement(Element.STATIC_CONNECTORS.getLocalName());
ALLOW_DIRECT_CONNECTIONS_ONLY.marshallAsAttribute(cluster, writer);
CONNECTOR_REFS.marshallAsElement(cluster, writer);
writer.writeEndElement();
} else if (ALLOW_DIRECT_CONNECTIONS_ONLY.isMarshallable(cluster)) {
writer.writeEmptyElement(Element.STATIC_CONNECTORS.getLocalName());
ALLOW_DIRECT_CONNECTIONS_ONLY.marshallAsAttribute(cluster, writer);
}
} else {
attribute.marshallAsElement(property.getValue(), writer);
}
}
writer.writeEndElement();
}
writer.writeEndElement();
writeNewLine(writer);
}
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class MessagingXMLWriter method writeJmsQueues.
private static void writeJmsQueues(final XMLExtendedStreamWriter writer, final ModelNode node) throws XMLStreamException {
if (!node.isDefined()) {
return;
}
if (node.asInt() > 0) {
for (String name : node.keys()) {
final ModelNode queue = node.get(name);
if (queue.isDefined()) {
writer.writeStartElement(Element.JMS_QUEUE.getLocalName());
writer.writeAttribute(Attribute.NAME.getLocalName(), name);
for (AttributeDefinition attribute : JMSQueueDefinition.ATTRIBUTES) {
attribute.marshallAsElement(queue, writer);
}
writer.writeEndElement();
}
}
}
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class MessagingXMLWriter method writeDiscoveryGroups.
private static void writeDiscoveryGroups(final XMLExtendedStreamWriter writer, final ModelNode node) throws XMLStreamException {
if (!node.isDefined()) {
return;
}
List<Property> properties = node.asPropertyList();
if (!properties.isEmpty()) {
writer.writeStartElement(Element.DISCOVERY_GROUPS.getLocalName());
for (final Property property : properties) {
writer.writeStartElement(Element.DISCOVERY_GROUP.getLocalName());
writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
for (AttributeDefinition attribute : DiscoveryGroupDefinition.ATTRIBUTES) {
attribute.marshallAsElement(property.getValue(), writer);
}
writer.writeEndElement();
}
writer.writeEndElement();
writeNewLine(writer);
}
}
Aggregations