KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > appserver > server > session > MemoryPersistence


1 package com.lutris.appserver.server.session;
2
3 import java.util.Hashtable JavaDoc;
4 /**
5  * <p>Title: </p>
6  * <p>Description: Save in memory active and passive sessions during restart Enhydra applications </p>
7  * <p>Copyright: Copyright (c) 2002</p>
8  * <p>Company: </p>
9  * @author Dacha (damir@uns.ns.ac.yu) & Tufa (tufex@uns.ns.ac.yu)
10  * @version 1.1
11  */

12
13 public class MemoryPersistence {
14
15   private static Hashtable JavaDoc managers = new Hashtable JavaDoc();
16   private static Hashtable JavaDoc classLoaders = new Hashtable JavaDoc();
17
18   private MemoryPersistence() {
19   }
20     /**
21      * Called when application restart.
22      *
23      * @param appName
24      * application name.
25      * @see #putSessionManager
26      */

27   static public SessionManager getSessionManager(String JavaDoc appName){
28     if(managers.containsKey(appName))
29       return (SessionManager) managers.remove(appName);
30     else return null;
31   }
32
33     /**
34      * Called when application shutdown.
35      *
36      * @param appName
37      * application name
38      * @param sessMgr
39      * application's SessionManager
40      * @see #getSessionManager
41      */

42   static public void putSessionManager(String JavaDoc appName,SessionManager sessMgr){
43     managers.put(appName,sessMgr);
44     }
45     /**
46      * Get ClassLoader (MultiClassLoader) for Enhydra Application.
47      * This ClassLoader was set when application started first time.
48      * ClassLoader is saved, because we need it to support MemoryPersistence.
49      * @param appName application name
50      * @return ClassLoader for given application name
51      */

52   static public ClassLoader JavaDoc getClassLoader(String JavaDoc appName){
53     if(classLoaders.containsKey(appName))
54       return ((ClassLoader JavaDoc) classLoaders.get(appName));
55     else return null;
56   }
57     /**
58      * When application first time startup, it sets ClassLoader and use them
59      * next time is restarting.
60      * @param appName application name
61      * @param cl ClassLoader or NULL
62      */

63   static public void setClassLoader(String JavaDoc appName, ClassLoader JavaDoc cl){
64     classLoaders.put(appName,cl);
65   }
66   /**
67    * If SessionManager.MemoryPersistence = false in conf file, don't need to save
68    * MultiClassLoader. This method is called when application shutdown.
69    * @param appName application name.
70    */

71   static public void removeClassLoader(String JavaDoc appName){
72     classLoaders.remove(appName);
73   }
74   /**
75    * When EnhydraServer stoped clean all.
76    */

77   static public void shutdown(){
78     managers = new Hashtable JavaDoc();
79     classLoaders = new Hashtable JavaDoc();
80   }
81 }
82
Popular Tags