KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > james > services > SpoolRepository


1 /***********************************************************************
2  * Copyright (c) 1999-2004 The Apache Software Foundation. *
3  * All rights reserved. *
4  * ------------------------------------------------------------------- *
5  * Licensed under the Apache License, Version 2.0 (the "License"); you *
6  * may not use this file except in compliance with the License. You *
7  * may obtain a copy of the License at: *
8  * *
9  * http://www.apache.org/licenses/LICENSE-2.0 *
10  * *
11  * Unless required by applicable law or agreed to in writing, software *
12  * distributed under the License is distributed on an "AS IS" BASIS, *
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
14  * implied. See the License for the specific language governing *
15  * permissions and limitations under the License. *
16  ***********************************************************************/

17
18 package org.apache.james.services;
19
20 import org.apache.mailet.Mail;
21
22 /**
23  * Interface for a Repository for Spooling Mails.
24  * A spool repository is a transitory repository which should empty itself
25  * if inbound deliveries stop.
26  *
27  * @version 1.0.0, 24/04/1999
28  */

29 public interface SpoolRepository
30     extends MailRepository {
31
32     /**
33      * Implementations of AcceptFilter can be used to select which mails a SpoolRepository
34      * implementation returns from its accept (AcceptFilter) method
35      **/

36     public static interface AcceptFilter
37     {
38         /**
39          * This method is called by accept(Filter) to determine if the message is
40          * ready for delivery.
41          *
42          * @param key message key
43          * @param state the state of the message
44          * @param lastUpdated the last time the message was written to the spool
45          * @param errorMessage the current errorMessage
46          * @return true if the message is ready for delivery
47          **/

48         boolean accept (String JavaDoc key, String JavaDoc state, long lastUpdated, String JavaDoc errorMessage) ;
49
50
51         /**
52          * This method allows the filter to determine how long the thread should wait for a
53          * message to get ready for delivery, when currently there are none.
54          * @return the time to wait for a message to get ready for delivery
55          **/

56         long getWaitTime ();
57     }
58     
59     /**
60      * Define a STREAM repository. Streams are stored in the specified
61      * destination.
62      */

63     String JavaDoc SPOOL = "SPOOL";
64
65     /**
66      * Returns an arbitrarily selected mail deposited in this Repository.
67      * Usage: SpoolManager calls accept() to see if there are any unprocessed
68      * mails in the spool repository.
69      *
70      * @return the mail
71      */

72     Mail accept() throws InterruptedException JavaDoc;
73
74     /**
75      * Returns an arbitrarily select mail deposited in this Repository that
76      * is either ready immediately for delivery, or is younger than it's last_updated plus
77      * the number of failed attempts times the delay time.
78      * Usage: RemoteDeliverySpool calls accept() with some delay and should block until an
79      * unprocessed mail is available.
80      *
81      * @return the mail
82      */

83     Mail accept(long delay) throws InterruptedException JavaDoc;
84
85     /**
86      * Returns an arbitrarily select mail deposited in this Repository for
87      * which the supplied filter's accept method returns true.
88      * Usage: RemoteDeliverySpool calls accept(filter) with some a filter which determines
89      * based on number of retries if the mail is ready for processing.
90      * If no message is ready the method will block until one is, the amount of time to block is
91      * determined by calling the filters getWaitTime method.
92      *
93      * @return the mail
94      */

95     Mail accept(AcceptFilter filter) throws InterruptedException JavaDoc;
96
97 }
98
Popular Tags