Interface PollingSource<T extends Event>

Type Parameters:
T - The type of events this event source creates.
All Superinterfaces:
EventSource<T>, Runnable
All Known Subinterfaces:
PollingFileSource, PollingMailSource, SharedPollingSource<T>
All Known Implementing Classes:
AbstractSharedEventSource, DBActivityEventSource, DBEventSource, FileEventActivitySource, FileEventSource, FilteredMailEventActivitySource, FilteredMailEventSource, MailEventActivitySource, MailEventSource, ReadOnlyRSEventSource

@ConfigurationDescription(properties={@Property(name="PollTime",type=LONG,defaultValue="300000",description="The time in milliseconds this event source polls. This is a time span between two polls. If handling the previous event takes longer than this time span, the next poll will take place right after the handling has completed."),}) public interface PollingSource<T extends Event> extends EventSource<T>
An event source that involves polling for an event. This omits the waiting by the source itself. Rather its run-method is executed regularly but will just exit if no event is to be created. If the run-method creates an event, the method will also call and perform the handling. It will not return before the event handling has completed. If the next poll time elapsed before the previous call to Runnable.run() has terminated, the next poll will be delayed.
The source does not need to take care of its deactivation. Even if event handling has successfully completed, it just continues polling.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Configuration key for the time in milliseconds between two polls.
    static final String
    Configuration key for the absolute point in time to use for calculating the start time.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Gets the time in milliseconds this event source polls, more precisely, the time span between two polls.
    long
    Gets the absolute time in milliseconds since midnight, January 1, 1970 UTC when this polling source should start polling.
    default void
    Initialises this polling source.
    default void
    Terminates this polling source.

    Methods inherited from interface de.aristaflow.adept2.model.events.sources.EventSource

    addAll, addHandler, getEventHandler, getHierarchicalSourceName, getID, getType, removeHandler, setConfiguration

    Methods inherited from interface java.lang.Runnable

    run
  • Field Details

    • CONF_POLL_TIME

      static final String CONF_POLL_TIME
      Configuration key for the time in milliseconds between two polls.
      See Also:
    • CONF_START_TIME

      static final String CONF_START_TIME
      Configuration key for the absolute point in time to use for calculating the start time.
      See Also:
  • Method Details

    • getPollTime

      long getPollTime()
      Gets the time in milliseconds this event source polls, more precisely, the time span between two polls. If this is 0 or negative, no polling will apply. However, init() and terminate() will be called.
      Returns:
      The time in milliseconds this event source polls (> 0).
    • getStartTime

      long getStartTime()
      Gets the absolute time in milliseconds since midnight, January 1, 1970 UTC when this polling source should start polling. This is used for calculating the first poll time by adding the time span defined in getPollTime().
      Returns:
      The absolute time in milliseconds since midnight, January 1, 1970 UTC when this polling source should start polling.
    • init

      default void init()
      Initialises this polling source. This is called once before polling is started the first time.
    • terminate

      default void terminate()
      Terminates this polling source. This is called once after polling has terminated and this source is removed.
      Note that this may be called any time, even when creating or handling an event. So take care to synchronise the implementation appropriately!