Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2012, Red Hat, Inc., and individual contributors
   * as indicated by the @author tags. See the copyright.txt file in the
   * distribution for a full listing of individual contributors.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
  *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 
 package org.jboss.as.connector.subsystems.resourceadapters;
 
 
 import java.util.List;
 
 import static org.jboss.as.connector.logging.ConnectorLogger.SUBSYSTEM_RA_LOGGER;
 import static org.jboss.as.connector.subsystems.common.pool.Constants.BACKGROUNDVALIDATION;
 import static org.jboss.as.connector.subsystems.common.pool.Constants.BACKGROUNDVALIDATIONMILLIS;
 import static org.jboss.as.connector.subsystems.common.pool.Constants.BLOCKING_TIMEOUT_WAIT_MILLIS;
 import static org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_DECREMENTER_CLASS;
 import static org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_DECREMENTER_PROPERTIES;
 import static org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_INCREMENTER_CLASS;
 import static org.jboss.as.connector.subsystems.common.pool.Constants.CAPACITY_INCREMENTER_PROPERTIES;
 import static org.jboss.as.connector.subsystems.common.pool.Constants.IDLETIMEOUTMINUTES;
 import static org.jboss.as.connector.subsystems.common.pool.Constants.INITIAL_POOL_SIZE;
 import static org.jboss.as.connector.subsystems.common.pool.Constants.MAX_POOL_SIZE;
 import static org.jboss.as.connector.subsystems.common.pool.Constants.MIN_POOL_SIZE;
 import static org.jboss.as.connector.subsystems.common.pool.Constants.POOL_FLUSH_STRATEGY;
 import static org.jboss.as.connector.subsystems.common.pool.Constants.POOL_PREFILL;
 import static org.jboss.as.connector.subsystems.common.pool.Constants.POOL_USE_STRICT_MIN;
 import static org.jboss.as.connector.subsystems.common.pool.Constants.USE_FAST_FAIL;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.ADMIN_OBJECTS_NAME;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.ALLOCATION_RETRY;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.ALLOCATION_RETRY_WAIT_MILLIS;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.APPLICATION;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.ARCHIVE;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.BEANVALIDATION_GROUPS;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.BOOTSTRAP_CONTEXT;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.CLASS_NAME;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.CONFIG_PROPERTIES;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.CONNECTIONDEFINITIONS_NAME;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.ENABLED;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.ENLISTMENT;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.WM_SECURITY_MAPPING_FROM;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.INTERLEAVING;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.JNDINAME;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.MODULE;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.NOTXSEPARATEPOOL;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.NO_RECOVERY;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.PAD_XID;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.RECOVERLUGIN_CLASSNAME;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.RECOVERLUGIN_PROPERTIES;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.RECOVERY_PASSWORD;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.RECOVERY_SECURITY_DOMAIN;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.RECOVERY_USERNAME;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.RESOURCEADAPTERS_NAME;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.RESOURCEADAPTER_NAME;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.SAME_RM_OVERRIDE;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.SECURITY_DOMAIN;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.SECURITY_DOMAIN_AND_APPLICATION;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.SHARABLE;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.WM_SECURITY_MAPPING_TO;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.TRANSACTION_SUPPORT;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.USE_CCM;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.USE_JAVA_CONTEXT;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.WM_SECURITY;
 import static org.jboss.as.connector.subsystems.resourceadapters.Constants.WM_SECURITY_DEFAULT_GROUP;
import static org.jboss.as.connector.subsystems.resourceadapters.Constants.WM_SECURITY_DEFAULT_GROUPS;
import static org.jboss.as.connector.subsystems.resourceadapters.Constants.WM_SECURITY_DEFAULT_PRINCIPAL;
import static org.jboss.as.connector.subsystems.resourceadapters.Constants.WM_SECURITY_DOMAIN;
import static org.jboss.as.connector.subsystems.resourceadapters.Constants.WM_SECURITY_MAPPING_GROUPS;
import static org.jboss.as.connector.subsystems.resourceadapters.Constants.WM_SECURITY_MAPPING_REQUIRED;
import static org.jboss.as.connector.subsystems.resourceadapters.Constants.WM_SECURITY_MAPPING_USERS;
import static org.jboss.as.connector.subsystems.resourceadapters.Constants.WRAP_XA_RESOURCE;
import static org.jboss.as.connector.subsystems.resourceadapters.Constants.XA_RESOURCE_TIMEOUT;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;

