1 7 8 package org.jboss.ha.httpsession.beanimpl.ejb; 9 10 11 import java.rmi.RemoteException ; 12 13 import javax.ejb.EJBException ; 14 15 import org.jboss.ha.httpsession.interfaces.SerializableHttpSession; 16 import org.jboss.invocation.MarshalledValue; 17 18 27 public abstract class ClusteredHTTPSessionBeanImpl extends ClusteredHTTPSessionBeanAbstract 28 { 29 30 32 34 protected SerializableHttpSession tmpSession = null; 35 protected boolean isModified = false; 36 37 39 41 43 45 public void ejbStore () throws EJBException , RemoteException 46 { 47 if (tmpSession != null) 48 { 49 serializeSession(); 53 } 54 } 55 56 public void ejbLoad () throws EJBException , RemoteException 57 { 58 tmpSession = null; 62 isModified = false; 63 } 64 65 public SerializableHttpSession getSession () 66 { 67 if (tmpSession == null) 68 { 69 unserializeSession (); 72 } 73 return this.tmpSession; 74 } 75 76 public void setSession (SerializableHttpSession session) 77 { 78 if (tmpSession == null) 79 isModified = true; 80 else 81 isModified = session.areAttributesModified (tmpSession); 82 83 this.setCreationTime (session.getContentCreationTime ()); 86 this.setLastAccessedTime (session.getContentLastAccessTime ()); 87 88 this.tmpSession = session; 96 } 97 98 public boolean isModified () { return this.isModified; } 101 102 104 106 protected void serializeSession() throws EJBException 107 { 108 try 109 { 110 this.setSerializedSession (new MarshalledValue (this.tmpSession)); 111 } 112 catch (Exception e) 113 { 114 throw new EJBException (e.toString ()); 115 } 116 } 117 118 protected void unserializeSession() throws EJBException 119 { 120 try 121 { 122 MarshalledValue mo = (MarshalledValue)this.getSerializedSession (); 123 if (mo != null) 124 this.tmpSession = (SerializableHttpSession)(mo.get ()); 125 } 126 catch (Exception e) 127 { 128 throw new EJBException (e.toString ()); 129 } 130 } 131 132 134 136 } 137 | Popular Tags |