Session Host Object
1.0 Introduction
The 'session' hosted object provides the ability for the users to share objects across different service invocations. The session object is global and thus does not need to be instantiated explicitly.
1.1 Example
this.serviceName = "ApplicationScopeService";
this.scope="application";
var key = "number";
function putValue(param){
session.put(key,2);
return <success/>;
}
function getValue(param){
number = session.get(key);
return <number>{number}</number>;
}
function removeValue(param){
number = session.remove(key);
return <success/>;
}
function clearSession(param){
session.clear();
return <success/>;
}
2.0 Session Object
Session scope for a deployed mashup can be given using the "scope" service property annotation. Following are the set of supported scopes.
'request' - The state date stored in the session object will be available only for the current invocation of the service. In other words the session object has no effect in this scope.
'transportsession' - The state date stored in the session object will be available only for the life time of the transport session used for invoking this service. This can be used to store data across invocations for a specific client.
'application' - The state date stored in the session object will be available throughout the life time of the service.
'soapsession'
- WS-Addressing is required for this. < Not Implemented as yet
>
By default, Mashup services deployed in the WSO2 Mashup Server are running in the "request" scope.
2.1 Session Object Interface
{
function void put(key,object);
function object get(key);
function void remove(key);
function void clear();
}
2.2 API Documentation
| Member | Description | Supported in version |
| void put(key,object); | Puts the key value pair in to the session object. This
pair will be available for the service invocations across the session. session.put("name", "WSO2 Mashup Server"); |
0.1 |
| object get(key); | Retrieves the value associated with the given "key"
from the current session object. session.get("name"); |
0.1 |
| void remove(key); | Removes the value associated with the given "key"
from the current session object. session.remove("name"); |
1.0 |
| void clear(); | Removes all values from the current session object. session.clear(); |
1.0 |