com.wm.app.b2b.server
Class Session

java.lang.Object
  extended by com.wm.util.Values
      extended by com.wm.app.b2b.server.Session
All Implemented Interfaces:
IData, Codable, java.io.Serializable, java.lang.Cloneable

public class Session
extends Values
implements java.lang.Cloneable

Session is a subclass of Values that stores the user's active session information including: session id, session timeout, start time, last call time, and call count.

The session object is available on every service invocation and can therefore be used to store user state between invocations. Use it just like Values to store and retrieve keyed values.

See Also:
Serialized Form

Field Summary
 boolean gDirty
          Used to indicate that the object has changed.
 
Constructor Summary
Session(java.lang.String name)
          Creates a new Session object with defaults.
Session(java.lang.String ssnid, long timeout, java.lang.String name)
          Creates a new Session object for the specified user, session id, and timeout.
 
Method Summary
 java.lang.Object clone()
          Clones a Session object.
 Values copyFrom(java.util.Hashtable v)
          Copies the elements from the given Hashtable object into the current Values object.
 Values copyFrom(Values v)
          Copies the elements from the given Values object into the current Values object.
 long getAge()
          Returns the age of the current session in milliseconds.
 int getCalls()
          Returns the total number of invocations on this session during its lifetime.
 iContext getIContext()
          Returns the iContext associated with this session.
 long getLast()
          Returns the time of the most recent invocation on this session, in milliseconds.
 java.util.Locale getLocale()
          Returns the locale of this session.
 java.lang.String getName()
          Returns the name of the current session.
 java.lang.String getSessionID()
          Returns the id of the current session.
 java.util.Date getStart()
          Returns the start time of the current session.
 long getTimeout()
          Returns the idle timeout value for the current session, in milliseconds.
 User getUser()
          Returns the user associated with the current session.
 java.lang.Object put(java.lang.Object value)
          Adds an "unnamed" object which can be retrieved by a positional get(int).
 java.lang.Object put(java.lang.String key, int value)
          put() which converts int value to an Integer object.
 java.lang.Object put(java.lang.String key, long value)
          put() which converts long value to a Long object.
 java.lang.Object put(java.lang.String k, java.lang.Object value)
          Adds a named object which can be retrieved by get(String).
 java.lang.Object putClean(java.lang.String k, java.lang.Object value)
          Adds a named object which can be retrieved by get(String).
 java.lang.Object remove(java.lang.String key)
          Returns a named object and permanently remove it from the Values object.
 void renameKey(java.lang.String oldKey, java.lang.String newKey)
          Renames a key, preserving its order.
 void setCalls(int val)
           
 void setIContext(iContext change)
          Sets the iContext to the given value.
 void setIContext(java.lang.String lang)
          Sets the iContext using the language string.
 void setLast(long val)
          Sets the time of the most recent invocation on this session, in milliseconds.
 void setLocale(java.util.Locale l)
          Sets the locale of this session.
 void setStart(java.util.Date val)
          Sets the start time of the current session.
 void setTimeout(long tmout)
          Sets the idle timeout value for the current session, in milliseconds.
 void setUser(User user)
          Sets the user associated with the current session.
 java.lang.String toString()
          Standard toString implementation.
 void update()
          Increments the session call count and update the last call time with the current time.
 
Methods inherited from class com.wm.util.Values
equals, get, get, getBoolean, getInt, getInt, getLong, getLong, getNonEmptyString, getString, getStringArray, getStringTable, getTrimmedString, getValues, getValuesArray, hashCode, isEmpty, sortedKeys, use
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.wm.data.IData
getCursor, getHashCursor, getIndexCursor, getSharedCursor, getTreeCursor
 
Methods inherited from interface com.wm.util.coder.Codable
getValue, getValueKeys, setValue
 

Field Detail

gDirty

public boolean gDirty
Used to indicate that the object has changed.

Constructor Detail

Session

public Session(java.lang.String name)
Creates a new Session object with defaults.


Session

public Session(java.lang.String ssnid,
               long timeout,
               java.lang.String name)
Creates a new Session object for the specified user, session id, and timeout.

Method Detail

getLocale

public java.util.Locale getLocale()
Returns the locale of this session.

Returns:
a Locale object

setLocale

public void setLocale(java.util.Locale l)
Sets the locale of this session.

Parameters:
l - the locale

getIContext

public iContext getIContext()
Returns the iContext associated with this session.

Returns:
an iContext object

setIContext

public void setIContext(iContext change)
Sets the iContext to the given value.

Parameters:
change - The new iContext. If change is null, the session's iContext is set to a new, empty iContext.

setIContext

public void setIContext(java.lang.String lang)
Sets the iContext using the language string.

Parameters:
lang - the locale. The language string can be one of the following:
  • RFC3066 language tag
  • Java Locale toString
  • Valid Microsoft .NET 'rfc1766' ID from CultureInfo
  • iContext string serialization

getName

public java.lang.String getName()
Returns the name of the current session.


getSessionID

public java.lang.String getSessionID()
Returns the id of the current session.


getAge

public long getAge()
Returns the age of the current session in milliseconds.


getStart

public java.util.Date getStart()
Returns the start time of the current session.


setStart

public void setStart(java.util.Date val)
Sets the start time of the current session.


getUser

public User getUser()
Returns the user associated with the current session.


setUser

public void setUser(User user)
Sets the user associated with the current session.


getLast

public long getLast()
Returns the time of the most recent invocation on this session, in milliseconds.


setLast

public void setLast(long val)
Sets the time of the most recent invocation on this session, in milliseconds.


getTimeout

public long getTimeout()
Returns the idle timeout value for the current session, in milliseconds.


setTimeout

public void setTimeout(long tmout)
Sets the idle timeout value for the current session, in milliseconds.


getCalls

public int getCalls()
Returns the total number of invocations on this session during its lifetime.


setCalls

public void setCalls(int val)

update

public void update()
Increments the session call count and update the last call time with the current time.


clone

public java.lang.Object clone()
Clones a Session object. Duplicates all session-specific data, as well as the Values key and element references, but not the actual data elements (nor the private data).

Overrides:
clone in class Values
See Also:
Hashtable.clone()

toString

public java.lang.String toString()
Standard toString implementation. For debugging purposes.

Overrides:
toString in class Values

put

public java.lang.Object put(java.lang.Object value)
Adds an "unnamed" object which can be retrieved by a positional get(int).

Overrides:
put in class Values

put

public java.lang.Object put(java.lang.String k,
                            java.lang.Object value)
Adds a named object which can be retrieved by get(String).

Overrides:
put in class Values

putClean

public java.lang.Object putClean(java.lang.String k,
                                 java.lang.Object value)
Adds a named object which can be retrieved by get(String).

See Also:
Hashtable.put(K, V)

put

public java.lang.Object put(java.lang.String key,
                            int value)
put() which converts int value to an Integer object.

Overrides:
put in class Values

put

public java.lang.Object put(java.lang.String key,
                            long value)
put() which converts long value to a Long object.

Overrides:
put in class Values

remove

public java.lang.Object remove(java.lang.String key)
Returns a named object and permanently remove it from the Values object.

Overrides:
remove in class Values
See Also:
Hashtable.remove(java.lang.Object)

renameKey

public void renameKey(java.lang.String oldKey,
                      java.lang.String newKey)
Renames a key, preserving its order.


copyFrom

public Values copyFrom(Values v)
Copies the elements from the given Values object into the current Values object.

Overrides:
copyFrom in class Values

copyFrom

public Values copyFrom(java.util.Hashtable v)
Copies the elements from the given Hashtable object into the current Values object.

Overrides:
copyFrom in class Values