You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by th...@apache.org on 2002/11/30 18:33:20 UTC
cvs commit: jakarta-ojb/src/java/org/apache/ojb/broker/metadata RepositoryXmlHandler.java
thma 2002/11/30 09:33:20
Modified: src/java/org/apache/ojb/broker/metadata
RepositoryXmlHandler.java
Log:
add accept locks attribute to class-descriptor
Revision Changes Path
1.22 +918 -904 jakarta-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryXmlHandler.java
Index: RepositoryXmlHandler.java
===================================================================
RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/metadata/RepositoryXmlHandler.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- RepositoryXmlHandler.java 28 Nov 2002 22:19:25 -0000 1.21
+++ RepositoryXmlHandler.java 30 Nov 2002 17:33:20 -0000 1.22
@@ -1,909 +1,923 @@
-package org.apache.ojb.broker.metadata;
-
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2001 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. The names "Apache" and "Apache Software Foundation" and
- * "Apache ObjectRelationalBridge" must not be used to endorse or promote products
- * derived from this software without prior written permission. For
- * written permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache",
- * "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
- * prior written permission of the Apache Software Foundation.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- */
-
-import org.apache.ojb.broker.PersistenceBrokerException;
-import org.apache.ojb.broker.util.logging.Logger;
-import org.apache.ojb.broker.util.logging.LoggerFactory;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * The handler catches Parsing events raised by the xml-parser
- * and builds up the DescriptorRepository that is used within the
- * OJB PersistenceBroker System.
- *
- * @author <a href="mailto:thma@apache.org">Thomas Mahler<a>
- * @author Jakob Br�uchi
- * @version $Id$
- */
-public class RepositoryXmlHandler
- extends DefaultHandler
- implements RepositoryElements, IsolationLevels
-{
- private Logger logger;
-
- private DescriptorRepository m_repository;
- private JdbcConnectionDescriptor m_CurrentJCD;
- private ClassDescriptor m_CurrentCLD;
- private FieldDescriptor m_CurrentFLD;
- private ObjectReferenceDescriptor m_CurrentORD;
- private CollectionDescriptor m_CurrentCOD;
- private String m_CurrentString;
- /** holds custom attributes */
- private AttributeContainer m_CurrentAttrContainer;
-
- /** the default isolation level*/
- private int defIsoLevel = IL_DEFAULT;
-
- /**
- * All known xml tags are kept in this table.
- * The tags table allows lookup from literal to id
- * and from id to literal.
- */
- private RepositoryTags tags = RepositoryTags.getInstance();
-
- /**
- * returns the XmlCapable id associated with the literal.
- * OJB maintains a RepositoryTags table that provides
- * a mapping from xml-tags to XmlCapable ids.
- * @param literal the literal to lookup
- * @return the int value representing the XmlCapable
- *
- * @throws MetadataException if no literal was found in tags mapping
- */
- private int getLiteralId(String literal) throws PersistenceBrokerException
- {
- //logger.debug("lookup: " + literal);
- try
- {
- return tags.getIdByTag(literal);
- }
- catch (NullPointerException t)
- {
- throw new MetadataException("unknown literal: '" + literal + "'", t);
- }
-
- }
-
- /**
- * build a handler that fills the given repository
- * from an XML file.
- */
- public RepositoryXmlHandler(DescriptorRepository dr)
- {
- if (dr != null)
- {
- m_repository = dr;
- }
- else
- {
- m_repository = DescriptorRepository.getDefaultInstance();
- }
- logger = LoggerFactory.getLogger(this.getClass());
- }
-
- /**
- * startDocument callback, nothing to do here.
- */
- public void startDocument()
- {
- logger.debug("startDoc");
- }
-
- /**
- * endDocument callback, nothing to do here.
- */
- public void endDocument()
- {
- logger.debug("endDoc");
- }
-
- /**
- * startElement callback.
- * Only some Elements need special start operations.
- * @throws MetadataException indicating mapping errors
- */
- public void startElement(String uri, String name, String qName, Attributes atts)
- {
- m_CurrentString = null;
- try
- {
- switch (getLiteralId(qName))
- {
- case MAPPING_REPOSITORY:
- {
- String defIso = atts.getValue(tags.getTagById(ISOLATION_LEVEL));
- if (defIso != null)
- {
- defIsoLevel = getIsoLevel(defIso);
- }
-
- // check repository version:
- String version = atts.getValue(tags.getTagById(REPOSITORY_VERSION));
- if (DescriptorRepository.getVersion().equals(version))
- {
- }
- else
- {
- throw new MetadataException("Repository version does not match. expected " +
- DescriptorRepository.getVersion() + " but found: " +
- version);
- }
-
- logger.debug(" > " + tags.getTagById(MAPPING_REPOSITORY));
-
- break;
- }
- case JDBC_CONNECTION_DESCRIPTOR:
- {
- logger.debug(" > " + tags.getTagById(JDBC_CONNECTION_DESCRIPTOR));
- m_CurrentJCD = new JdbcConnectionDescriptor();
- if (m_CurrentCLD == null)
- {
- m_repository.setDefaultJdbcConnection(m_CurrentJCD);
- }
- else
- {
- m_CurrentCLD.setConnectionDescriptor(m_CurrentJCD);
- }
- // set platform attribute
- String platform = atts.getValue(tags.getTagById(DBMS_NAME));
- logger.debug(" " + tags.getTagById(DBMS_NAME) + ": " + platform);
- m_CurrentJCD.setDbms(platform);
-
- // set jdbc-level attribute
- String level = atts.getValue(tags.getTagById(JDBC_LEVEL));
- logger.debug(" " + tags.getTagById(JDBC_LEVEL) + ": " + level);
- m_CurrentJCD.setJdbcLevel(level);
-
- // set driver attribute
- String driver = atts.getValue(tags.getTagById(DRIVER_NAME));
- logger.debug(" " + tags.getTagById(DRIVER_NAME) + ": " + driver);
- m_CurrentJCD.setDriver(driver);
-
- // set protocol attribute
- String protocol = atts.getValue(tags.getTagById(URL_PROTOCOL));
- logger.debug(" " + tags.getTagById(URL_PROTOCOL) + ": " + protocol);
- m_CurrentJCD.setProtocol(protocol);
-
- // set subprotocol attribute
- String subprotocol = atts.getValue(tags.getTagById(URL_SUBPROTOCOL));
- logger.debug(" " + tags.getTagById(URL_SUBPROTOCOL) + ": " + subprotocol);
- m_CurrentJCD.setSubProtocol(subprotocol);
-
- // set the dbalias attribute
- String dbalias = atts.getValue(tags.getTagById(URL_DBALIAS));
- logger.debug(" " + tags.getTagById(URL_DBALIAS) + ": " + dbalias);
- m_CurrentJCD.setDbAlias(dbalias);
-
- // set the datasource attribute
- String datasource = atts.getValue(tags.getTagById(DATASOURCE_NAME));
- logger.debug(" " + tags.getTagById(DATASOURCE_NAME) + ": " + datasource);
- m_CurrentJCD.setDatasourceName(datasource);
-
- // set the user attribute
- String user = atts.getValue(tags.getTagById(USER_NAME));
- logger.debug(" " + tags.getTagById(USER_NAME) + ": " + user);
- m_CurrentJCD.setUserName(user);
-
- // set the password attribute
- String password = atts.getValue(tags.getTagById(USER_PASSWD));
- logger.debug(" " + tags.getTagById(USER_PASSWD) + ": " + password);
- m_CurrentJCD.setPassWord(password);
-
- // set eager-release attribute
- String eagerRelease = atts.getValue(tags.getTagById(EAGER_RELEASE));
- logger.debug(" " + tags.getTagById(EAGER_RELEASE) + ": " + eagerRelease);
- m_CurrentJCD.setEagerRelease(Boolean.valueOf(eagerRelease).booleanValue());
-
- break;
- }
- case CLASS_DESCRIPTOR:
- {
- logger.debug(" > " + tags.getTagById(CLASS_DESCRIPTOR));
- m_CurrentCLD = new ClassDescriptor(m_repository);
-
- // prepare for custom attributes
- this.m_CurrentAttrContainer = this.m_CurrentCLD;
-
- // set isolation-level attribute
- String isoLevel = atts.getValue(tags.getTagById(ISOLATION_LEVEL));
- logger.debug(" " + tags.getTagById(ISOLATION_LEVEL) + ": " + isoLevel);
- m_CurrentCLD.setIsolationLevel(getIsoLevel(isoLevel));
-
- // set class attribute
- String classname = atts.getValue(tags.getTagById(CLASS_NAME));
- logger.debug(" " + tags.getTagById(CLASS_NAME) + ": " + classname);
- m_CurrentCLD.setIsolationLevel(getIsoLevel(isoLevel));
- try
- {
- m_CurrentCLD.setClassNameOfObject(classname);
- m_repository.put(classname, m_CurrentCLD);
- }
- catch (Exception ex)
- {
- logger.error(ex);
- throw new PersistenceBrokerException(ex);
- }
-
- // set schema attribute
- String schema = atts.getValue(tags.getTagById(SCHEMA_NAME));
- if (schema != null)
- {
- logger.debug(" " + tags.getTagById(SCHEMA_NAME) + ": " + schema);
- m_CurrentCLD.setSchema(schema);
- }
-
- // set proxy attribute
- String proxy = atts.getValue(tags.getTagById(CLASS_PROXY));
- logger.debug(" " + tags.getTagById(CLASS_PROXY) + ": " + proxy);
- if (proxy != null)
- {
- if (proxy.equalsIgnoreCase("dynamic"))
- {
- m_CurrentCLD.setProxyClassName("dynamic");
- }
- else
- {
- m_CurrentCLD.setProxyClassName(proxy);
- }
- }
-
- // set table attribute:
- String table = atts.getValue(tags.getTagById(TABLE_NAME));
- logger.debug(" " + tags.getTagById(TABLE_NAME) + ": " + table);
- m_CurrentCLD.setTableName(table);
- if (table == null)
- {
- m_CurrentCLD.setIsInterface(true);
- }
-
- // set row-reader attribute
- String rowreader = atts.getValue(tags.getTagById(ROW_READER));
- logger.debug(" " + tags.getTagById(ROW_READER) + ": " + rowreader);
- if (rowreader != null)
- {
- m_CurrentCLD.setRowReaderClassName(rowreader);
- }
-
- // set if extends
- // set row-reader attribute
- String extendsAtt = atts.getValue(tags.getTagById(EXTENDS));
- logger.debug(" " + tags.getTagById(EXTENDS) + ": " + extendsAtt);
- if (extendsAtt != null)
- {
- m_CurrentCLD.setSuperClass(extendsAtt);
- }
-
- break;
- }
-
- case CLASS_EXTENT:
- {
- String classname = atts.getValue("class-ref");
- logger.debug(" " + tags.getTagById(CLASS_EXTENT) + ": " + classname);
- m_CurrentCLD.addExtentClassName(classname);
- break;
- }
- /* case EXTENDS :
- {
- String classname = atts.getValue("class-ref");
- logger.debug(" " + tags.getTagById(EXTENDS) + ": " + classname);
- m_CurrentCLD.setSuperClass(classname);
-
- // get key for super class
- String fieldref = atts.getValue("field-id-ref");
- try
- {
- int fieldId;
- fieldId = Integer.parseInt(fieldref);
- logger.debug(" " + tags.getTagById(EXTENDS) + ": " +fieldId);
- m_CurrentCLD.setSuperClassFieldRef(fieldId);
- }
- catch (NumberFormatException rex)
- {
- throw new MetadataException(tags.getTagById(EXTENDS)
- + " attribute must be an int. Found: "
- + fieldref,rex);
- }
-
-
- break;
- }*/
-
- case FIELD_DESCRIPTOR:
- {
- logger.debug(" > " + tags.getTagById(FIELD_DESCRIPTOR));
-
- int id = Integer.parseInt(atts.getValue("id"));
- m_CurrentFLD = new FieldDescriptor(id);
- m_CurrentCLD.addFieldDescriptor(m_CurrentFLD);
-
- // prepare for custom attributes
- this.m_CurrentAttrContainer = this.m_CurrentFLD;
-
- String fieldName = atts.getValue(tags.getTagById(FIELD_NAME));
- logger.debug(" " + tags.getTagById(FIELD_NAME) + ": " + fieldName);
- String classname = m_CurrentCLD.getClassNameOfObject();
- m_CurrentFLD.setPersistentField(classname, fieldName);
-
- String columnName = atts.getValue(tags.getTagById(COLUMN_NAME));
- logger.debug(" " + tags.getTagById(COLUMN_NAME) + ": " + columnName);
- m_CurrentFLD.setColumnName(columnName);
-
- String jdbcType = atts.getValue(tags.getTagById(JDBC_TYPE));
- logger.debug(" " + tags.getTagById(JDBC_TYPE) + ": " + jdbcType);
- m_CurrentFLD.setColumnType(jdbcType);
-
- String primaryKey = atts.getValue(tags.getTagById(PRIMARY_KEY));
- logger.debug(" " + tags.getTagById(PRIMARY_KEY) + ": " + primaryKey);
- boolean b = (new Boolean(primaryKey)).booleanValue();
- m_CurrentFLD.setPrimaryKey(b);
-
- String nullable = atts.getValue(tags.getTagById(NULLABLE));
- if (nullable != null)
- {
- logger.debug(" " + tags.getTagById(NULLABLE) + ": " + nullable);
- b = !(new Boolean(nullable)).booleanValue();
- m_CurrentFLD.setRequired(b);
- }
-
- String indexed = atts.getValue(tags.getTagById(INDEXED));
- logger.debug(" " + tags.getTagById(INDEXED) + ": " + indexed);
- b = (new Boolean(indexed)).booleanValue();
- m_CurrentFLD.setIndexed(b);
-
- String autoincrement = atts.getValue(tags.getTagById(AUTO_INCREMENT));
- logger.debug(" " + tags.getTagById(AUTO_INCREMENT) + ": " + autoincrement);
- b = (new Boolean(autoincrement)).booleanValue();
- m_CurrentFLD.setAutoIncrement(b);
-
- String sequenceName = atts.getValue(tags.getTagById(SEQUENCE_NAME));
- logger.debug(" " + tags.getTagById(SEQUENCE_NAME) + ": " + sequenceName);
- m_CurrentFLD.setSequenceName(sequenceName);
-
- String locking = atts.getValue(tags.getTagById(LOCKING));
- logger.debug(" " + tags.getTagById(LOCKING) + ": " + locking);
- b = (new Boolean(locking)).booleanValue();
- m_CurrentFLD.setLocking(b);
-
- String fieldConversion = atts.getValue(tags.getTagById(FIELD_CONVERSION));
- logger.debug(" " + tags.getTagById(FIELD_CONVERSION) + ": " + fieldConversion);
- if (fieldConversion != null)
- {
- m_CurrentFLD.setFieldConversionClassName(fieldConversion);
- }
-
- // set length attribute
- String length = atts.getValue(tags.getTagById(LENGTH));
- if (length != null)
- {
- int i = Integer.parseInt(length);
- logger.debug(" " + tags.getTagById(LENGTH) + ": " + i);
- m_CurrentFLD.setLength(i);
- m_CurrentFLD.setLengthSpecified(true);
- }
-
- // set precision attribute
- String precision = atts.getValue(tags.getTagById(PRECISION));
- if (precision != null)
- {
- int i = Integer.parseInt(precision);
- logger.debug(" " + tags.getTagById(PRECISION) + ": " + i);
- m_CurrentFLD.setPrecision(i);
- m_CurrentFLD.setPrecisionSpecified(true);
- }
-
- // set scale attribute
- String scale = atts.getValue(tags.getTagById(SCALE));
- if (scale != null)
- {
- int i = Integer.parseInt(scale);
- logger.debug(" " + tags.getTagById(SCALE) + ": " + i);
- m_CurrentFLD.setScale(i);
- m_CurrentFLD.setScaleSpecified(true);
- }
-
- break;
- }
- case REFERENCE_DESCRIPTOR:
- {
- logger.debug(" > " + tags.getTagById(REFERENCE_DESCRIPTOR));
- m_CurrentORD = new ObjectReferenceDescriptor();
- m_CurrentCLD.addObjectReferenceDescriptor(m_CurrentORD);
-
- // prepare for custom attributes
- this.m_CurrentAttrContainer = m_CurrentORD;
-
- // set name attribute
- name = atts.getValue(tags.getTagById(FIELD_NAME));
- logger.debug(" " + tags.getTagById(FIELD_NAME) + ": " + name);
- m_CurrentORD.setPersistentField(m_CurrentCLD.getClassNameOfObject(), name);
-
- // set class-ref attribute
- String classRef = atts.getValue(tags.getTagById(REFERENCED_CLASS));
- logger.debug(" " + tags.getTagById(REFERENCED_CLASS) + ": " + classRef);
- m_CurrentORD.setItemClassName(classRef);
-
- // set proxy attribute
- String proxy = atts.getValue(tags.getTagById(PROXY_REFERENCE));
- logger.debug(" " + tags.getTagById(PROXY_REFERENCE) + ": " + proxy);
- boolean b = (new Boolean(proxy)).booleanValue();
- m_CurrentORD.setLazy(b);
-
- // set refresh attribute
- String refresh = atts.getValue(tags.getTagById(REFRESH_REFERENCE));
- logger.debug(" " + tags.getTagById(REFRESH_REFERENCE) + ": " + refresh);
- b = (new Boolean(refresh)).booleanValue();
- m_CurrentORD.setRefresh(b);
-
- // set auto-retrieve attribute
- String autoRetrieve = atts.getValue(tags.getTagById(AUTO_RETRIEVE));
- logger.debug(" " + tags.getTagById(AUTO_RETRIEVE) + ": " + autoRetrieve);
- b = (new Boolean(autoRetrieve)).booleanValue();
- m_CurrentORD.setCascadeRetrieve(b);
-
- // set auto-update attribute
- String autoUpdate = atts.getValue(tags.getTagById(AUTO_UPDATE));
- logger.debug(" " + tags.getTagById(AUTO_UPDATE) + ": " + autoUpdate);
- b = (new Boolean(autoUpdate)).booleanValue();
- m_CurrentORD.setCascadeStore(b);
-
- //set auto-delete attribute
- String autoDelete = atts.getValue(tags.getTagById(AUTO_DELETE));
- logger.debug(" " + tags.getTagById(AUTO_DELETE) + ": " + autoDelete);
- b = (new Boolean(autoDelete)).booleanValue();
- m_CurrentORD.setCascadeDelete(b);
-
- break;
- }
-
- case FOREIGN_KEY:
- {
- logger.debug(" > " + tags.getTagById(FOREIGN_KEY));
- String fieldIdRef = atts.getValue(tags.getTagById(FIELD_ID_REF));
- logger.debug(" " + tags.getTagById(FIELD_ID_REF) + ": " + fieldIdRef);
-
- try
- {
- int fieldId;
- fieldId = Integer.parseInt(fieldIdRef);
- m_CurrentORD.addForeignKeyField(fieldId);
- }
- catch (NumberFormatException rex)
- {
- throw new MetadataException(tags.getTagById(FIELD_ID_REF)
- + " attribute must be an int. Found: "
- + fieldIdRef, rex);
- }
- break;
- }
-
- case COLLECTION_DESCRIPTOR:
- {
- logger.debug(" > " + tags.getTagById(COLLECTION_DESCRIPTOR));
- m_CurrentCOD = new CollectionDescriptor();
- m_CurrentCLD.addCollectionDescriptor(m_CurrentCOD);
-
- // prepare for custom attributes
- this.m_CurrentAttrContainer = m_CurrentCOD;
-
- // set name attribute
- name = atts.getValue(tags.getTagById(FIELD_NAME));
- logger.debug(" " + tags.getTagById(FIELD_NAME) + ": " + name);
- m_CurrentCOD.setPersistentField(m_CurrentCLD.getClassNameOfObject(), name);
-
- // set collection-class attribute
- String collectionClassName = atts.getValue(tags.getTagById(COLLECTION_CLASS));
- if (collectionClassName != null)
- {
- logger.debug(" " + tags.getTagById(COLLECTION_CLASS) + ": " + collectionClassName);
- m_CurrentCOD.setCollectionClassName(collectionClassName);
- }
- // set element-class-ref attribute
- String elementClassRef = atts.getValue(tags.getTagById(ITEMS_CLASS));
- logger.debug(" " + tags.getTagById(ITEMS_CLASS) + ": " + elementClassRef);
- if (elementClassRef != null)
- {
- m_CurrentCOD.setItemClassName(elementClassRef);
- }
-
- //set orderby and sort attributes:
- String orderby = atts.getValue(tags.getTagById(ORDERBY));
- String sort = atts.getValue(tags.getTagById(SORT));
- logger.debug(" " + tags.getTagById(SORT) + ": " + orderby + ", " + sort);
-
- if (orderby != null)
- {
- boolean isAsc = true;
- if ("DESC".equalsIgnoreCase(sort))
- {
- isAsc = false;
- }
- m_CurrentCOD.setOrderBy(orderby);
- m_CurrentCOD.setAscending(isAsc);
- }
-
- // set indirection-table attribute
- String indirectionTable = atts.getValue(tags.getTagById(INDIRECTION_TABLE));
- logger.debug(" " + tags.getTagById(INDIRECTION_TABLE) + ": " + indirectionTable);
- m_CurrentCOD.setIndirectionTable(indirectionTable);
-
- // set proxy attribute
- String proxy = atts.getValue(tags.getTagById(PROXY_REFERENCE));
- logger.debug(" " + tags.getTagById(PROXY_REFERENCE) + ": " + proxy);
- boolean b = (new Boolean(proxy)).booleanValue();
- m_CurrentCOD.setLazy(b);
-
- // set refresh attribute
- String refresh = atts.getValue(tags.getTagById(REFRESH_REFERENCE));
- logger.debug(" " + tags.getTagById(REFRESH_REFERENCE) + ": " + refresh);
- b = (new Boolean(refresh)).booleanValue();
- m_CurrentCOD.setRefresh(b);
-
- // set auto-retrieve attribute
- String autoRetrieve = atts.getValue(tags.getTagById(AUTO_RETRIEVE));
- logger.debug(" " + tags.getTagById(AUTO_RETRIEVE) + ": " + autoRetrieve);
- b = (new Boolean(autoRetrieve)).booleanValue();
- m_CurrentCOD.setCascadeRetrieve(b);
-
- // set auto-update attribute
- String autoUpdate = atts.getValue(tags.getTagById(AUTO_UPDATE));
- logger.debug(" " + tags.getTagById(AUTO_UPDATE) + ": " + autoUpdate);
- b = (new Boolean(autoUpdate)).booleanValue();
- m_CurrentCOD.setCascadeStore(b);
-
- //set auto-delete attribute
- String autoDelete = atts.getValue(tags.getTagById(AUTO_DELETE));
- logger.debug(" " + tags.getTagById(AUTO_DELETE) + ": " + autoDelete);
- b = (new Boolean(autoDelete)).booleanValue();
- m_CurrentCOD.setCascadeDelete(b);
-
- break;
- }
- case INVERSE_FK:
- {
- logger.debug(" > " + tags.getTagById(INVERSE_FK));
- String fieldIdRef = atts.getValue(tags.getTagById(FIELD_ID_REF));
- logger.debug(" " + tags.getTagById(FIELD_ID_REF) + ": " + fieldIdRef);
-
- try
- {
- int fieldId;
- fieldId = Integer.parseInt(fieldIdRef);
- m_CurrentCOD.addForeignKeyField(fieldId);
- }
- catch (NumberFormatException rex)
- {
- throw new MetadataException(tags.getTagById(FIELD_ID_REF)
- + " attribute must be an int. Found: "
- + fieldIdRef, rex);
- }
- break;
- }
-
- case FK_POINTING_TO_THIS_CLASS:
- {
- logger.debug(" > " + tags.getTagById(FK_POINTING_TO_THIS_CLASS));
- String column = atts.getValue("column");
- logger.debug(" " + "column" + ": " + column);
- m_CurrentCOD.addFkToThisClass(column);
- break;
- }
-
- case FK_POINTING_TO_ITEMS_CLASS:
- {
- logger.debug(" > " + tags.getTagById(FK_POINTING_TO_ITEMS_CLASS));
- String column = atts.getValue("column");
- logger.debug(" " + "column" + ": " + column);
- m_CurrentCOD.addFkToItemClass(column);
- break;
- }
- case CONNECTION_POOL:
- {
- logger.debug(" > " + tags.getTagById(CONNECTION_POOL));
- ConnectionPoolDescriptor m_CurrentCPD = m_CurrentJCD.getConnectionPoolDescriptor();
-
- String maxActive = atts.getValue(tags.getTagById(CON_MAX_ACTIVE));
- logger.debug(" " + tags.getTagById(CON_MAX_ACTIVE) + ": " + maxActive);
- if (checkString(maxActive)) m_CurrentCPD.setMaxActive(new Integer(maxActive).intValue());
-
- String maxIdle = atts.getValue(tags.getTagById(CON_MAX_IDLE));
- logger.debug(" " + tags.getTagById(CON_MAX_IDLE) + ": " + maxIdle);
- if (checkString(maxIdle)) m_CurrentCPD.setMaxIdle(new Integer(maxIdle).intValue());
-
- String maxWait = atts.getValue(tags.getTagById(CON_MAX_WAIT));
- logger.debug(" " + tags.getTagById(CON_MAX_WAIT) + ": " + maxWait);
- if (checkString(maxWait)) m_CurrentCPD.setMaxWait(new Integer(maxWait).intValue());
-
- String minEvictableIdleTimeMillis = atts.getValue(tags.getTagById(CON_MIN_EVICTABLE_IDLE_TIME_MILLIS));
- logger.debug(" " + tags.getTagById(CON_MIN_EVICTABLE_IDLE_TIME_MILLIS) + ": " + minEvictableIdleTimeMillis);
- if (checkString(minEvictableIdleTimeMillis)) m_CurrentCPD.setMinEvictableIdleTimeMillis(new Long(minEvictableIdleTimeMillis).longValue());
-
- String numTestsPerEvictionRun = atts.getValue(tags.getTagById(CON_NUM_TESTS_PER_EVICTION_RUN));
- logger.debug(" " + tags.getTagById(CON_NUM_TESTS_PER_EVICTION_RUN) + ": " + numTestsPerEvictionRun);
- if (checkString(numTestsPerEvictionRun)) m_CurrentCPD.setNumTestsPerEvictionRun(new Integer(numTestsPerEvictionRun).intValue());
-
- String testOnBorrow = atts.getValue(tags.getTagById(CON_TEST_ON_BORROW));
- logger.debug(" " + tags.getTagById(CON_TEST_ON_BORROW) + ": " + testOnBorrow);
- if (checkString(testOnBorrow)) m_CurrentCPD.setTestOnBorrow(new Boolean(testOnBorrow).booleanValue());
-
- String testOnReturn = atts.getValue(tags.getTagById(CON_TEST_ON_RETURN));
- logger.debug(" " + tags.getTagById(CON_TEST_ON_RETURN) + ": " + testOnReturn);
- if (checkString(testOnReturn)) m_CurrentCPD.setTestOnReturn(new Boolean(testOnReturn).booleanValue());
-
- String testWhileIdle = atts.getValue(tags.getTagById(CON_TEST_WHILE_IDLE));
- logger.debug(" " + tags.getTagById(CON_TEST_WHILE_IDLE) + ": " + testWhileIdle);
- if (checkString(testWhileIdle)) m_CurrentCPD.setTestWhileIdle(new Boolean(testWhileIdle).booleanValue());
-
- String timeBetweenEvictionRunsMillis = atts.getValue(tags.getTagById(CON_TIME_BETWEEN_EVICTION_RUNS_MILLIS));
- logger.debug(" " + tags.getTagById(CON_TIME_BETWEEN_EVICTION_RUNS_MILLIS) + ": " + timeBetweenEvictionRunsMillis);
- if (checkString(timeBetweenEvictionRunsMillis)) m_CurrentCPD.setTimeBetweenEvictionRunsMillis(new Long(timeBetweenEvictionRunsMillis).longValue());
-
- String whenExhaustedAction = atts.getValue(tags.getTagById(CON_WHEN_EXHAUSTED_ACTION));
- logger.debug(" " + tags.getTagById(CON_WHEN_EXHAUSTED_ACTION) + ": " + whenExhaustedAction);
- if (checkString(whenExhaustedAction)) m_CurrentCPD.setWhenExhaustedAction(new Byte(whenExhaustedAction).byteValue());
-
- String connectionFactoryStr = atts.getValue(tags.getTagById(CONNECTION_FACTORY));
- logger.debug(" " + tags.getTagById(CONNECTION_FACTORY) + ": " + connectionFactoryStr);
- if (checkString(connectionFactoryStr)) m_CurrentCPD.setConnectionFactory(connectionFactoryStr);
- break;
- }
- case ATTRIBUTE:
- {
- //handle custom attributes
- String attributeName = atts.getValue(tags.getTagById(ATTRIBUTE_NAME));
- String attributeValue = atts.getValue(tags.getTagById(ATTRIBUTE_VALUE));
- logger.debug(" > " + tags.getTagById(ATTRIBUTE));
- logger.debug(" " + tags.getTagById(ATTRIBUTE_NAME) + ": " + attributeName);
- logger.debug(" " + tags.getTagById(ATTRIBUTE_VALUE) + ": " + attributeValue);
- // If we have a container to store this attribute in, then do so.
- if (this.m_CurrentAttrContainer != null)
- {
- this.m_CurrentAttrContainer.addAttribute(attributeName, attributeValue);
- }
- }
- default :
- {
- // nop
- }
- }
- }
- catch (Exception ex)
- {
- logger.error(ex);
- throw new PersistenceBrokerException(ex);
- }
- }
-
- private boolean checkString(String str)
- {
- return (str != null && !str.equals(""));
- }
-
- /**
- * endElement callback. most elements are build up from here.
- */
- public void endElement(String uri, String name, String qName)
- {
- try
- {
- switch (getLiteralId(qName))
- {
- case MAPPING_REPOSITORY:
- {
- logger.debug(" < " + tags.getTagById(MAPPING_REPOSITORY));
- break;
- }
- case JDBC_CONNECTION_DESCRIPTOR:
- {
- logger.debug(" < " + tags.getTagById(JDBC_CONNECTION_DESCRIPTOR));
- break;
- }
- case CONNECTION_POOL:
- {
- logger.debug(" < " + tags.getTagById(CONNECTION_POOL));
- break;
- }
- case CLASS_DESCRIPTOR:
- {
- logger.debug(" < " + tags.getTagById(CLASS_DESCRIPTOR));
- m_CurrentCLD = null;
- m_CurrentAttrContainer = null;
- break;
- }
- case CLASS_EXTENT:
- {
- break;
- }
- case FIELD_DESCRIPTOR:
- {
- logger.debug(" < " + tags.getTagById(FIELD_DESCRIPTOR));
- m_CurrentFLD = null;
- m_CurrentAttrContainer = m_CurrentCLD;
- break;
- }
- case REFERENCE_DESCRIPTOR:
- {
- logger.debug(" < " + tags.getTagById(REFERENCE_DESCRIPTOR));
- m_CurrentORD = null;
- m_CurrentAttrContainer = m_CurrentCLD;
- break;
- }
- case FOREIGN_KEY:
- {
- logger.debug(" < " + tags.getTagById(FOREIGN_KEY));
- break;
- }
- case COLLECTION_DESCRIPTOR:
- {
- logger.debug(" < " + tags.getTagById(COLLECTION_DESCRIPTOR));
- m_CurrentCOD = null;
- m_CurrentAttrContainer = m_CurrentCLD;
- break;
- }
- case INVERSE_FK:
- {
- logger.debug(" < " + tags.getTagById(INVERSE_FK));
- break;
- }
- case FK_POINTING_TO_THIS_CLASS:
- {
- logger.debug(" < " + tags.getTagById(FK_POINTING_TO_THIS_CLASS));
- break;
- }
- case FK_POINTING_TO_ITEMS_CLASS:
- {
- logger.debug(" < " + tags.getTagById(FK_POINTING_TO_ITEMS_CLASS));
- break;
- }
- case ATTRIBUTE:
- {
- logger.debug(" < " + tags.getTagById(ATTRIBUTE));
- break;
- }
+package org.apache.ojb.broker.metadata;
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ * "Apache ObjectRelationalBridge" must not be used to endorse or promote products
+ * derived from this software without prior written permission. For
+ * written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
+ * prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+import org.apache.ojb.broker.PersistenceBrokerException;
+import org.apache.ojb.broker.util.logging.Logger;
+import org.apache.ojb.broker.util.logging.LoggerFactory;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * The handler catches Parsing events raised by the xml-parser
+ * and builds up the DescriptorRepository that is used within the
+ * OJB PersistenceBroker System.
+ *
+ * @author <a href="mailto:thma@apache.org">Thomas Mahler<a>
+ * @author Jakob Br�uchi
+ * @version $Id$
+ */
+public class RepositoryXmlHandler
+ extends DefaultHandler
+ implements RepositoryElements, IsolationLevels
+{
+ private Logger logger;
+
+ private DescriptorRepository m_repository;
+ private JdbcConnectionDescriptor m_CurrentJCD;
+ private ClassDescriptor m_CurrentCLD;
+ private FieldDescriptor m_CurrentFLD;
+ private ObjectReferenceDescriptor m_CurrentORD;
+ private CollectionDescriptor m_CurrentCOD;
+ private String m_CurrentString;
+ /** holds custom attributes */
+ private AttributeContainer m_CurrentAttrContainer;
+
+ /** the default isolation level*/
+ private int defIsoLevel = IL_DEFAULT;
+
+ /**
+ * All known xml tags are kept in this table.
+ * The tags table allows lookup from literal to id
+ * and from id to literal.
+ */
+ private RepositoryTags tags = RepositoryTags.getInstance();
+
+ /**
+ * returns the XmlCapable id associated with the literal.
+ * OJB maintains a RepositoryTags table that provides
+ * a mapping from xml-tags to XmlCapable ids.
+ * @param literal the literal to lookup
+ * @return the int value representing the XmlCapable
+ *
+ * @throws MetadataException if no literal was found in tags mapping
+ */
+ private int getLiteralId(String literal) throws PersistenceBrokerException
+ {
+ //logger.debug("lookup: " + literal);
+ try
+ {
+ return tags.getIdByTag(literal);
+ }
+ catch (NullPointerException t)
+ {
+ throw new MetadataException("unknown literal: '" + literal + "'",t);
+ }
+
+ }
+
+ /**
+ * build a handler that fills the given repository
+ * from an XML file.
+ */
+ public RepositoryXmlHandler(DescriptorRepository dr)
+ {
+ if (dr != null)
+ {
+ m_repository = dr;
+ }
+ else
+ {
+ m_repository = DescriptorRepository.getDefaultInstance();
+ }
+ logger = LoggerFactory.getLogger(this.getClass());
+ }
+
+ /**
+ * startDocument callback, nothing to do here.
+ */
+ public void startDocument()
+ {
+ logger.debug("startDoc");
+ }
+
+ /**
+ * endDocument callback, nothing to do here.
+ */
+ public void endDocument()
+ {
+ logger.debug("endDoc");
+ }
+
+ /**
+ * startElement callback.
+ * Only some Elements need special start operations.
+ * @throws MetadataException indicating mapping errors
+ */
+ public void startElement(String uri, String name, String qName, Attributes atts)
+ {
+ m_CurrentString = null;
+ try
+ {
+ switch (getLiteralId(qName))
+ {
+ case MAPPING_REPOSITORY :
+ {
+ String defIso = atts.getValue(tags.getTagById(ISOLATION_LEVEL));
+ if (defIso != null)
+ {
+ defIsoLevel = getIsoLevel(defIso);
+ }
+
+ // check repository version:
+ String version = atts.getValue(tags.getTagById(REPOSITORY_VERSION));
+ if (DescriptorRepository.getVersion().equals(version))
+ {
+ }
+ else
+ {
+ throw new MetadataException("Repository version does not match. expected " +
+ DescriptorRepository.getVersion() + " but found: " +
+ version);
+ }
+
+ logger.debug(" > " + tags.getTagById(MAPPING_REPOSITORY));
+
+ break;
+ }
+ case JDBC_CONNECTION_DESCRIPTOR :
+ {
+ logger.debug(" > " + tags.getTagById(JDBC_CONNECTION_DESCRIPTOR));
+ m_CurrentJCD = new JdbcConnectionDescriptor();
+ if (m_CurrentCLD == null)
+ {
+ m_repository.setDefaultJdbcConnection(m_CurrentJCD);
+ }
+ else
+ {
+ m_CurrentCLD.setConnectionDescriptor(m_CurrentJCD);
+ }
+ // set platform attribute
+ String platform = atts.getValue(tags.getTagById(DBMS_NAME));
+ logger.debug(" " + tags.getTagById(DBMS_NAME) + ": " + platform);
+ m_CurrentJCD.setDbms(platform);
+
+ // set jdbc-level attribute
+ String level = atts.getValue(tags.getTagById(JDBC_LEVEL));
+ logger.debug(" " + tags.getTagById(JDBC_LEVEL) + ": " + level);
+ m_CurrentJCD.setJdbcLevel(level);
+
+ // set driver attribute
+ String driver = atts.getValue(tags.getTagById(DRIVER_NAME));
+ logger.debug(" " + tags.getTagById(DRIVER_NAME) + ": " + driver);
+ m_CurrentJCD.setDriver(driver);
+
+ // set protocol attribute
+ String protocol = atts.getValue(tags.getTagById(URL_PROTOCOL));
+ logger.debug(" " + tags.getTagById(URL_PROTOCOL) + ": " + protocol);
+ m_CurrentJCD.setProtocol(protocol);
+
+ // set subprotocol attribute
+ String subprotocol = atts.getValue(tags.getTagById(URL_SUBPROTOCOL));
+ logger.debug(" " + tags.getTagById(URL_SUBPROTOCOL) + ": " + subprotocol);
+ m_CurrentJCD.setSubProtocol(subprotocol);
+
+ // set the dbalias attribute
+ String dbalias = atts.getValue(tags.getTagById(URL_DBALIAS));
+ logger.debug(" " + tags.getTagById(URL_DBALIAS) + ": " + dbalias);
+ m_CurrentJCD.setDbAlias(dbalias);
+
+ // set the datasource attribute
+ String datasource = atts.getValue(tags.getTagById(DATASOURCE_NAME));
+ logger.debug(" " + tags.getTagById(DATASOURCE_NAME) + ": " + datasource);
+ m_CurrentJCD.setDatasourceName(datasource);
+
+ // set the user attribute
+ String user = atts.getValue(tags.getTagById(USER_NAME));
+ logger.debug(" " + tags.getTagById(USER_NAME) + ": " + user);
+ m_CurrentJCD.setUserName(user);
+
+ // set the password attribute
+ String password = atts.getValue(tags.getTagById(USER_PASSWD));
+ logger.debug(" " + tags.getTagById(USER_PASSWD) + ": " + password);
+ m_CurrentJCD.setPassWord(password);
+
+ // set eager-release attribute
+ String eagerRelease = atts.getValue(tags.getTagById(EAGER_RELEASE));
+ logger.debug(" " + tags.getTagById(EAGER_RELEASE) + ": " + eagerRelease);
+ m_CurrentJCD.setEagerRelease(Boolean.valueOf(eagerRelease).booleanValue());
+
+ break;
+ }
+ case CLASS_DESCRIPTOR :
+ {
+ logger.debug(" > " + tags.getTagById(CLASS_DESCRIPTOR));
+ m_CurrentCLD = new ClassDescriptor(m_repository);
+
+ // prepare for custom attributes
+ this.m_CurrentAttrContainer = this.m_CurrentCLD;
+
+ // set isolation-level attribute
+ String isoLevel = atts.getValue(tags.getTagById(ISOLATION_LEVEL));
+ logger.debug(" " + tags.getTagById(ISOLATION_LEVEL) + ": " + isoLevel);
+ m_CurrentCLD.setIsolationLevel(getIsoLevel(isoLevel));
+
+ // set class attribute
+ String classname = atts.getValue(tags.getTagById(CLASS_NAME));
+ logger.debug(" " + tags.getTagById(CLASS_NAME) + ": " + classname);
+ m_CurrentCLD.setIsolationLevel(getIsoLevel(isoLevel));
+ try
+ {
+ m_CurrentCLD.setClassNameOfObject(classname);
+ m_repository.put(classname, m_CurrentCLD);
+ }
+ catch (Exception ex)
+ {
+ logger.error(ex);
+ throw new PersistenceBrokerException(ex);
+ }
+
+ // set schema attribute
+ String schema = atts.getValue(tags.getTagById(SCHEMA_NAME));
+ if (schema != null)
+ {
+ logger.debug(" " + tags.getTagById(SCHEMA_NAME) + ": " + schema);
+ m_CurrentCLD.setSchema(schema);
+ }
+
+ // set proxy attribute
+ String proxy = atts.getValue(tags.getTagById(CLASS_PROXY));
+ logger.debug(" " + tags.getTagById(CLASS_PROXY) + ": " + proxy);
+ if (proxy != null)
+ {
+ if (proxy.equalsIgnoreCase("dynamic"))
+ {
+ m_CurrentCLD.setProxyClassName("dynamic");
+ }
+ else
+ {
+ m_CurrentCLD.setProxyClassName(proxy);
+ }
+ }
+
+ // set table attribute:
+ String table = atts.getValue(tags.getTagById(TABLE_NAME));
+ logger.debug(" " + tags.getTagById(TABLE_NAME) + ": " + table);
+ m_CurrentCLD.setTableName(table);
+ if (table == null)
+ {
+ m_CurrentCLD.setIsInterface(true);
+ }
+
+ // set row-reader attribute
+ String rowreader = atts.getValue(tags.getTagById(ROW_READER));
+ logger.debug(" " + tags.getTagById(ROW_READER) + ": " + rowreader);
+ if (rowreader != null)
+ {
+ m_CurrentCLD.setRowReaderClassName(rowreader);
+ }
+
+ // set if extends
+ // set row-reader attribute
+ String extendsAtt = atts.getValue(tags.getTagById(EXTENDS));
+ logger.debug(" " + tags.getTagById(EXTENDS) + ": " + extendsAtt);
+ if (extendsAtt != null)
+ {
+ m_CurrentCLD.setSuperClass(extendsAtt);
+ }
+
+ //set accept-locks attribute
+ String acceptLocks = atts.getValue(tags.getTagById(ACCEPT_LOCKS));
+ logger.debug(" " + tags.getTagById(ACCEPT_LOCKS) + ": " + acceptLocks);
+ boolean b = (new Boolean(acceptLocks)).booleanValue();
+ m_CurrentCLD.setAcceptLocks(b);
+
+ break;
+ }
+
+ case CLASS_EXTENT :
+ {
+ String classname = atts.getValue("class-ref");
+ logger.debug(" " + tags.getTagById(CLASS_EXTENT) + ": " + classname);
+ m_CurrentCLD.addExtentClassName(classname);
+ break;
+ }
+ /* case EXTENDS :
+ {
+ String classname = atts.getValue("class-ref");
+ logger.debug(" " + tags.getTagById(EXTENDS) + ": " + classname);
+ m_CurrentCLD.setSuperClass(classname);
+
+ // get key for super class
+ String fieldref = atts.getValue("field-id-ref");
+ try
+ {
+ int fieldId;
+ fieldId = Integer.parseInt(fieldref);
+ logger.debug(" " + tags.getTagById(EXTENDS) + ": " +fieldId);
+ m_CurrentCLD.setSuperClassFieldRef(fieldId);
+ }
+ catch (NumberFormatException rex)
+ {
+ throw new MetadataException(tags.getTagById(EXTENDS)
+ + " attribute must be an int. Found: "
+ + fieldref,rex);
+ }
+
+
+ break;
+ }*/
+
+ case FIELD_DESCRIPTOR :
+ {
+ logger.debug(" > " + tags.getTagById(FIELD_DESCRIPTOR));
+
+ int id = Integer.parseInt(atts.getValue("id"));
+ m_CurrentFLD = new FieldDescriptor(id);
+ m_CurrentCLD.addFieldDescriptor(m_CurrentFLD);
+
+ // prepare for custom attributes
+ this.m_CurrentAttrContainer = this.m_CurrentFLD;
+
+ String fieldName = atts.getValue(tags.getTagById(FIELD_NAME));
+ logger.debug(" " + tags.getTagById(FIELD_NAME) + ": " + fieldName);
+ String classname = m_CurrentCLD.getClassNameOfObject();
+ m_CurrentFLD.setPersistentField(classname, fieldName);
+
+ String columnName = atts.getValue(tags.getTagById(COLUMN_NAME));
+ logger.debug(" " + tags.getTagById(COLUMN_NAME) + ": " + columnName);
+ m_CurrentFLD.setColumnName(columnName);
+
+ String jdbcType = atts.getValue(tags.getTagById(JDBC_TYPE));
+ logger.debug(" " + tags.getTagById(JDBC_TYPE) + ": " + jdbcType);
+ m_CurrentFLD.setColumnType(jdbcType);
+
+ String primaryKey = atts.getValue(tags.getTagById(PRIMARY_KEY));
+ logger.debug(" " + tags.getTagById(PRIMARY_KEY) + ": " + primaryKey);
+ boolean b = (new Boolean(primaryKey)).booleanValue();
+ m_CurrentFLD.setPrimaryKey(b);
+
+ String nullable = atts.getValue(tags.getTagById(NULLABLE));
+ if (nullable != null)
+ {
+ logger.debug(" " + tags.getTagById(NULLABLE) + ": " + nullable);
+ b = ! (new Boolean(nullable)).booleanValue();
+ m_CurrentFLD.setRequired(b);
+ }
+
+ String indexed = atts.getValue(tags.getTagById(INDEXED));
+ logger.debug(" " + tags.getTagById(INDEXED) + ": " + indexed);
+ b = (new Boolean(indexed)).booleanValue();
+ m_CurrentFLD.setIndexed(b);
+
+ String autoincrement = atts.getValue(tags.getTagById(AUTO_INCREMENT));
+ logger.debug(" " + tags.getTagById(AUTO_INCREMENT) + ": " + autoincrement);
+ b = (new Boolean(autoincrement)).booleanValue();
+ m_CurrentFLD.setAutoIncrement(b);
+
+ String sequenceName = atts.getValue(tags.getTagById(SEQUENCE_NAME));
+ logger.debug(" " + tags.getTagById(SEQUENCE_NAME) + ": " + sequenceName);
+ m_CurrentFLD.setSequenceName(sequenceName);
+
+ String locking = atts.getValue(tags.getTagById(LOCKING));
+ logger.debug(" " + tags.getTagById(LOCKING) + ": " + locking);
+ b = (new Boolean(locking)).booleanValue();
+ m_CurrentFLD.setLocking(b);
+
+ String fieldConversion = atts.getValue(tags.getTagById(FIELD_CONVERSION));
+ logger.debug(" " + tags.getTagById(FIELD_CONVERSION) + ": " + fieldConversion);
+ if (fieldConversion != null)
+ {
+ m_CurrentFLD.setFieldConversionClassName(fieldConversion);
+ }
+
+ // set length attribute
+ String length = atts.getValue(tags.getTagById(LENGTH));
+ if (length != null)
+ {
+ int i = Integer.parseInt(length);
+ logger.debug(" " + tags.getTagById(LENGTH) + ": " + i);
+ m_CurrentFLD.setLength(i);
+ m_CurrentFLD.setLengthSpecified(true);
+ }
+
+ // set precision attribute
+ String precision = atts.getValue(tags.getTagById(PRECISION));
+ if (precision != null)
+ {
+ int i = Integer.parseInt(precision);
+ logger.debug(" " + tags.getTagById(PRECISION) + ": " + i);
+ m_CurrentFLD.setPrecision(i);
+ m_CurrentFLD.setPrecisionSpecified(true);
+ }
+
+ // set scale attribute
+ String scale = atts.getValue(tags.getTagById(SCALE));
+ if (scale != null)
+ {
+ int i = Integer.parseInt(scale);
+ logger.debug(" " + tags.getTagById(SCALE) + ": " + i);
+ m_CurrentFLD.setScale(i);
+ m_CurrentFLD.setScaleSpecified(true);
+ }
+
+ break;
+ }
+ case REFERENCE_DESCRIPTOR :
+ {
+ logger.debug(" > " + tags.getTagById(REFERENCE_DESCRIPTOR));
+ m_CurrentORD = new ObjectReferenceDescriptor();
+ m_CurrentCLD.addObjectReferenceDescriptor(m_CurrentORD);
+
+ // prepare for custom attributes
+ this.m_CurrentAttrContainer = m_CurrentORD;
+
+ // set name attribute
+ name = atts.getValue(tags.getTagById(FIELD_NAME));
+ logger.debug(" " + tags.getTagById(FIELD_NAME) + ": " + name);
+ m_CurrentORD.setPersistentField(m_CurrentCLD.getClassNameOfObject(), name);
+
+ // set class-ref attribute
+ String classRef = atts.getValue(tags.getTagById(REFERENCED_CLASS));
+ logger.debug(" " + tags.getTagById(REFERENCED_CLASS) + ": " + classRef);
+ m_CurrentORD.setItemClassName(classRef);
+
+ // set proxy attribute
+ String proxy = atts.getValue(tags.getTagById(PROXY_REFERENCE));
+ logger.debug(" " + tags.getTagById(PROXY_REFERENCE) + ": " + proxy);
+ boolean b = (new Boolean(proxy)).booleanValue();
+ m_CurrentORD.setLazy(b);
+
+ // set refresh attribute
+ String refresh = atts.getValue(tags.getTagById(REFRESH_REFERENCE));
+ logger.debug(" " + tags.getTagById(REFRESH_REFERENCE) + ": " + refresh);
+ b = (new Boolean(refresh)).booleanValue();
+ m_CurrentORD.setRefresh(b);
+
+ // set auto-retrieve attribute
+ String autoRetrieve = atts.getValue(tags.getTagById(AUTO_RETRIEVE));
+ logger.debug(" " + tags.getTagById(AUTO_RETRIEVE) + ": " + autoRetrieve);
+ b = (new Boolean(autoRetrieve)).booleanValue();
+ m_CurrentORD.setCascadeRetrieve(b);
+
+ // set auto-update attribute
+ String autoUpdate = atts.getValue(tags.getTagById(AUTO_UPDATE));
+ logger.debug(" " + tags.getTagById(AUTO_UPDATE) + ": " + autoUpdate);
+ b = (new Boolean(autoUpdate)).booleanValue();
+ m_CurrentORD.setCascadeStore(b);
+
+ //set auto-delete attribute
+ String autoDelete = atts.getValue(tags.getTagById(AUTO_DELETE));
+ logger.debug(" " + tags.getTagById(AUTO_DELETE) + ": " + autoDelete);
+ b = (new Boolean(autoDelete)).booleanValue();
+ m_CurrentORD.setCascadeDelete(b);
+
+ break;
+ }
+
+ case FOREIGN_KEY :
+ {
+ logger.debug(" > " + tags.getTagById(FOREIGN_KEY));
+ String fieldIdRef = atts.getValue(tags.getTagById(FIELD_ID_REF));
+ logger.debug(" " + tags.getTagById(FIELD_ID_REF) + ": " + fieldIdRef);
+
+ try
+ {
+ int fieldId;
+ fieldId = Integer.parseInt(fieldIdRef);
+ m_CurrentORD.addForeignKeyField(fieldId);
+ }
+ catch (NumberFormatException rex)
+ {
+ throw new MetadataException(tags.getTagById(FIELD_ID_REF)
+ + " attribute must be an int. Found: "
+ + fieldIdRef,rex);
+ }
+ break;
+ }
+
+ case COLLECTION_DESCRIPTOR :
+ {
+ logger.debug(" > " + tags.getTagById(COLLECTION_DESCRIPTOR));
+ m_CurrentCOD = new CollectionDescriptor();
+ m_CurrentCLD.addCollectionDescriptor(m_CurrentCOD);
+
+ // prepare for custom attributes
+ this.m_CurrentAttrContainer = m_CurrentCOD;
+
+ // set name attribute
+ name = atts.getValue(tags.getTagById(FIELD_NAME));
+ logger.debug(" " + tags.getTagById(FIELD_NAME) + ": " + name);
+ m_CurrentCOD.setPersistentField(m_CurrentCLD.getClassNameOfObject(), name);
+
+ // set collection-class attribute
+ String collectionClassName = atts.getValue(tags.getTagById(COLLECTION_CLASS));
+ if (collectionClassName != null)
+ {
+ logger.debug(" " + tags.getTagById(COLLECTION_CLASS) + ": " + collectionClassName);
+ m_CurrentCOD.setCollectionClassName(collectionClassName);
+ }
+ // set element-class-ref attribute
+ String elementClassRef = atts.getValue(tags.getTagById(ITEMS_CLASS));
+ logger.debug(" " + tags.getTagById(ITEMS_CLASS) + ": " + elementClassRef);
+ if (elementClassRef != null)
+ {
+ m_CurrentCOD.setItemClassName(elementClassRef);
+ }
+
+ //set orderby and sort attributes:
+ String orderby = atts.getValue(tags.getTagById(ORDERBY));
+ String sort = atts.getValue(tags.getTagById(SORT));
+ logger.debug(" " + tags.getTagById(SORT) + ": " + orderby + ", " + sort);
+
+ if (orderby != null)
+ {
+ boolean isAsc = true;
+ if ("DESC".equalsIgnoreCase(sort))
+ {
+ isAsc = false;
+ }
+ m_CurrentCOD.setOrderBy(orderby);
+ m_CurrentCOD.setAscending(isAsc);
+ }
+
+ // set indirection-table attribute
+ String indirectionTable = atts.getValue(tags.getTagById(INDIRECTION_TABLE));
+ logger.debug(" " + tags.getTagById(INDIRECTION_TABLE) + ": " + indirectionTable);
+ m_CurrentCOD.setIndirectionTable(indirectionTable);
+
+ // set proxy attribute
+ String proxy = atts.getValue(tags.getTagById(PROXY_REFERENCE));
+ logger.debug(" " + tags.getTagById(PROXY_REFERENCE) + ": " + proxy);
+ boolean b = (new Boolean(proxy)).booleanValue();
+ m_CurrentCOD.setLazy(b);
+
+ // set refresh attribute
+ String refresh = atts.getValue(tags.getTagById(REFRESH_REFERENCE));
+ logger.debug(" " + tags.getTagById(REFRESH_REFERENCE) + ": " + refresh);
+ b = (new Boolean(refresh)).booleanValue();
+ m_CurrentCOD.setRefresh(b);
+
+ // set auto-retrieve attribute
+ String autoRetrieve = atts.getValue(tags.getTagById(AUTO_RETRIEVE));
+ logger.debug(" " + tags.getTagById(AUTO_RETRIEVE) + ": " + autoRetrieve);
+ b = (new Boolean(autoRetrieve)).booleanValue();
+ m_CurrentCOD.setCascadeRetrieve(b);
+
+ // set auto-update attribute
+ String autoUpdate = atts.getValue(tags.getTagById(AUTO_UPDATE));
+ logger.debug(" " + tags.getTagById(AUTO_UPDATE) + ": " + autoUpdate);
+ b = (new Boolean(autoUpdate)).booleanValue();
+ m_CurrentCOD.setCascadeStore(b);
+
+ //set auto-delete attribute
+ String autoDelete = atts.getValue(tags.getTagById(AUTO_DELETE));
+ logger.debug(" " + tags.getTagById(AUTO_DELETE) + ": " + autoDelete);
+ b = (new Boolean(autoDelete)).booleanValue();
+ m_CurrentCOD.setCascadeDelete(b);
+
+ break;
+ }
+ case INVERSE_FK :
+ {
+ logger.debug(" > " + tags.getTagById(INVERSE_FK));
+ String fieldIdRef = atts.getValue(tags.getTagById(FIELD_ID_REF));
+ logger.debug(" " + tags.getTagById(FIELD_ID_REF) + ": " + fieldIdRef);
+
+ try
+ {
+ int fieldId;
+ fieldId = Integer.parseInt(fieldIdRef);
+ m_CurrentCOD.addForeignKeyField(fieldId);
+ }
+ catch (NumberFormatException rex)
+ {
+ throw new MetadataException(tags.getTagById(FIELD_ID_REF)
+ + " attribute must be an int. Found: "
+ + fieldIdRef,rex);
+ }
+ break;
+ }
+
+ case FK_POINTING_TO_THIS_CLASS :
+ {
+ logger.debug(" > " + tags.getTagById(FK_POINTING_TO_THIS_CLASS));
+ String column = atts.getValue("column");
+ logger.debug(" " + "column" + ": " + column);
+ m_CurrentCOD.addFkToThisClass(column);
+ break;
+ }
+
+ case FK_POINTING_TO_ITEMS_CLASS :
+ {
+ logger.debug(" > " + tags.getTagById(FK_POINTING_TO_ITEMS_CLASS));
+ String column = atts.getValue("column");
+ logger.debug(" " + "column" + ": " + column);
+ m_CurrentCOD.addFkToItemClass(column);
+ break;
+ }
+ case CONNECTION_POOL :
+ {
+ logger.debug(" > " + tags.getTagById(CONNECTION_POOL));
+ ConnectionPoolDescriptor m_CurrentCPD = m_CurrentJCD.getConnectionPoolDescriptor();
+
+ String maxActive = atts.getValue(tags.getTagById(CON_MAX_ACTIVE));
+ logger.debug(" " + tags.getTagById(CON_MAX_ACTIVE) + ": " + maxActive);
+ if(checkString(maxActive)) m_CurrentCPD.setMaxActive(new Integer(maxActive).intValue());
+
+ String maxIdle = atts.getValue(tags.getTagById(CON_MAX_IDLE));
+ logger.debug(" " + tags.getTagById(CON_MAX_IDLE) + ": " + maxIdle);
+ if(checkString(maxIdle)) m_CurrentCPD.setMaxIdle(new Integer(maxIdle).intValue());
+
+ String maxWait = atts.getValue(tags.getTagById(CON_MAX_WAIT));
+ logger.debug(" " + tags.getTagById(CON_MAX_WAIT) + ": " + maxWait);
+ if(checkString(maxWait)) m_CurrentCPD.setMaxWait(new Integer(maxWait).intValue());
+
+ String minEvictableIdleTimeMillis = atts.getValue(tags.getTagById(CON_MIN_EVICTABLE_IDLE_TIME_MILLIS));
+ logger.debug(" " + tags.getTagById(CON_MIN_EVICTABLE_IDLE_TIME_MILLIS) + ": " + minEvictableIdleTimeMillis);
+ if(checkString(minEvictableIdleTimeMillis)) m_CurrentCPD.setMinEvictableIdleTimeMillis(new Long(minEvictableIdleTimeMillis).longValue());
+
+ String numTestsPerEvictionRun = atts.getValue(tags.getTagById(CON_NUM_TESTS_PER_EVICTION_RUN));
+ logger.debug(" " + tags.getTagById(CON_NUM_TESTS_PER_EVICTION_RUN) + ": " + numTestsPerEvictionRun);
+ if(checkString(numTestsPerEvictionRun)) m_CurrentCPD.setNumTestsPerEvictionRun(new Integer(numTestsPerEvictionRun).intValue());
+
+ String testOnBorrow = atts.getValue(tags.getTagById(CON_TEST_ON_BORROW));
+ logger.debug(" " + tags.getTagById(CON_TEST_ON_BORROW) + ": " + testOnBorrow);
+ if(checkString(testOnBorrow)) m_CurrentCPD.setTestOnBorrow(new Boolean(testOnBorrow).booleanValue());
+
+ String testOnReturn = atts.getValue(tags.getTagById(CON_TEST_ON_RETURN));
+ logger.debug(" " + tags.getTagById(CON_TEST_ON_RETURN) + ": " + testOnReturn);
+ if(checkString(testOnReturn)) m_CurrentCPD.setTestOnReturn(new Boolean(testOnReturn).booleanValue());
+
+ String testWhileIdle = atts.getValue(tags.getTagById(CON_TEST_WHILE_IDLE));
+ logger.debug(" " + tags.getTagById(CON_TEST_WHILE_IDLE) + ": " + testWhileIdle);
+ if(checkString(testWhileIdle)) m_CurrentCPD.setTestWhileIdle(new Boolean(testWhileIdle).booleanValue());
+
+ String timeBetweenEvictionRunsMillis = atts.getValue(tags.getTagById(CON_TIME_BETWEEN_EVICTION_RUNS_MILLIS));
+ logger.debug(" " + tags.getTagById(CON_TIME_BETWEEN_EVICTION_RUNS_MILLIS) + ": " + timeBetweenEvictionRunsMillis);
+ if(checkString(timeBetweenEvictionRunsMillis)) m_CurrentCPD.setTimeBetweenEvictionRunsMillis(new Long(timeBetweenEvictionRunsMillis).longValue());
+
+ String whenExhaustedAction = atts.getValue(tags.getTagById(CON_WHEN_EXHAUSTED_ACTION));
+ logger.debug(" " + tags.getTagById(CON_WHEN_EXHAUSTED_ACTION) + ": " + whenExhaustedAction);
+ if(checkString(whenExhaustedAction)) m_CurrentCPD.setWhenExhaustedAction(new Byte(whenExhaustedAction).byteValue());
+
+ String connectionFactoryStr = atts.getValue(tags.getTagById(CONNECTION_FACTORY));
+ logger.debug(" " + tags.getTagById(CONNECTION_FACTORY) + ": " + connectionFactoryStr);
+ if(checkString(connectionFactoryStr)) m_CurrentCPD.setConnectionFactory(connectionFactoryStr);
+ break;
+ }
+
+ case ATTRIBUTE :
+ {
+ //handle custom attributes
+ String attributeName = atts.getValue(tags.getTagById(ATTRIBUTE_NAME));
+ String attributeValue = atts.getValue(tags.getTagById(ATTRIBUTE_VALUE));
+ logger.debug(" > " + tags.getTagById(ATTRIBUTE));
+ logger.debug(" " + tags.getTagById(ATTRIBUTE_NAME) + ": " + attributeName);
+ logger.debug(" " + tags.getTagById(ATTRIBUTE_VALUE) + ": " + attributeValue);
+ // If we have a container to store this attribute in, then do so.
+ if (this.m_CurrentAttrContainer!=null)
+ {
+ this.m_CurrentAttrContainer.addAttribute(attributeName,attributeValue);
+ }
+
+ }
+
+
+ default :
+ {
+ // nop
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ logger.error(ex);
+ throw new PersistenceBrokerException(ex);
+ }
+ }
+
+ private boolean checkString(String str)
+ {
+ return (str != null && !str.equals(""));
+ }
+
+ /**
+ * endElement callback. most elements are build up from here.
+ */
+ public void endElement(String uri, String name, String qName)
+ {
+ try
+ {
+ switch (getLiteralId(qName))
+ {
+ case MAPPING_REPOSITORY :
+ {
+ logger.debug(" < " + tags.getTagById(MAPPING_REPOSITORY));
+ break;
+ }
+ case JDBC_CONNECTION_DESCRIPTOR :
+ {
+ logger.debug(" < " + tags.getTagById(JDBC_CONNECTION_DESCRIPTOR));
+ break;
+ }
+ case CONNECTION_POOL :
+ {
+ logger.debug(" < " + tags.getTagById(CONNECTION_POOL));
+ break;
+ }
+ case CLASS_DESCRIPTOR :
+ {
+ logger.debug(" < " + tags.getTagById(CLASS_DESCRIPTOR));
+ m_CurrentCLD = null;
+ m_CurrentAttrContainer = null;
+ break;
+ }
+ case CLASS_EXTENT :
+ {
+ break;
+ }
+
+ case FIELD_DESCRIPTOR :
+ {
+ logger.debug(" < " + tags.getTagById(FIELD_DESCRIPTOR));
+ m_CurrentFLD = null;
+ m_CurrentAttrContainer = m_CurrentCLD;
+ break;
+ }
+ case REFERENCE_DESCRIPTOR :
+ {
+ logger.debug(" < " + tags.getTagById(REFERENCE_DESCRIPTOR));
+ m_CurrentORD = null;
+ m_CurrentAttrContainer = m_CurrentCLD;
+ break;
+ }
+ case FOREIGN_KEY :
+ {
+ logger.debug(" < " + tags.getTagById(FOREIGN_KEY));
+ break;
+ }
+
+ case COLLECTION_DESCRIPTOR :
+ {
+ logger.debug(" < " + tags.getTagById(COLLECTION_DESCRIPTOR));
+ m_CurrentCOD = null;
+ m_CurrentAttrContainer = m_CurrentCLD;
+ break;
+ }
+
+ case INVERSE_FK :
+ {
+ logger.debug(" < " + tags.getTagById(INVERSE_FK));
+ break;
+ }
+
+ case FK_POINTING_TO_THIS_CLASS :
+ {
+ logger.debug(" < " + tags.getTagById(FK_POINTING_TO_THIS_CLASS));
+ break;
+ }
+ case FK_POINTING_TO_ITEMS_CLASS :
+ {
+ logger.debug(" < " + tags.getTagById(FK_POINTING_TO_ITEMS_CLASS));
+ break;
+ }
+ case ATTRIBUTE :
+ {
+ logger.debug(" < " + tags.getTagById(ATTRIBUTE));
+ break;
+ }
case DOCUMENTATION:
{
logger.debug(" < " + tags.getTagById(DOCUMENTATION));
break;
}
- // handle failure:
- default :
- {
- logger.error("Ignoring unknown Element " + qName);
- }
- }
- }
- catch (Exception ex)
- {
- logger.error(ex);
- throw new PersistenceBrokerException(ex);
- }
- }
-
- /**
- * characters callback.
- */
- public void characters(char ch[], int start, int length)
- {
- if (m_CurrentString == null)
- m_CurrentString = new String(ch, start, length);
- else
- m_CurrentString += new String(ch, start, length);
- }
-
- /**
- * Error callback.
- */
- public void error(SAXParseException e) throws SAXException
- {
- logger.error(e);
- throw e;
- }
-
- /**
- * fatal error callback.
- */
- public void fatalError(SAXParseException e) throws SAXException
- {
- logger.fatal(e);
- throw e;
- }
-
- /**
- * warning callback.
- */
- public void warning(SAXParseException e) throws SAXException
- {
- logger.warn(e);
- throw e;
- }
-
- /**
- * maps IsolationLevel literals to the corresponding id
- * @param isoLevel
- * @return the id
- */
- private int getIsoLevel(String isoLevel)
- {
- if (isoLevel.equalsIgnoreCase(LITERAL_IL_READ_UNCOMMITTED))
- {
- return IL_READ_UNCOMMITTED;
- }
- else if (isoLevel.equalsIgnoreCase(LITERAL_IL_READ_COMMITTED))
- {
- return IL_READ_COMMITTED;
- }
- else if (isoLevel.equalsIgnoreCase(LITERAL_IL_REPEATABLE_READ))
- {
- return IL_REPEATABLE_READ;
- }
- else if (isoLevel.equalsIgnoreCase(LITERAL_IL_SERIALIZABLE))
- {
- return IL_SERIALIZABLE;
- }
- else if (isoLevel.equalsIgnoreCase(LITERAL_IL_OPTIMISTIC))
- {
- return IL_OPTIMISTIC;
- }
- logger.warn("unknown isolation-level: " + isoLevel + " using RW_UNCOMMITTED as default");
- return defIsoLevel;
- }
-
-
-}
+ // handle failure:
+ default :
+ {
+ logger.error("Ignoring unknown Element " + qName);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ logger.error(ex);
+ throw new PersistenceBrokerException(ex);
+ }
+ }
+
+ /**
+ * characters callback.
+ */
+ public void characters(char ch[], int start, int length)
+ {
+ if (m_CurrentString == null)
+ m_CurrentString = new String(ch, start, length);
+ else
+ m_CurrentString += new String(ch, start, length);
+ }
+
+ /**
+ * Error callback.
+ */
+ public void error(SAXParseException e) throws SAXException
+ {
+ logger.error(e);
+ throw e;
+ }
+
+ /**
+ * fatal error callback.
+ */
+ public void fatalError(SAXParseException e) throws SAXException
+ {
+ logger.fatal(e);
+ throw e;
+ }
+
+ /**
+ * warning callback.
+ */
+ public void warning(SAXParseException e) throws SAXException
+ {
+ logger.warn(e);
+ throw e;
+ }
+
+ /**
+ * maps IsolationLevel literals to the corresponding id
+ * @param isoLevel
+ * @return the id
+ */
+ private int getIsoLevel(String isoLevel)
+ {
+ if (isoLevel.equalsIgnoreCase(LITERAL_IL_READ_UNCOMMITTED))
+ {
+ return IL_READ_UNCOMMITTED;
+ }
+ else if (isoLevel.equalsIgnoreCase(LITERAL_IL_READ_COMMITTED))
+ {
+ return IL_READ_COMMITTED;
+ }
+ else if (isoLevel.equalsIgnoreCase(LITERAL_IL_REPEATABLE_READ))
+ {
+ return IL_REPEATABLE_READ;
+ }
+ else if (isoLevel.equalsIgnoreCase(LITERAL_IL_SERIALIZABLE))
+ {
+ return IL_SERIALIZABLE;
+ }
+ else if (isoLevel.equalsIgnoreCase(LITERAL_IL_OPTIMISTIC))
+ {
+ return IL_OPTIMISTIC;
+ }
+ logger.warn("unknown isolation-level: " + isoLevel + " using RW_UNCOMMITTED as default");
+ return defIsoLevel;
+ }
+
+
+}