Search in sources :

Example 6 with ParserException

use of org.jboss.as.connector.util.ParserException in project wildfly by wildfly.

the class DsParser method parseXADataSource_1_2.

private void parseXADataSource_1_2(XMLExtendedStreamReader reader, final List<ModelNode> list, final ModelNode parentAddress) throws XMLStreamException, ParserException, ValidateException {
    String poolName = null;
    final ModelNode operation = new ModelNode();
    operation.get(OP).set(ADD);
    boolean enabled = Defaults.ENABLED.booleanValue();
    // Persist the enabled flag because xml default is != from DMR default
    boolean persistEnabled = true;
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        if (!isNoNamespaceAttribute(reader, i)) {
            throw unexpectedAttribute(reader, i);
        }
        final XaDataSource.Attribute attribute = XaDataSource.Attribute.forName(reader.getAttributeLocalName(i));
        switch(attribute) {
            case ENABLED:
                {
                    final String value = rawAttributeText(reader, ENABLED.getXmlName());
                    if (value != null) {
                        enabled = Boolean.parseBoolean(value);
                        //ENABLED.parseAndSetParameter(value, operation, reader);
                        persistEnabled = true;
                    }
                    break;
                }
            case JNDI_NAME:
                {
                    final String jndiName = rawAttributeText(reader, JNDI_NAME.getXmlName());
                    JNDI_NAME.parseAndSetParameter(jndiName, operation, reader);
                    break;
                }
            case POOL_NAME:
                {
                    poolName = rawAttributeText(reader, POOLNAME_NAME);
                    break;
                }
            case USE_JAVA_CONTEXT:
                {
                    final String value = rawAttributeText(reader, USE_JAVA_CONTEXT.getXmlName());
                    if (value != null) {
                        USE_JAVA_CONTEXT.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case SPY:
                {
                    final String value = rawAttributeText(reader, SPY.getXmlName());
                    if (value != null) {
                        SPY.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case USE_CCM:
                {
                    final String value = rawAttributeText(reader, USE_CCM.getXmlName());
                    if (value != null) {
                        USE_CCM.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            default:
                if (Constants.STATISTICS_ENABLED.getName().equals(reader.getAttributeLocalName(i))) {
                    final String value = rawAttributeText(reader, Constants.STATISTICS_ENABLED.getXmlName());
                    if (value != null) {
                        Constants.STATISTICS_ENABLED.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                } else {
                    throw ParseUtils.unexpectedAttribute(reader, i);
                }
        }
    }
    final ModelNode dsAddress = parentAddress.clone();
    dsAddress.add(XA_DATASOURCE, poolName);
    dsAddress.protect();
    operation.get(OP_ADDR).set(dsAddress);
    List<ModelNode> xadatasourcePropertiesOperations = new ArrayList<ModelNode>(0);
    //elements reading
    while (reader.hasNext()) {
        switch(reader.nextTag()) {
            case END_ELEMENT:
                {
                    if (DataSources.Tag.forName(reader.getLocalName()) == DataSources.Tag.XA_DATASOURCE) {
                        list.add(operation);
                        list.addAll(xadatasourcePropertiesOperations);
                        if (enabled) {
                            final ModelNode enableOperation = new ModelNode();
                            enableOperation.get(OP).set(ENABLE);
                            enableOperation.get(OP_ADDR).set(dsAddress);
                            enableOperation.get(PERSISTENT).set(persistEnabled);
                            list.add(enableOperation);
                        }
                        return;
                    } else {
                        if (XaDataSource.Tag.forName(reader.getLocalName()) == XaDataSource.Tag.UNKNOWN) {
                            throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName()));
                        }
                    }
                    break;
                }
            case START_ELEMENT:
                {
                    switch(XaDataSource.Tag.forName(reader.getLocalName())) {
                        case XA_DATASOURCE_PROPERTY:
                            {
                                String name = rawAttributeText(reader, "name");
                                String value = rawElementText(reader);
                                final ModelNode configOperation = new ModelNode();
                                configOperation.get(OP).set(ADD);
                                final ModelNode configAddress = dsAddress.clone();
                                configAddress.add(XADATASOURCE_PROPERTIES.getName(), name);
                                configAddress.protect();
                                configOperation.get(OP_ADDR).set(configAddress);
                                XADATASOURCE_PROPERTY_VALUE.parseAndSetParameter(value, configOperation, reader);
                                xadatasourcePropertiesOperations.add(configOperation);
                                break;
                            }
                        case XA_DATASOURCE_CLASS:
                            {
                                String value = rawElementText(reader);
                                XA_DATASOURCE_CLASS.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case DRIVER:
                            {
                                String value = rawElementText(reader);
                                DATASOURCE_DRIVER.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case XA_POOL:
                            {
                                parseXaPool(reader, operation);
                                break;
                            }
                        case NEW_CONNECTION_SQL:
                            {
                                String value = rawElementText(reader);
                                NEW_CONNECTION_SQL.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case URL_DELIMITER:
                            {
                                String value = rawElementText(reader);
                                URL_DELIMITER.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case URL_SELECTOR_STRATEGY_CLASS_NAME:
                            {
                                String value = rawElementText(reader);
                                URL_SELECTOR_STRATEGY_CLASS_NAME.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case TRANSACTION_ISOLATION:
                            {
                                String value = rawElementText(reader);
                                TRANSACTION_ISOLATION.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case SECURITY:
                            {
                                parseDsSecurity(reader, operation);
                                break;
                            }
                        case STATEMENT:
                            {
                                parseStatementSettings(reader, operation);
                                break;
                            }
                        case TIMEOUT:
                            {
                                parseTimeOutSettings(reader, operation);
                                break;
                            }
                        case VALIDATION:
                            {
                                parseValidationSetting(reader, operation);
                                break;
                            }
                        case RECOVERY:
                            {
                                parseRecovery(reader, operation);
                                break;
                            }
                        default:
                            throw new ParserException(bundle.unexpectedElement(reader.getLocalName()));
                    }
                    break;
                }
        }
    }
    throw new ParserException(bundle.unexpectedEndOfDocument());
}
Also used : ParserException(org.jboss.as.connector.util.ParserException) ArrayList(java.util.ArrayList) ModelNode(org.jboss.dmr.ModelNode) XaDataSource(org.jboss.jca.common.api.metadata.ds.XaDataSource)

Example 7 with ParserException

use of org.jboss.as.connector.util.ParserException in project wildfly by wildfly.

the class DsParser method parseDataSource_4_0.

private void parseDataSource_4_0(final XMLExtendedStreamReader reader, final List<ModelNode> list, final ModelNode parentAddress) throws XMLStreamException, ParserException, ValidateException {
    String poolName = null;
    final ModelNode operation = new ModelNode();
    operation.get(OP).set(ADD);
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        if (!isNoNamespaceAttribute(reader, i)) {
            throw unexpectedAttribute(reader, i);
        }
        final DataSource.Attribute attribute = DataSource.Attribute.forName(reader.getAttributeLocalName(i));
        switch(attribute) {
            case ENABLED:
                {
                    final String value = rawAttributeText(reader, ENABLED.getXmlName());
                    if (value != null) {
                        ENABLED.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case JNDI_NAME:
                {
                    final String jndiName = rawAttributeText(reader, JNDI_NAME.getXmlName());
                    JNDI_NAME.parseAndSetParameter(jndiName, operation, reader);
                    break;
                }
            case POOL_NAME:
                {
                    poolName = rawAttributeText(reader, POOLNAME_NAME);
                    break;
                }
            case USE_JAVA_CONTEXT:
                {
                    final String value = rawAttributeText(reader, USE_JAVA_CONTEXT.getXmlName());
                    if (value != null) {
                        USE_JAVA_CONTEXT.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case SPY:
                {
                    final String value = rawAttributeText(reader, SPY.getXmlName());
                    if (value != null) {
                        SPY.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case USE_CCM:
                {
                    final String value = rawAttributeText(reader, USE_CCM.getXmlName());
                    if (value != null) {
                        USE_CCM.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case JTA:
                {
                    final String value = rawAttributeText(reader, JTA.getXmlName());
                    if (value != null) {
                        JTA.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case CONNECTABLE:
                {
                    final String value = rawAttributeText(reader, CONNECTABLE.getXmlName());
                    if (value != null) {
                        CONNECTABLE.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case MCP:
                {
                    final String value = rawAttributeText(reader, MCP.getXmlName());
                    if (value != null) {
                        MCP.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case ENLISTMENT_TRACE:
                {
                    final String value = rawAttributeText(reader, ENLISTMENT_TRACE.getXmlName());
                    ENLISTMENT_TRACE.parseAndSetParameter(value, operation, reader);
                    break;
                }
            case TRACKING:
                {
                    final String value = rawAttributeText(reader, TRACKING.getXmlName());
                    if (value != null) {
                        TRACKING.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            default:
                if (Constants.STATISTICS_ENABLED.getName().equals(reader.getAttributeLocalName(i))) {
                    final String value = rawAttributeText(reader, Constants.STATISTICS_ENABLED.getXmlName());
                    if (value != null) {
                        Constants.STATISTICS_ENABLED.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                } else {
                    throw ParseUtils.unexpectedAttribute(reader, i);
                }
        }
    }
    final ModelNode dsAddress = parentAddress.clone();
    dsAddress.add(DATA_SOURCE, poolName);
    dsAddress.protect();
    operation.get(OP_ADDR).set(dsAddress);
    List<ModelNode> configPropertiesOperations = new ArrayList<ModelNode>(0);
    //elements reading
    while (reader.hasNext()) {
        switch(reader.nextTag()) {
            case END_ELEMENT:
                {
                    if (DataSources.Tag.forName(reader.getLocalName()) == DataSources.Tag.DATASOURCE) {
                        list.add(operation);
                        list.addAll(configPropertiesOperations);
                        return;
                    } else {
                        if (DataSource.Tag.forName(reader.getLocalName()) == DataSource.Tag.UNKNOWN) {
                            throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName()));
                        }
                    }
                    break;
                }
            case START_ELEMENT:
                {
                    switch(DataSource.Tag.forName(reader.getLocalName())) {
                        case CONNECTION_PROPERTY:
                            {
                                String name = rawAttributeText(reader, "name");
                                String value = rawElementText(reader);
                                final ModelNode configOperation = new ModelNode();
                                configOperation.get(OP).set(ADD);
                                final ModelNode configAddress = dsAddress.clone();
                                configAddress.add(CONNECTION_PROPERTIES.getName(), name);
                                configAddress.protect();
                                configOperation.get(OP_ADDR).set(configAddress);
                                CONNECTION_PROPERTY_VALUE.parseAndSetParameter(value, configOperation, reader);
                                configPropertiesOperations.add(configOperation);
                                break;
                            }
                        case CONNECTION_URL:
                            {
                                String value = rawElementText(reader);
                                CONNECTION_URL.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case DRIVER_CLASS:
                            {
                                String value = rawElementText(reader);
                                DRIVER_CLASS.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case DATASOURCE_CLASS:
                            {
                                String value = rawElementText(reader);
                                DATASOURCE_CLASS.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case DRIVER:
                            {
                                String value = rawElementText(reader);
                                DATASOURCE_DRIVER.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case POOL:
                            {
                                parsePool(reader, operation);
                                break;
                            }
                        case NEW_CONNECTION_SQL:
                            {
                                String value = rawElementText(reader);
                                NEW_CONNECTION_SQL.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case URL_DELIMITER:
                            {
                                String value = rawElementText(reader);
                                URL_DELIMITER.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case URL_SELECTOR_STRATEGY_CLASS_NAME:
                            {
                                String value = rawElementText(reader);
                                URL_SELECTOR_STRATEGY_CLASS_NAME.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case TRANSACTION_ISOLATION:
                            {
                                String value = rawElementText(reader);
                                TRANSACTION_ISOLATION.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case SECURITY:
                            {
                                switch(Namespace.forUri(reader.getNamespaceURI())) {
                                    // This method is only called for version 4 and later.
                                    case DATASOURCES_4_0:
                                        parseDsSecurity(reader, operation);
                                        break;
                                    default:
                                        parseDsSecurity_5_0(reader, operation);
                                        break;
                                }
                                break;
                            }
                        case STATEMENT:
                            {
                                parseStatementSettings(reader, operation);
                                break;
                            }
                        case TIMEOUT:
                            {
                                parseTimeOutSettings(reader, operation);
                                break;
                            }
                        case VALIDATION:
                            {
                                parseValidationSetting(reader, operation);
                                break;
                            }
                        default:
                            throw new ParserException(bundle.unexpectedElement(reader.getLocalName()));
                    }
                    break;
                }
        }
    }
    throw new ParserException(bundle.unexpectedEndOfDocument());
}
Also used : ParserException(org.jboss.as.connector.util.ParserException) ArrayList(java.util.ArrayList) ModelNode(org.jboss.dmr.ModelNode) XaDataSource(org.jboss.jca.common.api.metadata.ds.XaDataSource) DataSource(org.jboss.jca.common.api.metadata.ds.DataSource)

Example 8 with ParserException

use of org.jboss.as.connector.util.ParserException in project wildfly by wildfly.

the class DsParser method parseDataSource_3_0.

private void parseDataSource_3_0(final XMLExtendedStreamReader reader, final List<ModelNode> list, final ModelNode parentAddress) throws XMLStreamException, ParserException, ValidateException {
    String poolName = null;
    final ModelNode operation = new ModelNode();
    operation.get(OP).set(ADD);
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        if (!isNoNamespaceAttribute(reader, i)) {
            throw unexpectedAttribute(reader, i);
        }
        final DataSource.Attribute attribute = DataSource.Attribute.forName(reader.getAttributeLocalName(i));
        switch(attribute) {
            case ENABLED:
                {
                    final String value = rawAttributeText(reader, ENABLED.getXmlName());
                    if (value != null) {
                        ENABLED.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case JNDI_NAME:
                {
                    final String jndiName = rawAttributeText(reader, JNDI_NAME.getXmlName());
                    JNDI_NAME.parseAndSetParameter(jndiName, operation, reader);
                    break;
                }
            case POOL_NAME:
                {
                    poolName = rawAttributeText(reader, POOLNAME_NAME);
                    break;
                }
            case USE_JAVA_CONTEXT:
                {
                    final String value = rawAttributeText(reader, USE_JAVA_CONTEXT.getXmlName());
                    if (value != null) {
                        USE_JAVA_CONTEXT.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case SPY:
                {
                    final String value = rawAttributeText(reader, SPY.getXmlName());
                    if (value != null) {
                        SPY.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case USE_CCM:
                {
                    final String value = rawAttributeText(reader, USE_CCM.getXmlName());
                    if (value != null) {
                        USE_CCM.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case JTA:
                {
                    final String value = rawAttributeText(reader, JTA.getXmlName());
                    if (value != null) {
                        JTA.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case CONNECTABLE:
                {
                    final String value = rawAttributeText(reader, CONNECTABLE.getXmlName());
                    if (value != null) {
                        CONNECTABLE.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case TRACKING:
                {
                    final String value = rawAttributeText(reader, TRACKING.getXmlName());
                    if (value != null) {
                        TRACKING.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            default:
                if (Constants.STATISTICS_ENABLED.getName().equals(reader.getAttributeLocalName(i))) {
                    final String value = rawAttributeText(reader, Constants.STATISTICS_ENABLED.getXmlName());
                    if (value != null) {
                        Constants.STATISTICS_ENABLED.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                } else {
                    throw ParseUtils.unexpectedAttribute(reader, i);
                }
        }
    }
    final ModelNode dsAddress = parentAddress.clone();
    dsAddress.add(DATA_SOURCE, poolName);
    dsAddress.protect();
    operation.get(OP_ADDR).set(dsAddress);
    List<ModelNode> configPropertiesOperations = new ArrayList<ModelNode>(0);
    //elements reading
    while (reader.hasNext()) {
        switch(reader.nextTag()) {
            case END_ELEMENT:
                {
                    if (DataSources.Tag.forName(reader.getLocalName()) == DataSources.Tag.DATASOURCE) {
                        list.add(operation);
                        list.addAll(configPropertiesOperations);
                        return;
                    } else {
                        if (DataSource.Tag.forName(reader.getLocalName()) == DataSource.Tag.UNKNOWN) {
                            throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName()));
                        }
                    }
                    break;
                }
            case START_ELEMENT:
                {
                    switch(DataSource.Tag.forName(reader.getLocalName())) {
                        case CONNECTION_PROPERTY:
                            {
                                String name = rawAttributeText(reader, "name");
                                String value = rawElementText(reader);
                                final ModelNode configOperation = new ModelNode();
                                configOperation.get(OP).set(ADD);
                                final ModelNode configAddress = dsAddress.clone();
                                configAddress.add(CONNECTION_PROPERTIES.getName(), name);
                                configAddress.protect();
                                configOperation.get(OP_ADDR).set(configAddress);
                                CONNECTION_PROPERTY_VALUE.parseAndSetParameter(value, configOperation, reader);
                                configPropertiesOperations.add(configOperation);
                                break;
                            }
                        case CONNECTION_URL:
                            {
                                String value = rawElementText(reader);
                                CONNECTION_URL.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case DRIVER_CLASS:
                            {
                                String value = rawElementText(reader);
                                DRIVER_CLASS.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case DATASOURCE_CLASS:
                            {
                                String value = rawElementText(reader);
                                DATASOURCE_CLASS.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case DRIVER:
                            {
                                String value = rawElementText(reader);
                                DATASOURCE_DRIVER.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case POOL:
                            {
                                parsePool(reader, operation);
                                break;
                            }
                        case NEW_CONNECTION_SQL:
                            {
                                String value = rawElementText(reader);
                                NEW_CONNECTION_SQL.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case URL_DELIMITER:
                            {
                                String value = rawElementText(reader);
                                URL_DELIMITER.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case URL_SELECTOR_STRATEGY_CLASS_NAME:
                            {
                                String value = rawElementText(reader);
                                URL_SELECTOR_STRATEGY_CLASS_NAME.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case TRANSACTION_ISOLATION:
                            {
                                String value = rawElementText(reader);
                                TRANSACTION_ISOLATION.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case SECURITY:
                            {
                                parseDsSecurity(reader, operation);
                                break;
                            }
                        case STATEMENT:
                            {
                                parseStatementSettings(reader, operation);
                                break;
                            }
                        case TIMEOUT:
                            {
                                parseTimeOutSettings(reader, operation);
                                break;
                            }
                        case VALIDATION:
                            {
                                parseValidationSetting(reader, operation);
                                break;
                            }
                        default:
                            throw new ParserException(bundle.unexpectedElement(reader.getLocalName()));
                    }
                    break;
                }
        }
    }
    throw new ParserException(bundle.unexpectedEndOfDocument());
}
Also used : ParserException(org.jboss.as.connector.util.ParserException) ArrayList(java.util.ArrayList) ModelNode(org.jboss.dmr.ModelNode) XaDataSource(org.jboss.jca.common.api.metadata.ds.XaDataSource) DataSource(org.jboss.jca.common.api.metadata.ds.DataSource)

Example 9 with ParserException

use of org.jboss.as.connector.util.ParserException in project wildfly by wildfly.

the class DsParser method parseXADataSource_3_0.

private void parseXADataSource_3_0(XMLExtendedStreamReader reader, final List<ModelNode> list, final ModelNode parentAddress) throws XMLStreamException, ParserException, ValidateException {
    String poolName = null;
    final ModelNode operation = new ModelNode();
    operation.get(OP).set(ADD);
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        if (!isNoNamespaceAttribute(reader, i)) {
            throw unexpectedAttribute(reader, i);
        }
        final XaDataSource.Attribute attribute = XaDataSource.Attribute.forName(reader.getAttributeLocalName(i));
        switch(attribute) {
            case ENABLED:
                {
                    final String value = rawAttributeText(reader, ENABLED.getXmlName());
                    if (value != null) {
                        ENABLED.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case JNDI_NAME:
                {
                    final String jndiName = rawAttributeText(reader, JNDI_NAME.getXmlName());
                    JNDI_NAME.parseAndSetParameter(jndiName, operation, reader);
                    break;
                }
            case POOL_NAME:
                {
                    poolName = rawAttributeText(reader, POOLNAME_NAME);
                    break;
                }
            case USE_JAVA_CONTEXT:
                {
                    final String value = rawAttributeText(reader, USE_JAVA_CONTEXT.getXmlName());
                    if (value != null) {
                        USE_JAVA_CONTEXT.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case SPY:
                {
                    final String value = rawAttributeText(reader, SPY.getXmlName());
                    if (value != null) {
                        SPY.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case USE_CCM:
                {
                    final String value = rawAttributeText(reader, USE_CCM.getXmlName());
                    if (value != null) {
                        USE_CCM.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case CONNECTABLE:
                {
                    final String value = rawAttributeText(reader, CONNECTABLE.getXmlName());
                    if (value != null) {
                        CONNECTABLE.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            case TRACKING:
                {
                    final String value = rawAttributeText(reader, TRACKING.getXmlName());
                    if (value != null) {
                        TRACKING.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                }
            default:
                if (Constants.STATISTICS_ENABLED.getName().equals(reader.getAttributeLocalName(i))) {
                    final String value = rawAttributeText(reader, Constants.STATISTICS_ENABLED.getXmlName());
                    if (value != null) {
                        Constants.STATISTICS_ENABLED.parseAndSetParameter(value, operation, reader);
                    }
                    break;
                } else {
                    throw ParseUtils.unexpectedAttribute(reader, i);
                }
        }
    }
    final ModelNode dsAddress = parentAddress.clone();
    dsAddress.add(XA_DATASOURCE, poolName);
    dsAddress.protect();
    operation.get(OP_ADDR).set(dsAddress);
    List<ModelNode> xadatasourcePropertiesOperations = new ArrayList<ModelNode>(0);
    //elements reading
    while (reader.hasNext()) {
        switch(reader.nextTag()) {
            case END_ELEMENT:
                {
                    if (DataSources.Tag.forName(reader.getLocalName()) == DataSources.Tag.XA_DATASOURCE) {
                        list.add(operation);
                        list.addAll(xadatasourcePropertiesOperations);
                        return;
                    } else {
                        if (XaDataSource.Tag.forName(reader.getLocalName()) == XaDataSource.Tag.UNKNOWN) {
                            throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName()));
                        }
                    }
                    break;
                }
            case START_ELEMENT:
                {
                    switch(XaDataSource.Tag.forName(reader.getLocalName())) {
                        case XA_DATASOURCE_PROPERTY:
                            {
                                String name = rawAttributeText(reader, "name");
                                String value = rawElementText(reader);
                                final ModelNode configOperation = new ModelNode();
                                configOperation.get(OP).set(ADD);
                                final ModelNode configAddress = dsAddress.clone();
                                configAddress.add(XADATASOURCE_PROPERTIES.getName(), name);
                                configAddress.protect();
                                configOperation.get(OP_ADDR).set(configAddress);
                                XADATASOURCE_PROPERTY_VALUE.parseAndSetParameter(value, configOperation, reader);
                                xadatasourcePropertiesOperations.add(configOperation);
                                break;
                            }
                        case XA_DATASOURCE_CLASS:
                            {
                                String value = rawElementText(reader);
                                XA_DATASOURCE_CLASS.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case DRIVER:
                            {
                                String value = rawElementText(reader);
                                DATASOURCE_DRIVER.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case XA_POOL:
                            {
                                parseXaPool(reader, operation);
                                break;
                            }
                        case NEW_CONNECTION_SQL:
                            {
                                String value = rawElementText(reader);
                                NEW_CONNECTION_SQL.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case URL_DELIMITER:
                            {
                                String value = rawElementText(reader);
                                URL_DELIMITER.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case URL_PROPERTY:
                            {
                                String value = rawElementText(reader);
                                URL_PROPERTY.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case URL_SELECTOR_STRATEGY_CLASS_NAME:
                            {
                                String value = rawElementText(reader);
                                URL_SELECTOR_STRATEGY_CLASS_NAME.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case TRANSACTION_ISOLATION:
                            {
                                String value = rawElementText(reader);
                                TRANSACTION_ISOLATION.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case SECURITY:
                            {
                                parseDsSecurity(reader, operation);
                                break;
                            }
                        case STATEMENT:
                            {
                                parseStatementSettings(reader, operation);
                                break;
                            }
                        case TIMEOUT:
                            {
                                parseTimeOutSettings(reader, operation);
                                break;
                            }
                        case VALIDATION:
                            {
                                parseValidationSetting(reader, operation);
                                break;
                            }
                        case RECOVERY:
                            {
                                parseRecovery(reader, operation);
                                break;
                            }
                        default:
                            throw new ParserException(bundle.unexpectedElement(reader.getLocalName()));
                    }
                    break;
                }
        }
    }
    throw new ParserException(bundle.unexpectedEndOfDocument());
}
Also used : ParserException(org.jboss.as.connector.util.ParserException) ArrayList(java.util.ArrayList) ModelNode(org.jboss.dmr.ModelNode) XaDataSource(org.jboss.jca.common.api.metadata.ds.XaDataSource)

Example 10 with ParserException

use of org.jboss.as.connector.util.ParserException in project wildfly by wildfly.

the class DsParser method parseTimeOutSettings.

private void parseTimeOutSettings(XMLExtendedStreamReader reader, final ModelNode operation) throws XMLStreamException, ParserException, ValidateException {
    while (reader.hasNext()) {
        switch(reader.nextTag()) {
            case END_ELEMENT:
                {
                    if (DataSource.Tag.forName(reader.getLocalName()) == DataSource.Tag.TIMEOUT) {
                        return;
                    } else {
                        if (TimeOut.Tag.forName(reader.getLocalName()) == TimeOut.Tag.UNKNOWN) {
                            throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName()));
                        }
                    }
                    break;
                }
            case START_ELEMENT:
                {
                    switch(TimeOut.Tag.forName(reader.getLocalName())) {
                        case ALLOCATION_RETRY:
                            {
                                String value = rawElementText(reader);
                                ALLOCATION_RETRY.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case ALLOCATION_RETRY_WAIT_MILLIS:
                            {
                                String value = rawElementText(reader);
                                ALLOCATION_RETRY_WAIT_MILLIS.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case BLOCKING_TIMEOUT_MILLIS:
                            {
                                String value = rawElementText(reader);
                                BLOCKING_TIMEOUT_WAIT_MILLIS.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case IDLE_TIMEOUT_MINUTES:
                            {
                                String value = rawElementText(reader);
                                IDLETIMEOUTMINUTES.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case QUERY_TIMEOUT:
                            {
                                String value = rawElementText(reader);
                                QUERY_TIMEOUT.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case SET_TX_QUERY_TIMEOUT:
                            {
                                //tag presence is sufficient to set it to true
                                String value = rawElementText(reader);
                                value = value == null ? "true" : value;
                                SET_TX_QUERY_TIMEOUT.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case USE_TRY_LOCK:
                            {
                                String value = rawElementText(reader);
                                USE_TRY_LOCK.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        case XA_RESOURCE_TIMEOUT:
                            {
                                String value = rawElementText(reader);
                                XA_RESOURCE_TIMEOUT.parseAndSetParameter(value, operation, reader);
                                break;
                            }
                        default:
                            throw new ParserException(bundle.unexpectedElement(reader.getLocalName()));
                    }
                    break;
                }
        }
    }
    throw new ParserException(bundle.unexpectedEndOfDocument());
}
Also used : ParserException(org.jboss.as.connector.util.ParserException)

Aggregations

ParserException (org.jboss.as.connector.util.ParserException)25 ModelNode (org.jboss.dmr.ModelNode)16 ArrayList (java.util.ArrayList)8 XaDataSource (org.jboss.jca.common.api.metadata.ds.XaDataSource)8 DataSource (org.jboss.jca.common.api.metadata.ds.DataSource)4 ConnectionDefinition (org.jboss.jca.common.api.metadata.resourceadapter.ConnectionDefinition)3 WorkManagerSecurityImpl (org.jboss.as.connector.metadata.resourceadapter.WorkManagerSecurityImpl)2 HashMap (java.util.HashMap)1 Driver (org.jboss.jca.common.api.metadata.ds.Driver)1