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 2003/07/18 08:14:54 UTC

cvs commit: db-ojb/src/java/org/apache/ojb/broker/accesslayer StatementsForClassFactory.java StatementManager.java StatementsForClassIF.java

thma        2003/07/17 23:14:54

  Modified:    src/java/org/apache/ojb/broker/accesslayer
                        StatementManager.java StatementsForClassIF.java
  Added:       src/java/org/apache/ojb/broker/accesslayer
                        StatementsForClassFactory.java
  Log:
  Make StatementsForClass configurable
  
  Revision  Changes    Path
  1.38      +5 -2      db-ojb/src/java/org/apache/ojb/broker/accesslayer/StatementManager.java
  
  Index: StatementManager.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/StatementManager.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- StatementManager.java	13 Jun 2003 23:06:45 -0000	1.37
  +++ StatementManager.java	18 Jul 2003 06:14:54 -0000	1.38
  @@ -91,6 +91,7 @@
    * manages JDBC Connection and Statement resources.
    *
    * @author Thomas Mahler
  + * @author <a href="mailto:rburt3@mchsi.com">Randall Burt</a>
    * @version $Id$
    */
   public class StatementManager implements StatementManagerIF
  @@ -130,7 +131,9 @@
   		{
   			synchronized (m_statementTable)
   			{
  -				sfc = (StatementsForClassIF) new StatementsForClassImpl(m_conMan.getConnectionDescriptor(), cds);
  +				// 07.17.2003 - RB: StatementsForClassImpl is now configurable
  +				//sfc = (StatementsForClassIF) new StatementsForClassImpl(m_conMan.getConnectionDescriptor(), cds);
  +				sfc = (StatementsForClassIF) StatementsForClassFactory.getInstance().getStatementsForClass(m_conMan.getConnectionDescriptor(), cds);
   				m_statementTable.put(cds, sfc);
   			}
   		}
  
  
  
  1.7       +6 -1      db-ojb/src/java/org/apache/ojb/broker/accesslayer/StatementsForClassIF.java
  
  Index: StatementsForClassIF.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/StatementsForClassIF.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- StatementsForClassIF.java	19 Jan 2003 12:18:44 -0000	1.6
  +++ StatementsForClassIF.java	18 Jul 2003 06:14:54 -0000	1.7
  @@ -70,6 +70,11 @@
   import java.sql.Connection;
   
   /**
  +  * A class that implements this interface serves as a cache for 
  +  * <code>java.sql.Statements<code> used for persistence operations
  +  * on a given class. 
  +  * @author brj
  +  * @author <a href="mailto:rburt3@mchsi.com">Randall Burt</a>
     * @version $Id$
     */
   
  
  
  
  1.1                  db-ojb/src/java/org/apache/ojb/broker/accesslayer/StatementsForClassFactory.java
  
  Index: StatementsForClassFactory.java
  ===================================================================
  package org.apache.ojb.broker.accesslayer;
  
  /* ====================================================================
   * 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.util.factory.ConfigurableFactory;
  import org.apache.ojb.broker.metadata.ClassDescriptor;
  import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
  
  /**
   * Factory for {@link org.apache.ojb.broker.accesslayer.StatementsForClassIF}
   * implementations. Developers may specify the specific implementation returned by
   * {@link #getStatementsForClass} by implementing the 
   * {@link org.apache.ojb.broker.accesslayer.StatementsForClassIF}
   * interface and setting the <code>StatementsForClassClass</code> property in 
   * <code>OJB.properties</code>.
   * <br/>
   * @see org.apache.ojb.broker.accesslayer.StatementManager#getStatementsForClass
   * @see org.apache.ojb.broker.accesslayer.StatementsForClassImpl
   * @author <a href="mailto:rburt3@mchsi.com">Randall Burt</a>
   * @version $Id: StatmentsForClassFactory.java,v 1.0 2003/07/17 20:50:48 rburt3 Exp $
   */
  
  public class StatementsForClassFactory extends ConfigurableFactory
  {
  	private static StatementsForClassFactory singleton;
  
  
  	/**
  	 * Get the singleton instance of this class
       * @return the singleton instance of StatementsForClassFactory
       */
      public static synchronized StatementsForClassFactory getInstance()
  	{
  		if (singleton == null)
  		{
  			singleton = new StatementsForClassFactory();
  		}
  		return singleton;
  	}
  	
      /*
       * @see org.apache.ojb.broker.util.factory.ConfigurableFactory#getConfigurationKey()
       */
      protected String getConfigurationKey()
      {
          return "StatementsForClassClass";
      }
  
  
      /**
       * Get an instance of {@link org.apache.ojb.broker.accesslayer.StatementsForClassIF}
       * @param cds our connection descriptor
       * @param cld the class descriptor of the persistant object
       * @return an instance of {@link org.apache.ojb.broker.accesslayer.StatementsForClassIF}
       */
      public StatementsForClassIF getStatementsForClass(JdbcConnectionDescriptor cds, ClassDescriptor cld)
      {
  		return (StatementsForClassIF) this.createNewInstance(new Class[]{JdbcConnectionDescriptor.class, ClassDescriptor.class}, 
  		                                                     new Object[]{cds, cld});
      }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org