You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2003/06/01 01:46:25 UTC

cvs commit: jakarta-james/src/java/org/apache/james/util SqlResources.java

noel        2003/05/31 16:46:25

  Modified:    src/java/org/apache/james/util Tag: branch_2_1_fcs
                        SqlResources.java
  Log:
  Introduced a shared string table rather than have each instance carry complete copies of every SQL command.  Also released Perl5Util after initialization, so that it can be garbage collected.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.5.4.3   +15 -1     jakarta-james/src/java/org/apache/james/util/SqlResources.java
  
  Index: SqlResources.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/util/SqlResources.java,v
  retrieving revision 1.5.4.2
  retrieving revision 1.5.4.3
  diff -u -r1.5.4.2 -r1.5.4.3
  --- SqlResources.java	8 Mar 2003 21:54:11 -0000	1.5.4.2
  +++ SqlResources.java	31 May 2003 23:46:25 -0000	1.5.4.3
  @@ -79,7 +79,6 @@
    * database products, by detecting product information from the
    * jdbc DatabaseMetaData object.
    * 
  - * @author Darrell DeBoer <dd...@bigdaz.com>
    */
   public class SqlResources
   {
  @@ -89,6 +88,11 @@
       private Map m_sql = new HashMap();
   
       /**
  +     * A set of all used String values
  +     */
  +    static private Map stringTable = java.util.Collections.synchronizedMap(new HashMap());
  +
  +    /**
        * A Perl5 regexp matching helper class
        */
       private Perl5Util m_perl5Util = new Perl5Util();
  @@ -126,6 +130,7 @@
           String dbProduct = null;
           if ( dbMatcherElement != null ) {
               dbProduct = matchDbConnection(conn, dbMatcherElement);
  +            m_perl5Util = null;     // release the PERL matcher!
           }
   
           // Now get the section defining sql for the repository required.
  @@ -217,6 +222,15 @@
                               .append(paramName)
                               .append("}");
                   sqlString = substituteSubString(sqlString, replaceBuffer.toString(), paramValue);
  +            }
  +
  +            // See if we already have registered a string of this value
  +            String shared = (String) stringTable.get(sqlString);
  +            // If not, register it -- we will use it next time
  +            if (shared == null) {
  +                stringTable.put(sqlString, sqlString);
  +            } else {
  +                sqlString = shared;
               }
   
               // Add to the sqlMap - either the "default" or the "product" map
  
  
  

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