KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > tool > instrument > InstrumentTask


1 //$Id: InstrumentTask.java,v 1.3 2005/03/17 21:29:08 oneovthafew Exp $
2
package org.hibernate.tool.instrument;
3
4 import java.util.Arrays JavaDoc;
5
6 import net.sf.cglib.transform.AbstractTransformTask;
7 import net.sf.cglib.transform.ClassTransformer;
8 import net.sf.cglib.transform.impl.InterceptFieldEnabled;
9 import net.sf.cglib.transform.impl.InterceptFieldFilter;
10 import net.sf.cglib.transform.impl.InterceptFieldTransformer;
11
12 import org.objectweb.asm.Type;
13
14 /**
15  * An Ant task for instrumenting persistent classes with
16  * CGLIB field interception
17  *
18  * @author Gavin King
19  */

20 public class InstrumentTask extends AbstractTransformTask {
21
22     protected ClassTransformer getClassTransformer(String JavaDoc[] classInfo) {
23         
24         if( Arrays.asList(classInfo).contains( InterceptFieldEnabled.class.getName() ) ){
25             return null;
26         }
27         else {
28             return new InterceptFieldTransformer(
29                 new InterceptFieldFilter() {
30                     public boolean acceptRead(Type owner, String JavaDoc name) {
31                         return true;
32                     }
33                     public boolean acceptWrite(Type owner, String JavaDoc name) {
34                         return true;
35                     }
36                 }
37             );
38         }
39         
40     }
41     
42 }
43
Popular Tags