Axis2 Event Generation and Notification
Submitted on February 13, 2008 - 21:27. Story : Level : Project :
Whenever changes occur to a Web service or a module, Axis2 will generate an event. Events generation occurs for the following scenarios:
- Service deploy
- Module deploy
- Service un-dploy
- Service activation
- Service inactivation
Applies To
| Project: | Axis2 java any version |
| Environment: | Any OS |
Depending on the type of event, a system administrator could perform some action. Say for example, whenever someone deploys a Web service to the system that administrator wants to be informed of, he could register an event listener to listen on events and notify him about that event. It could even be, a listener sending an email to the administrator. This kind of event generation and notification can be used as value addition for a Web service framework or a Web Service server.
A good example can be found in WSO2 WSAS. It has the ability to generate Atom and RSS feeds, representing service and module status and history. This way, whenever a service or module in WSAS is deployed, it would generate a Atom and RSS feed. Additionally, when a service is removed or someone performs service update, it would still generate a RSS and Atom feed. One can use these feeds to access past activities of a given service or a module.
Registering an event listener is very simple and straightforward. First you need to write a class implementing “org.apache.axis2.engine.AxisObserver”. Interface looks like what's given below:
public interface AxisObserver extends ParameterInclude
{
void init(AxisConfiguration axisConfig);
void serviceUpdate(AxisEvent event, AxisService service);
void serviceGroupUpdate(AxisEvent event, AxisServiceGroup serviceGroup);
void moduleUpdate(AxisEvent event, AxisModule module);
}
- init : When Axis2 start up init method will be invoked
- serviceUpdate : When some activities happen to a service this method will be invoked with AxisEvent object, from the value of AxisEvent we can decide what type of event has occurred (SERVICE_DEPLOY , SERVICE_REMOVE , SERVICE_STOP ,SERVICE_START).
- serviceGroupUpdate : This is identical to that of serviceUpdate , only difference is this method is for a ServiceGroup
- moduleUpdate : When a module deploy or remove from the system this method will be called.
Registering Event ListenerWe can registry the Event listener to axis2.xml as following
<listener class="org.apache.axis2.ObserverIMPL"/>
Author:
Deepal Jayasinghe, Teachnical Lead , WSO2 Inc, deepal AT wso2 dot com
- Login or register to post comments
- Printer friendly version
- 421 reads










