1 16 package org.mortbay.j2ee.session; 17 18 20 import java.rmi.RemoteException ; 21 22 import javax.servlet.http.HttpSessionActivationListener ; 23 import javax.servlet.http.HttpSessionEvent ; 24 25 import org.jfox.ioc.logger.Logger; 26 27 29 public class ActivationInterceptor 30 extends StateInterceptor 31 { 32 protected static final Logger _log=Logger.getLogger(ActivationInterceptor.class); 33 protected final HttpSessionEvent _event; 34 35 public 36 ActivationInterceptor() 37 { 38 _event=new HttpSessionEvent (getSession()); } 40 41 public Object 42 getAttribute(String name) 43 throws IllegalArgumentException , RemoteException 44 { 45 try 46 { 47 Object tmp=super.getAttribute(name); 48 if (tmp!=null && tmp instanceof HttpSessionActivationListener ) 49 ((HttpSessionActivationListener )tmp).sessionDidActivate(_event); 50 51 return tmp; 52 } 53 catch (Exception e) 54 { 55 _log.error("could not get Attribute: "+name, e); 56 throw new IllegalArgumentException ("could not get Attribute"); 57 } 58 } 59 60 public Object 61 setAttribute(String name, Object value, boolean returnValue) 62 throws IllegalArgumentException 63 { 64 try 65 { 66 Object tmp=value; 67 if (tmp!=null && tmp instanceof HttpSessionActivationListener ) 68 ((HttpSessionActivationListener )tmp).sessionWillPassivate(_event); 69 70 tmp=super.setAttribute(name, tmp, returnValue); 71 72 if (tmp!=null && tmp instanceof HttpSessionActivationListener ) 73 ((HttpSessionActivationListener )tmp).sessionDidActivate(_event); 74 75 return tmp; 76 } 77 catch (Exception e) 78 { 79 _log.error("could not set Attribute: "+name+":"+value, e); 80 throw new IllegalArgumentException ("could not set Attribute"); 81 } 82 } 83 84 public Object 86 removeAttribute(String name, boolean returnValue) 87 throws IllegalArgumentException 88 { 89 try 90 { 91 Object tmp=super.removeAttribute(name, returnValue); 92 93 if (tmp!=null && tmp instanceof HttpSessionActivationListener ) 94 ((HttpSessionActivationListener )tmp).sessionDidActivate(_event); 95 96 return tmp; 97 } 98 catch (Exception e) 99 { 100 _log.error("could not remove Attribute: "+name, e); 101 throw new IllegalArgumentException ("could not remove Attribute"); 102 } 103 } 104 105 } 107 | Popular Tags |