1 22 package org.jboss.test.aop.dynamicgenadvisor; 23 24 import java.util.ArrayList ; 25 26 import org.jboss.aop.advice.Interceptor; 27 import org.jboss.aop.joinpoint.FieldInvocation; 28 import org.jboss.aop.joinpoint.Invocation; 29 import org.jboss.aop.joinpoint.MethodInvocation; 30 31 36 public class MetadataInterceptor implements Interceptor 37 { 38 public static ArrayList lastDefaultMetadata = new ArrayList (); 40 public static ArrayList lastClassMetadata = new ArrayList (); 41 public static ArrayList lastMethodMetadata = new ArrayList (); 42 public static ArrayList lastFieldMetadata = new ArrayList (); 43 44 public static boolean intercepted; 45 46 public String getName() 47 { 48 return "MetadataInterceptor"; 49 } 50 51 public Object invoke(Invocation invocation) throws Throwable 52 { 53 System.out.println("MetadataInterceptor Intercepting"); 54 intercepted = true; 55 56 Object meta = invocation.getMetaData("TEST", "default"); 57 if (meta != null) lastDefaultMetadata.add(meta); 58 59 meta = invocation.resolveClassMetaData("TEST", "class"); 60 if (meta != null) lastClassMetadata.add(meta); 61 62 if (invocation instanceof FieldInvocation) 63 { 64 meta = invocation.getMetaData("TEST", "fm"); 65 if (meta != null) lastFieldMetadata.add(meta); 66 } 67 else if (invocation instanceof MethodInvocation) 68 { 69 meta = invocation.getMetaData("TEST", "fm"); 70 if (meta != null) lastMethodMetadata.add(meta); 71 } 72 73 return invocation.invokeNext(); 74 } 75 76 public static void clear() 77 { 78 lastClassMetadata.clear(); 79 lastDefaultMetadata.clear(); 80 lastFieldMetadata.clear(); 81 lastMethodMetadata.clear(); 82 intercepted = false; 83 } 84 85 } 86 | Popular Tags |