use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class MessagingXMLWriter method writeHornetQServer.
private static void writeHornetQServer(final XMLExtendedStreamWriter writer, final String serverName, final ModelNode node) throws XMLStreamException {
writer.writeStartElement(Element.HORNETQ_SERVER.getLocalName());
if (!DEFAULT.equals(serverName)) {
writer.writeAttribute(Attribute.NAME.getLocalName(), serverName);
}
for (AttributeDefinition simpleAttribute : CommonAttributes.SIMPLE_ROOT_RESOURCE_ATTRIBUTES) {
simpleAttribute.marshallAsElement(node, writer);
}
final ModelNode paths = node.get(ModelDescriptionConstants.PATH);
writeDirectory(writer, Element.PAGING_DIRECTORY, paths);
writeDirectory(writer, Element.BINDINGS_DIRECTORY, paths);
writeDirectory(writer, Element.JOURNAL_DIRECTORY, paths);
writeDirectory(writer, Element.LARGE_MESSAGES_DIRECTORY, paths);
// New line after the simpler elements
writeNewLine(writer);
writeConnectors(writer, node);
writeAcceptors(writer, node);
writeBroadcastGroups(writer, node.get(BROADCAST_GROUP));
writeDiscoveryGroups(writer, node.get(DISCOVERY_GROUP));
writeDiverts(writer, node.get(DIVERT));
writeQueues(writer, node.get(CommonAttributes.QUEUE));
writeBridges(writer, node.get(CommonAttributes.BRIDGE));
writeClusterConnections(writer, node.get(CommonAttributes.CLUSTER_CONNECTION));
writeGroupingHandler(writer, node.get(GROUPING_HANDLER));
writeSecuritySettings(writer, node.get(CommonAttributes.SECURITY_SETTING));
writeAddressSettings(writer, node.get(ADDRESS_SETTING));
writeConnectorServices(writer, node.get(CommonAttributes.CONNECTOR_SERVICE));
if (node.hasDefined(CONNECTION_FACTORY) || node.hasDefined(POOLED_CONNECTION_FACTORY)) {
ModelNode cf = node.get(CONNECTION_FACTORY);
ModelNode pcf = node.get(POOLED_CONNECTION_FACTORY);
boolean hasCf = cf.isDefined() && !cf.keys().isEmpty();
boolean hasPcf = pcf.isDefined() && !pcf.keys().isEmpty();
if (hasCf || hasPcf) {
writer.writeStartElement(JMS_CONNECTION_FACTORIES);
writeConnectionFactories(writer, cf);
writePooledConnectionFactories(writer, pcf);
writer.writeEndElement();
writeNewLine(writer);
}
}
if (node.hasDefined(JMS_QUEUE) || node.hasDefined(JMS_TOPIC)) {
ModelNode queue = node.get(JMS_QUEUE);
ModelNode topic = node.get(JMS_TOPIC);
boolean hasQueue = queue.isDefined() && !queue.keys().isEmpty();
boolean hasTopic = topic.isDefined() && !topic.keys().isEmpty();
if (hasQueue || hasTopic) {
writer.writeStartElement(JMS_DESTINATIONS);
writeJmsQueues(writer, node.get(JMS_QUEUE));
writeTopics(writer, node.get(JMS_TOPIC));
writer.writeEndElement();
}
}
writer.writeEndElement();
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class MessagingXMLWriter method writeDiverts.
private static void writeDiverts(final XMLExtendedStreamWriter writer, final ModelNode node) throws XMLStreamException {
if (!node.isDefined()) {
return;
}
List<Property> properties = node.asPropertyList();
if (!properties.isEmpty()) {
writer.writeStartElement(Element.DIVERTS.getLocalName());
for (final Property property : properties) {
writer.writeStartElement(Element.DIVERT.getLocalName());
writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
for (AttributeDefinition attribute : DivertDefinition.ATTRIBUTES) {
if (CommonAttributes.FILTER == attribute) {
writeFilter(writer, property.getValue());
} 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 writeBridges.
private static void writeBridges(XMLExtendedStreamWriter writer, ModelNode node) throws XMLStreamException {
if (!node.isDefined()) {
return;
}
List<Property> properties = node.asPropertyList();
if (!properties.isEmpty()) {
writer.writeStartElement(Element.BRIDGES.getLocalName());
for (final Property property : node.asPropertyList()) {
writer.writeStartElement(Element.BRIDGE.getLocalName());
writer.writeAttribute(Attribute.NAME.getLocalName(), property.getName());
for (AttributeDefinition attribute : BridgeDefinition.ATTRIBUTES) {
if (CommonAttributes.FILTER == attribute) {
writeFilter(writer, property.getValue());
} 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 writeGroupingHandler.
private static void writeGroupingHandler(XMLExtendedStreamWriter writer, ModelNode node) throws XMLStreamException {
if (!node.isDefined()) {
return;
}
boolean wroteHandler = false;
for (Property handler : node.asPropertyList()) {
if (wroteHandler) {
throw MessagingLogger.ROOT_LOGGER.multipleChildrenFound(GROUPING_HANDLER);
} else {
wroteHandler = true;
}
writer.writeStartElement(Element.GROUPING_HANDLER.getLocalName());
writer.writeAttribute(Attribute.NAME.getLocalName(), handler.getName());
final ModelNode resourceModel = handler.getValue();
for (AttributeDefinition attr : GroupingHandlerDefinition.ATTRIBUTES) {
attr.marshallAsElement(resourceModel, writer);
}
writer.writeEndElement();
writeNewLine(writer);
}
}
use of org.jboss.as.controller.AttributeDefinition in project wildfly by wildfly.
the class PooledConnectionFactoryDefinition method define.
// the generation of the Pooled CF attributes is a bit ugly but it is with purpose:
// * factorize the attributes which are common between the regular CF and the pooled CF
// * keep in a single place the subtle differences (e.g. different default values for reconnect-attempts between
// the regular and pooled CF
// * define the attributes in the *same order than the XSD* to write them to the XML configuration by simply iterating over the array
private static ConnectionFactoryAttribute[] define(ConnectionFactoryAttribute[] specific, ConnectionFactoryAttribute... common) {
int size = common.length + specific.length;
ConnectionFactoryAttribute[] result = new ConnectionFactoryAttribute[size];
arraycopy(specific, 0, result, 0, specific.length);
for (int i = 0; i < common.length; i++) {
ConnectionFactoryAttribute attr = common[i];
AttributeDefinition definition = attr.getDefinition();
ConnectionFactoryAttribute newAttr;
// replace the reconnect-attempts attribute to use a different default value for pooled CF
if (definition == Common.RECONNECT_ATTEMPTS) {
AttributeDefinition copy = copy(Pooled.RECONNECT_ATTEMPTS, AttributeAccess.Flag.RESTART_ALL_SERVICES);
newAttr = ConnectionFactoryAttribute.create(copy, Pooled.RECONNECT_ATTEMPTS_PROP_NAME, true);
} else {
AttributeDefinition copy = copy(definition, AttributeAccess.Flag.RESTART_ALL_SERVICES);
newAttr = ConnectionFactoryAttribute.create(copy, attr.getPropertyName(), attr.isResourceAdapterProperty(), attr.isInboundConfig());
}
result[specific.length + i] = newAttr;
}
return result;
}
Aggregations