1 22 package org.jboss.ejb.plugins; 23 24 import javax.ejb.EJBException ; 25 26 import org.jboss.ejb.Interceptor; 27 import org.jboss.invocation.Invocation; 28 import org.jboss.invocation.InvocationKey; 29 import org.jboss.naming.ENCThreadLocalKey; 30 31 38 public class ProxyFactoryFinderInterceptor 39 extends AbstractInterceptor 40 { 41 42 public void create() throws Exception 43 { 44 } 45 46 protected void setProxyFactory(String invokerBinding, Invocation mi) throws Exception 47 { 48 if (invokerBinding == null) 50 { 51 log.trace("invokerBInding is null in ProxyFactoryFinder"); 52 return; 53 } 54 66 Object proxyFactory = container.lookupProxyFactory(invokerBinding); 67 if (proxyFactory == null) 68 { 69 String methodName; 70 if(mi.getMethod() != null) { 71 methodName = mi.getMethod().getName(); 72 } else 73 { 74 methodName ="<no method>"; 75 } 76 77 log.error("***************** proxyFactory is null ********"); 78 log.error("Method name: " + methodName); 79 log.error("jmx name: " + container.getJmxName().toString()); 80 log.error("invokerBinding: " + invokerBinding); 81 log.error("Stack trace", new Throwable ()); 82 log.error("*************************"); 83 throw new EJBException ("Couldn't find proxy factory"); 84 } 85 container.setProxyFactory(proxyFactory); 86 } 87 88 public Object invokeHome(Invocation mi) 89 throws Exception 90 { 91 String invokerBinding = 92 (String )mi.getAsIsValue(InvocationKey.INVOKER_PROXY_BINDING); 93 setProxyFactory(invokerBinding, mi); 94 95 String oldInvokerBinding = ENCThreadLocalKey.getKey(); 96 if (invokerBinding != null || oldInvokerBinding == null) 99 { 100 ENCThreadLocalKey.setKey(invokerBinding); 101 } 102 103 Interceptor next = getNext(); 104 Object value = null; 105 try 106 { 107 value = next.invokeHome(mi); 108 } 109 finally 110 { 111 ENCThreadLocalKey.setKey(oldInvokerBinding); 112 } 113 114 return value; 115 } 116 117 public Object invoke(Invocation mi) 118 throws Exception 119 { 120 String invokerBinding = 121 (String )mi.getAsIsValue(InvocationKey.INVOKER_PROXY_BINDING); 122 setProxyFactory(invokerBinding, mi); 123 124 String oldInvokerBinding = ENCThreadLocalKey.getKey(); 125 if (invokerBinding != null || oldInvokerBinding == null) 128 { 129 ENCThreadLocalKey.setKey(invokerBinding); 130 } 131 132 Interceptor next = getNext(); 133 Object value = null; 134 try 135 { 136 value = next.invoke(mi); 137 } 138 finally 139 { 140 ENCThreadLocalKey.setKey(oldInvokerBinding); 141 } 142 143 return value; 144 } 145 146 } 147 | Popular Tags |