com.infoscape.proteus
Class PolledSource

java.lang.Object
  |
  +--com.infoscape.proteus.MessageHandlerImpl
        |
        +--com.infoscape.proteus.SourceImpl
              |
              +--com.infoscape.proteus.PolledSource
All Implemented Interfaces:
MessageHandler, MessageSource, Transactional
Direct Known Subclasses:
DBSource, FTPSource

public abstract class PolledSource
extends SourceImpl

Base class for polled sources. A lot of potential message sources are not, in and of themselves, event sources. Database tables, remote FTP servers, and directories in the local filesystem all come to mind. To treat these as event sources you need to listen to them actively. At regular intervals, you need to inquire whether there are any messages there and grab them if the answer is yes. Typically grabbing messages is an operation that returns more than one message, so you need to store the extra messages in some sort of cache and return them one by one in response to a call to getMessage(). PolledSource encapsulates these common features. A PolledSource is initialized with a pollPeriod, an integer value (in seconds) which defaults to 60. Descendants of PolledSource do not implement getMessage() (or even _getMessage()) directly. Instead they implement three methods: cacheEmpty(), loadCache() and getFromCache().


Field Summary
protected  int pollPeriod
           
 
Constructor Summary
PolledSource(Connection conn, org.jdom.Element elt)
           
 
Method Summary
protected  java.lang.Object _getMessage()
           
abstract  boolean cacheEmpty()
           
abstract  java.lang.Object getFromCache()
           
abstract  void loadCache()
           
 
Methods inherited from class com.infoscape.proteus.SourceImpl
getMessage
 
Methods inherited from class com.infoscape.proteus.MessageHandlerImpl
commit, disconnect, getConnection, log, log, reconnect, rollback, setSyncPoint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.infoscape.proteus.MessageHandler
disconnect, getConnection, reconnect
 
Methods inherited from interface com.infoscape.proteus.Transactional
commit, rollback, setSyncPoint
 

Field Detail

pollPeriod

protected int pollPeriod
Constructor Detail

PolledSource

public PolledSource(Connection conn,
                    org.jdom.Element elt)
             throws java.lang.Exception
Parameters:
conn -
elt -
Throws:
java.lang.Exception
Method Detail

_getMessage

protected java.lang.Object _getMessage()
                                throws java.lang.Exception
Specified by:
_getMessage in class SourceImpl
Throws:
java.lang.Exception

cacheEmpty

public abstract boolean cacheEmpty()
                            throws java.lang.Exception
java.lang.Exception

loadCache

public abstract void loadCache()
                        throws java.lang.Exception
java.lang.Exception

getFromCache

public abstract java.lang.Object getFromCache()
                                       throws java.lang.Exception
java.lang.Exception