1 22 package org.jboss.ejb3.stateless; 23 24 import javax.ejb.EJBException ; 25 26 import java.lang.reflect.Method ; 27 import java.lang.reflect.Proxy ; 28 import org.jboss.aspects.asynch.AsynchMixin; 29 import org.jboss.aspects.asynch.AsynchProvider; 30 import org.jboss.aspects.asynch.FutureHolder; 31 import org.jboss.ejb3.Container; 32 import org.jboss.ejb3.LocalProxy; 33 import org.jboss.ejb3.ProxyUtils; 34 35 41 public class StatelessLocalProxy extends LocalProxy 42 { 43 AsynchProvider provider; 44 45 public StatelessLocalProxy() 46 { 47 } 48 49 public StatelessLocalProxy(Container container) 50 { 51 super(container); 52 } 53 54 public StatelessLocalProxy(AsynchProvider provider, Container container) 55 { 56 super(container); 57 this.provider = provider; 58 } 59 60 public Object invoke(Object proxy, Method method, Object [] args) 61 throws Throwable 62 { 63 if (method.getDeclaringClass() == AsynchProvider.class) 64 { 65 return provider.getFuture(); 66 } 67 68 Object ret = ProxyUtils.handleCallLocally(proxy, this, method, args); 69 if (ret != null) 70 { 71 return ret; 72 } 73 74 if (container == null) 75 throw new EJBException ("Invalid invocation of local interface (null container)"); 76 77 StatelessContainer stateless = (StatelessContainer) container; 78 79 return stateless.localInvoke(method, args, (FutureHolder) provider); 80 } 81 82 public Object getAsynchronousProxy(Object proxy) 83 { 84 Class [] infs = proxy.getClass().getInterfaces(); 85 if (!ProxyUtils.isAsynchronous(infs)) 86 { 87 Class [] interfaces = ProxyUtils.addAsynchProviderInterface(infs); 88 AsynchMixin mixin = new AsynchMixin(); 89 StatelessLocalProxy handler = new StatelessLocalProxy(mixin, container); 90 return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), interfaces, handler); 91 } 92 93 return proxy; 95 } 96 111 112 public String toString() 113 { 114 return container.getEjbName().toString(); 115 } 116 } 117 | Popular Tags |