01: /**************************************************************************************
02: * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
03: * http://aspectwerkz.codehaus.org *
04: * ---------------------------------------------------------------------------------- *
05: * The software in this package is published under the terms of the BSD-style license *
06: * a copy of which has been included with this distribution in the license.txt file. *
07: **************************************************************************************/package org.codehaus.aspectwerkz.joinpoint.impl;
08:
09: import java.lang.reflect.Method;
10: import java.io.Serializable;
11:
12: /**
13: * Contains a pair of the original method and the wrapper method if such a method exists.
14: *
15: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
16: */
17: public class MethodTuple implements Serializable {
18: private final Method m_wrapperMethod;
19:
20: private final Method m_originalMethod;
21:
22: private final Class m_declaringClass;
23:
24: /**
25: * @param wrapperMethod
26: * @param originalMethod
27: */
28: public MethodTuple(Method wrapperMethod, Method originalMethod) {
29: if (originalMethod == null) {
30: originalMethod = wrapperMethod;
31: }
32: if (wrapperMethod.getDeclaringClass() != originalMethod
33: .getDeclaringClass()) {
34: throw new RuntimeException(wrapperMethod.getName()
35: + " and " + originalMethod.getName()
36: + " does not have the same declaring class");
37: }
38: m_declaringClass = wrapperMethod.getDeclaringClass();
39: m_wrapperMethod = wrapperMethod;
40: m_wrapperMethod.setAccessible(true);
41: m_originalMethod = originalMethod;
42: m_originalMethod.setAccessible(true);
43: }
44:
45: public boolean isWrapped() {
46: return m_originalMethod != null;
47: }
48:
49: public Class getDeclaringClass() {
50: return m_declaringClass;
51: }
52:
53: public Method getWrapperMethod() {
54: return m_wrapperMethod;
55: }
56:
57: public Method getOriginalMethod() {
58: return m_originalMethod;
59: }
60:
61: public String getName() {
62: return m_wrapperMethod.getName();
63: }
64: }
|