public class MEventSource extends MBaseComponent
MEventSource
and its subclasses generate events. MEvent
class can have subclasses for the different types of events.
An MEventSource
is never instantiated directly. Instead, applications either create instances of one of its
subclasses or create their own subclass of MEventSource
and instantiate that.
MEventSource
instances must be explicitly assigned to either an MRvSession
or MJmsSession
via the session name in the MRvSession
constructor.Modifier and Type | Field and Description |
---|---|
protected java.util.Vector |
m_handlers |
protected java.util.Vector |
m_listeners |
m_registry
Modifier | Constructor and Description |
---|---|
protected |
MEventSource(MComponentRegistry register,
java.lang.String name)
Constructor for creating instances of
MEventSource subclasses. |
protected |
MEventSource(java.lang.String p_name) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(MEventListener listener)
Add an event listener to this event source.
|
java.util.Enumeration |
getListeners()
Retrieve the listeners that have been added to this event source.
|
boolean |
hasListeners()
Return true if there is at least one listener attached to this event source, returns false otherwise
|
void |
notify(MEvent event)
Trigger an event in each event listener attached to this event source
|
MEventListener |
removeListener(MEventListener listener)
Remove specified event listener from this event source.
|
activate, deactivate, getComponentRegistry, getName, getStatus, isActivated, remove
protected java.util.Vector m_listeners
protected java.util.Vector m_handlers
protected MEventSource(MComponentRegistry register, java.lang.String name)
MEventSource
subclasses. Usually, applications use one of the
already existing MEventSource
subclasses. If you want to use custom events, however, you have to
create your own custom event source subclass and then call its constructor to instantiate it.register
- Component registry for which this event source is created.name
- Name of this event source.protected MEventSource(java.lang.String p_name)
public void addListener(MEventListener listener)
Applications can create multiple subclasses of MEventListener
for different types of events and attach multiple
listeners to one event source. For example, you could attach one listener that waits for data events and one
that waits for timeout events.
listener
- the event listener to register topublic MEventListener removeListener(MEventListener listener)
If you have multiple listeners attached to one event source, you must remove each one individually. This method does not cancel certified delivery agreement for RVCM.
listener
- Event listener to remove from this event source.public java.util.Enumeration getListeners()
Enumeration.nextElement()
can be cast to MEventListener
.public boolean hasListeners()
public void notify(MEvent event)
event
- Event to send to all attached listeners