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/singlevm PoolablePersistenceBroker.java DelegatingPersistenceBroker.java PersistenceBrokerImpl.java
Date Thu, 28 Nov 2002 22:10:59 GMT
arminw      2002/11/28 14:10:58

  Modified:    src/java/org/apache/ojb/broker/ta
                        PersistenceBrokerFactoryIF.java
                        PersistenceBrokerFactoryDefaultImpl.java
                        PBPoolInfo.java PBKeyedPoolableObjectFactory.java
               src/java/org/apache/ojb/broker/singlevm
                        PersistenceBrokerImpl.java
  Added:       src/java/org/apache/ojb/broker/singlevm
                        PoolablePersistenceBroker.java
                        DelegatingPersistenceBroker.java
  Log:
  remove unused methods, improve PB instance handling,
  new method PBF.setDefaultPBKey
  
  Revision  Changes    Path
  1.9       +8 -12     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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- PersistenceBrokerFactoryIF.java	23 Nov 2002 10:25:00 -0000	1.8
  +++ PersistenceBrokerFactoryIF.java	28 Nov 2002 22:10:57 -0000	1.9
  @@ -68,26 +68,22 @@
   public interface PersistenceBrokerFactoryIF extends Configurable
   {
       /**
  -     * For internal use! This methos creates real new PB instances
  +     * Set the default PersistenceBroker used within OJB
  +     * to find OJB internal tables.
        */
  -    public PersistenceBroker createNewBrokerInstance(PBKey key) throws PBFactoryException;
  -
  -
  -    /**
  -     * For internal use only!
  -     * Release broker back to pool, called
  -     * within {@link org.apache.ojb.broker.PersistenceBroker#close}
  -     */
  -    public void releaseInstance(PersistenceBroker broker);
  +    public void setDefaultPersistenceBroker(PBKey key);
   
       /**
  -     * Return {@link org.apache.ojb.broker.PersistenceBroker} instance for the given {@link
org.apache.ojb.broker.PBKey}.
  +     * Return {@link org.apache.ojb.broker.PersistenceBroker} instance for the given
  +     * {@link org.apache.ojb.broker.PBKey}.
  +     *
        * @param key
        */
       public PersistenceBroker createPersistenceBroker(PBKey key) throws PBFactoryException;
   
       /**
        * Return {@link org.apache.ojb.broker.PersistenceBroker} instance.
  +     *
        * @param repositoryFile repository.xml file name
        * @param user
        * @param password
  
  
  
  1.25      +121 -101  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.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- PersistenceBrokerFactoryDefaultImpl.java	27 Nov 2002 05:48:15 -0000	1.24
  +++ PersistenceBrokerFactoryDefaultImpl.java	28 Nov 2002 22:10:57 -0000	1.25
  @@ -55,17 +55,20 @@
    */
   
   import org.apache.commons.pool.KeyedObjectPool;
  +import org.apache.commons.pool.KeyedPoolableObjectFactory;
   import org.apache.commons.pool.impl.GenericKeyedObjectPool;
   import org.apache.ojb.broker.PBFactoryException;
   import org.apache.ojb.broker.PBKey;
   import org.apache.ojb.broker.PBState;
   import org.apache.ojb.broker.PersistenceBroker;
  -import org.apache.ojb.broker.metadata.DescriptorRepository;
   import org.apache.ojb.broker.accesslayer.ConnectionFactoryFactory;
  +import org.apache.ojb.broker.metadata.DescriptorRepository;
   import org.apache.ojb.broker.server.PersistenceBrokerClient;
   import org.apache.ojb.broker.server.ServerPool;
   import org.apache.ojb.broker.singlevm.PersistenceBrokerConfiguration;
  +import org.apache.ojb.broker.singlevm.PersistenceBrokerImpl;
   import org.apache.ojb.broker.singlevm.PersistenceBrokerThreadMapping;
  +import org.apache.ojb.broker.singlevm.PoolablePersistenceBroker;
   import org.apache.ojb.broker.util.configuration.Configuration;
   import org.apache.ojb.broker.util.configuration.ConfigurationException;
   import org.apache.ojb.broker.util.configuration.Configurator;
  @@ -76,6 +79,8 @@
   import org.apache.ojb.broker.util.logging.LoggerFactory;
   import org.apache.ojb.broker.util.logging.LoggingHelper;
   
  +import java.util.Properties;
  +
   /**
    * This is the default implementation of the {@link PersistenceBrokerFactoryIF}
    * interface.
  @@ -85,33 +90,64 @@
    */
   public class PersistenceBrokerFactoryDefaultImpl implements PersistenceBrokerFactoryIF
   {
  +    private static Logger log = LoggerFactory.getLogger(PersistenceBrokerFactoryDefaultImpl.class);
  +
       private Class implementationClass;
       private Configurator configurator;
  -    private Logger log;
       private PersistenceBroker lastServed;
       private long instanceCount;
  -    private KeyedObjectPool brokerPool;
  -    private PBKey defaultPBKey;
  +    private GenericKeyedObjectPool brokerPool;
  +    private PBPoolInfo poolConfig;
   
       public PersistenceBrokerFactoryDefaultImpl()
       {
  -        log = LoggerFactory.getLogger(PersistenceBrokerFactoryDefaultImpl.class);
           setConfigurator(OjbConfigurator.getInstance());
  +        // get PB-pool configuration properties from OJB.properties
  +        poolConfig = new PBPoolInfo();
  +        // setup pool for PB instances
           brokerPool = this.createPool();
  -        defaultPBKey = DescriptorRepository.getDefaultInstance().getPBkey();
  +        log.info("Create PersistenceBroker instance pool, pool configuration was " + getPoolConfiguration());
  +    }
   
  +    public void setDefaultPersistenceBroker(PBKey key)
  +    {
  +        DescriptorRepository.setDefaultPBKey(key);
       }
   
  +    /**
  +     * could be used for monitoring
  +     * @todo is this useful?
  +     */
  +    public Properties getPoolConfiguration()
  +    {
  +        return poolConfig;
  +    }
   
  +    /**
  +     * could be used for runtime configuration
  +     * @todo is this useful?
  +     */
  +    public void setPoolConfiguration(Properties prop)
  +    {
  +        poolConfig = new PBPoolInfo(prop);
  +        log.info("Change pooling configuration properties: " + poolConfig.getKeyedObjectPoolConfig());
  +        brokerPool.setConfig(poolConfig.getKeyedObjectPoolConfig());
  +    }
   
       /**
        * For internal use! This methos creates real new PB instances
        */
       public PersistenceBroker createNewBrokerInstance(PBKey key) throws PBFactoryException
       {
  -        if (log.isDebugEnabled()) log.debug("Create new PB instance");
  -        log.info("Already created persistence broker instances: "+instanceCount);
  -        ++this.instanceCount;
  +        if (log.isEnabledFor(Logger.INFO))
  +        {
  +            // only count created instances when INFO-Log-Level
  +            log.info("Create new PB instance, already created persistence broker instances:
" +
  +                    instanceCount);
  +            // useful for testing
  +            ++this.instanceCount;
  +        }
  +
           PersistenceBroker instance = null;
           Class[] types = {PBKey.class, PersistenceBrokerFactoryIF.class};
           Object[] args = {key, this};
  @@ -168,6 +204,7 @@
           return broker;
       }
   
  +
       public PersistenceBroker createPersistenceBroker(String repositoryFile, String user,
String password)
               throws PBFactoryException
       {
  @@ -176,40 +213,13 @@
   
       public PersistenceBroker defaultPersistenceBroker(String user, String password) throws
PBFactoryException
       {
  -        return this.createPersistenceBroker(new PBKey(this.defaultPBKey.getRepositoryFile(),
user, password));
  +        return this.createPersistenceBroker(
  +                new PBKey(DescriptorRepository.getDefaultPBKey().getRepositoryFile(), user,
password));
       }
   
       public PersistenceBroker defaultPersistenceBroker() throws PBFactoryException
       {
  -        return this.createPersistenceBroker(this.defaultPBKey);
  -    }
  -
  -    public void releaseInstance(PersistenceBroker broker)
  -    {
  -        if (broker == null) return;
  -        /*@todo while this method was public for user, redirect to the PB.close method
  -        to let PB do intern cleaning process, if all clients only use PB.close
  -        to release instance, we do no longer need this check*/
  -        if (broker instanceof PBState && !((PBState) broker).isClosed())
  -        {
  -            broker.close();
  -        }
  -        else if (broker instanceof PersistenceBrokerClient)
  -        {
  -            return;
  -        }
  -        else
  -        {
  -            try
  -            {
  -                brokerPool.returnObject(broker.getPBKey(), broker);
  -            }
  -            catch (Exception e)
  -            {
  -                log.error("Return broker instance to pool failed", e);
  -                //throw new PersistenceBrokerException(e);
  -            }
  -        }
  +        return this.createPersistenceBroker(DescriptorRepository.getDefaultPBKey());
       }
   
       /*
  @@ -260,7 +270,7 @@
           {
               instanceCount = 0;
               brokerPool.clear();
  -            ConnectionFactoryFactory.releaseAllResources();
  +            ConnectionFactoryFactory.getInstance().releaseAllResources();
               //release all resources regarding the connection pooling
           }
           catch (Exception e)
  @@ -274,30 +284,15 @@
        * the {@link org.apache.ojb.broker.PersistenceBroker} instances - override this method
to
        * implement your own pool and {@link org.apache.commons.pool.KeyedPoolableObjectFactory}.
        */
  -    public KeyedObjectPool createPool()
  +    private GenericKeyedObjectPool createPool()
       {
  -        PBPoolInfo poolInfo = getPBPoolConfiguration();
  -        GenericKeyedObjectPool.Config conf = new GenericKeyedObjectPool.Config();
  -        conf.maxActive = poolInfo.getMaxActive();
  -        conf.maxIdle = poolInfo.getMaxIdle();
  -        conf.maxWait = poolInfo.getMaxWait();
  -        conf.whenExhaustedAction = poolInfo.getWhenExhaustedAction();
  -        conf.minEvictableIdleTimeMillis = poolInfo.getMinEvictableIdleTimeMillis();
  -        conf.timeBetweenEvictionRunsMillis = poolInfo.getTimeBetweenEvictionRunsMillis();
  +        GenericKeyedObjectPool.Config conf = poolConfig.getKeyedObjectPoolConfig();
           if (log.isDebugEnabled())
  -            log.debug("PersistenceBroker pool will be setup with the following" +
  -                    " configuration" + LoggingHelper.traceObject(conf));
  -
  -        return new GenericKeyedObjectPool(new PBKeyedPoolableObjectFactory(this), conf);
  -    }
  -
  -    /**
  -     * Return a PB pool configuration object, comprised all settings
  -     * made in OJB config files.
  -     */
  -    public PBPoolInfo getPBPoolConfiguration()
  -    {
  -        return new PBPoolInfo();
  +            log.debug("PersistenceBroker pool will be setup with the following configuration
" +
  +                    LoggingHelper.traceObject(conf));
  +        GenericKeyedObjectPool pool = new GenericKeyedObjectPool(null, conf);
  +        pool.setFactory(new PBKeyedPoolableObjectFactory(this, pool));
  +        return pool;
       }
   
   //**************************************************************************************
  @@ -305,42 +300,67 @@
   //**************************************************************************************
   //
   
  -//    /**
  -//     * This is a {@link org.apache.commons.pool.KeyedPoolableObjectFactory} implementation,
  -//     * manage the life-cycle of {@link org.apache.ojb.broker.PersistenceBroker} instances
  -//     * hold in an {@link org.apache.commons.pool.KeyedObjectPool}.
  -//     *
  -//     * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
  -//     */
  -//    class PBKeyedPoolableObjectFactory implements KeyedPoolableObjectFactory
  -//    {
  -//        private PersistenceBrokerFactoryIF pbf;
  -//
  -//        public PBKeyedPoolableObjectFactory(PersistenceBrokerFactoryIF pbf)
  -//        {
  -//            this.pbf = pbf;
  -//        }
  -//
  -//        public Object makeObject(Object key) throws Exception
  -//        {
  -//            return null;
  -//        }
  -//
  -//        public void destroyObject(Object key, Object obj) throws Exception
  -//        {
  -//        }
  -//
  -//        public boolean validateObject(Object key, Object obj)
  -//        {
  -//            return false;
  -//        }
  -//
  -//        public void activateObject(Object key, Object obj) throws Exception
  -//        {
  -//        }
  -//
  -//        public void passivateObject(Object key, Object obj) throws Exception
  -//        {
  -//        }
  -//    }
  +    /**
  +     * This is a {@link org.apache.commons.pool.KeyedPoolableObjectFactory} implementation,
  +     * manage the life-cycle of {@link org.apache.ojb.broker.PersistenceBroker} instances
  +     * hold in an {@link org.apache.commons.pool.KeyedObjectPool}.
  +     *
  +     * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
  +     */
  +    class PBKeyedPoolableObjectFactory implements KeyedPoolableObjectFactory
  +    {
  +        private PersistenceBrokerFactoryDefaultImpl pbf;
  +        private KeyedObjectPool pool;
  +
  +        public PBKeyedPoolableObjectFactory(PersistenceBrokerFactoryDefaultImpl pbf, KeyedObjectPool
pool)
  +        {
  +            this.pbf = pbf;
  +            this.pool = pool;
  +        }
  +
  +        public Object makeObject(Object key) throws Exception
  +        {
  +            return new PoolablePersistenceBroker(pbf.createNewBrokerInstance((PBKey) key),
pool);
  +        }
  +
  +        /**
  +         * Do all cleanup stuff here.
  +         */
  +        public void destroyObject(Object key, Object obj) throws Exception
  +        {
  +            if (obj instanceof PersistenceBrokerImpl)
  +            {
  +                ((PersistenceBrokerImpl) obj).releaseAllResources();
  +            }
  +        }
  +
  +        /**
  +         * no-op - to use this feature, override
  +         * {@link org.apache.ojb.broker.ta.PBPoolInfo#init}
  +         * method. See documentation jakarta-connons-pool api.
  +         */
  +        public boolean validateObject(Object key, Object obj)
  +        {
  +            //here we could validate the PB instance
  +            //if corresponding configuration properties are set
  +            return true;
  +        }
  +
  +        /**
  +         * Called before borrow object from pool.
  +         */
  +        public void activateObject(Object key, Object obj) throws Exception
  +        {
  +            ((PBState) obj).setClosed(false);
  +        }
  +
  +        /**
  +         * Called before return object to pool.
  +         */
  +        public void passivateObject(Object key, Object obj) throws Exception
  +        {
  +            //this maybe already done before
  +            ((PBState) obj).setClosed(true);
  +        }
  +    }
   }
  
  
  
  1.2       +21 -5     jakarta-ojb/src/java/org/apache/ojb/broker/ta/PBPoolInfo.java
  
  Index: PBPoolInfo.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/ta/PBPoolInfo.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PBPoolInfo.java	2 Aug 2002 18:52:24 -0000	1.1
  +++ PBPoolInfo.java	28 Nov 2002 22:10:57 -0000	1.2
  @@ -1,29 +1,45 @@
   package org.apache.ojb.broker.ta;
   
  -import org.apache.ojb.broker.util.pooling.PoolInfo;
   import org.apache.ojb.broker.util.configuration.Configurable;
   import org.apache.ojb.broker.util.configuration.Configuration;
   import org.apache.ojb.broker.util.configuration.ConfigurationException;
   import org.apache.ojb.broker.util.configuration.impl.OjbConfigurator;
   import org.apache.ojb.broker.util.logging.LoggerFactory;
  +import org.apache.ojb.broker.util.pooling.PoolConfiguration;
  +
  +import java.util.Properties;
   
   /**
  - * Make available configuration pool properties used in
  + * Encapsulates  the PB-pool configuration properties used in
  + * in the {@link org.apache.ojb.broker.ta.PersistenceBrokerFactoryIF}
  + * implementations, e.g.
    * {@link org.apache.ojb.broker.ta.PersistenceBrokerDefaultImpl}.
    *
    * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
    */
  -public class PBPoolInfo extends PoolInfo implements Configurable
  +public class PBPoolInfo extends PoolConfiguration implements Configurable
   {
       public PBPoolInfo()
       {
  +        super();
  +        init();
  +        OjbConfigurator.getInstance().configure(this);
  +    }
  +
  +    public PBPoolInfo(Properties properties)
  +    {
  +        super();
           init();
           OjbConfigurator.getInstance().configure(this);
  +        this.putAll(properties);
       }
   
  +    /**
  +     * Read in the configuration properties.
  +     */
       public void configure(Configuration pConfig) throws ConfigurationException
       {
  -        if(pConfig instanceof PBPoolConfiguration)
  +        if (pConfig instanceof PBPoolConfiguration)
           {
               PBPoolConfiguration conf = (PBPoolConfiguration) pConfig;
               this.setMaxActive(conf.getMaxActive());
  @@ -35,7 +51,7 @@
           }
           else
           {
  -            LoggerFactory.getDefaultLogger().error(this.getClass().getName()+
  +            LoggerFactory.getDefaultLogger().error(this.getClass().getName() +
                       " cannot read configuration properties, use default.");
           }
       }
  
  
  
  1.3       +5 -1      jakarta-ojb/src/java/org/apache/ojb/broker/ta/PBKeyedPoolableObjectFactory.java
  
  Index: PBKeyedPoolableObjectFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/ta/PBKeyedPoolableObjectFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PBKeyedPoolableObjectFactory.java	2 Aug 2002 18:52:24 -0000	1.2
  +++ PBKeyedPoolableObjectFactory.java	28 Nov 2002 22:10:57 -0000	1.3
  @@ -12,6 +12,8 @@
    *
    * @see org.apache.ojb.broker.ta.PersistenceBrokerFactoryDefaultImpl
    *
  + * @deprecated
  + *
    * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
    */
   class PBKeyedPoolableObjectFactory implements KeyedPoolableObjectFactory
  @@ -25,7 +27,9 @@
   
       public Object makeObject(Object key) throws Exception
       {
  -        return pbf.createNewBrokerInstance((PBKey)key);
  +        /*@todo implementation*/
  +        throw new UnsupportedOperationException("Not implemented!!");
  +//        return pbf.createNewBrokerInstance((PBKey)key);
       }
   
       /**
  
  
  
  1.84      +2 -17     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.83
  retrieving revision 1.84
  diff -u -r1.83 -r1.84
  --- PersistenceBrokerImpl.java	27 Nov 2002 05:55:12 -0000	1.83
  +++ PersistenceBrokerImpl.java	28 Nov 2002 22:10:57 -0000	1.84
  @@ -275,18 +275,6 @@
           {
               this.setClosed(true);
           }
  -
  -        /*@todo while pbf.releaseInstance was public, we setClosed(true)
  -		in further versions this method should only called by the pool*/
  -        try
  -        {
  -            this.pbf.releaseInstance(this);
  -        }
  -        catch (Throwable t)
  -        {
  -            logger.error("Release this PB using PBF failed", t);
  -            return false;
  -        }
           PersistenceBrokerThreadMapping.unsetCurrentPersistenceBroker(this.pbKey, this);
           return true;
       }
  @@ -1939,7 +1927,7 @@
   
   
                   // cache object for symmetry with getObjectByXXX()
  -                objectCache.cache(obj);
  +                objectCache.cache(new Identity(obj, this), obj);
                   LoadedObjectsRegistry.register(obj);
                   // 4. store 1:n and m:n associations
                   storeCollections(obj, cld.getCollectionDescriptors(), markedForStore);
  @@ -2460,7 +2448,6 @@
       private OJBIterator getReportQueryIteratorFromQuery(Query query, ClassDescriptor cld)
throws PersistenceBrokerException
       {
           RsIteratorFactory factory = ReportRsIteratorFactoryImpl.getInstance();
  -
           return getRsIteratorFromQueryExtentAware(query, cld, factory);
       }
   
  @@ -2517,7 +2504,6 @@
       private boolean isPKautoIncrement(FieldDescriptor[] fdesc)
       {
           int fieldDescriptorSize = fdesc.length;
  -
           for (int i = 0; i < fieldDescriptorSize; i++)
           {
               /**
  @@ -2530,7 +2516,6 @@
                   return false;
               }
           }
  -
           return true;
       }
   
  
  
  
  1.1                  jakarta-ojb/src/java/org/apache/ojb/broker/singlevm/PoolablePersistenceBroker.java
  
  Index: PoolablePersistenceBroker.java
  ===================================================================
  package org.apache.ojb.broker.singlevm;
  
  import org.apache.commons.pool.KeyedObjectPool;
  import org.apache.ojb.broker.PersistenceBroker;
  import org.apache.ojb.broker.util.logging.LoggerFactory;
  
  /**
   * A delegating PersistenceBroker that, rather than closing the underlying
   * PersistenceBroker, returns itself to an ObjectPool when closed.
   *
   * <b>FOR INTERNAL USE ONLY</b>
   *
   * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
   * @version $Id: PoolablePersistenceBroker.java,v 1.1 2002/11/28 22:10:57 arminw Exp $
   */
  public class PoolablePersistenceBroker extends DelegatingPersistenceBroker
  {
      private KeyedObjectPool pool;
  
      public PoolablePersistenceBroker(PersistenceBroker broker, KeyedObjectPool pool)
      {
          super(broker);
          this.pool = pool;
      }
  
      public boolean close()
      {
          super.close();
          try
          {
              pool.returnObject(this.getPBKey(), this);
              return true;
          }
          catch (Exception e)
          {
              LoggerFactory.getDefaultLogger().error("Unexpected exception when returning
instance to pool", e);
              return false;
          }
      }
  }
  
  
  
  1.1                  jakarta-ojb/src/java/org/apache/ojb/broker/singlevm/DelegatingPersistenceBroker.java
  
  Index: DelegatingPersistenceBroker.java
  ===================================================================
  package org.apache.ojb.broker.singlevm;
  
  import org.apache.ojb.broker.Identity;
  import org.apache.ojb.broker.ManageableCollection;
  import org.apache.ojb.broker.PBKey;
  import org.apache.ojb.broker.PBState;
  import org.apache.ojb.broker.PersistenceBroker;
  import org.apache.ojb.broker.PersistenceBrokerException;
  import org.apache.ojb.broker.PersistenceBrokerListener;
  import org.apache.ojb.broker.TransactionAbortedException;
  import org.apache.ojb.broker.TransactionInProgressException;
  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.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.configuration.Configuration;
  import org.apache.ojb.broker.util.configuration.ConfigurationException;
  
  import java.util.Collection;
  import java.util.Enumeration;
  import java.util.Iterator;
  
  /**
   * Delegating implementation of a PersistenceBroker
   *
   * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
   */
  public class DelegatingPersistenceBroker implements PersistenceBroker, PBState
  {
      protected PersistenceBroker broker;
  
      public DelegatingPersistenceBroker(PersistenceBroker broker)
      {
          this.broker = broker;
      }
  
      public boolean isClosed()
      {
          return ((PBState) broker).isClosed();
      }
  
      public void setClosed(boolean closed)
      {
          ((PBState) broker).setClosed(closed);
      }
  
      public void beginTransaction()
              throws TransactionInProgressException, TransactionAbortedException
      {
          broker.beginTransaction();
      }
  
      public void commitTransaction()
              throws TransactionNotInProgressException, TransactionAbortedException
      {
          broker.commitTransaction();
      }
  
      public void abortTransaction() throws TransactionNotInProgressException
      {
          broker.abortTransaction();
      }
  
      public boolean isInTransaction() throws PersistenceBrokerException
      {
          return broker.isInTransaction();
      }
  
      public boolean close()
      {
          return broker.close();
      }
  
      public void delete(Object obj) throws PersistenceBrokerException
      {
          broker.delete(obj);
      }
  
      public void store(Object obj) throws PersistenceBrokerException
      {
          broker.store(obj);
      }
  
      public void store(Object obj,
                        ObjectModification modification) throws PersistenceBrokerException
      {
          broker.store(obj, modification);
      }
  
      public PBKey getPBKey()
      {
          return broker.getPBKey();
      }
  
      public void setPBKey(PBKey key)
      {
          broker.setPBKey(key);
      }
  
      public void removeFromCache(Object obj) throws PersistenceBrokerException
      {
          broker.removeFromCache(obj);
      }
  
      public void clearCache() throws PersistenceBrokerException
      {
          broker.clearCache();
      }
  
      public void invalidate(Identity oid) throws PersistenceBrokerException
      {
          broker.invalidate(oid);
      }
  
      public DescriptorRepository getDescriptorRepository()
      {
          return broker.getDescriptorRepository();
      }
  
      public void removeAllListeners() throws PersistenceBrokerException
      {
          broker.removeAllListeners();
      }
  
      public void removeListener(PersistenceBrokerListener listener) throws PersistenceBrokerException
      {
          broker.removeListener(listener);
      }
  
      public void addListener(PersistenceBrokerListener listener) throws PersistenceBrokerException
      {
          broker.addListener(listener);
      }
  
      public void retrieveReference(Object pInstance, String pAttributeName) throws PersistenceBrokerException
      {
          broker.retrieveReference(pInstance, pAttributeName);
      }
  
      public void retrieveAllReferences(Object pInstance) throws PersistenceBrokerException
      {
          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
      {
          return broker.getUniqueObject(extent, attribute);
      }
  
      public String getUniqueString(Class extent, String attribute) throws PersistenceBrokerException
      {
          return broker.getUniqueString(extent, attribute);
      }
  
      public long getUniqueLong(Class extent, String attribute) throws PersistenceBrokerException
      {
          return broker.getUniqueLong(extent, attribute);
      }
  
      public int getUniqueId(Class extent, String attribute) throws PersistenceBrokerException
      {
          return broker.getUniqueId(extent, attribute);
      }
  
  
      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);
      }
  
  
      public Enumeration getPKEnumerationByQuery(Class primaryKeyClass,
                                                 Query query) throws PersistenceBrokerException
      {
          return broker.getPKEnumerationByQuery(primaryKeyClass, query);
      }
  
      public Object getObjectByQuery(Query query) throws PersistenceBrokerException
      {
          return broker.getObjectByQuery(query);
      }
  
      public Object getObjectByIdentity(Identity id) throws PersistenceBrokerException
      {
          return broker.getObjectByIdentity(id);
      }
  
      public Iterator getReportQueryIteratorByQuery(Query query) throws PersistenceBrokerException
      {
          return broker.getReportQueryIteratorByQuery(query);
      }
  
      public Iterator getIteratorByQuery(Query query) throws PersistenceBrokerException
      {
          return broker.getIteratorByQuery(query);
      }
  
      public ManageableCollection getCollectionByQuery(Class collectionClass, Query query)
              throws PersistenceBrokerException
      {
          return broker.getCollectionByQuery(collectionClass, query);
      }
  
      public int getCount(Query query) throws PersistenceBrokerException
      {
          return broker.getCount(query);
      }
  
      public Collection getCollectionByQuery(Query query) throws PersistenceBrokerException
      {
          return broker.getCollectionByQuery(query);
      }
  
      public void configure(Configuration pConfig) throws ConfigurationException
      {
          broker.configure(pConfig);
      }
  
      public org.odbms.Query query()
      {
          return broker.query();
      }
  
      public void deleteByQuery(Query query) throws PersistenceBrokerException
      {
          broker.deleteByQuery(query);
      }
  }
  
  
  

Mime
View raw message