KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > EJBContainerInvocationWrapper


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.ejb3;
23
24 import java.lang.reflect.Method JavaDoc;
25 import java.util.Map JavaDoc;
26 import org.jboss.aop.Advisor;
27 import org.jboss.aop.advice.Interceptor;
28 import org.jboss.aop.joinpoint.Invocation;
29 import org.jboss.aop.metadata.SimpleMetaData;
30 import org.jboss.logging.Logger;
31
32 /**
33  * This wrapper class allows you to insert a chain of interceptors into the middle of a call stack.
34  *
35  * @author <a HREF="mailto:bill@jboss.org">Bill Burke</a>
36  * @version $Revision: 37459 $
37  */

38 public class EJBContainerInvocationWrapper extends EJBContainerInvocation
39 {
40    private static final Logger log = Logger.getLogger(EJBContainerInvocationWrapper.class);
41    
42    protected EJBContainerInvocation wrapped;
43
44    public EJBContainerInvocationWrapper(EJBContainerInvocation wrapped, Interceptor[] interceptors)
45    {
46       this.wrapped = wrapped;
47       this.interceptors = interceptors;
48    }
49
50    public Object JavaDoc invokeNext() throws Throwable JavaDoc
51    {
52       if (currentInterceptor < interceptors.length)
53       {
54          try
55          {
56             return interceptors[currentInterceptor++].invoke(this);
57          }
58          finally
59          {
60             // so that interceptors like clustering can reinvoke down the chain
61
currentInterceptor--;
62          }
63       }
64       try
65       {
66          return wrapped.invokeNext();
67       }
68       finally
69       {
70          responseContextInfo = wrapped.getResponseContextInfo();
71       }
72    }
73
74    public Method JavaDoc getMethod()
75    {
76       return wrapped.getMethod();
77    }
78
79    public long getMethodHash()
80    {
81       return wrapped.getMethodHash();
82    }
83
84    public Object JavaDoc getTargetObject()
85    {
86       return wrapped.getTargetObject();
87    }
88
89    public void setTargetObject(Object JavaDoc targetObject)
90    {
91       wrapped.setTargetObject(targetObject);
92    }
93
94    public Object JavaDoc[] getArguments()
95    {
96       return wrapped.getArguments();
97    }
98
99    public void setArguments(Object JavaDoc[] args)
100    {
101       wrapped.setArguments(args);
102    }
103
104    public Object JavaDoc resolveClassAnnotation(Class JavaDoc annotation)
105    {
106       return wrapped.resolveClassAnnotation(annotation);
107    }
108
109    public Object JavaDoc resolveAnnotation(Class JavaDoc annotation)
110    {
111       return wrapped.resolveAnnotation(annotation);
112    }
113
114    public Object JavaDoc getMetaData(Object JavaDoc key, Object JavaDoc attr)
115    {
116       return wrapped.getMetaData(key, attr);
117    }
118
119    public Invocation getWrapper(Interceptor[] newchain)
120    {
121       return wrapped.getWrapper(newchain);
122    }
123
124    public Invocation copy()
125    {
126       return wrapped.copy();
127    }
128
129    public Map JavaDoc getResponseContextInfo()
130    {
131       return wrapped.getResponseContextInfo();
132    }
133
134    public void setResponseContextInfo(Map JavaDoc responseContextInfo)
135    {
136       wrapped.setResponseContextInfo(responseContextInfo);
137    }
138
139    public void addResponseAttachment(Object JavaDoc key, Object JavaDoc val)
140    {
141       wrapped.addResponseAttachment(key, val);
142    }
143
144    public Object JavaDoc getResponseAttachment(Object JavaDoc key)
145    {
146       return wrapped.getResponseAttachment(key);
147    }
148
149    public SimpleMetaData getMetaData()
150    {
151       return wrapped.getMetaData();
152    }
153
154    public void setMetaData(SimpleMetaData data)
155    {
156       wrapped.setMetaData(data);
157    }
158
159    public Object JavaDoc resolveClassMetaData(Object JavaDoc key, Object JavaDoc attr)
160    {
161       return wrapped.resolveClassMetaData(key, attr);
162    }
163
164    public Object JavaDoc invokeNext(Interceptor[] newInterceptors) throws Throwable JavaDoc
165    {
166       return wrapped.invokeNext(newInterceptors);
167    }
168
169    public Advisor getAdvisor()
170    {
171       return wrapped.getAdvisor();
172    }
173 }
174
Popular Tags