1 22 package org.jboss.ejb.plugins.local; 23 24 import javax.ejb.EJBObject ; 25 import javax.ejb.EJBLocalObject ; 26 import javax.ejb.EJBException ; 27 import java.lang.reflect.InvocationHandler ; 28 import java.lang.reflect.Method ; 29 import java.rmi.RemoteException ; 30 31 36 class StatefulSessionProxy extends LocalProxy 37 implements InvocationHandler 38 { 39 static final long serialVersionUID = -3113762511947535929L; 40 private Object id; 41 42 StatefulSessionProxy(String jndiName, Object id, BaseLocalProxyFactory factory) 43 { 44 super(jndiName, factory); 45 this.id = id; 46 } 47 48 protected Object getId() 49 { 50 return id; 51 } 52 53 public final Object invoke(final Object proxy, final Method m, 54 Object [] args) 55 throws Throwable 56 { 57 if (args == null) 58 args = EMPTY_ARGS; 59 60 if (m.equals(GET_PRIMARY_KEY)) 64 { 65 if (proxy instanceof EJBObject ) 66 { 67 throw new RemoteException ("Call to getPrimaryKey not allowed on session bean"); 68 } 69 if (proxy instanceof EJBLocalObject ) 70 { 71 throw new EJBException ("Call to getPrimaryKey not allowed on session bean"); 72 } 73 } 74 75 Object retValue = super.invoke( proxy, m, args ); 76 if (retValue == null) 77 { 78 retValue = factory.invoke(id, m, args); 80 } 81 82 return retValue; 83 } 84 } 85 | Popular Tags |