1 22 package org.jboss.proxy.ejb; 23 24 import java.lang.reflect.Method ; 25 import java.rmi.RemoteException ; 26 27 import org.jboss.invocation.Invocation; 28 import org.jboss.invocation.InvocationContext; 29 import org.jboss.invocation.InvocationKey; 30 import org.jboss.invocation.InvocationType; 31 import org.jboss.proxy.ejb.handle.StatelessHandleImpl; 32 33 34 40 public class StatelessSessionInterceptor 41 extends GenericEJBInterceptor 42 { 43 44 private static final long serialVersionUID = -8807189798153718350L; 45 46 49 public StatelessSessionInterceptor() 50 {} 51 52 53 55 60 public Object invoke(Invocation invocation) 61 throws Throwable 62 { 63 InvocationContext ctx = invocation.getInvocationContext(); 64 Method m = invocation.getMethod(); 65 66 if (m.equals(TO_STRING)) 68 { 69 return toString(ctx); 70 } 71 else if (m.equals(EQUALS)) 72 { 73 Object [] args = invocation.getArguments(); 74 String argsString = args[0] != null ? args[0].toString() : ""; 75 String thisString = toString(ctx); 76 return new Boolean (thisString.equals(argsString)); 77 } 78 else if (m.equals(HASH_CODE)) 79 { 80 return new Integer (this.hashCode()); 83 } 84 else if (m.equals(GET_HANDLE)) 86 { 87 return new StatelessHandleImpl( 88 (String )ctx.getValue(InvocationKey.JNDI_NAME)); 89 } 90 else if (m.equals(GET_PRIMARY_KEY)) 91 { 92 throw new RemoteException ("Call to getPrimaryKey not allowed on session bean"); 93 } 94 else if (m.equals(GET_EJB_HOME)) 95 { 96 return getEJBHome(invocation); 97 } 98 else if (m.equals(IS_IDENTICAL)) 99 { 100 Object [] args = invocation.getArguments(); 103 String argsString = args[0].toString(); 104 String thisString = toString(ctx); 105 return new Boolean (thisString.equals(argsString)); 106 } 107 else 109 { 110 invocation.setType(InvocationType.REMOTE); 111 112 return getNext().invoke(invocation); 113 } 114 } 115 116 118 120 private String toString(InvocationContext ctx) 122 { 123 return ctx.getValue(InvocationKey.JNDI_NAME) + ":Stateless"; 124 } 125 } 126 | Popular Tags |