Package gov.usgs.earthquake.product
Class AbstractListener
- java.lang.Object
-
- gov.usgs.util.DefaultConfigurable
-
- gov.usgs.earthquake.product.AbstractListener
-
- All Implemented Interfaces:
Configurable
- Direct Known Subclasses:
DefaultIndexerListener
,DefaultNotificationListener
public class AbstractListener extends DefaultConfigurable
A base listener implementation for both NotificationListener and IndexerListener implementations. The AbstractListener implements the Configurable interface and defines the following configuration parameters:- includeTypes
- (Optional) A comma separated list of product types to include. If this list is defined it constitutes an "allow" list, and only types in this list are allowed.
- excludeTypes
- (Optional) A comma separated list of product types to exclude. If this list is defined it constitutes a "block" list, and types in this list are not allowed.
- includeSources
- (Optional) A comma separated list of product types to include. If this list is defined it constitutes an "allow" list, and only types in this list are allowed.
- excludeSources
- (Optional) A comma separated list of product types to exclude. If this list is defined it constitutes a "block" list, and types in this list are not allowed.
- includeTests
- (Optional, Default false) Flag to indicate test products should be accepted. Set to "true" or "yes" to enable.
- includeScenarios
- (Optional, Default false) Flag to indicate scenario products should be accepted. Set to "true" or "yes" to enable.
- includeActuals
- (Optional, Default true) Flag to indicate Actual products should be accepted. Set to "true" or "yes" to enable.
- includeInternals
- (Optional, Default false) Flag to indicate internal products should be accepted. Set to "true" or "yes" to enable.
- includeDevelopments
- (Optional, Default false) Flag to indicate development products should be accepted. Set to "true" or "yes" to enable.
- maxTries
- (Optional, Default 1) Number of times to attempt delivery of each notification, if the listener throws a ContinuableListenerException during onNotification(). A value <= 1 means do not re-attempt.
- timeout
- (Optional, Default 0) Number of milliseconds before thread running onNotification() is interrupted. A value <= 0 means never interrupt.
- retryDelay
- (Optional, Default 0) Number of milliseconds to wait before re-attempting processing of a notification, if the listener throws a ContinuableListenerException during onNotification(). A value <= 0 means no delay.
When excludeTypes (or sources) and includeTypes (or sources) are defined, excludes are processed first. This is usually not recommended.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ATTEMPT_COUNT_PROPERTY
Deprecated.Use MAX_TRIES_PROPERTY instead.static int
DEFAULT_ATTEMPT_COUNT
Default attempt count value is 1 = don't retry.static long
DEFAULT_RETRY_DELAY
Default delay is 300000ms = 5 minute delay.static long
DEFAULT_TIMEOUT
Default timeout is 0 = infinity.static java.lang.String
EXCLUDE_SOURCES_PROPERTY
Configuration parameter for exclude sources list.static java.lang.String
EXCLUDE_TYPES_PROPERTY
Configuration parameter for exclude types list.static java.lang.String
INCLUDE_ACTUALS_PROPERTY
Flag to indicate if actual type products should be includedstatic java.lang.String
INCLUDE_DEVELOPMENTS_PROPERTY
Flag to indicate if scenario type products should be includedstatic java.lang.String
INCLUDE_INTERNALS_PROPERTY
Flag to indicate if scenario type products should be includedstatic java.lang.String
INCLUDE_SCENARIOS_PROPERTY
Flag to indicate if scenario type products should be includedstatic java.lang.String
INCLUDE_SOURCES_PROPERTY
Configuration parameter for include sources list.static java.lang.String
INCLUDE_TESTS_PROPERTY
Flag to indicate if scenario type products should be includedstatic java.lang.String
INCLUDE_TYPES_PROPERTY
Configuration parameter for include types list.static java.lang.String
MAX_TRIES_PROPERTY
Configuration parameters for maxTries.static java.lang.String
RETRY_DELAY_PROPERTY
Configuration parameter for retryDelay.static java.lang.String
TIMEOUT_PROPERTY
Configuration parameter for timeout.
-
Constructor Summary
Constructors Constructor Description AbstractListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accept(ProductId id)
Determines if a listener accepts a message based on the incoming product id.void
configure(Config config)
Read the include and exclude types from config.java.util.List<java.lang.String>
getExcludeSources()
java.util.List<java.lang.String>
getExcludeTypes()
java.util.List<java.lang.String>
getIncludeSources()
java.util.List<java.lang.String>
getIncludeTypes()
int
getMaxTries()
Number of tries to deliver notification, when an Exception is thrown during onNotification().long
getRetryDelay()
long
getTimeout()
Number of milliseconds onNotification is allowed to run before being interrupted.boolean
isIncludeActuals()
boolean
isIncludeDevelopments()
boolean
isIncludeInternals()
boolean
isIncludeScenarios()
boolean
isIncludeTests()
void
setIncludeActuals(boolean includeActuals)
void
setIncludeDevelopments(boolean includeDevelopments)
void
setIncludeInternals(boolean includeInternals)
void
setIncludeScenarios(boolean includeScenarios)
void
setIncludeTests(boolean includeTests)
void
setMaxTries(int maxTries)
Set the maxTries.void
setRetryDelay(long retryDelay)
void
setTimeout(long timeout)
Set the timeout.-
Methods inherited from class gov.usgs.util.DefaultConfigurable
getName, setName, shutdown, startup
-
-
-
-
Field Detail
-
INCLUDE_TYPES_PROPERTY
public static final java.lang.String INCLUDE_TYPES_PROPERTY
Configuration parameter for include types list.- See Also:
- Constant Field Values
-
EXCLUDE_TYPES_PROPERTY
public static final java.lang.String EXCLUDE_TYPES_PROPERTY
Configuration parameter for exclude types list.- See Also:
- Constant Field Values
-
INCLUDE_SOURCES_PROPERTY
public static final java.lang.String INCLUDE_SOURCES_PROPERTY
Configuration parameter for include sources list.- See Also:
- Constant Field Values
-
EXCLUDE_SOURCES_PROPERTY
public static final java.lang.String EXCLUDE_SOURCES_PROPERTY
Configuration parameter for exclude sources list.- See Also:
- Constant Field Values
-
INCLUDE_TESTS_PROPERTY
public static final java.lang.String INCLUDE_TESTS_PROPERTY
Flag to indicate if scenario type products should be included- See Also:
- Constant Field Values
-
INCLUDE_SCENARIOS_PROPERTY
public static final java.lang.String INCLUDE_SCENARIOS_PROPERTY
Flag to indicate if scenario type products should be included- See Also:
- Constant Field Values
-
INCLUDE_ACTUALS_PROPERTY
public static final java.lang.String INCLUDE_ACTUALS_PROPERTY
Flag to indicate if actual type products should be included- See Also:
- Constant Field Values
-
INCLUDE_INTERNALS_PROPERTY
public static final java.lang.String INCLUDE_INTERNALS_PROPERTY
Flag to indicate if scenario type products should be included- See Also:
- Constant Field Values
-
INCLUDE_DEVELOPMENTS_PROPERTY
public static final java.lang.String INCLUDE_DEVELOPMENTS_PROPERTY
Flag to indicate if scenario type products should be included- See Also:
- Constant Field Values
-
ATTEMPT_COUNT_PROPERTY
public static final java.lang.String ATTEMPT_COUNT_PROPERTY
Deprecated.Use MAX_TRIES_PROPERTY instead.Configuration parameters for attemptCount.- See Also:
- Constant Field Values
-
MAX_TRIES_PROPERTY
public static final java.lang.String MAX_TRIES_PROPERTY
Configuration parameters for maxTries.- See Also:
- Constant Field Values
-
TIMEOUT_PROPERTY
public static final java.lang.String TIMEOUT_PROPERTY
Configuration parameter for timeout.- See Also:
- Constant Field Values
-
RETRY_DELAY_PROPERTY
public static final java.lang.String RETRY_DELAY_PROPERTY
Configuration parameter for retryDelay.- See Also:
- Constant Field Values
-
DEFAULT_ATTEMPT_COUNT
public static final int DEFAULT_ATTEMPT_COUNT
Default attempt count value is 1 = don't retry.- See Also:
- Constant Field Values
-
DEFAULT_TIMEOUT
public static final long DEFAULT_TIMEOUT
Default timeout is 0 = infinity.- See Also:
- Constant Field Values
-
DEFAULT_RETRY_DELAY
public static final long DEFAULT_RETRY_DELAY
Default delay is 300000ms = 5 minute delay.- See Also:
- Constant Field Values
-
-
Method Detail
-
accept
public boolean accept(ProductId id)
Determines if a listener accepts a message based on the incoming product id.- Parameters:
id
- The incoming id of the product that triggered the message.- Returns:
- True if the message should be processed, false otherwise.
-
configure
public void configure(Config config) throws java.lang.Exception
Read the include and exclude types from config.- Specified by:
configure
in interfaceConfigurable
- Overrides:
configure
in classDefaultConfigurable
- Parameters:
config
- the Config object with settings.- Throws:
java.lang.Exception
- if configuration exceptions occur.
-
getIncludeTypes
public java.util.List<java.lang.String> getIncludeTypes()
- Returns:
- the includeTypes
-
getExcludeTypes
public java.util.List<java.lang.String> getExcludeTypes()
- Returns:
- the excludeTypes
-
getIncludeSources
public java.util.List<java.lang.String> getIncludeSources()
- Returns:
- the includeSources
-
getExcludeSources
public java.util.List<java.lang.String> getExcludeSources()
- Returns:
- the excludeSources
-
getMaxTries
public int getMaxTries()
Number of tries to deliver notification, when an Exception is thrown during onNotification().- Returns:
- the attemptCount. A value < 1 means never try to deliver.
-
setMaxTries
public void setMaxTries(int maxTries)
Set the maxTries.- Parameters:
maxTries
- the maxTries. A value < 1 means never try to deliver.
-
getTimeout
public long getTimeout()
Number of milliseconds onNotification is allowed to run before being interrupted.- Returns:
- the timeout in milliseconds. A value <= 0 means never timeout.
-
setTimeout
public void setTimeout(long timeout)
Set the timeout.- Parameters:
timeout
- the timeout in milliseconds. A value <= 0 means never timeout.
-
isIncludeTests
public boolean isIncludeTests()
- Returns:
- the includeTests
-
setIncludeTests
public void setIncludeTests(boolean includeTests)
- Parameters:
includeTests
- the includeTests to set
-
isIncludeScenarios
public boolean isIncludeScenarios()
- Returns:
- the includeScenarios
-
setIncludeScenarios
public void setIncludeScenarios(boolean includeScenarios)
- Parameters:
includeScenarios
- the includeScenarios to set
-
isIncludeActuals
public boolean isIncludeActuals()
- Returns:
- the includeActuals
-
setIncludeActuals
public void setIncludeActuals(boolean includeActuals)
- Parameters:
includeActuals
- the includeActuals to set
-
isIncludeInternals
public boolean isIncludeInternals()
- Returns:
- the includeInternals
-
setIncludeInternals
public void setIncludeInternals(boolean includeInternals)
- Parameters:
includeInternals
- the includeInternals to set
-
isIncludeDevelopments
public boolean isIncludeDevelopments()
- Returns:
- the includeDevelopments
-
setIncludeDevelopments
public void setIncludeDevelopments(boolean includeDevelopments)
- Parameters:
includeDevelopments
- the includeDevelopments to set
-
getRetryDelay
public long getRetryDelay()
- Returns:
- the retryDelay
-
setRetryDelay
public void setRetryDelay(long retryDelay)
- Parameters:
retryDelay
- the retryDelay to set
-
-