KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > aop > instrument > NonOptimizedCallerTransformer


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.instrument;
23
24 import java.util.Iterator JavaDoc;
25
26 import javassist.CannotCompileException;
27 import javassist.CtBehavior;
28 import javassist.CtClass;
29 import javassist.CtConstructor;
30 import javassist.CtMethod;
31 import javassist.Modifier;
32 import javassist.NotFoundException;
33 import javassist.expr.MethodCall;
34 import javassist.expr.NewExpr;
35
36 import org.jboss.aop.AspectManager;
37 import org.jboss.aop.ClassAdvisor;
38 import org.jboss.aop.instrument.CallerTransformer.ConByConDetail;
39 import org.jboss.aop.instrument.CallerTransformer.ConByMethodDetail;
40 import org.jboss.aop.instrument.CallerTransformer.ConstructorDetail;
41 import org.jboss.aop.instrument.CallerTransformer.MethodDetail;
42 import org.jboss.aop.pointcut.Pointcut;
43
44 /**
45  * Comment
46  *
47  * @author <a HREF="mailto:kabir.khan@jboss.org">Kabir Khan</a>
48  * @version $Revision$
49  */

50 public class NonOptimizedCallerTransformer extends CallerTransformer
51 {
52    public final static String JavaDoc PLACEHOLDER = "whatever";
53    
54    public NonOptimizedCallerTransformer(Instrumentor instrumentor, AspectManager manager)
55    {
56       super(instrumentor, manager, false, new ClassicCallerInfoAdder(instrumentor));
57    }
58
59    protected CallerExprEditor callerExprEditorFactory(ClassAdvisor advisor, CtClass clazz)
60    {
61       return new NonOptimizedCallerExprEditor(advisor, clazz);
62    }
63    
64    class NonOptimizedCallerExprEditor extends CallerExprEditor
65    {
66
67       public NonOptimizedCallerExprEditor(ClassAdvisor advisor, CtClass callingClass)
68       {
69          super(advisor, callingClass);
70       }
71       
72       protected void setupConstructor(ConstructorDetail cd)throws NotFoundException, CannotCompileException
73       {
74          if (callerInfos.get(cd.callerInfoField) == null)
75          {
76             String JavaDoc invocationClassName = PLACEHOLDER;
77          
78             callerInfos.put(cd.callerInfoField, invocationClassName);
79             callerInfoAdder.addMethodByConInfoField(callingClass, cd.callerInfoField, cd.callingIndex, cd.classname, cd.calledHash);
80          }
81       }
82
83       protected void setupMethod(MethodDetail md) throws NotFoundException, CannotCompileException
84       {
85          if (callerInfos.get(md.callerInfoField) == null)
86          {
87             String JavaDoc invocationClassName = PLACEHOLDER;
88                   
89             callerInfos.put(md.callerInfoField, invocationClassName);
90             callerInfoAdder.addMethodByMethodInfoField(callingClass, md.callerInfoField, md.callingHash, md.classname, md.calledHash);
91          }
92       }
93
94       protected void setupMethod(ConByMethodDetail cd) throws NotFoundException, CannotCompileException
95       {
96          if (callerInfos.get(cd.callerInfoField) == null)
97          {
98             String JavaDoc invocationClassName = PLACEHOLDER;
99
100             callerInfos.put(cd.callerInfoField, invocationClassName);
101             callerInfoAdder.addConByMethodInfoField(callingClass, cd.callerInfoField, cd.callingHash, cd.classname, cd.calledHash);
102          }
103       }
104       
105       protected void setupConstructor(ConByConDetail cd)throws NotFoundException, CannotCompileException
106       {
107          if (callerInfos.get(cd.callerInfoField) == null)
108          {
109             String JavaDoc invocationClassName = PLACEHOLDER;
110             
111             callerInfos.put(cd.callerInfoField, invocationClassName);
112             callerInfoAdder.addConByConInfoField(callingClass, cd.callerInfoField, cd.callingIndex, cd.classname, cd.calledHash);
113          }
114       }
115
116       
117       
118    }
119
120 }
121
Popular Tags