LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.app
Class LyDataSession

java.lang.Object
  extended by leon.app.LyDataSession
All Implemented Interfaces:
LyEvaluator
Direct Known Subclasses:
LySession

public class LyDataSession
extends java.lang.Object
implements LyEvaluator

This class describes a user session. Each time a user connects itself on an application, a new instance of this class is created. By default, in heavy client versions a session is created when an application is started. In thin client versions (Servlet) a new session is created each time a new user connects himself on the servlet. A session is described by :

See Also:
LyApplication

Nested Class Summary
static class LyDataSession.State
          States of the session.
 
Field Summary
static java.lang.String __VERSION
          File version
static int _nbSessions
          Number of sessions.
static int _sessionsCounter
          Sessions counter.
 
Constructor Summary
LyDataSession(LyApplication application)
          Constructor with a given application.
LyDataSession(LyApplication application, boolean registerSession)
          Constructor with a given application.
LyDataSession(LyApplication application, LyDataSession parent, boolean registerSession)
          Constructor with a given application.
LyDataSession(LyApplication application, LyDataSession parent, boolean registerSession, java.lang.String perspectiveId)
          Constructor with a given application.
 
Method Summary
 void addInfoListener(LyInfoListener listener, java.lang.String prefix)
          Adds an info listener to the application.
 void addValue(java.lang.Object key, java.lang.Object value)
          Adds a pair key-value to the session.
 void close()
          Closes the session.
 void dumpLocks(boolean before)
           
 LyApplication getApplication()
          Returns the application owner of the session.
 LyContextManager getContextManager()
          Gets the context manager of this application.
 long getCreationTime()
          Returns the time of creation of this session.
 LyDataSource getDataSource(LyClass lyClass)
          Retrieves a data source on this session.
 LyDataSource getDataSource(java.lang.String classId)
          Retrieves a data source on this session.
 LyEnvironment getEnvironment()
          Returns the environment of the session.
 void getHardLock()
          Get a soft lock on this session.
 java.lang.String getId()
          Accessor for the identifier of the session.
 java.lang.Object getKeyValue(java.lang.String key)
          Retrieves a value from a registered key.
 LyObjectList getObjectsByName(LyInfoList<LyClassInfo> classInfos, java.lang.String[] objectNames)
          Retrieves a list of objects by their names from a list of classes.
 LyObjectSource getObjectSource(LyClassInfo classInfo)
          Retrieves an object source on this session.
 LyDataSession getParent()
          Returns the parent session.
 java.lang.String getPluginId()
          Get the plugin id for this session.
 LyDataSessionBehaviorInterface getSessionBehavior()
          Returns the client interface of this session.
 void getSoftLock()
          Get a soft lock on this session.
 LyDataSession.State getState()
          Gets state of this session.
 java.util.Vector<LyDataSession> getSubSessions()
          Get sub-sessions of this session.
 LyObject getUser()
          Accessor to the user of current session.
 java.lang.Object getValue(java.lang.Object key)
          Retrieves a value from a registered key.
 void handleException(java.lang.Throwable t)
          Called when an exception occured during proccessing.
 boolean hasTransaction()
          Test if the session has some pending transaction.
 boolean isClosed()
          Indicates whether the session is closed or not.
 boolean isObjectVisible(LyObject object)
          Checks whether an object is visible in this session or not.
 boolean isRegistered()
          Indicates whether the session is registered or not.
 boolean isValid()
          Indicates whether the session is valid or not.
 void notifyInfoListeners(java.lang.String prefix)
          Notify info listeners on a class that an event has occured.
 void putObjectSource(LyObjectSource objectSource)
          Registers an object source on this session.
 void register(boolean start)
          Registers the session on its application owner.
 void releaseHardLock()
          Release a soft lock on this session.
 void releaseSoftLock()
          Release a soft lock on this session.
 void removeInfoListener(LyInfoListener listener)
          Adds an info listener to the application.
 void removeObjectSource(LyObjectSource objectSource)
          Unregisters an object source on this session.
 void resetUndoRedo()
          Reset the undo redo stack
 void setPluginId(java.lang.String pluginId)
          Set the plugin id for the session.
 void setTimeZone(java.lang.String timeZone)
          Set the current time zone for the user
 void setUser(LyObject user)
          Sets the user of this session.
 void setValid(boolean valid)
          Validates the session.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
