org.objectweb.telosys.screen.env
Class ScreenSession

java.lang.Object
  extended byorg.objectweb.telosys.common.TelosysObject
      extended byorg.objectweb.telosys.screen.env.ScreenSession
All Implemented Interfaces:
java.io.Serializable

public class ScreenSession
extends TelosysObject
implements java.io.Serializable

This class is a context holder for a user session
It is attached to the standard http session, it contains the user informations,
the user screen contexts, the services results, etc...

See Also:
Serialized Form

Constructor Summary
ScreenSession(javax.servlet.http.HttpSession httpSession, LoginUser loginUser, IAppUser appUser)
          Constructor
 
Method Summary
 void close()
          Close the session (clean all the references held by the session)
 void freeScreenContextSlot(int iScreenContextId)
          Free a reserved slot Designed to be used if a error occurs between getAvailableScreenContextId() and setScreenContext()
 IAppUser getAppUser()
          Returns the application user
 java.lang.Object getAttribute(java.lang.String name)
          Gets an object from the 'screen session attributes' using the given name
If name is null : return null
 int getAvailableScreenContextId()
          Returns the first available ScreenContext ID and reserve it ( or -1 if no slot available )
 javax.servlet.http.HttpSession getHttpSession()
          Deprecated. use ScreenRequest|ServiceRequest.getHttpSession() instead
 java.lang.String getHttpSessionId()
          Deprecated. use ScreenRequest|ServiceRequest.getHttpSessionId() instead
 java.lang.String getLanguage()
          Returns the current session language ( e.g. : "fr", "en", ... ) or null if none
 LoginUser getLoginUser()
          Retuns the login user (technical user)
static int getMaxScreenId()
          Returns the maximum Screen ID ( 0 to N )
 ScreenApplication getScreenApplication()
          Deprecated. use ScreenApplicationManager.getScreenApplication() instead
 ScreenContext getScreenContext(int iScreenId)
          Returns the screen context bound with the specified id
 ScreenPostback getScreenPostback(java.lang.String sScreenKey)
          Returns the ScreenPostback object for the given Screen key (if not found, the ScreenPostback is created)
 ScreenPostback getScreenPostback(java.lang.String sScreenName, int iScreenContextId)
          Returns the ScreenPostback for the given Screen Name and Screen Context Id
 java.lang.Object getServiceResult(java.lang.String sKey)
          Returns the Service Result object from the ResultHolder stored in session with the given key
 ServiceResultHolder getServiceResultHolder(java.lang.String sKey)
          Returns the service result holder stored in screen session with the given key
 javax.servlet.ServletContext getServletContext()
          Deprecated. use ScreenApplicationManager.getServletContext() instead
 SessionPostback getSessionPostback()
          Returns the SessionPostback object
 java.lang.Object removeAttribute(java.lang.String name)
          Removes an object from the 'screen session attributes'
If name is null : do nothing and return null
 void removeScreenContext(int iScreenId)
          Removes the screen context bound with the specified id
 java.lang.Object setAttribute(java.lang.String name, java.lang.Object value)
          Sets an object as a 'screen session attribute', associated with a unique name
If name is null : do nothing
If value is null : remove the attribute associated with the given name
 void setLanguage(java.lang.String sLang)
          Sets the current session language
 void setScreenContext(int iScreenId, ScreenContext screen)
          Set a screen context in the screen session
 void setServiceResultHolder(java.lang.String sKey, ServiceResultHolder srh)
          Store a service result holder in screen session with the given key
 
Methods inherited from class org.objectweb.telosys.common.TelosysObject
error, error, error, getFlagTrace, info, setFlagTrace, trace, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScreenSession

public ScreenSession(javax.servlet.http.HttpSession httpSession,
                     LoginUser loginUser,
                     IAppUser appUser)
Constructor

Parameters:
httpSession -
loginUser -
appUser -
Method Detail

getHttpSession

public javax.servlet.http.HttpSession getHttpSession()
Deprecated. use ScreenRequest|ServiceRequest.getHttpSession() instead

Returns the standard HttpSession object

Returns:

getHttpSessionId

public java.lang.String getHttpSessionId()
Deprecated. use ScreenRequest|ServiceRequest.getHttpSessionId() instead

Returns the standard HttpSession id

