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().
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
pollPeriod
protected int pollPeriod
PolledSource
public PolledSource(Connection conn,
org.jdom.Element elt)
throws java.lang.Exception
- Parameters:
conn - elt -
- Throws:
java.lang.Exception
_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