KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > aop > beforeafter > ArgsAspect


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.test.aop.beforeafter;
23
24 import org.jboss.aop.ConstructorInfo;
25 import org.jboss.aop.FieldInfo;
26 import org.jboss.aop.JoinPointInfo;
27 import org.jboss.aop.MethodInfo;
28 import org.jboss.test.aop.construction.SuperPOJO;
29
30 /**
31  *
32  * @author <a HREF="kabir.khan@jboss.com">Kabir Khan</a>
33  * @version $Revision: 44253 $
34  */

35 public class ArgsAspect
36 {
37
38    public static String JavaDoc before;
39    public static String JavaDoc after;
40    public static String JavaDoc throwing;
41
42
43    public static void clear()
44    {
45       before = null;
46       after = null;
47       throwing = null;
48    }
49    
50    public void before(boolean b, int i)
51    {
52       before = "before1";
53    }
54    
55    public void before(MethodInfo mjp, int i)
56    {
57       before = "before2";
58    }
59    
60    public void before(FieldInfo fjp, int i)
61    {
62       before = "before3";
63    }
64    
65    public void before(FieldInfo fjp)
66    {
67       before = "before4";
68    }
69    
70    public void before(FieldInfo fjp, SubValue val)
71    {
72       before = "before5";
73    }
74    
75    public void before(SubValue sup, SubValue sub)
76    {
77       before = "before6";
78    }
79    
80    public void before(SuperValue sup, SubValue sub)
81    {
82       before = "before7";
83    }
84    
85    public POJO after(MethodInfo mjp, POJO ret, int i, long l)
86    {
87       after = "after1";
88       return ret;
89    }
90    
91    public POJO after(ConstructorInfo cjp, POJO ret)
92    {
93       after = "after2";
94       return ret;
95    }
96    
97    //This should be able to handle both reads and writes
98
public int after(FieldInfo fp, int i)
99    {
100       after = "after3";
101       return i;
102    }
103    
104    //This should be able to handle both reads and writes
105
public SubValue after(FieldInfo fp, SubValue ret)
106    {
107       after = "after4";
108       ret.doubleValue();
109       return ret;
110    }
111       
112    //This should be able to handle both reads and writes
113
public SuperValue after(SuperValue ret)
114    {
115       after = "after5";
116       ret.doubleValue();
117       return ret;
118    }
119
120    public SubValue after(SuperValue ret, SuperValue sup, SuperValue sup2)
121    {
122       throw new RuntimeException JavaDoc("Should not be called");
123    }
124    
125    public SuperValue after(SuperValue ret, SubValue sup, SuperValue sub)
126    {
127       after = "after6";
128       ret.doubleValue();
129       return new SubValue(ret.getValue());
130    }
131    
132    public void after(SuperValue sup, SuperValue sup2)
133    {
134       after = "after7";
135    }
136    
137    public Throwable JavaDoc throwing(Throwable JavaDoc t, int i)
138    {
139       throwing = "throwing1";
140       return t;
141    }
142    
143    public Throwable JavaDoc throwing(MethodInfo mjp, Throwable JavaDoc t)
144    {
145       throwing = "throwing2";
146       return t;
147    }
148    
149    public Throwable JavaDoc throwing(MethodInfo mjp, Throwable JavaDoc t, int i)
150    {
151       throwing = "throwing3";
152       return t;
153    }
154 }
155
Popular Tags