Returns:

getServletContext

public javax.servlet.ServletContext getServletContext()
Deprecated. use ScreenApplicationManager.getServletContext() instead

Returns the standard ServletContext

Returns:

getScreenApplication

public ScreenApplication getScreenApplication()
Deprecated. use ScreenApplicationManager.getScreenApplication() instead

Returns the ScreenApplication object
As each ScreenSession creation check if the ScreenApplication exists
, this method never returns null

Returns:

getSessionPostback

public SessionPostback getSessionPostback()
Returns the SessionPostback object

Returns:
the postback object (or null if not yet created)

getScreenPostback

public ScreenPostback getScreenPostback(java.lang.String sScreenKey)
                                 throws TelosysException
Returns the ScreenPostback object for the given Screen key (if not found, the ScreenPostback is created)

Parameters:
sScreenKey - the "screen key" ( Screen Name + Screen Context Id )
Returns:
Throws:
TelosysException

getScreenPostback

public ScreenPostback getScreenPostback(java.lang.String sScreenName,
                                        int iScreenContextId)
Returns the ScreenPostback for the given Screen Name and Screen Context Id

Parameters:
sScreenName -
iScreenContextId -
Returns:
the ScreenPostback (or null if not found)

getMaxScreenId

public static int getMaxScreenId()
Returns the maximum Screen ID ( 0 to N )

Returns:

setScreenContext

public void setScreenContext(int iScreenId,
                             ScreenContext screen)
Set a screen context in the screen session

Parameters:
iScreenId -
screen -

getScreenContext

public ScreenContext getScreenContext(int iScreenId)
Returns the screen context bound with the specified id

Parameters:
iScreenId -
Returns:

getAvailableScreenContextId

public int getAvailableScreenContextId()
Returns the first available ScreenContext ID and reserve it ( or -1 if no slot available )

Returns:
Since:
1.0.4

freeScreenContextSlot

public void freeScreenContextSlot(int iScreenContextId)
Free a reserved slot Designed to be used if a error occurs between getAvailableScreenContextId() and setScreenContext()

Parameters:
iScreenContextId -
Since:
1.0.4

removeScreenContext

public void removeScreenContext(int iScreenId)
Removes the screen context bound with the specified id

Parameters:
iScreenId -

setServiceResultHolder

public void setServiceResultHolder(java.lang.String sKey,
                                   ServiceResultHolder srh)
Store a service result holder in screen session with the given key

Parameters:
sKey -
srh - the service result holder

getServiceResultHolder

public ServiceResultHolder getServiceResultHolder(java.lang.String sKey)
Returns the service result holder stored in screen session with the given key

Parameters:
sKey -
Returns:
the service result holder found (or null if not found)

getServiceResult

public java.lang.Object getServiceResult(java.lang.String sKey)
Returns the Service Result object from the ResultHolder stored in session with the given key

Parameters:
sKey -
Returns:
object instance or null if not found

getLoginUser

public LoginUser getLoginUser()
Retuns the login user (technical user)

Returns:

getAppUser

public IAppUser getAppUser()
Returns the application user

Returns:

setLanguage

public void setLanguage(java.lang.String sLang)
Sets the current session language

Parameters:
sLang - ( e.g. : "fr", "en", ... )

getLanguage

public java.lang.String getLanguage()
Returns the current session language ( e.g. : "fr", "en", ... ) or null if none

Returns:

setAttribute

public java.lang.Object setAttribute(java.lang.String name,
                                     java.lang.Object value)
Sets an object as a 'screen session attribute', associated with a unique name
If name is null : do nothing
If value is null : remove the attribute associated with the given name

Parameters:
name - : a string specifying the name of the object
value - : the value
Returns:
: the previous value of the specified key in this hashtable, or null have one

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Gets an object from the 'screen session attributes' using the given name
If name is null : return null

Parameters:
name - : a string specifying the name of the object
Returns:
: value instance ( or null if key is null or not found )

removeAttribute

public java.lang.Object removeAttribute(java.lang.String name)
Removes an object from the 'screen session attributes'
If name is null : do nothing and return null

Parameters:
name - : a string specifying the name of the object
Returns:
: the value removed, or null if not found

close

public void close()
Close the session (clean all the references held by the session)