1 package org.enhydra.server; 2 3 import java.util.Date ; 4 5 import com.lutris.appserver.server.Application; 6 import com.lutris.appserver.server.session.SessionException; 7 import com.lutris.appserver.server.session.SessionManager; 8 import com.lutris.appserver.server.sessionEnhydra.StandardSessionManager; 9 import com.lutris.util.Config; 10 import com.lutris.util.KeywordValueException; 11 22 23 public class SessionsInfo { 24 25 private SessionManager sm ; 26 private String type; 27 private String persistence; 28 private String pageSessionsOnStop; 29 private String saveSessionsToMemoryOnStop; 30 private String activeSessions; 31 private String pagedSessions; 32 private String peakSessions; 33 private Date peakSessionsWhen; 34 35 private Config config; 36 41 public SessionsInfo(Application app,Config smConfig)throws SessionException,KeywordValueException{ 42 sm = null; 44 activeSessions = "N/A"; 45 pagedSessions = "N/A"; 46 peakSessions = "N/A"; 47 peakSessionsWhen = null; 48 49 if(app != null) { 50 sm = app.getSessionManager(); 51 if (sm != null){ 52 activeSessions = String.valueOf(sm.activeSessionCount()); 53 boolean classKnown=true; 54 try{ 55 Class auxClass=Class.forName("com.lutris.appserver.server.sessionEnhydra.StandardSessionManager"); 56 57 }catch (Exception e){ 58 classKnown=false; 59 } 60 if (classKnown && sm instanceof StandardSessionManager) 61 pagedSessions = String.valueOf(((StandardSessionManager)sm).pagedSessionCount()); 62 63 peakSessions = String.valueOf(sm.maxSessionCount()); 64 peakSessionsWhen = sm.maxSessionCountDate(); 65 }else log("WARNING: SessionManager = null !"); 66 }else log("WARNING: app = null !"); 67 68 config = smConfig; 70 persistence = "NO"; 71 pageSessionsOnStop = "NO"; 72 saveSessionsToMemoryOnStop = "NO"; 73 if (config != null){ 74 type = "Enhydra Standard Session Manager"; if (config.containsKey("MemoryPersistence")){ 76 if(config.getBoolean("MemoryPersistence")) saveSessionsToMemoryOnStop = "YES"; 77 } 78 79 if (config.containsKey("SessionHome")){ 80 config = (Config) config.getSection("SessionHome"); 81 if (config.containsKey("Mode")){ 82 String s = (String ) config.get("Mode"); 83 if (s.equalsIgnoreCase("BASIC")) persistence = "NO" ; 84 if (s.equalsIgnoreCase("PAGE_TO_DISK")) persistence = "Page to disk" ; 85 if (s.equalsIgnoreCase("PAGE_TO_DB")) persistence = "Page to DB" ; 86 } 87 if (config.containsKey("SaveOnRestart")){ 88 if(config.getBoolean("SaveOnRestart")) pageSessionsOnStop = "YES"; 89 } 90 } 91 } 92 } 93 97 public String getActiveSessions() { 98 return activeSessions; 99 } 100 104 public String getPagedSessions() { 105 return pagedSessions; 106 } 107 111 public String getPageSessionsOnStop() { 112 return pageSessionsOnStop; 113 } 114 public String getPeakSessions() { 115 return peakSessions; 116 } 117 public Date getPeakSessionsWhen() { 118 return peakSessionsWhen; 119 } 120 public String getPersistence() { 121 return persistence; 122 } 123 public String getSaveSessionsToMemoryOnStop() { 124 return saveSessionsToMemoryOnStop; 125 } 126 public String getType() { 127 return type; 128 } 129 private void log(String message){ 130 System.err.println("EnhydraServer, SessionsInfo: "+message); 132 } 133 } | Popular Tags |