01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.aspectwerkz.joinpoint.impl;
05:
06: import java.lang.reflect.Method;
07: import java.io.Serializable;
08:
09: /**
10: * Contains a pair of the original method and the wrapper method if such a method exists.
11: *
12: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
13: */
14: public class MethodTuple implements Serializable {
15: private final Method m_wrapperMethod;
16:
17: private final Method m_originalMethod;
18:
19: private final Class m_declaringClass;
20:
21: /**
22: * @param wrapperMethod
23: * @param originalMethod
24: */
25: public MethodTuple(Method wrapperMethod, Method originalMethod) {
26: if (originalMethod == null) {
27: originalMethod = wrapperMethod;
28: }
29: if (wrapperMethod.getDeclaringClass() != originalMethod
30: .getDeclaringClass()) {
31: throw new RuntimeException(wrapperMethod.getName()
32: + " and " + originalMethod.getName()
33: + " does not have the same declaring class");
34: }
35: m_declaringClass = wrapperMethod.getDeclaringClass();
36: m_wrapperMethod = wrapperMethod;
37: m_wrapperMethod.setAccessible(true);
38: m_originalMethod = originalMethod;
39: m_originalMethod.setAccessible(true);
40: }
41:
42: public boolean isWrapped() {
43: return m_originalMethod != null;
44: }
45:
46: public Class getDeclaringClass() {
47: return m_declaringClass;
48: }
49:
50: public Method getWrapperMethod() {
51: return m_wrapperMethod;
52: }
53:
54: public Method getOriginalMethod() {
55: return m_originalMethod;
56: }
57:
58: public String getName() {
59: return m_wrapperMethod.getName();
60: }
61: }
|