WSO2Con 2013 CFP Banner

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

Archived Content
This article is provided for historical perspective only, and may not reflect current conditions. Please refer to relevant product page for more up-to-date product information and resources.
Discuss this article on Stack Overflow
By Deepal Jayasingha
  • 13 Jun, 2006
  • Level: 
  • Reads: 4323
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){