org.springframework.context.event
public class: SourceFilteringListener [javadoc |
source]
java.lang.Object
org.springframework.context.event.SourceFilteringListener
All Implemented Interfaces:
ApplicationListener
org.springframework.context.ApplicationListener decorator that filters
events from a specified event source, invoking its delegate listener for
matching
org.springframework.context.ApplicationEvent objects only.
Can also be used as base class, overriding the #onApplicationEventInternal
method instead of specifying a delegate listener.
- author:
Juergen - Hoeller
- since:
2.0.5 -
| Constructor: |
protected SourceFilteringListener(Object source) {
this.source = source;
}
Create a SourceFilteringListener for the given event source,
expecting subclasses to override the #onApplicationEventInternal
method (instead of specifying a delegate listener). Parameters:
source - the event source that this listener filters for,
only processing events from this source
|
public SourceFilteringListener(Object source,
ApplicationListener delegate) {
this.source = source;
this.delegate = delegate;
}
Create a SourceFilteringListener for the given event source. Parameters:
source - the event source that this listener filters for,
only processing events from this source
delegate - the delegate listener to invoke with event
from the specified source
|
| Method from org.springframework.context.event.SourceFilteringListener Detail: |
public void onApplicationEvent(ApplicationEvent event) {
if (event.getSource() == this.source) {
onApplicationEventInternal(event);
}
}
|
protected void onApplicationEventInternal(ApplicationEvent event) {
if (this.delegate == null) {
throw new IllegalStateException(
"Must specify a delegate object or override the onApplicationEventInternal method");
}
this.delegate.onApplicationEvent(event);
}
Actually process the event, after having filtered according to the
desired event source already.
The default implementation invokes the specified delegate, if any. |