Author(s):
Tomaz Cerar (c) 2012 Red Hat Inc.
    @Override
    public void writeContent(XMLExtendedStreamWriter writerSubsystemMarshallingContext contextthrows XMLStreamException {
        ModelNode node = context.getModelNode();
        boolean hasChildren = node.hasDefined() && node.get().asPropertyList().size() > 0;
        context.startSubsystemElement(..getUriString(), !hasChildren);
        if (hasChildren) {
            writer.writeStartElement(..getLocalName());
            for (Property property : node.get().asPropertyList()) {
                final ModelNode ra = property.getValue();
                final String  name = property.getName();
                writeRaElement(writerraname);
            }
            writer.writeEndElement();
            // Close the subsystem element
            writer.writeEndElement();
        }
    }
    private void writeRaElement(XMLExtendedStreamWriter streamWriterModelNode rafinal String namethrows XMLStreamException {
        streamWriter.writeAttribute(...getLocalName(), name);
        .marshallAsElement(rastreamWriter);
        .marshallAsElement(rastreamWriter);
        .marshallAsElement(rastreamWriter);
        if (ra.hasDefined(.getName())) {
            for (ModelNode bvg : ra.get(.getName()).asList()) {
                streamWriter.writeStartElement(.getXmlName());
                streamWriter.writeCharacters(bvg.asString());
                streamWriter.writeEndElement();
            }
            streamWriter.writeEndElement();
        }
        .marshallAsElement(rastreamWriter);
        writeNewConfigProperties(streamWriterra);
        TransactionSupportEnum transactionSupport = ra.hasDefined(.getName()) ? TransactionSupportEnum
            .valueOf(ra.get(.getName()).asString()) : null;
        boolean isXa = false;
        if (transactionSupport == .) {
            isXa = true;
        }
        if (ra.hasDefined(.getName()) && ra.get(.getName()).asBoolean()) {
            streamWriter.writeStartElement(...getLocalName());
            streamWriter.writeStartElement(...getLocalName());
            .marshallAsElement(rastreamWriter);
            .marshallAsElement(rastreamWriter);
            .marshallAsElement(rastreamWriter);
            if (ra.hasDefined(.getName())) {
                streamWriter.writeStartElement(.getXmlName());
                for (ModelNode group : ra.get(.getName()).asList()) {
                    streamWriter.writeStartElement(.getXmlName());
                    streamWriter.writeCharacters(group.asString());
                    streamWriter.writeEndElement();
                }
                streamWriter.writeEndElement();
            }
                streamWriter.writeStartElement(...getLocalName());
                if (ra.hasDefined(.getName())) {
                    streamWriter.writeStartElement(...getLocalName());
                    for (ModelNode node : ra.get(.getName()).asList()) {
                        streamWriter.writeStartElement(...getLocalName());
                        .marshallAsAttribute(nodestreamWriter);
                        .marshallAsAttribute(nodestreamWriter);
                        streamWriter.writeEndElement();
                    }
                    streamWriter.writeEndElement();
                }
                if (ra.hasDefined(.getName())) {
                    streamWriter.writeStartElement(...getLocalName());
                    for (ModelNode node : ra.get(.getName()).asList()) {
                        streamWriter.writeStartElement(...getLocalName());
                        .marshallAsAttribute(nodestreamWriter);
                        .marshallAsAttribute(nodestreamWriter);
                        streamWriter.writeEndElement();
                    }
                    streamWriter.writeEndElement();
                }
                streamWriter.writeEndElement();
            }
            streamWriter.writeEndElement();
            streamWriter.writeEndElement();
        }
        if (ra.hasDefined()) {
            for (Property conDef : ra.get().asPropertyList()) {
                writeConDef(streamWriterconDef.getValue(), conDef.getName(), isXa);
            }
            streamWriter.writeEndElement();
        }
        if (ra.hasDefined()) {
            streamWriter.writeStartElement(...getLocalName());
            for (Property adminObject : ra.get().asPropertyList()) {
                writeAdminObject(streamWriteradminObject.getValue(), adminObject.getName());
            }
            streamWriter.writeEndElement();
        }
        streamWriter.writeEndElement();
    }
    private void writeNewConfigProperties(XMLExtendedStreamWriter streamWriterModelNode rathrows XMLStreamException {
        if (ra.hasDefined(.getName())) {
            for (Property connectionProperty : ra.get(.getName()).asPropertyList()) {
                writeProperty(streamWriterraconnectionProperty.getName(), connectionProperty
                        .getValue().get("value").asString(), ...getLocalName());
            }
        }
    }
    private void writeProperty(XMLExtendedStreamWriter writerModelNode nodeString nameString valueString localName)
            throws XMLStreamException {
        writer.writeStartElement(localName);
        writer.writeAttribute("name"name);
        writer.writeCharacters(value);
        writer.writeEndElement();
    }
    private void writeAdminObject(XMLExtendedStreamWriter streamWriterModelNode adminObjectfinal String poolNamethrows XMLStreamException {
        .marshallAsAttribute(adminObjectstreamWriter);
        .marshallAsAttribute(adminObjectstreamWriter);
        .marshallAsAttribute(adminObjectstreamWriter);
        .marshallAsAttribute(adminObjectstreamWriter);
        streamWriter.writeAttribute("pool-name"poolName);
        writeNewConfigProperties(streamWriteradminObject);
        streamWriter.writeEndElement();
    }
    private void writeConDef(XMLExtendedStreamWriter streamWriterModelNode conDeffinal String poolNamefinal boolean isXathrows XMLStreamException {
        .marshallAsAttribute(conDefstreamWriter);
        .marshallAsAttribute(conDefstreamWriter);
        .marshallAsAttribute(conDefstreamWriter);
        .marshallAsAttribute(conDefstreamWriter);
        streamWriter.writeAttribute("pool-name"poolName);
        .marshallAsAttribute(conDefstreamWriter);
        .marshallAsAttribute(conDefstreamWriter);
        .marshallAsAttribute(conDefstreamWriter);
        writeNewConfigProperties(streamWriterconDef);
        boolean poolRequired = .isMarshallable(conDef) || .isMarshallable(conDef) || .isMarshallable(conDef) ||
                .isMarshallable(conDef) || .isMarshallable(conDef) || .isMarshallable(conDef);
        final boolean capacityRequired = .isMarshallable(conDef) ||
                .isMarshallable(conDef) ||
                .isMarshallable(conDef) ||
                .isMarshallable(conDef);
        poolRequired = poolRequired || capacityRequired;
        if (poolRequired) {
            if (isXa) {
                streamWriter.writeStartElement(...getLocalName());
                .marshallAsElement(conDefstreamWriter);
                .marshallAsElement(conDefstreamWriter);
                .marshallAsElement(conDefstreamWriter);
                .marshallAsElement(conDefstreamWriter);
                .marshallAsElement(conDefstreamWriter);
                .marshallAsElement(conDefstreamWriter);
                .marshallAsElement(conDefstreamWriter);
                if (conDef.hasDefined(.getName()) && conDef.get(.getName()).asBoolean()) {
                    streamWriter.writeEmptyElement(.getXmlName());
                } else {
                    .marshallAsElement(conDefstreamWriter);
                }
                if (conDef.hasDefined(.getName()) && conDef.get(.getName()).asBoolean()) {
                    streamWriter.writeEmptyElement(.getXmlName());
                } else {
                    .marshallAsElement(conDefstreamWriter);
                }
                .marshallAsElement(conDefstreamWriter);
                .marshallAsElement(conDefstreamWriter);
            } else {
                streamWriter.writeStartElement(...getLocalName());
                .marshallAsElement(conDefstreamWriter);
                .marshallAsElement(conDefstreamWriter);
                .marshallAsElement(conDefstreamWriter);
                .marshallAsElement(conDefstreamWriter);
                .marshallAsElement(conDefstreamWriter);
                .marshallAsElement(conDefstreamWriter);
            }
            if (capacityRequired) {
                streamWriter.writeStartElement(...getLocalName());
                if (conDef.hasDefined(.getName())) {
                    streamWriter.writeStartElement(...getLocalName());
                    .marshallAsAttribute(conDefstreamWriter);
                    .marshallAsElement(conDefstreamWriter);
                    streamWriter.writeEndElement();
                }
                if (conDef.hasDefined(.getName())) {
                    streamWriter.writeStartElement(...getLocalName());
                    .marshallAsAttribute(conDefstreamWriter);
                    .marshallAsElement(conDefstreamWriter);
                    streamWriter.writeEndElement();
                }
                streamWriter.writeEndElement();
            }
            streamWriter.writeEndElement();
        }
        if (conDef.hasDefined(.getName()) || conDef.hasDefined(.getName())
                || conDef.hasDefined(.getName())) {
            streamWriter.writeStartElement(...getLocalName());
            if (conDef.hasDefined(.getName()) && conDef.get(.getName()).asBoolean()) {
                streamWriter.writeEmptyElement(.getXmlName());
            } else {
                .marshallAsElement(conDefstreamWriter);
            }
            .marshallAsElement(conDefstreamWriter);
            .marshallAsElement(conDefstreamWriter);
            streamWriter.writeEndElement();
        }
                || conDef.hasDefined(.getName()) || conDef.hasDefined(.getName())) {
            streamWriter.writeStartElement(...getLocalName());
            .marshallAsElement(conDefstreamWriter);
            .marshallAsElement(conDefstreamWriter);
            .marshallAsElement(conDefstreamWriter);
            .marshallAsElement(conDefstreamWriter);
            .marshallAsElement(conDefstreamWriter);
            streamWriter.writeEndElement();
        }
            streamWriter.writeStartElement(...getLocalName());
            .marshallAsElement(conDefstreamWriter);
            .marshallAsElement(conDefstreamWriter);
            .marshallAsElement(conDefstreamWriter);
            streamWriter.writeEndElement();
        }
        if (conDef.hasDefined(.getName()) || conDef.hasDefined(.getName())
                || conDef.hasDefined(.getName()) || conDef.hasDefined(.getName())
                || conDef.hasDefined(.getName()) || conDef.hasDefined(.getName())) {
            streamWriter.writeStartElement(...getLocalName());
            .marshallAsAttribute(conDefstreamWriter);
            if (conDef.hasDefined(.getName()) || conDef.hasDefined(.getName())
                    || conDef.hasDefined(.getName())) {
                streamWriter.writeStartElement(...getLocalName());
                .marshallAsElement(conDefstreamWriter);
                .marshallAsElement(conDefstreamWriter);
                .marshallAsElement(conDefstreamWriter);
                streamWriter.writeEndElement();
            }
            if (conDef.hasDefined(.getName()) || conDef.hasDefined(.getName())) {
                streamWriter.writeStartElement(...getLocalName());
                .marshallAsAttribute(conDefstreamWriter);
                if (conDef.hasDefined(.getName())) {
                    for (Property property : conDef.get(.getName()).asPropertyList()) {
                        writeProperty(streamWriterconDefproperty.getName(), property
                                    .getValue().asString(), ..........getLocalName());
                    }
                }
                streamWriter.writeEndElement();
            }
            streamWriter.writeEndElement();
        }
        streamWriter.writeEndElement();
    }
    @Override
    public void readElement(final XMLExtendedStreamReader readerfinal List<ModelNodelistthrows XMLStreamException {
        final ModelNode address = new ModelNode();
        address.protect();
        final ModelNode subsystem = new ModelNode();
        subsystem.get().set();
        subsystem.get().set(address);
        list.add(subsystem);
        try {
            String localName;
            switch (Namespace.forUri(reader.getNamespaceURI())) {
                case :
                case :
                case : {
                    localName = reader.getLocalName();
                    final Element element = Element.forName(reader.getLocalName());
                    .tracef("%s -> %s"localNameelement);
                    switch (element) {
                        case : {
                            ResourceAdapterParser parser = new ResourceAdapterParser();
                            parser.parse(readerlistaddress);
                            ParseUtils.requireNoContent(reader);
                            break;
                        }
                    }
                    break;
                }
            }
        } catch (Exception e) {
            throw new XMLStreamException(e);
        }
    }
New to GrepCode? Check out our FAQ X