You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by bl...@apache.org on 2001/01/09 15:15:30 UTC

cvs commit: xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/java esql.xsl

bloritsch    01/01/09 06:15:30

  Modified:    src/org/apache/cocoon/components/datasource Tag: xml-cocoon2
                        JdbcConnectionPool.java
               src/org/apache/cocoon/components/language/markup/xsp/java
                        Tag: xml-cocoon2 esql.xsl
  Log:
  A couple of minor updates for esql and pooling
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +7 -1      xml-cocoon/src/org/apache/cocoon/components/datasource/Attic/JdbcConnectionPool.java
  
  Index: JdbcConnectionPool.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/datasource/Attic/JdbcConnectionPool.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- JdbcConnectionPool.java	2001/01/08 20:25:45	1.1.2.1
  +++ JdbcConnectionPool.java	2001/01/09 14:15:23	1.1.2.2
  @@ -25,7 +25,7 @@
    * The Pool implementation for JdbcConnections.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2001/01/08 20:25:45 $
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2001/01/09 14:15:23 $
    */
   public class JdbcConnectionPool implements Pool, Runnable, Disposable {
       private final String dburl;
  @@ -112,6 +112,8 @@
               }
           }
   
  +        log.debug("JdbcConnection '" + this.dburl + "' has been requested from pool.");
  +
           return obj;
       }
   
  @@ -122,15 +124,19 @@
           if (this.monitoring) {
               this.ready.add(obj);
           }
  +
  +        log.debug("JdbcConnection '" + this.dburl + "' has been returned to the pool.");
       }
   
       public void run() {
           while (this.monitoring) {
               if (this.ready.size() < this.min) {
  +                log.debug("There are not enough Connections for pool: " + this.dburl);
                   while ((this.ready.size() < this.min) && (this.currentCount < this.max)) {
                       this.ready.add(this.createJdbcConnection());
                   }
               } else {
  +                log.debug("Trimming excess fat from pool: " + this.dburl);
                   while (this.ready.size() > this.min) {
                       this.recycle((Recyclable) this.ready.remove(0));
                   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.20  +10 -20    xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/java/Attic/esql.xsl
  
  Index: esql.xsl
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/markup/xsp/java/Attic/esql.xsl,v
  retrieving revision 1.1.2.19
  retrieving revision 1.1.2.20
  diff -u -r1.1.2.19 -r1.1.2.20
  --- esql.xsl	2001/01/05 23:07:35	1.1.2.19
  +++ esql.xsl	2001/01/09 14:15:28	1.1.2.20
  @@ -1,5 +1,5 @@
   <?xml version="1.0"?>
  -<!-- $Id: esql.xsl,v 1.1.2.19 2001/01/05 23:07:35 bloritsch Exp $-->
  +<!-- $Id: esql.xsl,v 1.1.2.20 2001/01/09 14:15:28 bloritsch Exp $-->
   <!--
   
    ============================================================================
  @@ -109,13 +109,12 @@
           <xsp:include>java.sql.SQLException</xsp:include>
           <xsp:include>java.text.SimpleDateFormat</xsp:include>
           <xsp:include>java.text.DecimalFormat</xsp:include>
  -	<xsp:include>org.apache.cocoon.components.datasource.DataSourceComponent</xsp:include>
  +    <xsp:include>org.apache.cocoon.components.datasource.DataSourceComponent</xsp:include>
         </xsp:structure>
         <xsp:logic>
   
           class EsqlSession {
               Connection connection=null;
  -            boolean closeConnection = true;
               String query;
               Statement statement;
               PreparedStatement preparedStatement;
  @@ -265,13 +264,11 @@
             <xsl:choose>
               <xsl:when test="not(esql:use-connection or esql:dburl)">
                 esqlSession.connection = ((EsqlSession)esqlSessions.peek()).connection;
  -              esqlSession.closeConnection = false;
               </xsl:when>
               <xsl:when test="esql:use-connection">
  -	      ComponentSelector esqlDSSelector = (ComponentSelector) this.manager.lookup(Roles.DB_CONNECTION);
  -	      DataSourceComponent esqlDS = (DataSourceComponent) esqlDSSelector.select(String.valueOf(<xsl:copy-of select="$use-connection"/>));
  -	      esqlSession.connection = esqlDS.getConnection();
  -              <!-- FIXME - need to do avalon pooling here maybe? -->
  +          ComponentSelector esqlDSSelector = (ComponentSelector) this.manager.lookup(Roles.DB_CONNECTION);
  +          DataSourceComponent esqlDS = (DataSourceComponent) esqlDSSelector.select(String.valueOf(<xsl:copy-of select="$use-connection"/>));
  +          esqlSession.connection = esqlDS.getConnection();
               </xsl:when>
               <xsl:otherwise>
                 ClassUtils.newInstance(String.valueOf(<xsl:copy-of select="$driver"/>).trim());
  @@ -371,19 +368,12 @@
   
             <xsl:apply-templates select="esql:error-results/*"/>
         } finally {
  -          if (esqlSession.closeConnection) {
  -              if (esqlSession.connection != null) {
  -                  try {
  -                      esqlSession.connection.close();
  -                  } catch (SQLException esqlException) {
  -                      cocoonLogger.debug("Could not close DB connection", esqlException);
  -                  }
  +          if (esqlSession.connection != null) {
  +              try {
  +                  esqlSession.connection.close();
  +              } catch (SQLException esqlException) {
  +                  cocoonLogger.debug("Could not close DB connection", esqlException);
                 }
  -
  -              <xsl:if test="esql:use-connection">
  -	        esqlSession.connection = null;
  -                <!-- FIXME - need to release avalon pooling here maybe -->
  -              </xsl:if>
             }
   
             if (esqlSessions.empty()) {