KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > aop > basic > CallerTypedefCaller


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.basic;
23
24
25 /**
26  * @author <a HREF="mailto:kabirkhan@bigfoot.com">Kabir Khan</a>
27  */

28 public class CallerTypedefCaller
29 {
30
31    public void call()
32    {
33       System.out.println("intercept class constructor");
34       CallerInterceptor.called = false;
35       CallerTypedefPOJO pojo = new CallerTypedefPOJO();
36       if (!CallerInterceptor.called) throw new RuntimeException JavaDoc("Did not intercept CallerTypedefPOJO constructor");
37       CallerInterceptor.called = false;
38
39       System.out.println("intercept class field read");
40       int i = pojo.field1;
41       if (!CallerInterceptor.called) throw new RuntimeException JavaDoc("Did not intercept CallerTypedefPOJO.field1 read " + i);
42       CallerInterceptor.called = false;
43
44       System.out.println("intercept class field write");
45       pojo.field1 = 1;
46       if (!CallerInterceptor.called) throw new RuntimeException JavaDoc("Did not intercept CallerTypedefPOJO.field1 write");
47       CallerInterceptor.called = false;
48
49       System.out.println("intercept class field read");
50       i = pojo.field2;
51       if (!CallerInterceptor.called) throw new RuntimeException JavaDoc("Did not intercept CallerTypedefPOJO.field2 read");
52       CallerInterceptor.called = false;
53
54       System.out.println("intercept class field write");
55       pojo.field2 = 1;
56       if (!CallerInterceptor.called) throw new RuntimeException JavaDoc("Did not intercept CallerTypedefPOJO.field1 write");
57       CallerInterceptor.called = false;
58
59       System.out.println("intercept class method Caller");
60       pojo.method();
61       if (!CallerInterceptor.called) throw new RuntimeException JavaDoc("Did not intercept CallerTypedefPOJO.method() execution");
62       CallerInterceptor.called = false;
63       
64       System.out.println("intercept instanceof constructor");
65       CallerTypedefPOJO2 pojo2 = new CallerTypedefPOJO2();
66       if (!CallerInterceptor.called) throw new RuntimeException JavaDoc("Did not intercept CallerTypedefPOJO2 constructor");
67       CallerInterceptor.called = false;
68
69       System.out.println("intercept instanceof field read");
70       i = pojo2.field1;
71       if (!CallerInterceptor.called) throw new RuntimeException JavaDoc("Did not intercept CallerTypedefPOJO2.field1 read");
72       CallerInterceptor.called = false;
73
74       System.out.println("intercept instanceof field write");
75       pojo2.field1 = 1;
76       if (!CallerInterceptor.called) throw new RuntimeException JavaDoc("Did not intercept CallerTypedefPOJO2.field1 write");
77       CallerInterceptor.called = false;
78
79       System.out.println("intercept instanceof field read");
80       i = pojo2.field2;
81       if (!CallerInterceptor.called) throw new RuntimeException JavaDoc("Did not intercept CallerTypedefPOJO2.field2 read");
82       CallerInterceptor.called = false;
83
84       System.out.println("intercept instanceof field write");
85       pojo2.field2 = 1;
86       if (!CallerInterceptor.called) throw new RuntimeException JavaDoc("Did not intercept CallerTypedefPOJO2.field1 write");
87       CallerInterceptor.called = false;
88
89       System.out.println("intercept instanceof method Caller");
90       pojo2.method();
91       if (!CallerInterceptor.called) throw new RuntimeException JavaDoc("Did not intercept CallerTypedefPOJO2 method execution");
92       CallerInterceptor.called = false;
93
94       System.out.println("intercept annotation constructor");
95       CallerTypedefPOJO3 pojo3 = new CallerTypedefPOJO3();
96       if (!CallerInterceptor.called) throw new RuntimeException JavaDoc("Did not intercept CallerTypedefPOJO3 constructor");
97       CallerInterceptor.called = false;
98
99       System.out.println("intercept annotation field read");
100       i = pojo3.field1;
101       if (!CallerInterceptor.called) throw new RuntimeException JavaDoc("Did not intercept CallerTypedefPOJO3.field1 read");
102       CallerInterceptor.called = false;
103
104       System.out.println("intercept annotation field write");
105       pojo3.field1 = 1;
106       if (!CallerInterceptor.called) throw new RuntimeException JavaDoc("Did not intercept CallerTypedefPOJO3.field1 write");
107       CallerInterceptor.called = false;
108
109       System.out.println("intercept annotation field read");
110       i = pojo3.field2;
111       if (!CallerInterceptor.called) throw new RuntimeException JavaDoc("Did not intercept CallerTypedefPOJO3.field2 read");
112       CallerInterceptor.called = false;
113
114       System.out.println("intercept annotation field write");
115       pojo3.field2 = 1;
116       if (!CallerInterceptor.called) throw new RuntimeException JavaDoc("Did not intercept CallerTypedefPOJO3.field2 write");
117       CallerInterceptor.called = false;
118
119       System.out.println("intercept annotation method Caller");
120       pojo3.method();
121       if (!CallerInterceptor.called) throw new RuntimeException JavaDoc("Did not intercept CallerTypedefPOJO3 method execution");
122
123    }
124 }
125
Popular Tags