db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb/broker ConnectionFactoryTest.java
Date Mon, 15 Nov 2004 17:35:36 GMT
arminw      2004/11/15 09:35:36

  Modified:    src/java/org/apache/ojb/broker/accesslayer
                        ConnectionFactoryDBCPImpl.java
                        ConnectionFactoryPooledImpl.java
               src/java/org/apache/ojb/broker/metadata
                        ConnectionDescriptorXmlHandler.java
                        JdbcConnectionDescriptor.java
               src/test/org/apache/ojb/broker/metadata MetadataTest.java
               src/test/org/apache/ojb/broker ConnectionFactoryTest.java
  Added:       src/java/org/apache/ojb/broker/metadata
                        ConnectionFactoryDescriptor.java
  Removed:     src/java/org/apache/ojb/broker/metadata
                        ConnectionPoolDescriptor.java
  Log:
  rename ConnectionPoolDescriptor to ConnectionFactorzDescriptor
  
  Revision  Changes    Path
  1.13      +4 -4      db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionFactoryDBCPImpl.java
  
  Index: ConnectionFactoryDBCPImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionFactoryDBCPImpl.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ConnectionFactoryDBCPImpl.java	14 Sep 2004 16:03:32 -0000	1.12
  +++ ConnectionFactoryDBCPImpl.java	15 Nov 2004 17:35:35 -0000	1.13
  @@ -151,7 +151,7 @@
   
           KeyedObjectPoolFactory statementPoolFactory = createStatementPoolFactory(null);
           // set the validation query
  -        String validationQuery = jcd.getConnectionPoolDescriptor().getValidationQuery();
  +        String validationQuery = jcd.getConnectionFactoryDescriptor().getValidationQuery();
           boolean defaultReadOnly = false;
           // set autocommit mode
           boolean defaultAutoCommit = (jcd.getUseAutoCommit() == JdbcConnectionDescriptor.AUTO_COMMIT_SET_FALSE)
