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/java/org/apache/ojb/broker/accesslayer ConnectionFactoryDBCPImpl.java ConnectionFactoryPooledImpl.java
Date Sun, 09 Oct 2005 23:51:01 GMT
arminw      2005/10/09 16:51:01

  Modified:    src/java/org/apache/ojb/broker/accesslayer Tag:
                        OJB_1_0_RELEASE ConnectionFactoryDBCPImpl.java
                        ConnectionFactoryPooledImpl.java
  Log:
  code cleanup
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.10.2.5  +15 -22    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.10.2.4
  retrieving revision 1.10.2.5
  diff -u -r1.10.2.4 -r1.10.2.5
  --- ConnectionFactoryDBCPImpl.java	30 Apr 2005 20:55:15 -0000	1.10.2.4
  +++ ConnectionFactoryDBCPImpl.java	9 Oct 2005 23:51:01 -0000	1.10.2.5
  @@ -67,7 +67,7 @@
       /** Key=PBKey, value=PoolingDataSource. */
       private Map dsMap = Collections.synchronizedMap(new HashMap());
       /** Synchronize object for operations not synchronized on Map only. */
  -    private Object poolSynch = new Object();
  +    private final Object poolSynch = new Object();
   
       public Connection checkOutJdbcConnection(JdbcConnectionDescriptor jcd) throws LookupException
       {
  @@ -219,8 +219,7 @@
           final boolean defaultAutoCommit;
           final boolean defaultReadOnly = false;
           validationQuery = jcd.getConnectionPoolDescriptor().getValidationQuery();
  -        defaultAutoCommit = (jcd.getUseAutoCommit() == JdbcConnectionDescriptor.AUTO_COMMIT_SET_FALSE)
?
  -                false : true;
  +        defaultAutoCommit = (jcd.getUseAutoCommit() != JdbcConnectionDescriptor.AUTO_COMMIT_SET_FALSE);
   
           //
           // Now we'll create the PoolableConnectionFactory, which wraps
  @@ -242,7 +241,7 @@
                                                 AbandonedConfig ac)
       {
           final GenericObjectPool connectionPool;
  -        final boolean doRemoveAbandoned = ac != null && ac.getRemoveAbandoned()
== true;
  +        final boolean doRemoveAbandoned = ac != null && ac.getRemoveAbandoned();
   
           if (doRemoveAbandoned) {
               connectionPool = new AbandonedObjectPool(null, ac);
  @@ -277,10 +276,8 @@
           final String poolStmtParam = properties.getProperty(PARAM_NAME_POOL_STATEMENTS);
           if (poolStmtParam != null && Boolean.valueOf(poolStmtParam).booleanValue())
           {
  -            final String maxOpenPrepStmtString;
  -
               int maxOpenPreparedStatements = GenericKeyedObjectPool.DEFAULT_MAX_TOTAL;
  -            maxOpenPrepStmtString = properties.getProperty(PARAM_NAME_STATEMENT_POOL_MAX_TOTAL);
  +            final String maxOpenPrepStmtString = properties.getProperty(PARAM_NAME_STATEMENT_POOL_MAX_TOTAL);
               if (maxOpenPrepStmtString != null)
               {
                   maxOpenPreparedStatements = Integer.parseInt(maxOpenPrepStmtString);
  @@ -319,25 +316,21 @@
               final Properties properties = jcd.getConnectionPoolDescriptor().getDbcpProperties();
               final String allowConnectionUnwrapParam;
               allowConnectionUnwrapParam = properties.getProperty(PARAM_NAME_UNWRAP_ALLOWED);
  -            if (allowConnectionUnwrapParam != null &&
  -                Boolean.valueOf(allowConnectionUnwrapParam).booleanValue())
  -            {
  -                allowConnectionUnwrap = true;
  -            }
  -            else
  -            {
  -                allowConnectionUnwrap = false;
  -            }
  +            allowConnectionUnwrap = allowConnectionUnwrapParam != null &&
  +                    Boolean.valueOf(allowConnectionUnwrapParam).booleanValue();
           }
           final PoolingDataSource dataSource;
           dataSource = new PoolingDataSource(connectionPool);
           dataSource.setAccessToUnderlyingConnectionAllowed(allowConnectionUnwrap);
   
  -        final AbandonedConfig ac = jcd.getConnectionPoolDescriptor().getAbandonedConfig();
  -        if (ac.getRemoveAbandoned() && ac.getLogAbandoned()) {
  -            final LoggerWrapperPrintWriter loggerPiggyBack;
  -            loggerPiggyBack = new LoggerWrapperPrintWriter(log, Logger.ERROR);
  -            dataSource.setLogWriter(loggerPiggyBack);
  +        if(jcd != null)
  +        {
  +            final AbandonedConfig ac = jcd.getConnectionPoolDescriptor().getAbandonedConfig();
  +            if (ac.getRemoveAbandoned() && ac.getLogAbandoned()) {
  +                final LoggerWrapperPrintWriter loggerPiggyBack;
  +                loggerPiggyBack = new LoggerWrapperPrintWriter(log, Logger.ERROR);
  +                dataSource.setLogWriter(loggerPiggyBack);
  +            }
           }
           return dataSource;
       }
  
  
  
  1.15.2.8  +3 -4      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.15.2.7
  retrieving revision 1.15.2.8
  diff -u -r1.15.2.7 -r1.15.2.8
  --- ConnectionFactoryPooledImpl.java	24 Jul 2005 23:40:18 -0000	1.15.2.7
  +++ ConnectionFactoryPooledImpl.java	9 Oct 2005 23:51:01 -0000	1.15.2.8
  @@ -49,7 +49,7 @@
       /** Key=PBKey, value=ObjectPool. */
       private Map poolMap = new HashMap();
       /** Synchronize object for operations not synchronized on Map only. */
  -    private Object poolSynch = new Object();
  +    private final Object poolSynch = new Object();
   
       public void releaseJdbcConnection(JdbcConnectionDescriptor jcd, Connection con)
               throws LookupException
  @@ -132,8 +132,7 @@
           if (log.isDebugEnabled()) log.debug("createPool was called");
           PoolableObjectFactory pof = new ConPoolFactory(this, jcd);
           GenericObjectPool.Config conf = jcd.getConnectionPoolDescriptor().getObjectPoolConfig();
  -        ObjectPool op = new GenericObjectPool(pof, conf);
  -        return op;
  +        return (ObjectPool)new GenericObjectPool(pof, conf);
       }
   
       /**
  
  
  

---------------------------------------------------------------------
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