File version

See Also:
Constant Field Values

_nbSessions

public static int _nbSessions
Number of sessions.


_sessionsCounter

public static int _sessionsCounter
Sessions counter.

Constructor Detail

LyDataSession

public LyDataSession(LyApplication application)
Constructor with a given application. Registers the session on the application.

Parameters:
application - The application owner of the session.

LyDataSession

public LyDataSession(LyApplication application,
                     boolean registerSession)
Constructor with a given application.

Parameters:
application - The application owner of the session.
registerSession - Indicates if the session must be registered on the application (default is true), or if this is a temporary session which should be ignored.

LyDataSession

public LyDataSession(LyApplication application,
                     LyDataSession parent,
                     boolean registerSession)
Constructor with a given application.

Parameters:
application - The application owner of the session.
parent - Parent session: used for a module.
registerSession - Indicates if the session must be registered on the application (default is true), or if this is a temporary session which should be ignored.

LyDataSession

public LyDataSession(LyApplication application,
                     LyDataSession parent,
                     boolean registerSession,
                     java.lang.String perspectiveId)
Constructor with a given application.

Parameters:
application - The application owner of the session.
parent - Parent session: used for a module.
registerSession - Indicates if the session must be registered on the application (default is true), or if this is a temporary session which should be ignored.
perspectiveId - The perspective id for this session.
Method Detail

getId

public java.lang.String getId()
Accessor for the identifier of the session.

Returns:
The identifier of the session.

getState

public final LyDataSession.State getState()
Gets state of this session. One of the static codes named STATE_XXX.

Returns:
Current state of this session.

isClosed

public final boolean isClosed()
Indicates whether the session is closed or not.

Returns:
true if the session is closed, false otherwise.
See Also:
close()

isValid

public boolean isValid()
Indicates whether the session is valid or not.

Returns:
true if the session is valid, false otherwise.

isRegistered

public boolean isRegistered()
Indicates whether the session is registered or not.

Returns:
true if the session is registered on its application, false otherwise.
See Also:
register(boolean)

getEnvironment

public LyEnvironment getEnvironment()
Returns the environment of the session.

Returns:
The environment of the session.
See Also:
LyEnvironment

getApplication

public LyApplication getApplication()
Returns the application owner of the session.

Returns:
The application owner of the session.
See Also:
LyApplication

getParent

public LyDataSession getParent()
Returns the parent session.

Returns:
The parent session.

getSessionBehavior

public LyDataSessionBehaviorInterface getSessionBehavior()
Returns the client interface of this session.

Returns:
The client interface of this session.
See Also:
LyDataSessionBehaviorInterface

getCreationTime

public long getCreationTime()
Returns the time of creation of this session.

Returns:
the creation time in milliseconds.

setValid

public void setValid(boolean valid)
Validates the session.

Parameters:
valid - a boolean indicating if the session is valid

register

public void register(boolean start)
Registers the session on its application owner. This method starts the session if the given parameter is true by calling the start() method.

Parameters:
start - Indicates whether the session must be started or not.
Throws:
java.lang.IllegalStateException - if the session has already been registered.

hasTransaction

public boolean hasTransaction()
Test if the session has some pending transaction.

Returns:
true if this session has somme pending transaction, else false.

close

public void close()
Closes the session. Removes the session from its application, sets all the controllers, the object sources and the view manager free.


addValue

public void addValue(java.lang.Object key,
                     java.lang.Object value)
Adds a pair key-value to the session. May be used for example to store the login used to create the session.

Parameters:
key - The key that must be stored.
value - The value that must be stored with the key.
See Also:
getValue(java.lang.Object)

getValue

public java.lang.Object getValue(java.lang.Object key)
Retrieves a value from a registered key.

Parameters:
key - The key that must be used.
Returns:
The value stored with the key or null if the key is not registered.
See Also:
addValue(java.lang.Object, java.lang.Object)

putObjectSource

public void putObjectSource(LyObjectSource objectSource)
Registers an object source on this session.

Parameters:
objectSource - The object source that must be registered.
See Also:
LyObjectSource, getObjectSource(leon.info.LyClassInfo)

