KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > aop > LoadInterceptedClassesStrategy


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;
23
24 import javassist.CodeConverter;
25 import javassist.CtClass;
26 import javassist.CtField;
27
28 import org.jboss.aop.instrument.DynamicTransformationObserver;
29 import org.jboss.aop.instrument.JoinpointClassifier;
30 import org.jboss.aop.instrument.JoinpointSimpleClassifier;
31
32
33 /**
34  * Dynamic AOP Strategy that instruments prepared classes code
35  * for interception before they get loaded in the system.
36  * This way, no change to a class code has to be made during runtime.
37  * @author Flavia Rainone
38  */

39 class LoadInterceptedClassesStrategy implements DynamicAOPStrategy
40 {
41    /**
42     * Dummy DynamicTransformationObserver. No action is need when a dynamic
43     * transformation occurs.
44     */

45    private DynamicTransformationObserver dynamicTransformationObserver =
46       new DynamicTransformationObserver(){
47       public void fieldReadDynamicalyWrapped(CtField field) {}
48       public void fieldWriteDynamicalyWrapped(CtField field) {}
49       public void constructorDynamicalyWrapped() {}
50       public void transformationFinished(CtClass clazz, CodeConverter converter) {}
51    };
52    
53    /**
54     * Simple classifier to be used during transformation.
55     */

56    JoinpointClassifier joinpointClassifier = new JoinpointSimpleClassifier();
57
58    /**
59     * Returns <code>null</code> because, as long as no runtime action is required
60     * in this strategy, no observer is required.
61     * @see org.jboss.aop.DynamicAOPStrategy#getInterceptorChainObserver(Class)
62     */

63    public InterceptorChainObserver getInterceptorChainObserver(Class JavaDoc clazz)
64    {
65       return null;
66    }
67    
68    /**
69     * Notifies the strategy that one or more interceptor chains in the
70     * system may have been updated.
71     * This method does nothing because no runtime action is required.
72     * @see org.jboss.aop.DynamicAOPStrategy#interceptorChainsUpdated()
73     */

74    public void interceptorChainsUpdated() { }
75    
76    /**
77     * Returns a <code>org.jboss.aop.instrument.JoinpointSimpleClassifier</code>
78     * instance. This classifier assures that prepared classes will be fully instrumented
79     * for interception before they get loaded in the system.
80     * @see org.jboss.aop.DynamicAOPStrategy#getJoinpointClassifier()
81     */

82    public JoinpointClassifier getJoinpointClassifier()
83    {
84       return this.joinpointClassifier;
85    }
86    
87    /**
88     * Returns a dynamic transformation observer to be notified of the dynamic
89     * events during the <code>clazz</code> transformation. This observer does nothing
90     * because no action is required when a dynamic transformation happens.
91     * @see org.jboss.aop.DynamicAOPStrategy#getJoinpointClassifier()
92     */

93    public DynamicTransformationObserver getDynamicTransformationObserver(CtClass clazz)
94    {
95       return this.dynamicTransformationObserver;
96    }
97 }
Popular Tags