Library

How does service know when session starts and finishes when its deployed in one of many sessions?

  • By Deepal Jayasingha
  • 13 Jun, 2006

A : There are four session scopes that one can deploy his service in Apache Axis2. No matter which session scope you deploy your service in, it will notify when session starts and when the session finishes. Axis2 notifies service implementation class using Java reflection. Therefor, you have to add two more methods to your service implementation class to have this feature. Both at start and finish of session, it passes ServiceContext so you can store state properties there in service context to manage session.

//This method will called when session start
public void init(ServiceContext stctx){
.....
}

// This method will call when the session finish
public void destroy(ServiceContext stctx){
.....
}