1 23 24 package com.sun.ejb.containers.interceptors; 25 26 import java.lang.reflect.Method ; 27 import javax.interceptor.InvocationContext; 28 import javax.ejb.EJBContext ; 29 30 import com.sun.ejb.EJBUtils; 31 import com.sun.ejb.Invocation.InterceptorChain; 32 import com.sun.ejb.containers.EJBContextImpl; 33 34 import java.util.Map ; 35 import java.util.HashMap ; 36 import java.util.logging.Level ; 37 import java.util.logging.Logger ; 38 39 40 44 public class CallbackInvocationContext implements InvocationContext { 45 46 private EJBContextImpl ejbContext; 47 private Map contextData; 48 private int callbackIndex = 0; 49 private CallbackChainImpl callbackChain; 50 51 public CallbackInvocationContext(EJBContextImpl ejbContextImpl, 52 CallbackChainImpl chain) { 53 ejbContext = ejbContextImpl; 54 callbackChain = chain; 55 } 56 57 public Object getTarget() { 58 return ejbContext.getEJB(); 59 } 60 61 public Method getMethod() { 62 return null; 63 } 64 65 public Object [] getParameters() { 66 throw new IllegalStateException ("not applicable to Callback methods"); 67 } 68 69 public void setParameters(Object [] params) { 70 throw new IllegalStateException ("not applicable to Callback methods"); 71 } 72 73 public EJBContext getEJBContext() { 74 return ejbContext; 75 } 76 77 public Map <String , Object > getContextData() { 78 if( contextData == null ) { 79 contextData = new HashMap (); 80 } 81 82 return contextData; 83 } 84 85 public Object proceed() throws Exception { 86 try { 87 callbackIndex++; 88 return callbackChain.invokeNext(callbackIndex, this); 89 } catch (Exception ex) { 90 throw ex; 91 } catch (Throwable th) { 92 throw new Exception (th); 93 } 94 } 95 96 } 97 98 | Popular Tags |