Managing deployed Axis2 services

There can be certain tasks we need to carry out,

1. at the time a service/service group being added
2. at the time a service/service group being updated
3. at the time a service/service group being deleted.

Let's say we need to have a service parameter for a given service.

But, there is no way we could derive the value of it at the time of development and that value is specific to the deployment setup.

Say you want to pass the key store name and it's key name as service parameters.

These value differ from one deployment setup to another.

So, setting up that parameter in the services.xml will not work.

But, we can setup it at the time service being deployed.

To do this, we need to register an event listener in axis2.xml.

The event listener is an implementation of org.apache.axis2.engine.AxisObserver.

Let's see a sample implementation of AxisObserver and how we could configure it in axis2.xml.

import java.util.ArrayList;

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;

public class ServiceInterceptor implements AxisObserver {

public void init(AxisConfiguration arg0) {

public void moduleUpdate(AxisEvent arg0, AxisModule arg1) {

public void serviceGroupUpdate(AxisEvent arg0, AxisServiceGroup arg1) {

public void serviceUpdate(AxisEvent event, AxisService service) {
int eventType;
String serviceName = null;

eventType = event.getEventType();
serviceName = service.getName();

if (eventType == AxisEvent.SERVICE_DEPLOY) {
} else if (eventType == AxisEvent.SERVICE_START) {
if ("MyService".equals(serviceName)) {
} else if (eventType == AxisEvent.SERVICE_STOP) {
} else if (eventType == AxisEvent.SERVICE_REMOVE) {

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 {

Now, we need to configure the listener in [AXIS2_HOME]\conf\axis2.xml.

<listener class="ServiceInterceptor"/>