1 22 package org.jboss.aspects.versioned; 23 24 import java.lang.reflect.Method ; 25 import java.util.HashMap ; 26 27 import org.jboss.aop.joinpoint.MethodInvocation; 28 import org.jboss.aop.util.reference.MethodPersistentReference; 29 30 31 32 37 public class CollectionStateChangeInterceptor implements org.jboss.aop.advice.Interceptor 38 { 39 protected CollectionStateManager manager; 40 41 public CollectionStateChangeInterceptor(CollectionStateManager manager) 42 { 43 this.manager = manager; 44 } 45 46 public String getName() { return "CollectionChangeInterceptor"; } 47 48 49 52 public Object invoke(org.jboss.aop.joinpoint.Invocation invocation) throws Throwable 53 { 54 if (invocation instanceof MethodInvocation) 55 { 56 org.jboss.aop.joinpoint.MethodInvocation methodInvocation = (org.jboss.aop.joinpoint.MethodInvocation)invocation; 57 long methodHash = methodInvocation.getMethodHash(); 58 Method managerMethod = manager.isManagerMethod(methodHash); 59 if (managerMethod != null) 60 { 61 Object [] args = methodInvocation.getArguments(); 62 return managerMethod.invoke(manager, args); 63 } 64 Object target = methodInvocation.getTargetObject(); 65 Method method = methodInvocation.getMethod(); 66 if (method == null) 67 { 68 HashMap methodMap = manager.getMethodMap(); 69 MethodPersistentReference ref = (MethodPersistentReference)methodMap.get(new Long (methodHash)); 70 method = (Method )ref.get(); 71 } 72 return method.invoke(target, methodInvocation.getArguments()); 73 } 74 return invocation.invokeNext(); 75 } 76 77 } 78 | Popular Tags |