KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > aop > advice > AdviceMethodProperties


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.advice;
23
24 import java.lang.reflect.Method JavaDoc;
25 import java.util.ArrayList JavaDoc;
26
27 import javassist.CtClass;
28 import javassist.CtMethod;
29 import javassist.NotFoundException;
30
31 /** Contains the properties of an advice method that we want to find.
32  * Once found it is populated with the arguments
33  *
34  * @author <a HREF="kabir.khan@jboss.com">Kabir Khan</a>
35  * @version $Revision: 39513 $
36  */

37 public class AdviceMethodProperties
38 {
39    public static final Integer JavaDoc JOINPOINT_ARG = new Integer JavaDoc(-1);
40    public static final Integer JavaDoc INVOCATION_ARG = new Integer JavaDoc(-2);
41    public static final Integer JavaDoc RETURN_ARG = new Integer JavaDoc(-3);
42    public static final Integer JavaDoc THROWABLE_ARG = new Integer JavaDoc(-4);
43    
44    public static final CtClass[] EMPTY_PARAMETERS = {};
45    
46    //find properties
47
private Class JavaDoc aspectClass;
48    private String JavaDoc adviceName;
49    private Class JavaDoc infoType;
50    private Class JavaDoc invocationType;
51    private Class JavaDoc joinpointReturnType;
52    private Class JavaDoc[] joinpointParameters;
53    private Class JavaDoc[] joinpointExceptions;
54
55    //found properties
56
private Method JavaDoc adviceMethod;
57    private Integer JavaDoc[] args;
58
59    public AdviceMethodProperties(
60          Class JavaDoc aspectClass,
61          String JavaDoc adviceName,
62          Class JavaDoc infoType,
63          Class JavaDoc invocationType,
64          Class JavaDoc joinpointReturnType,
65          Class JavaDoc[] joinpointParameters,
66          Class JavaDoc[] joinpointExceptions)
67    {
68       this.aspectClass = aspectClass;
69       this.adviceName = adviceName;
70       this.infoType = infoType;
71       this.invocationType = invocationType;
72       this.joinpointReturnType = joinpointReturnType;
73       this.joinpointParameters = joinpointParameters;
74       this.joinpointExceptions = joinpointExceptions;
75    }
76
77    public void setFoundProperties(Method JavaDoc adviceMethod, ArrayList JavaDoc args)
78    {
79       this.adviceMethod = adviceMethod;
80       this.args = (Integer JavaDoc[])args.toArray(new Integer JavaDoc[args.size()]);
81    }
82
83    public String JavaDoc getAdviceName()
84    {
85       return adviceName;
86    }
87
88
89    public Class JavaDoc getAspectClass()
90    {
91       return aspectClass;
92    }
93
94
95    public Class JavaDoc getInfoType()
96    {
97       return infoType;
98    }
99
100
101    public Class JavaDoc getInvocationType()
102    {
103       return invocationType;
104    }
105
106
107    public Class JavaDoc[] getJoinpointExceptions()
108    {
109       return joinpointExceptions;
110    }
111
112
113    public Class JavaDoc[] getJoinpointParameters()
114    {
115       return joinpointParameters;
116    }
117
118
119    public Class JavaDoc getJoinpointReturnType()
120    {
121       return joinpointReturnType;
122    }
123    
124    public boolean isAdviceVoid() throws NotFoundException
125    {
126       return adviceMethod.getReturnType().equals(CtClass.voidType);
127    }
128
129    public Method JavaDoc getAdviceMethod()
130    {
131       return adviceMethod;
132    }
133
134    public Integer JavaDoc[] getArgs()
135    {
136       return args;
137    }
138    
139 }
140
Popular Tags