Events Manager
What is it?
It is a bundle which administrates the delivery of events through the different bundles propagating between the ASTRA nodes.
Provided Functionality
This bundle provides functionality for:
Sending any kind of AstraEvent instance from a Sender to any EventsListener
Allowing EventsListener to subscribe to a subset of AstraEvents (only tag related events "TagEvents", community related events...)
Allowing EventsListener to subscribe to a concrete channel of Events. Channels are identified by a String. It is possible to subscribe to both subset of events and only one channel.
- Events will be forwarded to the bundles inside the ASTRA node or ASTRA backend. Events will also be forwarded from any node or the backend to the rest of the nodes excluding the node who sent the event.
- Nodes that are hidden behind a NAT or a firewall will automatically become Active listeners and will receive the events by polling system.
- Events may contain any kind of arbitrary information that will travel all along the net.
- New Event Classes can be created in the hierarchy without necesity of changing the already existing implementation.
Access
The main idea for using the EventsManager is to follow these steps:
Notification
1- Retrieve the EventsServer reference:
private void getEventsManagerReference(){
ServiceReference sr = bc.getServiceReference(IEventsServer.class.getName());
if (sr == null) {
es = null;
return;
}
es = (IEventsServer)bc.getService(sr);
}
2.- Import into the project the package eu.ist.astra.em.events
3.- Notify the event (Example:)
es.notify(this, new NewTagAstraEvent("user@astra", "my_application", "tag1"), "PUBLIC");
Subscription
1- Retrieve the EventsServer reference:
private void getEventsManagerReference(){
ServiceReference sr = bc.getServiceReference(IEventsServer.class.getName());
if (sr == null) {
es = null;
return;
}
es = (IEventsServer)bc.getService(sr);
}
2.- Implement the interface eu.ist.astra.em.IEventsListener
3.- Override the update method.
public void update(Object sender,AstraEvent e,String channel){
//TODO: implement the handler
}
4.- Subscribe to the desired Event and Channel
es.addListener(this, TagAstraEvent.class , "PUBLIC");
Design
Connection with other bundles
EventsManager makes use of the following bundles:
RemoteFrameworkManager: Necessary in order to communicate to the BackEnd or the nodes and to propagate the Event.