You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2007/01/31 17:27:50 UTC
svn commit: r501883 -
/cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/conf/UnitDescriptorParser.java
Author: aadamchik
Date: Wed Jan 31 08:27:50 2007
New Revision: 501883
URL: http://svn.apache.org/viewvc?view=rev&rev=501883
Log:
can't call reset on the parser - some parsers blow in this functionality
Modified:
cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/conf/UnitDescriptorParser.java
Modified: cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/conf/UnitDescriptorParser.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/conf/UnitDescriptorParser.java?view=diff&rev=501883&r1=501882&r2=501883
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/conf/UnitDescriptorParser.java (original)
+++ cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/conf/UnitDescriptorParser.java Wed Jan 31 08:27:50 2007
@@ -17,7 +17,6 @@
* under the License.
****************************************************************/
-
package org.apache.cayenne.jpa.conf;
import java.io.IOException;
@@ -69,21 +68,19 @@
static final String PROPERTY = "property";
static final String VALUE = "value";
- protected SAXParser parser;
+ protected SAXParserFactory parserFactory;
protected JpaUnitFactory unitFactory;
- public UnitDescriptorParser() throws SAXException,
- ParserConfigurationException {
+ public UnitDescriptorParser() throws SAXException, ParserConfigurationException {
this(null, false);
}
- public UnitDescriptorParser(JpaUnitFactory unitFactory,
- boolean validatesAgainstSchema) throws SAXException,
- ParserConfigurationException {
+ public UnitDescriptorParser(JpaUnitFactory unitFactory, boolean validatesAgainstSchema)
+ throws SAXException {
this.unitFactory = unitFactory;
- SAXParserFactory parserFactory = SAXParserFactory.newInstance();
+ parserFactory = SAXParserFactory.newInstance();
parserFactory.setNamespaceAware(true);
// note that validation requires that persistence.xml declares a schema like this:
@@ -102,8 +99,6 @@
Schema schema = factory.newSchema(ss);
parserFactory.setSchema(schema);
}
-
- this.parser = parserFactory.newSAXParser();
}
/**
@@ -111,12 +106,12 @@
*/
public synchronized Collection<JpaUnit> getPersistenceUnits(
InputSource in,
- final URL persistenceUnitRootUrl) throws SAXException, IOException {
+ final URL persistenceUnitRootUrl) throws SAXException, IOException,
+ ParserConfigurationException {
- final Collection<JpaUnit> unitInfos = new ArrayList<JpaUnit>(
- 2);
+ final Collection<JpaUnit> unitInfos = new ArrayList<JpaUnit>(2);
- parser.reset();
+ SAXParser parser = parserFactory.newSAXParser();
parser.parse(in, new DefaultHandler() {
JpaUnit unit;
@@ -139,9 +134,7 @@
String name = attributes.getValue("", NAME);
String transactionType = attributes.getValue("", TRANSACTION_TYPE);
- unit = unitFactory != null
- ? unitFactory.newUnit()
- : new JpaUnit();
+ unit = unitFactory != null ? unitFactory.newUnit() : new JpaUnit();
unit.setPersistenceUnitName(name);
unit.setPersistenceUnitRootUrl(persistenceUnitRootUrl);