org.wso2.mashup.hostobjects.session
Class SessionHostObject

java.lang.Object
  extended by org.mozilla.javascript.ScriptableObject
      extended by org.wso2.mashup.hostobjects.session.SessionHostObject
All Implemented Interfaces:
java.io.Serializable, org.mozilla.javascript.ConstProperties, org.mozilla.javascript.debug.DebuggableObject, org.mozilla.javascript.Scriptable

public class SessionHostObject
extends org.mozilla.javascript.ScriptableObject

This is a JavaScript Rhino host object to provide the ability for the users to share objects across different service invocations. Scope for the session of a deployed mashup can be given using the "scope" service property annotation.

For more information refer to JavaScript Session Host Object.

See Also:
Serialized Form

Field Summary
static java.lang.String MASHUP_SESSION_OBJECT
           
 
Fields inherited from class org.mozilla.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
 
Fields inherited from interface org.mozilla.javascript.Scriptable
NOT_FOUND
 
Constructor Summary
SessionHostObject()
          Contructor that will be used by the java engine..
 
Method Summary
 java.lang.String getClassName()
           
static org.mozilla.javascript.Scriptable jsConstructor(org.mozilla.javascript.Context cx, java.lang.Object[] args, org.mozilla.javascript.Function ctorObj, boolean inNewExpr)
          Constructor that gets called when creating the session object from Rhino.
 void jsFunction_clear()
          Removes all values (clears) from the current java script session object.
 java.lang.Object jsFunction_get(java.lang.String key)
          Retrieves the value associated with the given "key" from the current java script session object.
 void jsFunction_put(java.lang.String key, java.lang.Object object)
          Puts the key value pair in to the java script session object.
 void jsFunction_remove(java.lang.String key)
          Removes the value associated with the given "key" from the current java script session object.
 
Methods inherited from class org.mozilla.javascript.ScriptableObject
associateValue, callMethod, callMethod, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, get, get, getAllIds, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, has, has, hasInstance, hasProperty, hasProperty, isConst, isSealed, put, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setParentScope, setPrototype
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MASHUP_SESSION_OBJECT

public static final java.lang.String MASHUP_SESSION_OBJECT
See Also:
Constant Field Values
Constructor Detail

SessionHostObject

public SessionHostObject()
Contructor that will be used by the java engine..

Method Detail

jsConstructor

public static org.mozilla.javascript.Scriptable jsConstructor(org.mozilla.javascript.Context cx,
                                                              java.lang.Object[] args,
                                                              org.mozilla.javascript.Function ctorObj,
                                                              boolean inNewExpr)
                                                       throws java.io.IOException

Constructor that gets called when creating the session object from Rhino.

Retrieve the instance of this class available in the ServiceGroupContext of the current invocation and returns is to the user. If an instance of this is not available in the ServiceGroupContext, create an instance of this object and stores it in the ServiceGroupContext of the current message.

Throws:
java.io.IOException

getClassName

public java.lang.String getClassName()
Specified by:
getClassName in interface org.mozilla.javascript.Scriptable
Specified by:
getClassName in class org.mozilla.javascript.ScriptableObject

jsFunction_put

public void jsFunction_put(java.lang.String key,
                           java.lang.Object object)
Puts the key value pair in to the java script session object. This pair will be available in the session object for the service invocations across the session.

 session.put("name", "WSO2 Mashup Server");
 

Parameters:
key - - The key of the object added to the session
object - - The value of the object added to the session

jsFunction_get

public java.lang.Object jsFunction_get(java.lang.String key)
Retrieves the value associated with the given "key" from the current java script session object.

 session.get("name");
 

Parameters:
key - - The key of the object that the value is needed for
Returns:
the value associated with the given key or null if there isn't a associated value.

jsFunction_remove

public void jsFunction_remove(java.lang.String key)
Removes the value associated with the given "key" from the current java script session object.

 session.remove("name");
 

Parameters:
key - - The key of the object that needs to be removed

jsFunction_clear

public void jsFunction_clear()
Removes all values (clears) from the current java script session object.

 session.clear();