@Override protected org.jboss.jca.common.api.metadata.ds.XaDataSource parseXADataSource( XMLStreamReader reader) throws XMLStreamException, ParserException, ValidateException { TransactionIsolation transactionIsolation = null; Map<String, String> xaDataSourceProperty = new HashMap<String, String>(); TimeOut timeOutSettings = null; DsSecurity securitySettings = null; Statement statementSettings = null; Validation validationSettings = null; String urlDelimiter = null; String urlSelectorStrategyClassName = null; String newConnectionSql = null; DsXaPool xaPool = null; Recovery recovery = null; String xaDataSourceClass = null; String driver = null; // attributes reading Boolean useJavaContext = Defaults.USE_JAVA_CONTEXT; String poolName = null; Boolean enabled = Defaults.ENABLED; String jndiName = null; Boolean spy = Defaults.SPY; Boolean useCcm = Defaults.USE_CCM; for (org.jboss.jca.common.api.metadata.ds.v11.XaDataSource.Attribute attribute : org.jboss.jca.common.api.metadata.ds.v11.XaDataSource.Attribute.values()) { switch (attribute) { case ENABLED: { enabled = attributeAsBoolean(reader, attribute.getLocalName(), true); break; } case JNDI_NAME: { jndiName = attributeAsString(reader, attribute.getLocalName()); break; } case POOL_NAME: { poolName = attributeAsString(reader, attribute.getLocalName()); break; } case USE_JAVA_CONTEXT: { useJavaContext = attributeAsBoolean(reader, attribute.getLocalName(), true); break; } case SPY: { spy = attributeAsBoolean(reader, attribute.getLocalName(), false); break; } case USE_CCM: { useCcm = attributeAsBoolean(reader, attribute.getLocalName(), true); break; } default: break; } } // elements reading while (reader.hasNext()) { switch (reader.nextTag()) { case END_ELEMENT: { if (DataSources.Tag.forName(reader.getLocalName()) == DataSources.Tag.XA_DATASOURCE) { return new XADataSourceImpl( transactionIsolation, timeOutSettings, securitySettings, statementSettings, validationSettings, urlDelimiter, urlSelectorStrategyClassName, useJavaContext, poolName, enabled, jndiName, spy, useCcm, xaDataSourceProperty, xaDataSourceClass, driver, newConnectionSql, xaPool, recovery); } else { if (org.jboss.jca.common.api.metadata.ds.v11.XaDataSource.Tag.forName( reader.getLocalName()) == org.jboss.jca.common.api.metadata.ds.v11.XaDataSource.Tag.UNKNOWN) { throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName())); } } break; } case START_ELEMENT: { switch (org.jboss.jca.common.api.metadata.ds.v11.XaDataSource.Tag.forName( reader.getLocalName())) { case XA_DATASOURCE_PROPERTY: { parseConfigProperty(xaDataSourceProperty, reader); break; } case XA_DATASOURCE_CLASS: { xaDataSourceClass = elementAsString(reader); break; } case DRIVER: { driver = elementAsString(reader); break; } case XA_POOL: { xaPool = parseXaPool(reader); break; } case NEW_CONNECTION_SQL: { newConnectionSql = elementAsString(reader); break; } case URL_DELIMITER: { urlDelimiter = elementAsString(reader); break; } case URL_SELECTOR_STRATEGY_CLASS_NAME: { urlSelectorStrategyClassName = elementAsString(reader); break; } case TRANSACTION_ISOLATION: { String str = elementAsString(reader); transactionIsolation = TransactionIsolation.forName(str); if (transactionIsolation == null) { transactionIsolation = TransactionIsolation.customLevel(str); } break; } case SECURITY: { securitySettings = parseDsSecurity(reader); break; } case STATEMENT: { statementSettings = parseStatementSettings(reader); break; } case TIMEOUT: { timeOutSettings = parseTimeOutSettings(reader); break; } case VALIDATION: { validationSettings = parseValidationSetting(reader); break; } case RECOVERY: { recovery = parseRecovery(reader); break; } default: throw new ParserException(bundle.unexpectedElement(reader.getLocalName())); } break; } } } throw new ParserException(bundle.unexpectedEndOfDocument()); }
/** * parse a {@link CommonXaPool} object * * @param reader reader * @return the parsed {@link CommonXaPool} object * @throws XMLStreamException XMLStreamException * @throws ParserException ParserException * @throws ValidateException ValidateException */ protected DsXaPool parseXaPool(XMLStreamReader reader) throws XMLStreamException, ParserException, ValidateException { Integer minPoolSize = Defaults.MIN_POOL_SIZE; Integer maxPoolSize = Defaults.MAX_POOL_SIZE; Boolean prefill = Defaults.PREFILL; FlushStrategy flushStrategy = Defaults.FLUSH_STRATEGY; Boolean allowMultipleUsers = Defaults.ALLOW_MULTIPLE_USERS; Boolean interleaving = Defaults.INTERLEAVING; Boolean isSameRmOverride = Defaults.IS_SAME_RM_OVERRIDE; Boolean padXid = Defaults.PAD_XID; Boolean noTxSeparatePool = Defaults.NO_TX_SEPARATE_POOL; Boolean wrapXaDataSource = Defaults.WRAP_XA_RESOURCE; Boolean useStrictMin = Defaults.USE_STRICT_MIN; while (reader.hasNext()) { switch (reader.nextTag()) { case END_ELEMENT: { if (XaDataSource.Tag.forName(reader.getLocalName()) == XaDataSource.Tag.XA_POOL) { return new DsXaPoolImpl( minPoolSize, maxPoolSize, prefill, useStrictMin, flushStrategy, isSameRmOverride, interleaving, padXid, wrapXaDataSource, noTxSeparatePool, allowMultipleUsers); } else { if (DsXaPool.Tag.forName(reader.getLocalName()) == DsXaPool.Tag.UNKNOWN) { throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName())); } } break; } case START_ELEMENT: { switch (DsXaPool.Tag.forName(reader.getLocalName())) { case MAX_POOL_SIZE: { maxPoolSize = elementAsInteger(reader); break; } case MIN_POOL_SIZE: { minPoolSize = elementAsInteger(reader); break; } case INTERLEAVING: { interleaving = elementAsBoolean(reader); break; } case IS_SAME_RM_OVERRIDE: { isSameRmOverride = elementAsBoolean(reader); break; } case NO_TX_SEPARATE_POOLS: { noTxSeparatePool = elementAsBoolean(reader); break; } case PAD_XID: { padXid = elementAsBoolean(reader); break; } case WRAP_XA_RESOURCE: { wrapXaDataSource = elementAsBoolean(reader); break; } case PREFILL: { prefill = elementAsBoolean(reader); break; } case USE_STRICT_MIN: { useStrictMin = elementAsBoolean(reader); break; } case FLUSH_STRATEGY: { flushStrategy = elementAsFlushStrategy(reader); break; } case ALLOW_MULTIPLE_USERS: { allowMultipleUsers = Boolean.TRUE; break; } default: throw new ParserException(bundle.unexpectedElement(reader.getLocalName())); } break; } } } throw new ParserException(bundle.unexpectedEndOfDocument()); }