noel        2003/02/04 11:38:25

  Modified:    src/java/org/apache/james/mailrepository Tag: branch_2_1_fcs
                        AvalonSpoolRepository.java JDBCMailRepository.java
                        JDBCSpoolRepository.java
               src/java/org/apache/james/services Tag: branch_2_1_fcs
                        SpoolRepository.java
  Log:
  made SpoolRepository.accept() interruptable; logged 'impossible' exceptions; fixed 
bad javadoc markup
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.7.4.1   +17 -13    
jakarta-james/src/java/org/apache/james/mailrepository/AvalonSpoolRepository.java
  
  Index: AvalonSpoolRepository.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-james/src/java/org/apache/james/mailrepository/AvalonSpoolRepository.java,v
  retrieving revision 1.7
  retrieving revision 1.7.4.1
  diff -u -r1.7 -r1.7.4.1
  --- AvalonSpoolRepository.java        18 Aug 2002 07:23:55 -0000      1.7
  +++ AvalonSpoolRepository.java        4 Feb 2003 19:38:24 -0000       1.7.4.1
  @@ -18,14 +18,12 @@
    * Implementation of a MailRepository on a FileSystem.
    *
    * Requires a configuration element in the .conf.xml file of the form:
  - *  <repository destinationURL="file://path-to-root-dir-for-repository"
  + *  &lt;repository destinationURL="file://path-to-root-dir-for-repository"
    *              type="MAIL"
  - *              model="SYNCHRONOUS"/>
  + *              model="SYNCHRONOUS"/&gt;
    * Requires a logger called MailRepository.
    *
    * @version 1.0.0, 24/04/1999
  - * @author  Federico Barbieri <[EMAIL PROTECTED]>
  - * @author Charles Benett <[EMAIL PROTECTED]>
    */
   public class AvalonSpoolRepository
       extends AvalonMailRepository
  @@ -40,15 +38,15 @@
        *
        * @return the key for the mail
        */
  -    public synchronized String accept() {
  +    public synchronized String accept() throws InterruptedException {
           if ((DEEP_DEBUG) && (getLogger().isDebugEnabled())) {
               getLogger().debug("Method accept() called");
           }
  -        while (true) {
  +        while (!Thread.currentThread().isInterrupted()) {
               try {
                   for(Iterator it = list(); it.hasNext(); ) {
   
  -                    String s = it.next().toString();                    
  +                    String s = it.next().toString();
                       if ((DEEP_DEBUG) && (getLogger().isDebugEnabled())) {
                           StringBuffer logBuffer =
                               new StringBuffer(64)
  @@ -66,11 +64,14 @@
                   }
   
                   wait();
  -            } catch (InterruptedException ignored) {
  -            } catch (ConcurrentModificationException ignoredAlso) {
  +            } catch (InterruptedException ex) {
  +                throw ex;
  +            } catch (ConcurrentModificationException cme) {
                  // Should never get here now that list methods clones keyset for 
iterator
  +                getLogger().error("CME in spooler - please report to 
http://james.apache.org";, cme);
               }
           }
  +        throw new InterruptedException();
       }
   
       /**
  @@ -84,11 +85,11 @@
        *
        * @return the key for the mail
        */
  -    public synchronized String accept(long delay) {
  +    public synchronized String accept(long delay) throws InterruptedException {
           if ((DEEP_DEBUG) && (getLogger().isDebugEnabled())) {
               getLogger().debug("Method accept(delay) called");
           }
  -        while (true) {
  +        while (!Thread.currentThread().isInterrupted()) {
               long youngest = 0;
               for (Iterator it = list(); it.hasNext(); ) {
                   String s = it.next().toString();
  @@ -139,10 +140,13 @@
                   } else {
                       wait(youngest - System.currentTimeMillis());
                   }
  -            } catch (InterruptedException ignored) {
  -            } catch (ConcurrentModificationException ignoredAlso) {
  +            } catch (InterruptedException ex) {
  +                throw ex;
  +            } catch (ConcurrentModificationException cme) {
                  // Should never get here now that list methods clones keyset for 
iterator
  +                getLogger().error("CME in spooler - please report to 
http://james.apache.org";, cme);
               }
           }
  +        throw new InterruptedException();
       }
   }
  
  
  
  1.30.4.2  +1 -1      
jakarta-james/src/java/org/apache/james/mailrepository/JDBCMailRepository.java
  
  Index: JDBCMailRepository.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-james/src/java/org/apache/james/mailrepository/JDBCMailRepository.java,v
  retrieving revision 1.30.4.1
  retrieving revision 1.30.4.2
  diff -u -r1.30.4.1 -r1.30.4.2
  --- JDBCMailRepository.java   2 Feb 2003 23:38:25 -0000       1.30.4.1
  +++ JDBCMailRepository.java   4 Feb 2003 19:38:24 -0000       1.30.4.2
  @@ -743,7 +743,7 @@
               rsListMessages = listMessages.executeQuery();
   
               List messageList = new ArrayList();
  -            while (rsListMessages.next()) {
  +            while (rsListMessages.next() && 
!Thread.currentThread().isInterrupted()) {
                   messageList.add(rsListMessages.getString(1));
               }
               return messageList.iterator();
  
  
  
  1.15.4.1  +19 -17    
jakarta-james/src/java/org/apache/james/mailrepository/JDBCSpoolRepository.java
  
  Index: JDBCSpoolRepository.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-james/src/java/org/apache/james/mailrepository/JDBCSpoolRepository.java,v
  retrieving revision 1.15
  retrieving revision 1.15.4.1
  diff -u -r1.15 -r1.15.4.1
  --- JDBCSpoolRepository.java  12 Aug 2002 07:41:36 -0000      1.15
  +++ JDBCSpoolRepository.java  4 Feb 2003 19:38:24 -0000       1.15.4.1
  @@ -22,13 +22,13 @@
    * Implementation of a SpoolRepository on a database.
    *
    * <p>Requires a configuration element in the .conf.xml file of the form:
  - *  <br><repository destinationURL="town://path"
  + *  <br>&lt;repository destinationURL="town://path"
    *  <br>            type="MAIL"
  - *  <br>            model="SYNCHRONOUS"/>
  - *  <br>            <driver>sun.jdbc.odbc.JdbcOdbcDriver</conn>
  - *  <br>            <conn>jdbc:odbc:LocalDB</conn>
  - *  <br>            <table>Message</table>
  - *  <br></repository>
  + *  <br>            model="SYNCHRONOUS"/&gt;
  + *  <br>            &lt;driver&gt;sun.jdbc.odbc.JdbcOdbcDriver&lt;/conn&gt;
  + *  <br>            &lt;conn&gt;jdbc:odbc:LocalDB&lt;/conn&gt;
  + *  <br>            &lt;table&gt;Message&lt;/table&gt;
  + *  <br>&lt;/repository&gt;
    * <p>destinationURL specifies..(Serge??)
    * <br>Type can be SPOOL or MAIL
    * <br>Model is currently not used and may be dropped
  @@ -72,7 +72,6 @@
    *
    *
    * @version 1.0.0, 24/04/1999
  - * @author  Serge Knystautas <[EMAIL PROTECTED]>
    */
   public class JDBCSpoolRepository extends JDBCMailRepository implements 
SpoolRepository {
   
  @@ -96,12 +95,12 @@
       /**
        * Return the key of a message to process.  This is a message in the spool that 
is not locked.
        */
  -    public String accept() {
  -        while (true) {
  +    public String accept() throws InterruptedException {
  +        while (!Thread.currentThread().isInterrupted()) {
               //Loop through until we are either out of pending messages or have a 
message
               // that we can lock
               PendingMessage next = null;
  -            while ((next = getNextPendingMessage()) != null) {
  +            while ((next = getNextPendingMessage()) != null && 
!Thread.currentThread().isInterrupted()) {
                   if (lock(next.key)) {
                       return next.key;
                   }
  @@ -118,9 +117,11 @@
                       //System.err.println(errorBuffer.toString());
                       wait(WAIT_LIMIT);
                   }
  -            } catch (InterruptedException ignored) {
  +            } catch (InterruptedException ex) {
  +                throw ex;
               }
           }
  +        throw new InterruptedException();
       }
   
       /**
  @@ -128,13 +129,13 @@
        * then check the last updated time, and don't try it until the long 'delay' 
parameter
        * milliseconds has passed.
        */
  -    public synchronized String accept(long delay) {
  -        while (true) {
  +    public synchronized String accept(long delay) throws InterruptedException {
  +        while (!Thread.currentThread().isInterrupted()) {
               //Loop through until we are either out of pending messages or have a 
message
               // that we can lock
               PendingMessage next = null;
               long sleepUntil = 0;
  -            while ((next = getNextPendingMessage()) != null) {
  +            while ((next = getNextPendingMessage()) != null && 
!Thread.currentThread().isInterrupted()) {
                   //Check whether this is time to expire
                   boolean shouldProcess = false;
                   if (Mail.ERROR.equals(next.state)) {
  @@ -173,10 +174,11 @@
                       //System.err.println(errorBuffer.toString());
                       wait(waitTime);
                   }
  -            } catch (InterruptedException ignored) {
  +            } catch (InterruptedException ex) {
  +                throw ex;
               }
  -
           }
  +        throw new InterruptedException();
       }
   
       /**
  @@ -234,7 +236,7 @@
                   //  a possible message, or we retrieve 1000 messages.  This 1000 
cap is to
                   //  avoid loading thousands or hundreds of thousands of messages 
when the
                   //  spool is enourmous.
  -                while (rsListMessages.next() && pendingMessages.size() < 1000) {
  +                while (rsListMessages.next() && pendingMessages.size() < 1000 && 
!Thread.currentThread().isInterrupted()) {
                       String key = rsListMessages.getString(1);
                       String state = rsListMessages.getString(2);
                       long lastUpdated = rsListMessages.getTimestamp(3).getTime();
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.2.4.1   +2 -3      
jakarta-james/src/java/org/apache/james/services/Attic/SpoolRepository.java
  
  Index: SpoolRepository.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-james/src/java/org/apache/james/services/Attic/SpoolRepository.java,v
  retrieving revision 1.2
  retrieving revision 1.2.4.1
  diff -u -r1.2 -r1.2.4.1
  --- SpoolRepository.java      16 Aug 2002 22:00:07 -0000      1.2
  +++ SpoolRepository.java      4 Feb 2003 19:38:24 -0000       1.2.4.1
  @@ -13,7 +13,6 @@
    * if inbound deliveries stop.
    *
    * @version 1.0.0, 24/04/1999
  - * @author  Federico Barbieri <[EMAIL PROTECTED]>
    */
   public interface SpoolRepository 
       extends MailRepository {
  @@ -31,7 +30,7 @@
        *
        * @return the key for the mail
        */
  -    String accept();
  +    String accept() throws InterruptedException;
   
       /**
        * Returns the key for an arbitrarily select mail deposited in this Repository 
that
  @@ -42,5 +41,5 @@
        *
        * @return the key for the mail
        */
  -    String accept(long delay);
  +    String accept(long delay) throws InterruptedException;
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to