noel        2003/05/31 17:02:31

  Modified:    src/java/org/apache/james/util 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
  1.11      +15 -0     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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SqlResources.java 8 Mar 2003 21:14:12 -0000       1.10
  +++ SqlResources.java 1 Jun 2003 00:02:31 -0000       1.11
  @@ -93,6 +93,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();
  @@ -130,6 +135,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.
  @@ -221,6 +227,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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to