KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > aop > joinpoint > MethodCalledByMethodInvocationWrapper


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.aop.joinpoint;
23
24 import org.jboss.aop.Advisor;
25 import org.jboss.aop.advice.Interceptor;
26 import org.jboss.aop.metadata.MetaDataResolver;
27 import org.jboss.aop.metadata.SimpleMetaData;
28
29 import java.lang.reflect.Method JavaDoc;
30 import java.util.Map JavaDoc;
31
32 /**
33  * Comment
34  *
35  * @author <a HREF="mailto:bill@jboss.org">Bill Burke</a>
36  * @version $Revision: 44098 $
37  */

38 public class MethodCalledByMethodInvocationWrapper extends MethodCalledByMethodInvocation
39 {
40    private static final long serialVersionUID = 5130026569290691583L;
41
42    MethodCalledByMethodInvocation wrapped;
43
44    public MethodCalledByMethodInvocationWrapper(MethodCalledByMethodInvocation wrapped, Interceptor[] interceptors)
45    {
46       super(interceptors);
47       this.wrapped = wrapped;
48    }
49
50    public Object JavaDoc getMetaData(Object JavaDoc group, Object JavaDoc attr)
51    {
52       return wrapped.getMetaData(group, attr);
53    }
54
55    public Object JavaDoc invokeNext() throws Throwable JavaDoc
56    {
57       if (interceptors != null && currentInterceptor < interceptors.length)
58       {
59          try
60          {
61             return interceptors[currentInterceptor++].invoke(this);
62          }
63          finally
64          {
65             // so that interceptors like clustering can reinvoke down the chain
66
currentInterceptor--;
67          }
68       }
69       try
70       {
71          return wrapped.invokeNext();
72       }
73       finally
74       {
75          responseContextInfo = wrapped.getResponseContextInfo();
76       }
77    }
78
79    public MetaDataResolver getInstanceResolver()
80    {
81       return wrapped.getInstanceResolver();
82    }
83
84    public Invocation copy()
85    {
86       MethodCalledByMethodInvocationWrapper invocation = new MethodCalledByMethodInvocationWrapper((MethodCalledByMethodInvocation) wrapped.copy(), interceptors);
87       invocation.currentInterceptor = this.currentInterceptor;
88       return invocation;
89    }
90
91    public Object JavaDoc[] getArguments()
92    {
93       return wrapped.getArguments();
94    }
95
96    public void setArguments(Object JavaDoc[] arguments)
97    {
98       wrapped.setArguments(arguments);
99    }
100
101    public Class JavaDoc getCallingClass()
102    {
103       return wrapped.getCallingClass();
104    }
105
106    public Method JavaDoc getCallingMethod()
107    {
108       return wrapped.getCallingMethod();
109    }
110
111    public Map JavaDoc getResponseContextInfo()
112    {
113       return wrapped.getResponseContextInfo();
114    }
115
116    public void setResponseContextInfo(Map JavaDoc responseContextInfo)
117    {
118       wrapped.setResponseContextInfo(responseContextInfo);
119    }
120
121    public void addResponseAttachment(Object JavaDoc key, Object JavaDoc val)
122    {
123       wrapped.addResponseAttachment(key, val);
124    }
125
126    public Object JavaDoc getResponseAttachment(Object JavaDoc key)
127    {
128       return wrapped.getResponseAttachment(key);
129    }
130
131    public void setMetaData(SimpleMetaData data)
132    {
133       wrapped.setMetaData(data);
134    }
135
136    public Advisor getAdvisor()
137    {
138       return wrapped.getAdvisor();
139    }
140
141    public Object JavaDoc getTargetObject()
142    {
143       return wrapped.getTargetObject();
144    }
145
146    public void setTargetObject(Object JavaDoc targetObject)
147    {
148       wrapped.setTargetObject(targetObject);
149    }
150
151    /**
152     * @return the method that is being called
153     */

154    public Method JavaDoc getCalledMethod()
155    {
156       return wrapped.getCalledMethod();
157    }
158
159    public Object JavaDoc getCallingObject()
160    {
161       return wrapped.getCallingObject();
162    }
163
164 }
165
Popular Tags