To monitor hosted service statuses, register a listener in the axis2.xml. The listener should implement the "AxisObserver". Currently four statuses can be monitored ;
The above listener can be registered in the axis2 configuration (axis2.xml) as follows;
<listener class="org.test.axisobserver.ServiceMonitorObserver"/>
- Services
- Start
- Stop
- Deploy
- Undeploy
- Modules
- Engage
- Disengage
- Deploy
- Undeploy
Eg:
package org.test.axisobserver;
import java.util.ArrayList;
import java.util.ArrayList;
import org.apache.axiom.om.OMElement;
import org.apache.axis2.AxisFault;
import org.apache.axis2.description.AxisModule;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.AxisServiceGroup;
import org.apache.axis2.description.Parameter;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.engine.AxisEvent;
import org.apache.axis2.engine.AxisObserver;
/**
* Axis observer to get notification of service activate/deactiavte/deploy/undeploy operations
*
*/
public class ServiceMonitorObserver implements AxisObserver {
public void init(AxisConfiguration arg0) {
}
public void serviceUpdate(AxisEvent event, AxisService axisService) {
//if service is activated
if(AxisEvent.SERVICE_START == event.getEventType()){
//do your stuff
}
//if service is deployed
if(AxisEvent.SERVICE_DEPLOY == event.getEventType()){
//do your stuff
}
}
public void addParameter(Parameter arg0) throws AxisFault {
}
public void deserializeParameters(OMElement arg0) throws AxisFault {
}
public Parameter getParameter(String arg0) {
return null;
}
public ArrayList getParameters() {
return null;
}
public boolean isParameterLocked(String arg0) {
return false;
}
public void removeParameter(Parameter arg0) throws AxisFault {
}
public void moduleUpdate(AxisEvent arg0, AxisModule arg1) {
}
public void serviceGroupUpdate(AxisEvent arg0, AxisServiceGroup arg1) {
}
}
The above listener can be registered in the axis2 configuration (axis2.xml) as follows;
<listener class="org.test.axisobserver.ServiceMonitorObserver"/>
No comments:
Post a Comment