Common
Class SessionMgr

java.lang.Object
  extended by Common.SessionMgr
All Implemented Interfaces:
java.io.Serializable

public class SessionMgr
extends java.lang.Object
implements java.io.Serializable

Session manager class. This class stores all the session wide data. Upon application exit, the class serializes all its variables. Upon application restart, those variables are read back in and restored to their original values. Eg, directory locations for input files are remembered across sessions.

Since:
1.0
See Also:
Serialized Form

Field Summary
private  java.util.Map<java.lang.String,java.lang.String> mAttributeToVal
          Map storing attributes.
private static SessionMgr mInstance
           
private  java.lang.String mMapFileName
           
private static char mSeparator
           
static java.lang.String mSerialFileName
           
private static long serialVersionUID
           
 
Constructor Summary
private SessionMgr()
          SessionMgr is a singleton class.
 
Method Summary
 java.lang.String GetAttribute(java.lang.String moduleName, java.lang.String attrName)
          Get the attribute value for the module name and attribute.
 java.lang.String GetMapFileName()
           
static SessionMgr Instance()
          Get the SessionMgr singleton instance.
private  void ReadMap()
           
private  void readObject(java.io.ObjectInputStream in)
          Read object back (deserialization).
 void SaveAttribute(java.lang.String moduleName, java.lang.String attrName, java.lang.String val)
           
private  void WriteMap()
           
private  void writeObject(java.io.ObjectOutputStream out)
          Write object for serialization.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

mSeparator

private static final char mSeparator
See Also:
Constant Field Values

mSerialFileName

public static final java.lang.String mSerialFileName
See Also:
Constant Field Values

mMapFileName

private java.lang.String mMapFileName

mAttributeToVal

private java.util.Map<java.lang.String,java.lang.String> mAttributeToVal
Map storing attributes. Key of this map is constructed as follows: module_name + ":" + attr_name


mInstance

private static SessionMgr mInstance
Constructor Detail

SessionMgr

private SessionMgr()
SessionMgr is a singleton class.

Method Detail

Instance

public static SessionMgr Instance()
Get the SessionMgr singleton instance.

Returns:
SesionMgr instance

GetMapFileName

public java.lang.String GetMapFileName()

SaveAttribute

public void SaveAttribute(java.lang.String moduleName,
                          java.lang.String attrName,
                          java.lang.String val)

GetAttribute

public java.lang.String GetAttribute(java.lang.String moduleName,
                                     java.lang.String attrName)
                              throws java.lang.IllegalArgumentException
Get the attribute value for the module name and attribute.

Parameters:
moduleName - Name of module
attrName - Name of attribute
Returns:
Value of attribute for a particular module
Throws:
java.lang.IllegalArgumentException - If the attribute or module name has not been stored.

WriteMap

private void WriteMap()

ReadMap

private void ReadMap()

writeObject

private void writeObject(java.io.ObjectOutputStream out)
                  throws java.io.IOException
Write object for serialization.

Parameters:
out - ObjectOutputStream
Throws:
java.io.IOException

readObject

private void readObject(java.io.ObjectInputStream in)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Read object back (deserialization).

Parameters:
in - ObjectInputStream
Throws:
java.io.IOException
java.lang.ClassNotFoundException