?
  @@ -185,7 +185,7 @@
       {
           PoolConfiguration poolConf = new PoolConfiguration();
           // read all attributes from descriptor and add them to ..Conf class
  -        poolConf.putAll(jcd.getConnectionPoolDescriptor().getAttributes());
  +        poolConf.putAll(jcd.getConnectionFactoryDescriptor().getAttributes());
   
           GenericObjectPool.Config conf = poolConf.getObjectPoolConfig();
           return conf;
  @@ -195,7 +195,7 @@
       {
           PoolConfiguration poolConf = new PoolConfiguration();
           // read all attributes from descriptor and add them to ..Conf class
  -        poolConf.putAll(jcd.getConnectionPoolDescriptor().getAttributes());
  +        poolConf.putAll(jcd.getConnectionFactoryDescriptor().getAttributes());
   
           AbandonedConfig ac = poolConf.getAbandonedConfig();
           return ac;
  
  
  
  1.18      +3 -3      db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionFactoryPooledImpl.java
  
  Index: ConnectionFactoryPooledImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionFactoryPooledImpl.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ConnectionFactoryPooledImpl.java	14 Sep 2004 16:03:33 -0000	1.17
  +++ ConnectionFactoryPooledImpl.java	15 Nov 2004 17:35:35 -0000	1.18
  @@ -108,7 +108,7 @@
       {
           PoolConfiguration poolConf = new PoolConfiguration();
           // read all attributes from descriptor and add them to ..Conf class
  -        poolConf.putAll(jcd.getConnectionPoolDescriptor().getAttributes());
  +        poolConf.putAll(jcd.getConnectionFactoryDescriptor().getAttributes());
   
           GenericObjectPool.Config conf = poolConf.getObjectPoolConfig();
           return conf;
  @@ -133,7 +133,7 @@
           public boolean validateObject(Object obj)
           {
               Connection con = (Connection) obj;
  -            String query = getJcd().getConnectionPoolDescriptor().getValidationQuery();
  +            String query = getJcd().getConnectionFactoryDescriptor().getValidationQuery();
               if (query == null || query.trim().equals(""))
               {
                   try
  
  
  
  1.14      +2 -2      db-ojb/src/java/org/apache/ojb/broker/metadata/ConnectionDescriptorXmlHandler.java
  
  Index: ConnectionDescriptorXmlHandler.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/ConnectionDescriptorXmlHandler.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ConnectionDescriptorXmlHandler.java	14 Sep 2004 16:17:41 -0000	1.13
  +++ ConnectionDescriptorXmlHandler.java	15 Nov 2004 17:35:35 -0000	1.14
  @@ -226,7 +226,7 @@
                   case CONNECTION_FACTORY:
                       {
                           if (isDebug) logger.debug("    > " + RepositoryTags.getTagById(CONNECTION_FACTORY));
  -                        ConnectionPoolDescriptor m_CurrentCPD = m_CurrentJCD.getConnectionPoolDescriptor();
  +                        ConnectionFactoryDescriptor m_CurrentCPD = m_CurrentJCD.getConnectionFactoryDescriptor();
                           this.currentAttributeContainer = m_CurrentCPD;
   
                           String connectionFactoryStr = atts.getValue(RepositoryTags.getTagById(CLASS_NAME));
  
  
  
  1.34      +7 -7      db-ojb/src/java/org/apache/ojb/broker/metadata/JdbcConnectionDescriptor.java
  
  Index: JdbcConnectionDescriptor.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/JdbcConnectionDescriptor.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- JdbcConnectionDescriptor.java	14 Sep 2004 16:17:41 -0000	1.33
  +++ JdbcConnectionDescriptor.java	15 Nov 2004 17:35:35 -0000	1.34
  @@ -53,7 +53,7 @@
       private int useAutoCommit = 1;
       private boolean ignoreAutoCommitExceptions = false;
       private PBKey pbKey;
  -    private ConnectionPoolDescriptor cpd;
  +    private ConnectionFactoryDescriptor cpd;
       private SequenceDescriptor sequenceDescriptor;
       private ObjectCacheDescriptor objectCacheDescriptor;
       private BatchDescriptor batchDescriptor;
  @@ -69,7 +69,7 @@
        */
       public JdbcConnectionDescriptor()
       {
  -        cpd = new ConnectionPoolDescriptor();
  +        cpd = new ConnectionFactoryDescriptor();
           sequenceDescriptor = new SequenceDescriptor(this);
           objectCacheDescriptor = new ObjectCacheDescriptor();
           batchDescriptor = new BatchDescriptor();
  @@ -161,7 +161,7 @@
       /**
        * Returns the connection pool descriptor.
        */
  -    public ConnectionPoolDescriptor getConnectionPoolDescriptor()
  +    public ConnectionFactoryDescriptor getConnectionFactoryDescriptor()
       {
           return cpd;
       }
  @@ -169,7 +169,7 @@
       /**
        * Sets the connection pool descriptor.
        */
  -    public void setConnectionPoolDescriptor(ConnectionPoolDescriptor cpd)
  +    public void setConnectionFactoryDescriptor(ConnectionFactoryDescriptor cpd)
       {
           this.cpd = cpd;
       }
  @@ -424,7 +424,7 @@
           append("db-alias", m_DbAlias).
           append("user", m_UserName).
           append("password", "*****").
  -        append("ConnectionPoolDescriptor", cpd).
  +        append("ConnectionFactoryDescriptor", cpd).
           append("batch-mode", m_batchMode).
           append("useAutoCommit", getUseAutoCommitAsString(useAutoCommit)).
           append("ignoreAutoCommitExceptions", ignoreAutoCommitExceptions).
  @@ -530,7 +530,7 @@
           strReturn.append( this.getBatchDescriptor().toXML() );
           strReturn.append( eol );
   
  -        strReturn.append( this.getConnectionPoolDescriptor().toXML() );
  +        strReturn.append( this.getConnectionFactoryDescriptor().toXML() );
           strReturn.append( eol );
           if( this.getSequenceDescriptor() != null )
           {
  
  
  
  1.1                  db-ojb/src/java/org/apache/ojb/broker/metadata/ConnectionFactoryDescriptor.java
  
  Index: ConnectionFactoryDescriptor.java
  ===================================================================
  package org.apache.ojb.broker.metadata;
  
  
  /* Copyright 2002-2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  import java.util.Enumeration;
  import java.util.Properties;
  
  import org.apache.commons.lang.SystemUtils;
  import org.apache.commons.lang.builder.ToStringBuilder;
  import org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl;
  
  
  /**
   * Encapsulates connection pooling configuration properties managed by
   * {@link org.apache.ojb.broker.metadata.JdbcConnectionDescriptor}.
   * <br/>
   * Every new instantiated <code>ConnectionFactoryDescriptor</code> was
   * associated with default connection pool attributes.
   *
   * @author <a href="mailto:armin@codeAuLait.de">Armin Waibel</a>
   * @version $Id: ConnectionFactoryDescriptor.java,v 1.1 2004/11/15 17:35:35 arminw Exp $
   */
  public class ConnectionFactoryDescriptor extends DescriptorBase implements  XmlCapable
  {
  	private static final long serialVersionUID = -3071461685659671879L;
  
      private static final Class DEF_CONNECTION_FACTORY = ConnectionFactoryPooledImpl.class;
  
      private Class connectionFactory;
      private String validationQuery;
  
      public ConnectionFactoryDescriptor()
      {
          super();
          this.connectionFactory = DEF_CONNECTION_FACTORY;
          this.validationQuery = null;
      }
  
      public Class getConnectionFactory()
      {
          return this.connectionFactory;
      }
  
      public void setConnectionFactory(Class connectionFactory)
      {
          if (connectionFactory == null) throw new MetadataException("Given ConnectionFactory
was null");
          this.connectionFactory = connectionFactory;
      }
  
      public String getValidationQuery()
      {
          return validationQuery;
      }
  
      public void setValidationQuery(String validationQuery)
      {
          this.validationQuery = validationQuery;
      }
  
      public String toString()
      {
          ToStringBuilder buf = new ToStringBuilder(this);
          buf.
          append("connectionFactory", connectionFactory).
          append("validationQuery", validationQuery);
          return buf.toString();
  
      }
  
      public String toXML()
      {
          String eol = SystemUtils.LINE_SEPARATOR;
          StringBuffer buf = new StringBuffer();
          buf.append( "      " );
          buf.append( RepositoryTags.getOpeningTagNonClosingById(CONNECTION_FACTORY) );
          buf.append( eol );
          buf.append("         " + RepositoryTags.getAttribute(RepositoryElements.CLASS_NAME,
getConnectionFactory().getName()));
          buf.append( eol );
          buf.append("         " + RepositoryTags.getAttribute(RepositoryElements.VALIDATION_QUERY,
                   (getValidationQuery()!=null ? getValidationQuery() : "")) + eol);
          buf.append( "      >" );
          buf.append( eol );
          buf.append( "         <!-- " );
          buf.append( eol );
          buf.append( "         Add connection factory properties here, using custom attributes"
);
          buf.append( eol );
          buf.append( "         e.g. <attribute attribute-name=\"maxActive\" attribute-value=\"20\"/>"
);
          buf.append( eol );
          buf.append( "         -->" );
          buf.append( eol );
          buf.append( buildAttributes() );
          buf.append( "      " );
          buf.append( RepositoryTags.getClosingTagById(CONNECTION_FACTORY));
          buf.append( eol );
          return buf.toString();
      }
  
      private String buildAttributes()
      {
          String eol = SystemUtils.LINE_SEPARATOR;
          Properties prop = getAttributes();
          if( prop == null || prop.isEmpty() )
              return "";
  
          StringBuffer buf = new StringBuffer();
          Enumeration en = prop.keys();
          while( en.hasMoreElements() )
          {
              String key = ( String ) en.nextElement();
              String value = prop.getProperty( key );
              buf.append( "         <attribute attribute-name=\"" );
              buf.append( key );
              buf.append( "\" attribute-value=\"" );
              buf.append( value );
              buf.append( "\"/>" );
              buf.append( eol );
          }
          return buf.toString();
      }
  }
  
  
  
  
  1.20      +1 -1      db-ojb/src/test/org/apache/ojb/broker/metadata/MetadataTest.java
  
  Index: MetadataTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/metadata/MetadataTest.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- MetadataTest.java	1 Oct 2004 16:42:10 -0000	1.19
  +++ MetadataTest.java	15 Nov 2004 17:35:36 -0000	1.20
  @@ -479,7 +479,7 @@
           assertEquals("cacheValue1", ocd.getAttribute("cacheKey1"));
           assertEquals("cacheValue2", ocd.getAttribute("cacheKey2"));
   
  -        ConnectionPoolDescriptor cpd = jcd.getConnectionPoolDescriptor();
  +        ConnectionFactoryDescriptor cpd = jcd.getConnectionFactoryDescriptor();
   
           assertNotNull(cpd.getConnectionFactory());
           assertEquals(ConnectionFactoryNotPooledImpl.class, cpd.getConnectionFactory());
  
  
  
  1.8       +11 -11    db-ojb/src/test/org/apache/ojb/broker/ConnectionFactoryTest.java
  
  Index: ConnectionFactoryTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/ConnectionFactoryTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ConnectionFactoryTest.java	14 Nov 2004 09:41:31 -0000	1.7
  +++ ConnectionFactoryTest.java	15 Nov 2004 17:35:36 -0000	1.8
  @@ -47,7 +47,7 @@
       private void checkFactory(Class factory) throws Exception
       {
           JdbcConnectionDescriptor jcd = broker.getConfiguration().getJdbcConnectionDescriptor();
  -        Class oldCF = jcd.getConnectionPoolDescriptor().getConnectionFactory();
  +        Class oldCF = jcd.getConnectionFactoryDescriptor().getConnectionFactory();
           int oldAutoCommit = jcd.getUseAutoCommit();
           try
           {
  @@ -56,7 +56,7 @@
               // change autoCommit state
               jcd.setUseAutoCommit(2);
               // set connection factory we want to test
  -            jcd.getConnectionPoolDescriptor().setConnectionFactory(factory);
  +            jcd.getConnectionFactoryDescriptor().setConnectionFactory(factory);
   
               // get the connetion factory for used JCD
               ConnectionFactory cf = broker.serviceConnectionManager().getConnectionFactory();
  @@ -83,7 +83,7 @@
               broker.serviceConnectionManager().releaseConnection();
               // restore settings
               jcd.setUseAutoCommit(oldAutoCommit);
  -            jcd.getConnectionPoolDescriptor().setConnectionFactory(oldCF);
  +            jcd.getConnectionFactoryDescriptor().setConnectionFactory(oldCF);
           }
       }
   
  @@ -100,19 +100,19 @@
       private void checkFactoryPoolExhausted(Class factory) throws Exception
       {
           JdbcConnectionDescriptor jcd = broker.getConfiguration().getJdbcConnectionDescriptor();
  -        Class oldCF = jcd.getConnectionPoolDescriptor().getConnectionFactory();
  +        Class oldCF = jcd.getConnectionFactoryDescriptor().getConnectionFactory();
           int oldAutoCommit = jcd.getUseAutoCommit();
  -        String oldMaxActive = jcd.getConnectionPoolDescriptor().getAttribute(PoolConfiguration.MAX_ACTIVE);
  +        String oldMaxActive = jcd.getConnectionFactoryDescriptor().getAttribute(PoolConfiguration.MAX_ACTIVE);
           try
           {
               // release connection factory of current broker
               broker.serviceConnectionManager().releaseConnection();
               // set connection factory we want to test
  -            jcd.getConnectionPoolDescriptor().setConnectionFactory(factory);
  +            jcd.getConnectionFactoryDescriptor().setConnectionFactory(factory);
   
               jcd.setUseAutoCommit(1);
  -            jcd.getConnectionPoolDescriptor().addAttribute(PoolConfiguration.MAX_ACTIVE,
"2");
  -            jcd.getConnectionPoolDescriptor().setConnectionFactory(factory);
  +            jcd.getConnectionFactoryDescriptor().addAttribute(PoolConfiguration.MAX_ACTIVE,
"2");
  +            jcd.getConnectionFactoryDescriptor().setConnectionFactory(factory);
   
               Connection con = null;
               Connection con2 = null;
  @@ -159,8 +159,8 @@
               broker.serviceConnectionManager().releaseConnection();
               // restore settings
               jcd.setUseAutoCommit(oldAutoCommit);
  -            jcd.getConnectionPoolDescriptor().setConnectionFactory(oldCF);
  -            jcd.getConnectionPoolDescriptor().addAttribute(PoolConfiguration.MAX_ACTIVE,
oldMaxActive);
  +            jcd.getConnectionFactoryDescriptor().setConnectionFactory(oldCF);
  +            jcd.getConnectionFactoryDescriptor().addAttribute(PoolConfiguration.MAX_ACTIVE,
oldMaxActive);
           }
       }
   }
  
  
  

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


Mime
View raw message