Ejemplo n.º 1
0
 private static boolean hasDefinedInboundConfigAttributes(ModelNode pcf) {
   for (ConnectionFactoryAttribute attribute : PooledConnectionFactoryDefinition.ATTRIBUTES) {
     if (attribute.isInboundConfig() && pcf.hasDefined(attribute.getDefinition().getName())) {
       return true;
     }
   }
   return false;
 }
Ejemplo n.º 2
0
  private static void writePooledConnectionFactories(
      final XMLExtendedStreamWriter writer, final ModelNode node) throws XMLStreamException {
    if (!node.isDefined() || node.keys().size() == 0) {
      return;
    }
    List<Property> properties = node.asPropertyList();
    if (!properties.isEmpty()) {
      for (Property prop : properties) {
        final String name = prop.getName();
        final ModelNode factory = prop.getValue();
        if (factory.isDefined()) {
          writer.writeStartElement(Element.POOLED_CONNECTION_FACTORY.getLocalName());

          writer.writeAttribute(Attribute.NAME.getLocalName(), name);

          // write inbound config attributes first...
          if (hasDefinedInboundConfigAttributes(factory)) {
            writer.writeStartElement(Element.INBOUND_CONFIG.getLocalName());
            for (ConnectionFactoryAttribute attribute :
                PooledConnectionFactoryDefinition.ATTRIBUTES) {
              if (attribute.isInboundConfig()) {
                attribute.getDefinition().marshallAsElement(factory, writer);
              }
            }
            writer.writeEndElement();
          }

          // ... then the attributes that are not part of the inbound config
          for (ConnectionFactoryAttribute attribute :
              PooledConnectionFactoryDefinition.ATTRIBUTES) {
            if (!attribute.isInboundConfig()) {
              attribute.getDefinition().marshallAsElement(factory, writer);
            }
          }

          writer.writeEndElement();
        }
      }
    }
  }