WSO2Con 2013 CFP Banner

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

Discuss this article on Stack Overflow
By Deepal Jayasingha
  • 13 Jun, 2006
  • Level: 
  • Reads: 3855
Q : When I deploy my service in one of the four sessions, how does my service know when its session starts and finishes.
Deepal Jayasingha

WSO2 Inc.
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){
.....
}
WSO2Con 2014 USA