Last change
on this file since 53 was
44,
checked in by stoda, 11 years ago
|
Objectmq converted to maven project
|
File size:
827 bytes
|
Rev | Line | |
---|
[44] | 1 | package omq.common.event; |
---|
| 2 | |
---|
| 3 | /** |
---|
| 4 | * Abstract class that enables to create new EventListeners. The eventListeners |
---|
| 5 | * are done to execute the notifyEvent function. |
---|
| 6 | * |
---|
| 7 | * @author Sergi Toda <sergi.toda@estudiants.urv.cat> |
---|
| 8 | * |
---|
| 9 | */ |
---|
| 10 | public abstract class EventListener<E extends Event> { |
---|
| 11 | private String topic; |
---|
| 12 | |
---|
| 13 | public EventListener() { |
---|
| 14 | topic = null; |
---|
| 15 | } |
---|
| 16 | |
---|
| 17 | /** |
---|
| 18 | * Constructor. This constructor uses a String to indicate manually which |
---|
| 19 | * event we want to receive |
---|
| 20 | * |
---|
| 21 | * @param topic |
---|
| 22 | */ |
---|
| 23 | public EventListener(String topic) { |
---|
| 24 | this.topic = topic; |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | /** |
---|
| 28 | * Whenever this listener it's notified of an event, will execute this |
---|
| 29 | * function |
---|
| 30 | * |
---|
| 31 | * @param event |
---|
| 32 | */ |
---|
| 33 | public abstract void notifyEvent(E event); |
---|
| 34 | |
---|
| 35 | public void setTopic(String topic) { |
---|
| 36 | this.topic = topic; |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | public String getTopic() { |
---|
| 40 | return topic; |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.