org.mule.transport
Class AbstractPollingMessageReceiver

java.lang.Object
  extended by org.mule.transport.AbstractConnectable
      extended by org.mule.transport.AbstractMessageReceiver
          extended by org.mule.transport.AbstractPollingMessageReceiver
All Implemented Interfaces:
ExceptionListener, Disposable, Initialisable, Startable, Stoppable, Connectable, MessageReceiver
Direct Known Subclasses:
FileMessageReceiver, FtpMessageReceiver, PollingHttpMessageReceiver, RetrieveMessageReceiver, RmiMessageReceiver, StdioMessageReceiver, TransactedPollingMessageReceiver

public abstract class AbstractPollingMessageReceiver
extends AbstractMessageReceiver

AbstractPollingMessageReceiver implements a base class for polling message receivers. The receiver provides a poll() method that implementations must implement to execute their custom code. Note that the receiver will not poll if the associated connector is not started.


Field Summary
static long DEFAULT_POLL_FREQUENCY
           
static edu.emory.mathcs.backport.java.util.concurrent.TimeUnit DEFAULT_POLL_TIMEUNIT
           
static long DEFAULT_STARTUP_DELAY
           
protected  List schedules
           
 
Fields inherited from class org.mule.transport.AbstractMessageReceiver
receiverKey, responseEndpoint, service
 
Fields inherited from class org.mule.transport.AbstractConnectable
connected, connector, disposed, endpoint, logger, retryTemplate, started, startOnConnect
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Disposable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Startable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Stoppable
PHASE_NAME
 
Constructor Summary
AbstractPollingMessageReceiver(Connector connector, Service service, InboundEndpoint endpoint)
           
 
Method Summary
protected  PollingReceiverWorker createWork()
           
protected  void doStart()
           
protected  void doStop()
           
 long getFrequency()
           
 edu.emory.mathcs.backport.java.util.concurrent.TimeUnit getTimeUnit()
           
abstract  void poll()
           
protected  void schedule()
          This method registers this receiver for periodic polling ticks with the connectors scheduler.
 void setFrequency(long value)
           
 void setTimeUnit(edu.emory.mathcs.backport.java.util.concurrent.TimeUnit timeUnit)
           
protected  void unschedule()
          This method cancels the schedules which were created in schedule().
 
Methods inherited from class org.mule.transport.AbstractMessageReceiver
dispose, getConnectEventId, getConnectionDescription, getEndpoint, getEndpointURI, getListener, getReceiverKey, getService, getWorkManager, handleUnacceptedFilter, initialise, routeMessage, routeMessage, routeMessage, routeMessage, routeMessage, routeMessage, setEndpoint, setExceptionDetails, setListener, setReceiverKey, setService, toString
 
Methods inherited from class org.mule.transport.AbstractConnectable
activate, connect, disconnect, disposeAndLogException, doConnect, doDisconnect, doDispose, doInitialise, exceptionThrown, getConnectEventId, getConnector, handleException, isConnected, isDoThreading, isStarted, passivate, setEndpoint, start, stop, validate, validateConnection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mule.api.transport.Connectable
connect, disconnect, isConnected, validateConnection
 
Methods inherited from interface org.mule.api.lifecycle.Startable
start
 
Methods inherited from interface org.mule.api.lifecycle.Stoppable
stop
 

Field Detail

DEFAULT_POLL_FREQUENCY

public static final long DEFAULT_POLL_FREQUENCY
See Also:
Constant Field Values

DEFAULT_POLL_TIMEUNIT

public static final edu.emory.mathcs.backport.java.util.concurrent.TimeUnit DEFAULT_POLL_TIMEUNIT

DEFAULT_STARTUP_DELAY

public static final long DEFAULT_STARTUP_DELAY
See Also:
Constant Field Values

schedules

protected final List schedules
Constructor Detail

AbstractPollingMessageReceiver

public AbstractPollingMessageReceiver(Connector connector,
                                      Service service,
                                      InboundEndpoint endpoint)
                               throws CreateException
Throws:
CreateException
Method Detail

doStart

protected void doStart()
                throws MuleException
Overrides:
doStart in class AbstractConnectable
Throws:
MuleException

doStop

protected void doStop()
               throws MuleException
Overrides:
doStop in class AbstractConnectable
Throws:
MuleException

schedule

protected void schedule()
                 throws edu.emory.mathcs.backport.java.util.concurrent.RejectedExecutionException,
                        NullPointerException,
                        IllegalArgumentException
This method registers this receiver for periodic polling ticks with the connectors scheduler. Subclasses can override this in case they want to handle their polling differently.

Throws:
edu.emory.mathcs.backport.java.util.concurrent.RejectedExecutionException
NullPointerException
IllegalArgumentException
See Also:
ScheduledExecutorService#scheduleWithFixedDelay(Runnable, long, long, TimeUnit)}

unschedule

protected void unschedule()
This method cancels the schedules which were created in schedule().

See Also:
Future#cancel(boolean)}

createWork

protected PollingReceiverWorker createWork()

getFrequency

public long getFrequency()

setFrequency

public void setFrequency(long value)

getTimeUnit

public edu.emory.mathcs.backport.java.util.concurrent.TimeUnit getTimeUnit()

setTimeUnit

public void setTimeUnit(edu.emory.mathcs.backport.java.util.concurrent.TimeUnit timeUnit)

poll

public abstract void poll()
                   throws Exception
Throws:
Exception


Copyright © 2003-2009 MuleSource, Inc.. All Rights Reserved.