removeObjectSource

public void removeObjectSource(LyObjectSource objectSource)
Unregisters an object source on this session.

Parameters:
objectSource - The object source that must be unregistered.
See Also:
LyObjectSource, getObjectSource(leon.info.LyClassInfo)

getObjectSource

public LyObjectSource getObjectSource(LyClassInfo classInfo)
Retrieves an object source on this session.

Parameters:
classInfo - The class corresponding to the object source that must be returned.
Returns:
The object source corresponding to the given class info.
See Also:
LyObjectSource, putObjectSource(leon.data.LyObjectSource)

getObjectsByName

public LyObjectList getObjectsByName(LyInfoList<LyClassInfo> classInfos,
                                     java.lang.String[] objectNames)
Retrieves a list of objects by their names from a list of classes.

Parameters:
classInfos - the list of target classes used to retrieve the objects.
objectNames - the list of object names used to retrieve the objects.
Returns:
the list of objects matching the given object names for given list of classes.

getDataSource

public LyDataSource getDataSource(java.lang.String classId)
Retrieves a data source on this session.

Parameters:
classId - The identifier of the class corresponding to the object source that must be returned.
Returns:
The object source corresponding to the given class identifier.
See Also:
LyDataSource, getDataSource(LyClass)

getDataSource

public LyDataSource getDataSource(LyClass lyClass)
Retrieves a data source on this session.

Parameters:
lyClass - The class corresponding to the object source that must be returned.
Returns:
The object source corresponding to the given class.
See Also:
LyDataSource, getDataSource(String)

handleException

public void handleException(java.lang.Throwable t)
Called when an exception occured during proccessing.

Parameters:
t - The throwable instance that causes the stop of the processing.

addInfoListener

public void addInfoListener(LyInfoListener listener,
                            java.lang.String prefix)
Adds an info listener to the application.

Parameters:
listener - Info listener that must be added.
prefix - Prefix of the files from which objects info were loaded.

removeInfoListener

public void removeInfoListener(LyInfoListener listener)
Adds an info listener to the application.

Parameters:
listener - Info listener that must be removed.

notifyInfoListeners

public void notifyInfoListeners(java.lang.String prefix)
Notify info listeners on a class that an event has occured.

Parameters:
prefix - Prefix of the files from which objects info were loaded.

getSubSessions

public java.util.Vector<LyDataSession> getSubSessions()
Get sub-sessions of this session.

Returns:
A vector containing all sub-sessions, null if no sub-sessions found.

getContextManager

public LyContextManager getContextManager()
Gets the context manager of this application.

Returns:
The associated context manager.

resetUndoRedo

public void resetUndoRedo()
Reset the undo redo stack


setPluginId

public void setPluginId(java.lang.String pluginId)
Set the plugin id for the session.

Parameters:
pluginId - The plugin id.

getPluginId

public java.lang.String getPluginId()
Get the plugin id for this session.

Returns:
The plugin id.

getUser

public LyObject getUser()
Accessor to the user of current session.

Returns:
The value of $USER value stored by the login controller if any, otherwise return null

isObjectVisible

public boolean isObjectVisible(LyObject object)
Checks whether an object is visible in this session or not. Object may not be visible if a filtered object source has been created on its class info.

Parameters:
object - the object that must be checked
Returns:
true if object is visible, false otherwise

getKeyValue

public java.lang.Object getKeyValue(java.lang.String key)
Retrieves a value from a registered key.

Specified by:
getKeyValue in interface LyEvaluator
Parameters:
key - The key that must be used.
Returns:
The value stored with the key or null if the key is not registered.

dumpLocks

public void dumpLocks(boolean before)

getSoftLock

public void getSoftLock()
Get a soft lock on this session. Internal Use Only.


releaseSoftLock

public void releaseSoftLock()
Release a soft lock on this session. Internal Use Only.


getHardLock

public void getHardLock()
Get a soft lock on this session. Internal Use Only.


releaseHardLock

public void releaseHardLock()
Release a soft lock on this session. Internal Use Only.


setUser

public void setUser(LyObject user)
Sets the user of this session.


setTimeZone

public void setTimeZone(java.lang.String timeZone)
Set the current time zone for the user

Parameters:
timeZoneId -

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com