View Javadoc

1   /*
2    * Copyright 2007 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springframework.ws.transport.mail.monitor;
18  
19  import javax.mail.Folder;
20  import javax.mail.Message;
21  import javax.mail.MessagingException;
22  
23  /**
24   * Defines the contract for objects that monitor a given folder for new messages. Allows for multiple implementation
25   * strategies, including polling, or event-driven techniques such as IMAP's <code>IDLE</code> command.
26   *
27   * @author Arjen Poutsma
28   */
29  public interface MonitoringStrategy {
30  
31      /**
32       * Monitors the given folder, and returns any new messages when they arrive.
33       *
34       * @param folder the folder in which to look for new messages
35       * @return the new messages
36       * @throws MessagingException   in case of JavaMail errors
37       * @throws InterruptedException if a thread is interrupted
38       */
39      Message[] monitor(Folder folder) throws MessagingException, InterruptedException;
40  
41      /**
42       * Returns the folder open mode to be used by this strategy. Can be either {@link Folder#READ_ONLY} or {@link
43       * Folder#READ_WRITE}.
44       */
45      int getFolderOpenMode();
46  
47  }