Spring Web Services Framework

org.springframework.ws.transport.mail.monitor
Class PollingMonitoringStrategy

java.lang.Object
  extended by org.springframework.ws.transport.mail.monitor.AbstractMonitoringStrategy
      extended by org.springframework.ws.transport.mail.monitor.PollingMonitoringStrategy
All Implemented Interfaces:
MonitoringStrategy
Direct Known Subclasses:
Pop3PollingMonitoringStrategy

public class PollingMonitoringStrategy
extends AbstractMonitoringStrategy

Implementation of the MonitoringStrategy interface that uses a simple polling mechanism. Defines a polling interval property which defines the interval in between message polls.

Note that this implementation is not suitable for use with POP3 servers. Use the Pop3PollingMonitoringStrategy instead.

Since:
1.5.0
Author:
Arjen Poutsma

Field Summary
static long DEFAULT_POLLING_FREQUENCY
          Defines the default polling frequency.
 
Fields inherited from class org.springframework.ws.transport.mail.monitor.AbstractMonitoringStrategy
logger
 
Constructor Summary
PollingMonitoringStrategy()
           
 
Method Summary
protected  void afterSleep(Folder folder)
          Invoked after the Thread.sleep(long) method has been invoked.
 void setPollingInterval(long pollingInterval)
          Sets the interval used in between message polls, in milliseconds.
protected  void waitForNewMessages(Folder folder)
          Template method that blocks until new messages arrive in the given folder.
 
Methods inherited from class org.springframework.ws.transport.mail.monitor.AbstractMonitoringStrategy
deleteMessages, fetchMessages, getFolderOpenMode, monitor, searchForNewMessages, setDeleteMessages
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_POLLING_FREQUENCY

public static final long DEFAULT_POLLING_FREQUENCY
Defines the default polling frequency. Set to 1000 * 60 milliseconds (i.e. 1 minute).

See Also:
Constant Field Values
Constructor Detail

PollingMonitoringStrategy

public PollingMonitoringStrategy()
Method Detail

setPollingInterval

public void setPollingInterval(long pollingInterval)
Sets the interval used in between message polls, in milliseconds. The default is 1000 * 60 ms, that is 1 minute.


waitForNewMessages

protected void waitForNewMessages(Folder folder)
                           throws MessagingException,
                                  InterruptedException
Description copied from class: AbstractMonitoringStrategy
Template method that blocks until new messages arrive in the given folder. Typical implementations use Thread.sleep(long) or the IMAP IDLE command.

Specified by:
waitForNewMessages in class AbstractMonitoringStrategy
Parameters:
folder - the folder to monitor
Throws:
MessagingException - in case of JavaMail errors
InterruptedException - when a thread is interrupted

afterSleep

protected void afterSleep(Folder folder)
                   throws MessagingException
Invoked after the Thread.sleep(long) method has been invoked. This implementation calls Folder.getMessageCount(), to force new messages to be seen.

Parameters:
folder - the folder to check for new messages
Throws:
MessagingException - in case of JavaMail errors

Spring Web Services Framework

Copyright © 2005-2010 The Spring Web Services Framework. All Rights Reserved.