/** * parse a {@link CommonSecurity} element * * @param reader reader * @return a {@link CommonSecurity} object * @throws XMLStreamException XMLStreamException * @throws ParserException ParserException * @throws ValidateException ValidateException */ protected CommonSecurity parseSecuritySettings(XMLStreamReader reader) throws XMLStreamException, ParserException, ValidateException { String securityDomain = null; String securityDomainAndApplication = null; boolean application = false; while (reader.hasNext()) { switch (reader.nextTag()) { case END_ELEMENT: { if (DataSource.Tag.forName(reader.getLocalName()) == DataSource.Tag.SECURITY) { return new CommonSecurityImpl( securityDomain, securityDomainAndApplication, application); } else { if (CommonSecurity.Tag.forName(reader.getLocalName()) == CommonSecurity.Tag.UNKNOWN) { throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName())); } } break; } case START_ELEMENT: { switch (CommonSecurity.Tag.forName(reader.getLocalName())) { case SECURITY_DOMAIN: { securityDomain = elementAsString(reader); break; } case SECURITY_DOMAIN_AND_APPLICATION: { securityDomainAndApplication = elementAsString(reader); break; } case APPLICATION: { application = elementAsBoolean(reader); break; } default: throw new ParserException(bundle.unexpectedElement(reader.getLocalName())); } break; } } } throw new ParserException(bundle.unexpectedEndOfDocument()); }
/** * parse credential tag * * @param reader reader * @return the parse Object * @throws XMLStreamException in case of error * @throws ParserException in case of error * @throws ValidateException in case of error */ protected Credential parseCredential(XMLStreamReader reader) throws XMLStreamException, ParserException, ValidateException { String userName = null; String password = null; String securityDomain = null; while (reader.hasNext()) { switch (reader.nextTag()) { case END_ELEMENT: { if (DataSource.Tag.forName(reader.getLocalName()) == DataSource.Tag.SECURITY || Recovery.Tag.forName(reader.getLocalName()) == Recovery.Tag.RECOVER_CREDENTIAL) { return new CredentialImpl(userName, password, securityDomain); } else { if (Credential.Tag.forName(reader.getLocalName()) == Credential.Tag.UNKNOWN) { throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName())); } } break; } case START_ELEMENT: { switch (Credential.Tag.forName(reader.getLocalName())) { case PASSWORD: { password = elementAsString(reader); break; } case USER_NAME: { userName = elementAsString(reader); break; } case SECURITY_DOMAIN: { securityDomain = elementAsString(reader); break; } default: throw new ParserException(bundle.unexpectedElement(reader.getLocalName())); } break; } } } throw new ParserException(bundle.unexpectedEndOfDocument()); }
/** * parse a {@link CommonPool} object * * @param reader reader * @return the parsed {@link CommonPool} object * @throws XMLStreamException XMLStreamException * @throws ParserException ParserException * @throws ValidateException ValidateException */ protected CommonPool parsePool(XMLStreamReader reader) throws XMLStreamException, ParserException, ValidateException { Integer minPoolSize = null; Integer maxPoolSize = null; Boolean prefill = Boolean.FALSE; Boolean useStrictMin = Boolean.FALSE; FlushStrategy flushStrategy = FlushStrategy.FAILING_CONNECTION_ONLY; while (reader.hasNext()) { switch (reader.nextTag()) { case END_ELEMENT: { if (DataSource.Tag.forName(reader.getLocalName()) == DataSource.Tag.POOL) { return new CommonPoolImpl( minPoolSize, maxPoolSize, prefill, useStrictMin, flushStrategy); } else { if (CommonPool.Tag.forName(reader.getLocalName()) == CommonPool.Tag.UNKNOWN) { throw new ParserException(bundle.unexpectedEndTag(reader.getLocalName())); } } break; } case START_ELEMENT: { switch (CommonPool.Tag.forName(reader.getLocalName())) { case MAX_POOL_SIZE: { maxPoolSize = elementAsInteger(reader); break; } case MIN_POOL_SIZE: { minPoolSize = elementAsInteger(reader); break; } case PREFILL: { prefill = elementAsBoolean(reader); break; } case USE_STRICT_MIN: { useStrictMin = elementAsBoolean(reader); break; } case FLUSH_STRATEGY: { flushStrategy = elementAsFlushStrategy(reader); break; } default: throw new ParserException(bundle.unexpectedElement(reader.getLocalName())); } break; } } } throw new ParserException(bundle.unexpectedEndOfDocument()); }