1 17 18 package org.apache.geronimo.clustering.web; 19 20 import java.util.HashMap ; 21 import java.util.Map ; 22 23 import javax.management.ObjectName ; 24 25 import org.apache.commons.logging.Log; 26 import org.apache.commons.logging.LogFactory; 27 import org.apache.geronimo.clustering.MBeanImpl; 28 import org.apache.geronimo.clustering.Tier; 29 30 36 public class 37 HttpSessionManager 38 extends MBeanImpl 39 { 40 protected Log _log=LogFactory.getLog(HttpSessionManager.class); 41 45 protected Map _sessions=new HashMap (); 46 47 public int getSize(){return _sessions.size();} 48 49 protected Tier _tier; 50 public Tier getTier(){return _tier;} 51 52 public ObjectName getTierObjectName() {return _tier==null?null:_tier.getObjectName();} 53 54 protected String _clusterName; 55 public String getClusterName(){return _clusterName;} 56 public void setClusterName(String clusterName){_clusterName=clusterName;} 57 58 protected String _nodeName; 59 public String getNodeName(){return _nodeName;} 60 public void setNodeName(String nodeName){_nodeName=nodeName;} 61 62 protected String _tierName="web"; 63 public String getTierName(){return _tierName;} 64 public void setTierName(String tierName){_tierName=tierName;} 65 66 protected String _contextPath; 67 public String getContextPath(){return _contextPath;} 68 public void setContextPath(String contextPath){_contextPath=contextPath;} 69 70 protected String _uid; 71 public String getUID(){return _uid;} 72 73 77 public boolean 78 canStart() 79 { 80 if (!super.canStart()) return false; 81 82 try 83 { 84 _tier=(Tier)_server.getAttribute(Tier.makeObjectName(getClusterName(), getNodeName(), getTierName()), "Reference"); 86 _log.debug("Tier: "+_tier); 87 } 88 catch (Exception e) 89 { 90 _log.error("could not find Tier", e); 91 return false; 92 } 93 94 return true; 95 } 96 97 public void 98 doStart() 99 { 100 _uid=_contextPath; _log=LogFactory.getLog(getClass().getName()+"#"+getUID()); 102 _log.info("starting"); 103 _tier.registerData(getUID(),_sessions); 104 _log.info("sessions registered: "+getUID()); 105 106 _sessions.put("aaa", new Object ()); 108 _sessions.put("bbb", new Object ()); 109 _sessions.put("ccc", new Object ()); 110 } 111 112 public void 113 doStop() 114 { 115 _log.info("stopping"); 116 117 _tier.deregisterData(getUID()); 118 } 120 139 } 140 | Popular Tags |