Class DBEventSource

    • Field Detail

      • pollTime

        protected Long pollTime
        The time in milliseconds this event source polls its data source.
      • startTime

        protected Long startTime
        The start point (in milliseconds) this event should start polling.
      • dataSource

        protected String dataSource
        The simple instance name of the data source which to poll for the event. This is not required if the driver, the connection URL, the user name and the password are provided instead. If all are provided, the data source will be used.
      • jdbcDriver

        protected String jdbcDriver
        The fully-qualified name of the class of the JDBC-driver. This is only required if no data source is provided.
      • jdbcConnectionURL

        protected String jdbcConnectionURL
        The URL to connect to the database. This is only required if no data source is provided.
      • jdbcUserName

        protected String jdbcUserName
        The name of the user to log on at the database with. This is only required if no data source is provided.
      • jdbcPassword

        protected String jdbcPassword
        The password to log on a the database with. This is only required if no data source is provided.
      • selectStatement

        protected String selectStatement
        The statement which is executed and provides the result set for the event.
      • notifyEmptyOnly

        protected Boolean notifyEmptyOnly
        Whether the event should be produced in case the result set is empty.
      • eventManager

        protected final DefaultEventManager eventManager
        The event manager of this data source providing the connection to the data source.
    • Constructor Detail

      • DBEventSource

        public DBEventSource​(org.apache.commons.configuration2.Configuration conf,
                             DefaultEventManager eventManager,
                             Registry registry)
                      throws ConfigurationException
        Default constructor for a plugin of the DefaultEventManager called by a service registry.

        Note that this constructor calls setConfiguration(Configuration, boolean); subclasses may not be fully initialised at this point.

        Parameters:
        conf - The configuration as provided from the registry.
        eventManager - The event manager this event source is a plugin of.
        registry - The registry of this plugin.
        Throws:
        ConfigurationException - If the configuration is not valid for a ResultSetSource, a ConfigurationException will be thrown.
    • Method Detail

      • setConfiguration

        protected void setConfiguration​(org.apache.commons.configuration2.Configuration conf,
                                        boolean completed)
                                 throws ConfigurationException
        Sets the internal fields according to the values of the designated configuration. Note that this method is called from the constructor and therefore this object may not be fully initialised!
        Parameters:
        conf - The configuration from which to get the configuration values.
        completed - Whether the configuration is complete after this setting and therefore the values should be verified.
        Throws:
        ConfigurationException - If there are problems with the configuration, for instance the configuration does not provide required values, a ConfigurationException may be thrown.
      • verifyConfigurationValues

        protected void verifyConfigurationValues()
                                          throws ConfigurationException
        This method verifies whether the required configuration values and the data context have been set yet. If configuration values or the data context are missing or inappropriate, a ConfigurationException will be thrown.
        Throws:
        ConfigurationException - If there are problems with the configuration, for instance the configuration does not provide required values or the data context is not set, a ConfigurationException may be thrown.
      • setConfiguration

        public void setConfiguration​(org.apache.commons.configuration2.Configuration conf,
                                     String id)
                              throws ConfigurationException
        Description copied from interface: EventSource
        Sets the (additional) configuration of this event source and its ID. The configuration is additional with respect to the configuration provided by the plugin load mechanism, if the event source is loaded as plugin.
        It is ensured that this method will be called before Runnable.run().
        Specified by:
        setConfiguration in interface EventSource<ResultSetEvent>
        Overrides:
        setConfiguration in class AbstractEventSource<ResultSetEvent>
        Parameters:
        conf - The configuration of this event source. This adheres (and overwrites) the configuration provided by the plugin loading, if this event source has been loaded as plugin. Whether this is allowed to be null depends on the implementation of the event source.
        id - The ID of this event source. This must not be null nor the empty string.
        Throws:
        ConfigurationException - If there are problems with the designated configuration (configuration is null although this is not allowed, a required configuration value is missing, ...), a ConfigurationException will be thrown.
      • getStartTime

        public long getStartTime()
        Description copied from interface: PollingSource
        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 PollingSource.getPollTime().
        Specified by:
        getStartTime in interface PollingSource<ResultSetEvent>
        Returns:
        The absolute time in milliseconds since midnight, January 1, 1970 UTC when this polling source should start polling.
      • init

        public void init()
        Description copied from interface: PollingSource
        Initialises this polling source. This is called once before polling is started the first time.
        Specified by:
        init in interface PollingSource<ResultSetEvent>
      • terminate

        public void terminate()
        Description copied from interface: PollingSource
        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!
        Specified by:
        terminate in interface PollingSource<ResultSetEvent>
      • createResultSetEvent

        protected ResultSetEvent createResultSetEvent​(ResultSet resultSet)
        Creates a ResultSetEvent for the designated result set.
        Parameters:
        resultSet - The result set for which to create a ResultSetEvent.
        Returns:
        The ResultSetEvent created for the designated result set.
      • nextHandler

        protected boolean nextHandler​(ResultSetEvent event,
                                      boolean consumed,
                                      boolean concurrent)
        Description copied from class: AbstractEventSource
        This method is called right before an event is offered to the next handler. In case of concurrent handling, this method will only be called once for all concurrent handling but this will be indicated by the corresponding parameter.
        Specified by:
        nextHandler in class AbstractEventSource<ResultSetEvent>
        Parameters:
        event - The event which is about to be handled by the next registered handler.
        consumed - Whether the event has been consumed yet.
        concurrent - Whether the next event handling is concurrent and thus the event will be offered to several event handler concurrently.
        Returns:
        Whether the event handling may continue. In case of serious problems preventing further event handling, return false here.