private static void parseProperties(XMLStreamReader reader, Properties properties, final PropertyReplacer propertyReplacer) throws XMLStreamException { final Element element = Element.forName(reader.getLocalName()); switch (element) { case PROPERTY: String name = null, value = null; for (int i = 0; i < count; i++) { final String attributeValue = getAttribute(reader, i, propertyReplacer); final String attributeNamespace = reader.getAttributeNamespace(i); if (attributeNamespace != null && !attributeNamespace.isEmpty()) { continue; final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case NAME: break; default: throw unexpectedAttribute(reader, i); throw unexpectedElement(reader); throw unexpectedElement(reader);
while (reader.hasNext() && reader.next() != START_ELEMENT) { if (reader.getEventType() == DTD) { final String dtdLocation = readDTDLocation(reader); if (dtdLocation != null) { version = Version.forLocation(dtdLocation); final String schemaLocation = readSchemaLocation(reader); if (schemaLocation != null) { version = Version.forLocation(schemaLocation); if (version == null || Version.UNKNOWN.equals(version)) { final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); if (attribute == Attribute.VERSION) { versionString = reader.getAttributeValue(i); final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case VERSION: throw unexpectedAttribute(reader, i); final Element element = Element.forName(reader.getLocalName()); switch (element) { case PERSISTENCEUNIT: PersistenceUnitMetadata pu = parsePU(reader, version, propertyReplacer); PUs.add(pu); ROOT_LOGGER.readingPersistenceXml(pu.getPersistenceUnitName());
pu.setSharedCacheMode(SharedCacheMode.UNSPECIFIED); pu.setPersistenceProviderClassName(Configuration.PROVIDER_CLASS_DEFAULT); if (version.equals(Version.JPA_1_0)) { pu.setPersistenceXMLSchemaVersion("1.0"); } else if (version.equals(Version.JPA_2_0)) { pu.setPersistenceXMLSchemaVersion("2.0"); } else if (version.equals(Version.JPA_2_1)) { pu.setPersistenceXMLSchemaVersion("2.1"); } else { final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case NAME: break; default: throw unexpectedAttribute(reader, i); final Element element = Element.forName(reader.getLocalName()); if (traceEnabled) { ROOT_LOGGER.tracef("parse persistence.xml: element=%s", element.getLocalName()); classes.add(getElement(reader, propertyReplacer)); break; final String description = getElement(reader, propertyReplacer); break; String text = getElement(reader, propertyReplacer);
private void parse( final VirtualFile persistence_xml, final List<PersistenceUnitMetadataHolder> listPUHolders, final DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException { ROOT_LOGGER.tracef("parse checking if %s exists, result = %b",persistence_xml.toString(), persistence_xml.exists()); if (persistence_xml.exists() && persistence_xml.isFile()) { InputStream is = null; try { is = persistence_xml.openStream(); final XMLInputFactory inputFactory = XMLInputFactory.newInstance(); inputFactory.setXMLResolver(NoopXMLResolver.create()); XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(is); PersistenceUnitMetadataHolder puHolder = PersistenceUnitXmlParser.parse(xmlReader, SpecDescriptorPropertyReplacement.propertyReplacer(deploymentUnit)); postParseSteps(persistence_xml, puHolder, deploymentUnit); listPUHolders.add(puHolder); } catch (Exception e) { throw new DeploymentUnitProcessingException(JpaLogger.ROOT_LOGGER.failedToParse(persistence_xml), e); } finally { try { if (is != null) { is.close(); } } catch (IOException e) { // Ignore } } } }
while (reader.hasNext() && reader.next() != START_ELEMENT) { if (reader.getEventType() == DTD) { final String dtdLocation = readDTDLocation(reader); if (dtdLocation != null) { version = Version.forLocation(dtdLocation); final String schemaLocation = readSchemaLocation(reader); if (schemaLocation != null) { version = Version.forLocation(schemaLocation); if (version == null || Version.UNKNOWN.equals(version)) { final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); if (attribute == Attribute.VERSION) { versionString = reader.getAttributeValue(i); final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case VERSION: throw unexpectedAttribute(reader, i); final Element element = Element.forName(reader.getLocalName()); switch (element) { case PERSISTENCEUNIT: PersistenceUnitMetadata pu = parsePU(reader, version, propertyReplacer); PUs.add(pu); ROOT_LOGGER.readingPersistenceXml(pu.getPersistenceUnitName());
pu.setSharedCacheMode(SharedCacheMode.UNSPECIFIED); pu.setPersistenceProviderClassName(Configuration.PROVIDER_CLASS_DEFAULT); if (version.equals(Version.JPA_1_0)) { pu.setPersistenceXMLSchemaVersion("1.0"); } else if (version.equals(Version.JPA_2_0)) { pu.setPersistenceXMLSchemaVersion("2.0"); } else if (version.equals(Version.JPA_2_1)) { pu.setPersistenceXMLSchemaVersion("2.1"); } else { final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case NAME: break; default: throw unexpectedAttribute(reader, i); final Element element = Element.forName(reader.getLocalName()); if (traceEnabled) { ROOT_LOGGER.tracef("parse persistence.xml: element=%s", element.getLocalName()); classes.add(getElement(reader, propertyReplacer)); break; final String description = getElement(reader, propertyReplacer); break; String text = getElement(reader, propertyReplacer);
private static void parseProperties(XMLStreamReader reader, Properties properties, final PropertyReplacer propertyReplacer) throws XMLStreamException { final Element element = Element.forName(reader.getLocalName()); switch (element) { case PROPERTY: String name = null, value = null; for (int i = 0; i < count; i++) { final String attributeValue = getAttribute(reader, i, propertyReplacer); final String attributeNamespace = reader.getAttributeNamespace(i); if (attributeNamespace != null && !attributeNamespace.isEmpty()) { continue; final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i)); switch (attribute) { case NAME: break; default: throw unexpectedAttribute(reader, i); throw unexpectedElement(reader); throw unexpectedElement(reader);
private void parse( final VirtualFile persistence_xml, final List<PersistenceUnitMetadataHolder> listPUHolders, final DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException { ROOT_LOGGER.tracef("parse checking if %s exists, result = %b",persistence_xml.toString(), persistence_xml.exists()); if (persistence_xml.exists() && persistence_xml.isFile()) { InputStream is = null; try { is = persistence_xml.openStream(); final XMLInputFactory inputFactory = XMLInputFactory.newInstance(); inputFactory.setXMLResolver(NoopXMLResolver.create()); XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(is); PersistenceUnitMetadataHolder puHolder = PersistenceUnitXmlParser.parse(xmlReader, SpecDescriptorPropertyReplacement.propertyReplacer(deploymentUnit)); postParseSteps(persistence_xml, puHolder, deploymentUnit); listPUHolders.add(puHolder); } catch (Exception e) { throw new DeploymentUnitProcessingException(JpaLogger.ROOT_LOGGER.failedToParse(persistence_xml), e); } finally { try { if (is != null) { is.close(); } } catch (IOException e) { // Ignore } } } }