1 22 package org.jboss.ejb.plugins.local; 23 24 import java.lang.reflect.InvocationHandler ; 25 import java.lang.reflect.Method ; 26 import java.rmi.RemoteException ; 27 import javax.naming.InitialContext ; 28 import javax.ejb.EJBObject ; 29 import javax.ejb.EJBLocalObject ; 30 import javax.ejb.EJBException ; 31 32 33 38 class StatelessSessionProxy extends LocalProxy 39 implements InvocationHandler 40 { 41 static final long serialVersionUID = 5677941766264344565L; 42 43 StatelessSessionProxy(String jndiName, BaseLocalProxyFactory factory) 44 { 45 super(jndiName, factory); 46 } 47 48 protected Object getId() 49 { 50 return jndiName; 51 } 52 53 public final Object invoke(final Object proxy, final Method m, Object [] args) 54 throws Throwable 55 { 56 Object retValue = null; 57 if (args == null) 58 args = EMPTY_ARGS; 59 60 if (m.equals(TO_STRING)) 62 { 63 retValue = jndiName + ":Stateless"; 64 } 65 else if (m.equals(EQUALS)) 66 { 67 retValue = invoke(proxy, IS_IDENTICAL, args); 68 } 69 else if (m.equals(HASH_CODE)) 70 { 71 retValue = new Integer (this.hashCode()); 74 } 75 else if (m.equals(GET_PRIMARY_KEY)) 76 { 77 if (proxy instanceof EJBObject ) 81 { 82 throw new RemoteException ("Call to getPrimaryKey not allowed on session bean"); 83 } 84 if (proxy instanceof EJBLocalObject ) 85 { 86 throw new EJBException ("Call to getPrimaryKey not allowed on session bean"); 87 } 88 } 89 else if (m.equals(GET_EJB_HOME)) 90 { 91 InitialContext ctx = new InitialContext (); 92 return ctx.lookup(jndiName); 93 } 94 else if (m.equals(IS_IDENTICAL)) 95 { 96 retValue = isIdentical(args[0], jndiName + ":Stateless"); 99 } 100 else 102 { 103 retValue = factory.invoke(jndiName, m, args); 104 } 105 106 return retValue; 107 } 108 } 109 | Popular Tags |