db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: jakarta-ojb/src/java/org/apache/ojb/broker/ta PersistenceBrokerFactoryDefaultImpl.java PersistenceBrokerFactoryFactory.java PersistenceBrokerFactoryIF.java
Date Tue, 24 Dec 2002 13:20:03 GMT
arminw      2002/12/24 05:20:03

  Modified:    src/java/org/apache/ojb/broker/singlevm
                        DelegatingPersistenceBroker.java
                        PersistenceBrokerAbstractImpl.java
                        PersistenceBrokerImpl.java
               src/java/org/apache/ojb/broker/ta
                        PersistenceBrokerFactoryDefaultImpl.java
                        PersistenceBrokerFactoryFactory.java
                        PersistenceBrokerFactoryIF.java
  Log:
  improve metadata handling:
  separate the object stuff (class descriptor, field descriptor, ...)
  from the connection stuff (jdbc descriptor).
  DescriptorRepository now handles only object
  specific properties.
  
  Do some performance improvements
  
  Revision  Changes    Path
  1.4       +74 -61    jakarta-ojb/src/java/org/apache/ojb/broker/singlevm/DelegatingPersistenceBroker.java
  
  Index: DelegatingPersistenceBroker.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/singlevm/DelegatingPersistenceBroker.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DelegatingPersistenceBroker.java	1 Dec 2002 11:48:38 -0000	1.3
  +++ DelegatingPersistenceBroker.java	24 Dec 2002 13:20:03 -0000	1.4
  @@ -12,11 +12,14 @@
   import org.apache.ojb.broker.TransactionNotInProgressException;
   import org.apache.ojb.broker.accesslayer.ConnectionManagerIF;
   import org.apache.ojb.broker.accesslayer.StatementManagerIF;
  +import org.apache.ojb.broker.accesslayer.sql.SqlGenerator;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.metadata.DescriptorRepository;
   import org.apache.ojb.broker.metadata.FieldDescriptor;
   import org.apache.ojb.broker.query.Query;
   import org.apache.ojb.broker.util.ObjectModification;
  +import org.apache.ojb.broker.util.BrokerHelper;
  +import org.apache.ojb.broker.util.sequence.SequenceManager;
   import org.apache.ojb.broker.util.configuration.Configuration;
   import org.apache.ojb.broker.util.configuration.ConfigurationException;
   
  @@ -113,6 +116,11 @@
           return broker.close();
       }
   
  +    public SqlGenerator serviceSqlGenerator()
  +    {
  +        return broker.serviceSqlGenerator();
  +    }
  +
       public void delete(Object obj) throws PersistenceBrokerException
       {
           broker.delete(obj);
  @@ -134,11 +142,6 @@
           return broker.getPBKey();
       }
   
  -    public void setPBKey(PBKey key)
  -    {
  -        broker.setPBKey(key);
  -    }
  -
       public void removeFromCache(Object obj) throws PersistenceBrokerException
       {
           broker.removeFromCache(obj);
  @@ -184,86 +187,46 @@
           broker.retrieveAllReferences(pInstance);
       }
   
  -    public ConnectionManagerIF getConnectionManager()
  -    {
  -        return broker.getConnectionManager();
  -    }
  -
  -    public StatementManagerIF getStatementManager()
  -    {
  -        return broker.getStatementManager();
  -    }
  -
  -    public Class getExtentClass(Class clazz) throws PersistenceBrokerException
  -    {
  -        return broker.getExtentClass(clazz);
  -    }
  -
  -    public void setClassDescriptor(ClassDescriptor modifiedOrNewDescriptor) throws PersistenceBrokerException
  -    {
  -        broker.setClassDescriptor(modifiedOrNewDescriptor);
  -    }
  -
  -    public boolean hasClassDescriptor(Class clazz)
  -    {
  -        return broker.hasClassDescriptor(clazz);
  -    }
  -
  -    public ClassDescriptor getClassDescriptor(Class clazz) throws PersistenceBrokerException
  -    {
  -        return broker.getClassDescriptor(clazz);
  -    }
  -
  -    public Object getUniqueObject(Class extent, String attribute) throws PersistenceBrokerException
  +    public ConnectionManagerIF serviceConnectionManager()
       {
  -    	ClassDescriptor cld = broker.getClassDescriptor(extent);
  -    	FieldDescriptor fld = cld.getFieldDescriptorByName(attribute);
  -        return broker.getUniqueObject(fld);
  +        return broker.serviceConnectionManager();
       }
   
  -    public String getUniqueString(Class extent, String attribute) throws PersistenceBrokerException
  +    public StatementManagerIF serviceStatementManager()
       {
  -    	ClassDescriptor cld = broker.getClassDescriptor(extent);
  -    	FieldDescriptor fld = cld.getFieldDescriptorByName(attribute);   	
  -        return broker.getUniqueString(fld);
  +        return broker.serviceStatementManager();
       }
   
  -    public long getUniqueLong(Class extent, String attribute) throws PersistenceBrokerException
  +    public SequenceManager serviceSequenceManager()
       {
  -    	ClassDescriptor cld = broker.getClassDescriptor(extent);
  -    	FieldDescriptor fld = cld.getFieldDescriptorByName(attribute);
  -        return broker.getUniqueLong(fld);
  +        return broker.serviceSequenceManager();
       }
   
  -    public int getUniqueId(Class extent, String attribute) throws PersistenceBrokerException
  +    public BrokerHelper serviceBrokerHelper()
       {
  -    	ClassDescriptor cld = broker.getClassDescriptor(extent);
  -        FieldDescriptor fld = cld.getFieldDescriptorByName(attribute);   	
  -        return broker.getUniqueId(fld);
  +        return broker.serviceBrokerHelper();
       }
   
  -
  -    public int getUniqueId(FieldDescriptor field) throws PersistenceBrokerException
  +    public void fireBrokerEvent(Object instance, int eventId)
       {
  -        return broker.getUniqueId(field);
  +        broker.fireBrokerEvent(instance, eventId);
       }
   
  -    public long getUniqueLong(FieldDescriptor field) throws PersistenceBrokerException
  +    public Class getExtentClass(Class clazz) throws PersistenceBrokerException
       {
  -        return broker.getUniqueLong(field);
  +        return broker.getExtentClass(clazz);
       }
   
  -    public String getUniqueString(FieldDescriptor field) throws PersistenceBrokerException
  +    public boolean hasClassDescriptor(Class clazz)
       {
  -        return broker.getUniqueString(field);
  +        return broker.hasClassDescriptor(clazz);
       }
   
  -    public Object getUniqueObject(FieldDescriptor field) throws PersistenceBrokerException
  +    public ClassDescriptor getClassDescriptor(Class clazz) throws PersistenceBrokerException
       {
  -        return broker.getUniqueObject(field);
  +        return broker.getClassDescriptor(clazz);
       }
   
  -
       public Enumeration getPKEnumerationByQuery(Class primaryKeyClass,
                                                  Query query) throws PersistenceBrokerException
       {
  @@ -320,4 +283,54 @@
       {
           broker.deleteByQuery(query);
       }
  +
  +//    public Object getUniqueObject(Class extent, String attribute) throws PersistenceBrokerException
  +//    {
  +//        ClassDescriptor cld = broker.getClassDescriptor(extent);
  +//        FieldDescriptor fld = cld.getFieldDescriptorByName(attribute);
  +//        return broker.getUniqueObject(fld);
  +//    }
  +//
  +//    public String getUniqueString(Class extent, String attribute) throws PersistenceBrokerException
  +//    {
  +//        ClassDescriptor cld = broker.getClassDescriptor(extent);
  +//        FieldDescriptor fld = cld.getFieldDescriptorByName(attribute);
  +//        return broker.getUniqueString(fld);
  +//    }
  +//
  +//    public long getUniqueLong(Class extent, String attribute) throws PersistenceBrokerException
  +//    {
  +//        ClassDescriptor cld = broker.getClassDescriptor(extent);
  +//        FieldDescriptor fld = cld.getFieldDescriptorByName(attribute);
  +//        return broker.getUniqueLong(fld);
  +//    }
  +//
  +//    public int getUniqueId(Class extent, String attribute) throws PersistenceBrokerException
  +//    {
  +//        ClassDescriptor cld = broker.getClassDescriptor(extent);
  +//        FieldDescriptor fld = cld.getFieldDescriptorByName(attribute);
  +//        return broker.getUniqueId(fld);
  +//    }
  +//
  +//
  +//    public int getUniqueId(FieldDescriptor field) throws PersistenceBrokerException
  +//    {
  +//        return broker.getUniqueId(field);
  +//    }
  +//
  +//    public long getUniqueLong(FieldDescriptor field) throws PersistenceBrokerException
  +//    {
  +//        return broker.getUniqueLong(field);
  +//    }
  +//
  +//    public String getUniqueString(FieldDescriptor field) throws PersistenceBrokerException
  +//    {
  +//        return broker.getUniqueString(field);
  +//    }
  +//
  +//    public Object getUniqueObject(FieldDescriptor field) throws PersistenceBrokerException
  +//    {
  +//        return broker.getUniqueObject(field);
  +//    }
  +
   }
  
  
  
  1.6       +3 -8      jakarta-ojb/src/java/org/apache/ojb/broker/singlevm/PersistenceBrokerAbstractImpl.java
  
  Index: PersistenceBrokerAbstractImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/singlevm/PersistenceBrokerAbstractImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PersistenceBrokerAbstractImpl.java	13 Sep 2002 16:02:59 -0000	1.5
  +++ PersistenceBrokerAbstractImpl.java	24 Dec 2002 13:20:03 -0000	1.6
  @@ -63,18 +63,13 @@
   
   /**
    * Abstract Implementation of PersistenceBroker
  - * 
  + *
    * @see org.apache.ojb.broker.PersistenceBroker
    * @author Created by Charles on 12-Sep-2002 08:04:47
  - * @version $Id$ 
  + * @version $Id$
    */
   public abstract class PersistenceBrokerAbstractImpl implements PersistenceBroker
    {
  -    public static final int EVENT_BEFORE_STORE = 1;
  -    public static final int EVENT_AFTER_STORE = 2;
  -    public static final int EVENT_BEFORE_DELETE = 3;
  -    public static final int EVENT_AFTER_DELETE = 4;
  -    public static final int EVENT_AFTER_LOOKUP = 5;
       /**
        * A list of PersistenceBrokerListener instances
        */
  @@ -115,7 +110,7 @@
        *  EVENT_BEFORE_STORE, EVENT_AFTER_STORE, EVENT_BEFORE_DELETE,
        *  EVENT_AFTER_DELETE, EVENT_AFTER_LOOKUP;
        */
  -    public void invokeEvent(Object instance, int eventId)
  +    public void fireBrokerEvent(Object instance, int eventId)
       {
           if(instance instanceof PersistenceBrokerAware)
           {
  
  
  
  1.97      +239 -376  jakarta-ojb/src/java/org/apache/ojb/broker/singlevm/PersistenceBrokerImpl.java
  
  Index: PersistenceBrokerImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/singlevm/PersistenceBrokerImpl.java,v
  retrieving revision 1.96
  retrieving revision 1.97
  diff -u -r1.96 -r1.97
  --- PersistenceBrokerImpl.java	21 Dec 2002 16:12:49 -0000	1.96
  +++ PersistenceBrokerImpl.java	24 Dec 2002 13:20:03 -0000	1.97
  @@ -55,16 +55,15 @@
    */
   
   import java.lang.reflect.Array;
  -import java.sql.Connection;
   import java.util.ArrayList;
   import java.util.Collection;
   import java.util.Enumeration;
   import java.util.HashMap;
  -import java.util.HashSet;
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
   import java.util.Vector;
  +import java.util.HashSet;
   
   import org.apache.commons.beanutils.BeanUtils;
   import org.apache.ojb.broker.Identity;
  @@ -76,17 +75,7 @@
   import org.apache.ojb.broker.TransactionInProgressException;
   import org.apache.ojb.broker.TransactionNotInProgressException;
   import org.apache.ojb.broker.VirtualProxy;
  -import org.apache.ojb.broker.accesslayer.ChainingIterator;
  -import org.apache.ojb.broker.accesslayer.CollectionProxy;
  -import org.apache.ojb.broker.accesslayer.ConnectionManager;
  -import org.apache.ojb.broker.accesslayer.ConnectionManagerIF;
  -import org.apache.ojb.broker.accesslayer.JdbcAccess;
  -import org.apache.ojb.broker.accesslayer.LookupException;
  -import org.apache.ojb.broker.accesslayer.OJBIterator;
  -import org.apache.ojb.broker.accesslayer.PkEnumeration;
  -import org.apache.ojb.broker.accesslayer.ResultSetAndStatement;
  -import org.apache.ojb.broker.accesslayer.StatementManager;
  -import org.apache.ojb.broker.accesslayer.StatementManagerIF;
  +import org.apache.ojb.broker.accesslayer.*;
   import org.apache.ojb.broker.accesslayer.sql.SqlGenerator;
   import org.apache.ojb.broker.accesslayer.sql.SqlGeneratorFactory;
   import org.apache.ojb.broker.cache.ObjectCache;
  @@ -96,8 +85,9 @@
   import org.apache.ojb.broker.metadata.CollectionDescriptor;
   import org.apache.ojb.broker.metadata.DescriptorRepository;
   import org.apache.ojb.broker.metadata.FieldDescriptor;
  -import org.apache.ojb.broker.metadata.FieldHelper;
   import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor;
  +import org.apache.ojb.broker.metadata.MetadataManager;
  +import org.apache.ojb.broker.metadata.FieldHelper;
   import org.apache.ojb.broker.metadata.auto.AutoCreatorDb;
   import org.apache.ojb.broker.metadata.fieldaccess.PersistentField;
   import org.apache.ojb.broker.query.Criteria;
  @@ -113,10 +103,13 @@
   import org.apache.ojb.broker.server.PersistenceBrokerClient;
   import org.apache.ojb.broker.server.ServerEntry;
   import org.apache.ojb.broker.server.ServerPool;
  +import org.apache.ojb.broker.singlevm.PersistenceBrokerThreadMapping;
   import org.apache.ojb.broker.ta.PersistenceBrokerFactoryFactory;
   import org.apache.ojb.broker.ta.PersistenceBrokerFactoryIF;
   import org.apache.ojb.broker.util.ArrayIterator;
   import org.apache.ojb.broker.util.ObjectModification;
  +import org.apache.ojb.broker.util.SqlHelper;
  +import org.apache.ojb.broker.util.BrokerHelper;
   import org.apache.ojb.broker.util.ProxyHelper;
   import org.apache.ojb.broker.util.collections.ManageableArrayList;
   import org.apache.ojb.broker.util.collections.ManageableVector;
  @@ -150,15 +143,13 @@
    */
   public class PersistenceBrokerImpl extends PersistenceBrokerAbstractImpl implements PBState
   {
  -    private Logger logger = LoggerFactory.getLogger(getClass());
  -    /**
  -     * m_DbAccess is used to do all Jdbc related work: connecting, executing...
  -     */
  -    protected JdbcAccess dbAccess;
  -    /**
  -     * m_SqlGen is a simple SQL Generator that produces all SQL Queries
  -     */
  -    private SqlGenerator sqlGenerator = SqlGeneratorFactory.getInstance().createSqlGenerator();//SqlGenerator.getInstance();
  +    private Logger logger = LoggerFactory.getLogger(PersistenceBrokerImpl.class);
  +
  +    protected PersistenceBrokerFactoryIF pbf;
  +
  +    private boolean runningInServerMode;
  +    private ServerPool pool = null;
  +
       /**
        * m_ObjectCache caches object already loaded from db and protects the uniqueness
        * of objects. When an object is loaded from the db it is stored in the cache.
  @@ -167,20 +158,24 @@
        */
       private ObjectCache objectCache = ObjectCacheFactory.getInstance().getObjectCache();
       /**
  +     * m_DbAccess is used to do all Jdbc related work: connecting, executing...
  +     */
  +    protected JdbcAccess dbAccess;
  +    /**
        * signs if this broker was closed
        */
       private boolean isClosed;
       /**
        * holds mapping information for all classes to be treated by PersistenceBroker
        */
  -    protected DescriptorRepository descriptorRepository = null;
  -    protected ConnectionManagerIF connectionManager = null;
  -    protected SequenceManager sequenceManager = null;
  -    protected StatementManagerIF statementManager = null;
  -    protected PersistenceBrokerFactoryIF pbf;
  -    private ServerPool pool = null;
  -    private boolean runningInServerMode;
  -    protected PBKey pbKey;
  +    private DescriptorRepository descriptorRepository = null;
  +
  +    private ConnectionManagerIF connectionManager = null;
  +    private SequenceManager sequenceManager = null;
  +    private StatementManagerIF statementManager = null;
  +    private SqlGenerator sqlGenerator;
  +    private BrokerHelper brokerHelper;
  +    private PBKey pbKey;
   
       protected PersistenceBrokerImpl()
       {
  @@ -191,27 +186,62 @@
        */
       public PersistenceBrokerImpl(PBKey key, PersistenceBrokerFactoryIF pbf)
       {
  -        this.descriptorRepository = DescriptorRepository.getInstance(key);
  +        refresh();
           this.pbf = pbf;
           this.pbKey = key;
           connectionManager = new ConnectionManager(this);
           dbAccess = new JdbcAccess(this);
           sequenceManager = SequenceManagerFactory.getSequenceManager(this);
           statementManager = new StatementManager(this);
  +        sqlGenerator = SqlGeneratorFactory.getInstance().createSqlGenerator(
  +                        connectionManager.getSupportedPlatform());
  +        brokerHelper = new BrokerHelper(this);
       }
   
  -    /**
  -     * @deprecated
  -     */
  -    public PersistenceBrokerImpl(DescriptorRepository repository)
  +
  +
  +    public SqlGenerator serviceSqlGenerator()
       {
  -        descriptorRepository = repository;
  -        this.pbKey = repository.getPBkey();
  -        this.pbf = PersistenceBrokerFactoryFactory.instance();
  -        connectionManager = new ConnectionManager(this);
  -        dbAccess = new JdbcAccess(this);
  -        sequenceManager = SequenceManagerFactory.getSequenceManager(this);
  -        statementManager = new StatementManager(this);
  +        return this.sqlGenerator;
  +    }
  +
  +    public StatementManagerIF serviceStatementManager()
  +    {
  +        return statementManager;
  +    }
  +
  +    public ConnectionManagerIF serviceConnectionManager()
  +    {
  +        return connectionManager;
  +    }
  +
  +    public SequenceManager serviceSequenceManager()
  +    {
  +        return this.sequenceManager;
  +    }
  +
  +    public BrokerHelper serviceBrokerHelper()
  +    {
  +        return this.brokerHelper;
  +    }
  +
  +    public boolean isClosed()
  +    {
  +        return this.isClosed;
  +    }
  +
  +    public void setClosed(boolean closed)
  +    {
  +        if(closed == false)
  +        {
  +            refresh();
  +        }
  +        this.isClosed = closed;
  +    }
  +
  +    public void refresh()
  +    {
  +        this.descriptorRepository = MetadataManager.getInstance().getRepository();
       }
   
       /**
  @@ -250,16 +280,6 @@
           this.pbKey = key;
       }
   
  -    public boolean isClosed()
  -    {
  -        return this.isClosed;
  -    }
  -
  -    public void setClosed(boolean closed)
  -    {
  -        this.isClosed = closed;
  -    }
  -
       /**
        * @see org.apache.ojb.broker.PersistenceBroker#close()
        */
  @@ -342,16 +362,6 @@
           this.connectionManager.localCommit();
       }
   
  -    public StatementManagerIF getStatementManager()
  -    {
  -        return statementManager;
  -    }
  -
  -    public ConnectionManagerIF getConnectionManager()
  -    {
  -        return connectionManager;
  -    }
  -
       /**
        * deletes Object obj's representation in the underlying RDBMS
        */
  @@ -396,7 +406,6 @@
                   {
                       ec = (Class) extentClasses.get(i);
                       cld = getClassDescriptor(ec);
  -
                       // read same table only once
                       if (!cld.isInterface() && cld.getFullTableName().equals(lastUsedTable))
                       {
  @@ -436,8 +445,7 @@
           // only delete if object is not null
           if (obj != null)
           {
  -            obj = ProxyHelper.getRealObject(obj); 
  -
  +            obj = ProxyHelper.getRealObject(obj);
               /**
                * MBAIRD
                * 1. if we are marked for delete already, avoid recursing on this object
  @@ -453,13 +461,13 @@
               markedForDelete.put(obj, obj);
   
               // Invoke events on PersistenceBrokerAware instances and listeners
  -            invokeEvent(obj, EVENT_BEFORE_DELETE);
  +            fireBrokerEvent(obj, EVENT_BEFORE_DELETE);
   
               ClassDescriptor cld = descriptorRepository.getDescriptorFor(obj.getClass());
               // 1. delete dependend collections
               deleteCollections(obj, cld.getCollectionDescriptors(), markedForDelete);
               // 2. delete object from directly mapped table
  -            Identity oid = new Identity(obj, this);
  +            Identity oid = new Identity(obj, this, cld);
               dbAccess.executeDelete(cld, obj); // use obj not oid to delete, BRJ
               // 3. delete dependend upon objects last to avoid FK violations
               deleteReferences(obj, cld.getObjectReferenceDescriptors(), markedForDelete);
  @@ -467,7 +475,7 @@
               objectCache.remove(oid);
   
               // Invoke events on PersistenceBrokerAware instances and listeners
  -            invokeEvent(obj, EVENT_AFTER_DELETE);
  +            fireBrokerEvent(obj, EVENT_AFTER_DELETE);
           }
       }
   
  @@ -578,7 +586,6 @@
           }
       }
   
  -
       /**
        * Store an Object
        * @see org.apache.ojb.broker.PersistenceBroker#store(Object)
  @@ -597,12 +604,12 @@
               obj = ProxyHelper.getRealObjectIfMaterialized(obj);
               if (obj == null)    // null for unmaterialized Proxy
               {
  +                if(logger.isDebugEnabled())
  +                    logger.debug("No materialized object could be found -> nothing to store");
                   return;
               }
  -
               ClassDescriptor cld = descriptorRepository.getDescriptorFor(obj.getClass());
  -            Identity oid = new Identity(obj, this);
  -            
  +            Identity oid = new Identity(obj, this, cld);
               // check if update or insert is needed
               boolean doInsert = false;
               // lookup cache or db to see whether object needs insert or update
  @@ -611,7 +618,7 @@
                   doInsert = true;
                   // now store it:
               }
  -            store(obj, oid, doInsert, markedForStore);
  +            store(obj, oid, cld, doInsert, markedForStore);
           }
           // if Object == null do nothing
           else
  @@ -640,6 +647,11 @@
               {
                   store(ref, markedForStore);
               }
  +            else
  +            {
  +                if(logger.isEnabledFor(Logger.INFO)) logger.info("Cascade store for this reference ("+rds.getItemClassName()
  +                        +") was set to false.");
  +            }
           }
       }
   
  @@ -675,7 +687,7 @@
                   && (!(ref instanceof Proxy)))
           {
               ClassDescriptor refCld = descriptorRepository.getDescriptorFor(ref.getClass());
  -            Object[] refPkValues = refCld.getKeyValues(ref, false);
  +            Object[] refPkValues = brokerHelper.getKeyValues(refCld, ref, false);
               ClassDescriptor objCld = descriptorRepository.getDescriptorFor(obj.getClass());
               FieldDescriptor[] objFkFields = rds.getForeignKeyFieldDescriptors(objCld);
               if (objFkFields != null)
  @@ -708,7 +720,7 @@
               CollectionDescriptor cds = (CollectionDescriptor) i.next();
               Object col = cds.getPersistentField().get(obj);
               Collection currentMtoNKeys = null;
  -            
  +
               if (col != null)
               {
                   if (cds.isMtoNRelation())
  @@ -752,8 +764,7 @@
                   }
                   while (colIterator.hasNext())
                   {
  -                    Object otherObj = colIterator.next();          
  -                    
  +                    Object otherObj = colIterator.next();
                       // for m:n mapped collections store association implementing entries
                       if (cds.isMtoNRelation())
                       {
  @@ -795,12 +806,12 @@
        */
       private void storeMtoNImplementor(CollectionDescriptor cod, Object obj, Object otherObj, Collection mnKeys)
       {
  -        otherObj = ProxyHelper.getRealObject(otherObj);       
  +        otherObj = ProxyHelper.getRealObject(otherObj);
           ClassDescriptor cld = getDescriptorRepository().getDescriptorFor(obj.getClass());
  -        Object[] pkValues = cld.getKeyValues(obj);      
  +        Object[] pkValues = brokerHelper.getKeyValues(cld, obj);
           Object[] pkColumns = cod.getFksToThisClass();
           ClassDescriptor otherCld = getDescriptorRepository().getDescriptorFor(otherObj.getClass());
  -        Object[] otherPkValues = otherCld.getKeyValues(otherObj);
  +        Object[] otherPkValues = brokerHelper.getKeyValues(otherCld, otherObj);
           Object[] otherPkColumns = cod.getFksToItemClass();
           String table = cod.getIndirectionTable();
           Key key = new Key(otherPkValues);
  @@ -808,10 +819,11 @@
           if (mnKeys.contains(key))
           {
               return;
  -        }    
  -                
  -        String insertStmt = sqlGenerator.getInsertStatement(table, pkColumns, pkValues ,otherPkColumns ,otherPkValues);
  -		dbAccess.executeUpdateSQL(insertStmt, cld);
  +        }
  +
  +        String insertStmt = sqlGenerator.getInsertStatement(
  +                table, pkColumns, pkValues ,otherPkColumns ,otherPkValues);
  +        dbAccess.executeUpdateSQL(insertStmt, cld);
       }
   
       /**
  @@ -825,12 +837,12 @@
           ResultSetAndStatement rs;
           List result = new ArrayList();
           ClassDescriptor cld = getDescriptorRepository().getDescriptorFor(obj.getClass());
  -        Object[] pkValues = cld.getKeyValues(obj);
  +        Object[] pkValues = brokerHelper.getKeyValues(cld, obj);
           Object[] pkColumns = cod.getFksToThisClass();
           Object[] fkColumns = cod.getFksToItemClass();
           String table = cod.getIndirectionTable();
           String selectStmt = sqlGenerator.getSelectStatement(table, fkColumns, pkColumns, pkValues);
  -        
  +
           try
           {
               rs = dbAccess.executeSQL(selectStmt, cld);
  @@ -840,21 +852,21 @@
                   for (int i = 0; i < row.length; i++)
                   {
                       row[i] = rs.m_rs.getObject(i + 1);
  -                }  
  -                result.add(new Key(row));  
  -            }    
  +                }
  +                result.add(new Key(row));
  +            }
               rs.m_rs.close();
               rs.m_stmt.close();
           }
           catch (Exception e)
           {
               throw new PersistenceBrokerException(e);
  -        } 
  +        }
   
           return result;
       }
  -  
  -   /**
  +
  +    /**
       * delete all rows from m:n table belonging to obj
       * @param cod
       * @param obj
  @@ -862,14 +874,13 @@
       private void deleteMtoNImplementor(CollectionDescriptor cod, Object obj)
       {
           ClassDescriptor cld = getDescriptorRepository().getDescriptorFor(obj.getClass());
  -        Object[] pkValues = cld.getKeyValues(obj);
  +        Object[] pkValues = brokerHelper.getKeyValues(cld, obj);
           Object[] pkColumns = cod.getFksToThisClass();
           String table = cod.getIndirectionTable();
  -
           String deleteStmt = sqlGenerator.getDeleteStatement(table, pkColumns, pkValues, null ,null);
           dbAccess.executeUpdateSQL(deleteStmt, cld);
       }
  -  
  +
       /**
        * deletes all rows from m:n table that are not used in relatedObjects
        * @param cod
  @@ -882,33 +893,33 @@
           if (mnKeys.isEmpty() || relatedObjects == null)
           {
               return;
  -        }    
  -            
  +        }
  +
           List workList = new ArrayList(mnKeys);
           Iterator iter;
           Key relatedObjKeys;
           ClassDescriptor relatedCld = getDescriptorRepository().getDescriptorFor(cod.getItemClass());
           Object relatedObj;
  -     
  +
   		// remove keys of relatedObject from the existing m:n rows in workList
   		iter = relatedObjects.iterator();
   
   		while (iter.hasNext())
   		{
   			relatedObj = iter.next();
  -			relatedObjKeys = new Key(relatedCld.getKeyValues(relatedObj, true));
  +			relatedObjKeys = new Key(brokerHelper.getKeyValues(relatedCld, relatedObj, true));
   			workList.remove(relatedObjKeys);
   		}
  -	    
  -        // delete all remaining keys in workList 
  +
  +        // delete all remaining keys in workList
           ClassDescriptor cld = getDescriptorRepository().getDescriptorFor(obj.getClass());
  -        Object[] pkValues = cld.getKeyValues(obj);
  +        Object[] pkValues = brokerHelper.getKeyValues(cld, obj);
           Object[] pkColumns = cod.getFksToThisClass();
           Object[] fkValues;
           Object[] fkColumns = cod.getFksToItemClass();
           String table = cod.getIndirectionTable();
           String deleteStmt;
  -        
  +
           iter = workList.iterator();
           while (iter.hasNext())
           {
  @@ -916,9 +927,9 @@
               deleteStmt = sqlGenerator.getDeleteStatement(table, pkColumns, pkValues, fkColumns, fkValues);
               dbAccess.executeUpdateSQL(deleteStmt, cld);
           }
  -        
  +
       }
  -      
  +
       /**
        * retrieve all References (also Collection-attributes) of a given instance.
        * Loading is forced, even if the collection- and reference-descriptors differ.
  @@ -964,7 +975,7 @@
   
       /**
        * Retrieve all References
  -     * 
  +     *
        * @param newObj the instance to be loaded or refreshed
        * @param cld the ClassDescriptor of the instance
        * @param forced if set to true loading is forced even if cld differs.
  @@ -982,13 +993,13 @@
   
       /**
        * Retrieve a single Reference.
  -     * This implementation retrieves a referenced object from the data backend 
  +     * This implementation retrieves a referenced object from the data backend
        * if <b>cascade-retrieve</b> is true or if <b>forced</b> is true.
        *
        * @param obj - object that will have it's field set with a referenced object.
  -     * @param cld - the ClassDescriptor describring obj 
  +     * @param cld - the ClassDescriptor describring obj
        * @param rds - the ObjectReferenceDescriptor of the reference attribute to be loaded
  -     * @param forced - if set to true, the reference is loaded even if the rds differs. 
  +     * @param forced - if set to true, the reference is loaded even if the rds differs.
        */
       private void retrieveReference(Object obj, ClassDescriptor cld, ObjectReferenceDescriptor rds, boolean forced)
       {
  @@ -1004,7 +1015,7 @@
   
       /**
        * Retrieve a single Collection on behalf of <b>obj</b>.
  -     * The Collection is retrieved only if <b>cascade.retrieve is true</b> 
  +     * The Collection is retrieved only if <b>cascade.retrieve is true</b>
        * or if <b>forced</b> is set to true.     *
        *
        * @param obj - the object to be updated
  @@ -1039,8 +1050,7 @@
                   {
                       fkQuery.getCriteria().addOrderBy((FieldHelper)iter.next());
                   }
  -            }    
  -            
  +            }
               if (collectionClass == null)
               {
                   Collection result = getCollectionByQuery(fkQuery, cds.isLazy());
  @@ -1564,8 +1574,8 @@
           else
           {
               return getRsIteratorFromQueryExtentAware(query, cld, factory);
  -        }    
  -        
  +        }
  +
       }
   
       /**
  @@ -1587,54 +1597,56 @@
        * <b>TODO</b> : handle nested Criteria element <br>
        * <b>pre-condition</b> : query must be an instance of QueryByCriteria
        */
  -	private OJBIterator getRsIteratorFromQueryExtentAware(Query query, ClassDescriptor cld, RsIteratorFactory factory)
  -	{
  -		if (logger.isDebugEnabled())
  -		{
  -			logger.debug("-> Looking for objects of type [" + cld.getClassNameOfObject() + "]");
  -		}
  -
  -		/*
  -		 * PRE CONDITIONS
  -		 */
  +    private OJBIterator getRsIteratorFromQueryExtentAware(Query query,
  +                                                          ClassDescriptor cld,
  +                                                          RsIteratorFactory factory)
  +    {
  +        if (logger.isDebugEnabled())
  +        {
  +            logger.debug("-> Looking for objects of type [" + cld.getClassNameOfObject()+"]");
  +        }
   
  -		/* We must use a criteria object */
  -		if (!(query instanceof QueryByCriteria))
  -		{
  -			return getRsIteratorFromQuery(query, cld, factory);
  -		}
  +        /*
  +         * PRE CONDITIONS
  +         */
   
  -		Criteria criteria = query.getCriteria();
  -		if (criteria == null)
  -		{
  -			return getRsIteratorFromQuery(query, cld, factory);
  -		}
  +        /* We must use a criteria object */
  +        if(!(query instanceof QueryByCriteria))
  +        {
  +            return getRsIteratorFromQuery(query,cld,factory);
  +        }
   
  -		Enumeration enum = criteria.getElements();
  -		if (enum == null)
  -		{
  -			return getRsIteratorFromQuery(query, cld, factory);
  -		}
  +        Criteria criteria = query.getCriteria();
  +        if(criteria == null)
  +        {
  +            return getRsIteratorFromQuery(query,cld,factory);
  +        }
   
  -		/*
  -		 * Ok, we have some criteria elements to traverse
  -		 */
  -		ChainingIterator chainingIterator = new ChainingIterator();
  -		boolean pathElementPresent = false;
  -		HashSet processedClasses = new HashSet();
  +        Enumeration enum = criteria.getElements();
  +        if(enum == null)
  +        {
  +            return getRsIteratorFromQuery(query,cld,factory);
  +        }
   
  -		while (enum.hasMoreElements())
  -		{
  -			Object criteriaElement = enum.nextElement();
  -			logger.debug("  --# Criteria element [" + criteriaElement + "] class " + criteriaElement.getClass().getName());
  -			if (criteriaElement instanceof Criteria)
  -			{
  -				// TODO : nested criteria
  -				//logger.debug("  --# Nested Criteria ["+criteriaElement+"]");
  -				continue;
  -			}
  +        /*
  +         * Ok, we have some criteria elements to traverse
  +         */
  +        ChainingIterator chainingIterator = new ChainingIterator();
  +        boolean pathElementPresent = false;
  +        HashSet processedClasses = new HashSet();
  +
  +        while(enum.hasMoreElements())
  +        {
  +            Object criteriaElement = enum.nextElement();
  +            logger.debug("  --# Criteria element ["+criteriaElement+"] class "+criteriaElement.getClass().getName());
  +            if (criteriaElement instanceof Criteria)
  +            {
  +                // TODO : nested criteria
  +                //logger.debug("  --# Nested Criteria ["+criteriaElement+"]");
  +                continue;
  +            }
   
  -			SelectionCriteria selectionCriteria = (SelectionCriteria) criteriaElement;
  +            SelectionCriteria selectionCriteria = (SelectionCriteria) criteriaElement;
   			String attribute = selectionCriteria.getAttribute();
   			int dotPos = attribute.lastIndexOf(".");
   
  @@ -1642,7 +1654,7 @@
   			{
   				//We are dealing with a path expression, include iterators for all concrete subclasses
   
  -				String pathElement = ClassDescriptor.cleanPath(attribute).substring(0, dotPos);
  +				String pathElement = SqlHelper.cleanPath(attribute).substring(0, dotPos);
   				logger.debug("  --# Looking for concrete classes on pathElement [" + pathElement + "]");
   
   				//TODO revise this cast
  @@ -1658,6 +1670,7 @@
   					pathElementPresent = true;
                       //preserve user supplied hint
   
  +
   					chainingIterator.addIterator(getRsIteratorFromQuery(query, cld, factory));
   				}
   				else
  @@ -1698,15 +1711,15 @@
   			}
   		}
   
  -		if (pathElementPresent)
  -		{
  -			return chainingIterator;
  -		}
  -		else
  -		{
  -			return getRsIteratorFromQuery(query, cld, factory);
  -		}
  -	}
  +        if(pathElementPresent)
  +        {
  +            return chainingIterator;
  +        }
  +        else
  +        {
  +            return getRsIteratorFromQuery(query,cld,factory);
  +        }
  +    }
   
       /**
        * Helper method that analyses que pathElement of a query to see if we need to
  @@ -1773,7 +1786,7 @@
           }
   
           // Invoke events on PersistenceBrokerAware instances and listeners
  -        invokeEvent(obj, EVENT_AFTER_LOOKUP);
  +        fireBrokerEvent(obj, EVENT_AFTER_LOOKUP);
   
           //logger.info("RETRIEVING object " + obj);
           return obj;
  @@ -1794,9 +1807,9 @@
               {
               	oid = (Identity) obj;
               }
  -            else 
  +            else
               {
  -            	oid = new Identity(obj);
  +            	oid = new Identity(obj, this);
               }
               return getObjectByIdentity(oid);
           }
  @@ -1845,16 +1858,17 @@
   
       private void store(Object obj, ObjectModification mod, Map markedForStore) throws PersistenceBrokerException
       {
  +        ClassDescriptor cld = descriptorRepository.getDescriptorFor(obj.getClass());
           // this call ensures that all autoincremented primary key attributes are filled
  -        Identity oid = new Identity(obj, this);
  +        Identity oid = new Identity(obj, this, cld);
           // select flag for insert / update selection by checking the ObjectModification
           if (mod.needsInsert())
           {
  -            store(obj, oid, true, markedForStore);
  +            store(obj, oid, cld, true, markedForStore);
           }
           else if (mod.needsUpdate())
           {
  -            store(obj, oid, false, markedForStore);
  +            store(obj, oid, cld, false, markedForStore);
           }
           else
           {
  @@ -1874,10 +1888,10 @@
        * use update cascading to referenced objects.
        *
        */
  -    private void store(Object obj, Identity oid, boolean insert, Map markedForStore)
  +    private void store(Object obj, Identity oid, ClassDescriptor cld, boolean insert, Map markedForStore)
       {
           // Invoke events on PersistenceBrokerAware instances and listeners
  -        invokeEvent(obj, EVENT_BEFORE_STORE);
  +        fireBrokerEvent(obj, EVENT_BEFORE_STORE);
   
           if (obj != null)
           {
  @@ -1900,17 +1914,14 @@
                * 2. register object in markedForStore map with proper marker (insert flag)
                */
               markedForStore.put(obj, new Boolean(insert));
  -
  -            ClassDescriptor cld = descriptorRepository.getDescriptorFor(obj.getClass());
               storeToDb(obj, cld, oid, markedForStore, insert);
           }
           else
           {
               return;
           }
  -
           // Invoke events on PersistenceBrokerAware instances and listeners
  -        invokeEvent(obj, EVENT_AFTER_STORE);
  +        fireBrokerEvent(obj, EVENT_AFTER_STORE);
       }
   
       /**
  @@ -1984,7 +1995,13 @@
   
   
               // cache object for symmetry with getObjectByXXX()
  -            objectCache.cache(obj);
  +            /*
  +            arminw
  +            TODO Check it out. Cache the object with Identity oid, because Cache does
  +            intern generate a new Identity object as key for the object.
  +            */
  +            // objectCache.cache(obj);
  +            objectCache.cache(oid, obj);
               // 4. store 1:n and m:n associations
               storeCollections(obj, cld.getCollectionDescriptors(), markedForStore);
           }
  @@ -2001,7 +2018,8 @@
       private void storeSuperClasses(Object obj, ClassDescriptor cld, Identity oid, Map markedForStore, boolean insert)
       {
           // get super class cld then store it with the object
  -        if(cld.getSuperClass() != null){
  +        if(cld.getSuperClass() != null)
  +        {
   
               ClassDescriptor superCld = getDescriptorRepository().getDescriptorFor(cld.getSuperClass());
               storeToDb(obj, superCld, oid, markedForStore, insert);
  @@ -2014,14 +2032,19 @@
               FieldDescriptor currIdField = cld.getPrimaryKey();
               pf.set(obj, new Integer(newid));*/
   
  +            // cache object for symmetry with getObjectByXXX()
  +            /*
   
  -                // cache object for symmetry with getObjectByXXX()
  -                objectCache.cache(obj);
  -                LoadedObjectsRegistry.register(obj);
  -                // 4. store 1:n and m:n associations
  -                storeCollections(obj, cld.getCollectionDescriptors(), markedForStore);
  -            }
  +            arminw
  +            TODO: Check it out. I comment out this, because the storeToDB-method
  +            does cache the given object too.
  +            */
  +            // objectCache.cache(obj);
  +            LoadedObjectsRegistry.register(obj);
  +            // 4. store 1:n and m:n associations
  +            storeCollections(obj, cld.getCollectionDescriptors(), markedForStore);
           }
  +    }
   
   
       /**
  @@ -2058,7 +2081,7 @@
        */
       private Query getForeignKeyQuery(Object obj, ClassDescriptor cld, CollectionDescriptor cod)
       {
  -        Object[] values = cld.getKeyValues(obj);
  +        Object[] values = brokerHelper.getKeyValues(cld, obj);
           ClassDescriptor refCld = getClassDescriptor(cod.getItemClass());
           FieldDescriptor[] fields = cod.getForeignKeyFieldDescriptors(refCld);
           Criteria criteria = new Criteria();
  @@ -2084,7 +2107,7 @@
        */
       private Query getMtoNQuery(Object obj, ClassDescriptor cld, CollectionDescriptor cod)
       {
  -        Object[] values = cld.getKeyValues(obj);
  +        Object[] values = brokerHelper.getKeyValues(cld, obj);
           Object[] thisClassFks = cod.getFksToThisClass();
           Object[] itemClassFks = cod.getFksToItemClass();
           ClassDescriptor refCld = getClassDescriptor(cod.getItemClass());
  @@ -2118,7 +2141,7 @@
        */
       private Query getMtoNQuery_inverse(Object obj, ClassDescriptor cld, CollectionDescriptor cod)
       {
  -        Object[] values = cld.getKeyValues(obj);
  +        Object[] values = brokerHelper.getKeyValues(cld, obj);
           ClassDescriptor refCld = getClassDescriptor(cod.getItemClass());
           FieldDescriptor[] pks = cld.getPkFields();
           CollectionDescriptor inverseCod = null;
  @@ -2165,156 +2188,6 @@
           return query;
       }
   
  -    /**
  -     * Returns a unique int value for the given field attribute.
  -     * The returned int value is unique accross all tables in the extent
  -     * of class the field belongs to.
  -     *
  -     * @deprecated use {@link #getUniqueId(FieldDescriptor field)} instead
  -     */
  -    public int getUniqueId(Class extent, String attribute)
  -    {
  -        try
  -        {
  -            return sequenceManager.getUniqueId(
  -                    this.getClassDescriptor(extent).getFieldDescriptorByName(attribute));
  -        }
  -        catch (SequenceManagerException e)
  -        {
  -            throw new PersistenceBrokerException(e);
  -        }
  -    }
  -
  -   /**
  -     * Returns a unique long value for the given field attribute.
  -     * The returned long value is unique accross all tables in the extent
  -     * of class the field belongs to.
  -     *
  -     * @deprecated use {@link #getUniqueLong(FieldDescriptor field)} instead
  -     */
  -    public long getUniqueLong(Class extent, String attribute) throws PersistenceBrokerException
  -    {
  -        try
  -        {
  -            return sequenceManager.getUniqueLong(
  -                    this.getClassDescriptor(extent).getFieldDescriptorByName(attribute));
  -        }
  -        catch (SequenceManagerException e)
  -        {
  -            throw new PersistenceBrokerException(e);
  -        }
  -    }
  -
  -    /**
  -     * Returns a unique String for the given field attribute.
  -     * The returned String is unique accross all tables in the extent
  -     * of class the field belongs to.
  -     *
  -     * @deprecated use {@link #getUniqueString(FieldDescriptor field)} instead
  -     */
  -    public String getUniqueString(Class extent, String attribute) throws PersistenceBrokerException
  -    {
  -        try
  -        {
  -            return sequenceManager.getUniqueString(
  -                    this.getClassDescriptor(extent).getFieldDescriptorByName(attribute));
  -        }
  -        catch (SequenceManagerException e)
  -        {
  -            throw new PersistenceBrokerException(e);
  -        }
  -    }
  -
  -    /**
  -     * Returns a unique object for the given field attribute.
  -     * The returned object is unique accross all tables in the extent
  -     * of class the field belongs to.
  -     *
  -     * @deprecated use {@link #getUniqueObject(FieldDescriptor field)} instead
  -     */
  -    public Object getUniqueObject(Class extent, String attribute) throws PersistenceBrokerException
  -    {
  -        try
  -        {
  -            return sequenceManager.getUniqueObject(
  -                    this.getClassDescriptor(extent).getFieldDescriptorByName(attribute));
  -        }
  -        catch (SequenceManagerException e)
  -        {
  -            throw new PersistenceBrokerException(e);
  -        }
  -    }
  -
  -
  -    /**
  -     * Returns a unique int value for the given field attribute.
  -     * The returned int value is unique accross all tables in the extent
  -     * of class the field belongs to.
  -     */
  -    public int getUniqueId(FieldDescriptor field) throws PersistenceBrokerException
  -    {
  -        try
  -        {
  -            return sequenceManager.getUniqueId(field);
  -        }
  -        catch (SequenceManagerException e)
  -        {
  -            throw new PersistenceBrokerException(e);
  -        }
  -    }
  -
  -    /**
  -     * Returns a unique long value for the given field attribute.
  -     * The returned long value is unique accross all tables in the extent
  -     * of class the field belongs to.
  -     */
  -    public long getUniqueLong(FieldDescriptor field) throws PersistenceBrokerException
  -    {
  -        try
  -        {
  -            return sequenceManager.getUniqueLong(field);
  -        }
  -        catch (SequenceManagerException e)
  -        {
  -            throw new PersistenceBrokerException(e);
  -        }
  -    }
  -
  -
  -    /**
  -     * Returns a unique String for the given field attribute.
  -     * The returned String is unique accross all tables in the extent
  -     * of class the field belongs to.
  -     */
  -    public String getUniqueString(FieldDescriptor field) throws PersistenceBrokerException
  -    {
  -        try
  -        {
  -            return sequenceManager.getUniqueString(field);
  -        }
  -        catch (SequenceManagerException e)
  -        {
  -            throw new PersistenceBrokerException(e);
  -        }
  -    }
  -
  -    /**
  -     * Returns a unique object for the given field attribute.
  -     * The returned object is unique accross all tables in the extent
  -     * of class the field belongs to.
  -     */
  -    public Object getUniqueObject(FieldDescriptor field) throws PersistenceBrokerException
  -    {
  -        try
  -        {
  -            return sequenceManager.getUniqueObject(field);
  -        }
  -        catch (SequenceManagerException e)
  -        {
  -            throw new PersistenceBrokerException(e);
  -        }
  -    }
  -
   
   
       /**
  @@ -2353,18 +2226,10 @@
       }
   
       /**
  -     * adds a new or replaces an existing ClassDescriptor to the DescriptorRepository.
  -     */
  -    public void setClassDescriptor(ClassDescriptor modifiedOrNewDescriptor) throws PersistenceBrokerException
  -    {
  -        descriptorRepository.put(modifiedOrNewDescriptor.getClassOfObject(), modifiedOrNewDescriptor);
  -    }
  -
  -    /**
        * returns the Extent to which the class clazz belongs.
        * This may be a baseclass,an interface or clazz itself, if no Extent
        * is defined.
  -     * throws a PersistenceBrokerException if clazz is not persistence capable,
  +     * @throws PersistenceBrokerException if clazz is not persistence capable,
        * i.e. if clazz is not defined in the DescriptorRepository.
        * @param clazz the class to lookup the Extent for
        */
  @@ -2537,7 +2402,7 @@
       private OJBIterator getReportQueryIteratorFromQuery(Query query, ClassDescriptor cld) throws PersistenceBrokerException
       {
           RsIteratorFactory factory = ReportRsIteratorFactoryImpl.getInstance();
  -        
  +
           // BRJ MtoNQueries can't be extent aware
           if (query instanceof MtoNQuery)
           {
  @@ -2546,8 +2411,8 @@
           else
           {
               return getRsIteratorFromQueryExtentAware(query, cld, factory);
  -        }    
  -            
  +        }
  +
       }
   
       /*
  @@ -2571,17 +2436,9 @@
        */
       private void autoCreateDb(Configuration config)
       {
  -        if(config.getBoolean("autobuild", false)){
  -
  -            try
  -            {
  -                Connection conn = connectionManager.getConnection();
  -                AutoCreatorDb.autoCreate(descriptorRepository, conn);
  -            }
  -            catch (LookupException e)
  -            {
  -                e.printStackTrace();
  -            }
  +        if(config.getBoolean("autobuild", false))
  +        {
  +            AutoCreatorDb.autoCreate(descriptorRepository, connectionManager);
           }
   
       }
  @@ -2677,26 +2534,32 @@
           }
       }
   
  +
  +
  +
  +// ************************************************************************
  +// inner class
  +// ************************************************************************
       /**
        * This is a helper class to model a Key of an Object
        */
       private class Key
       {
           Object[] m_key;
  -        
  +
           Key(Object[] aKey)
           {
               m_key = aKey;
  -        }    
  -        
  +        }
  +
           public boolean equals(Object otherKey)
           {
               boolean result = false;
  -            
  +
               if (otherKey instanceof Key)
               {
                   Key k = (Key)otherKey;
  -                
  +
                   if (k.m_key.length == m_key.length)
                   {
                       for (int i= 0;i < m_key.length; i++)
  @@ -2704,15 +2567,15 @@
                           if (k.m_key[i].equals(m_key[i]))
                           {
                               result = true;
  -                        }    
  +                        }
                           else
                           {
                               break;
  -                        }    
  -                    }   
  -                }   
  -            }    
  +                        }
  +                    }
  +                }
  +            }
               return result;
  -        }    
  -    }    
  +        }
  +    }
   }
  
  
  
  1.27      +35 -6     jakarta-ojb/src/java/org/apache/ojb/broker/ta/PersistenceBrokerFactoryDefaultImpl.java
  
  Index: PersistenceBrokerFactoryDefaultImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/ta/PersistenceBrokerFactoryDefaultImpl.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- PersistenceBrokerFactoryDefaultImpl.java	29 Nov 2002 14:14:27 -0000	1.26
  +++ PersistenceBrokerFactoryDefaultImpl.java	24 Dec 2002 13:20:03 -0000	1.27
  @@ -63,6 +63,8 @@
   import org.apache.ojb.broker.PersistenceBroker;
   import org.apache.ojb.broker.accesslayer.ConnectionFactoryFactory;
   import org.apache.ojb.broker.metadata.DescriptorRepository;
  +import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
  +import org.apache.ojb.broker.metadata.MetadataManager;
   import org.apache.ojb.broker.server.PersistenceBrokerClient;
   import org.apache.ojb.broker.server.ServerPool;
   import org.apache.ojb.broker.singlevm.PersistenceBrokerConfiguration;
  @@ -79,8 +81,12 @@
   import org.apache.ojb.broker.util.logging.Logger;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
   import org.apache.ojb.broker.util.logging.LoggingHelper;
  +import org.apache.ojb.broker.util.ClassHelper;
   
   import java.util.Properties;
  +import java.util.Map;
  +import java.util.List;
  +import java.util.Iterator;
   
   /**
    * This is the default implementation of the {@link PersistenceBrokerFactoryIF}
  @@ -99,6 +105,7 @@
       private long instanceCount;
       private GenericKeyedObjectPool brokerPool;
       private PBPoolInfo poolConfig;
  +    private PBKey defaultPBKey;
   
       public PersistenceBrokerFactoryDefaultImpl()
       {
  @@ -108,11 +115,33 @@
           // setup pool for PB instances
           brokerPool = this.createPool();
           log.info("Create PersistenceBroker instance pool, pool configuration was " + getPoolConfiguration());
  +        setDefaultKey(buildDefaultKey());
       }
   
  -    public void setDefaultPersistenceBroker(PBKey key)
  +    public void setDefaultKey(PBKey key)
       {
  -        DescriptorRepository.setDefaultPBKey(key);
  +        log.info("Set default PBKey: "+key);
  +        this.defaultPBKey = key;
  +    }
  +
  +    public PBKey getDefaultKey()
  +    {
  +        return this.defaultPBKey;
  +    }
  +
  +    private PBKey buildDefaultKey()
  +    {
  +        List descriptors = MetadataManager.getInstance().connectionRepository().getAllDescriptor();
  +        JdbcConnectionDescriptor descriptor;
  +        for (Iterator iterator = descriptors.iterator(); iterator.hasNext();)
  +        {
  +            descriptor = (JdbcConnectionDescriptor) iterator.next();
  +            if(descriptor.isDefaultConnection())
  +            {
  +                return new PBKey(descriptor.getJcdAlias(),descriptor.getUserName(), descriptor.getPassWord());
  +            }
  +        }
  +        return null;
       }
   
       /**
  @@ -154,7 +183,7 @@
           Object[] args = {key, this};
           try
           {
  -            instance = (PersistenceBroker) implementationClass.getConstructor(types).newInstance(args);
  +            instance = (PersistenceBroker) ClassHelper.newInstance(implementationClass, types, args);
               getConfigurator().configure(instance);
               instance = (PersistenceBroker) InterceptorFactory.getInstance().createInterceptorFor(instance);
           }
  @@ -215,12 +244,12 @@
       public PersistenceBroker defaultPersistenceBroker(String user, String password) throws PBFactoryException
       {
           return this.createPersistenceBroker(
  -                new PBKey(DescriptorRepository.getDefaultPBKey().getRepositoryFile(), user, password));
  +                new PBKey(getDefaultKey().getAlias(), user, password));
       }
   
       public PersistenceBroker defaultPersistenceBroker() throws PBFactoryException
       {
  -        return this.createPersistenceBroker(DescriptorRepository.getDefaultPBKey());
  +        return this.createPersistenceBroker(getDefaultKey());
       }
   
       /*
  
  
  
  1.5       +9 -14     jakarta-ojb/src/java/org/apache/ojb/broker/ta/PersistenceBrokerFactoryFactory.java
  
  Index: PersistenceBrokerFactoryFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/ta/PersistenceBrokerFactoryFactory.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PersistenceBrokerFactoryFactory.java	2 Oct 2002 04:18:45 -0000	1.4
  +++ PersistenceBrokerFactoryFactory.java	24 Dec 2002 13:20:03 -0000	1.5
  @@ -67,16 +67,10 @@
    */
   public class PersistenceBrokerFactoryFactory
   {
  -    private static PersistenceBrokerFactoryIF singleton;
  -    private static Configurator configurator;
  -    private static Logger log;
  -
  +    //private static Logger log = LoggerFactory.getLogger(PersistenceBrokerFactoryFactory.class);
  +    private static Logger log = LoggerFactory.getBootLogger();
   
  -    static
  -    {
  -        configurator = OjbConfigurator.getInstance();
  -        log = LoggerFactory.getLogger(PersistenceBrokerFactoryFactory.class);
  -    }
  +    private static PersistenceBrokerFactoryIF singleton;
   
       /**
        *
  @@ -98,12 +92,13 @@
           if (log.isDebugEnabled()) log.debug("Instantiate PersistenceBrokerFactory");
           try
           {
  -            Configuration config = getConfigurator().getConfigurationFor(null);
  +            Configurator configurator = OjbConfigurator.getInstance();
  +            Configuration config = configurator.getConfigurationFor(null);
               Class pbfClass = config.getClass("PersistenceBrokerFactoryClass",
                       PersistenceBrokerFactoryDefaultImpl.class);
               PersistenceBrokerFactoryIF result = (PersistenceBrokerFactoryIF)
                       pbfClass.newInstance();
  -            getConfigurator().configure(result);
  +            configurator.configure(result);
               if (log.isDebugEnabled()) log.debug("PersistencebrokerFactory class: " + pbfClass.getName());
               return result;
           }
  @@ -114,11 +109,11 @@
           }
       }
   
  -    /**
  +     /**
        *
        */
       public static Configurator getConfigurator()
       {
  -        return configurator;
  +        return OjbConfigurator.getInstance();
       }
   }
  
  
  
  1.10      +10 -4     jakarta-ojb/src/java/org/apache/ojb/broker/ta/PersistenceBrokerFactoryIF.java
  
  Index: PersistenceBrokerFactoryIF.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/ta/PersistenceBrokerFactoryIF.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- PersistenceBrokerFactoryIF.java	28 Nov 2002 22:10:57 -0000	1.9
  +++ PersistenceBrokerFactoryIF.java	24 Dec 2002 13:20:03 -0000	1.10
  @@ -68,10 +68,16 @@
   public interface PersistenceBrokerFactoryIF extends Configurable
   {
       /**
  -     * Set the default PersistenceBroker used within OJB
  -     * to find OJB internal tables.
  +     * Set the default PersistenceBroker (e.g. used within OJB
  +     * to find OJB internal tables)
        */
  -    public void setDefaultPersistenceBroker(PBKey key);
  +    public void setDefaultKey(PBKey key);
  +
  +    /**
  +     * Get the default PersistenceBroker (e.g. used within OJB
  +     * to find OJB internal tables)
  +     */
  +    public PBKey getDefaultKey();
   
       /**
        * Return {@link org.apache.ojb.broker.PersistenceBroker} instance for the given
  
  
  

Mime
View raw message