1 16 package com.jdon.aop.interceptor; 17 18 import java.util.ArrayList ; 19 import java.util.HashMap ; 20 import java.util.List ; 21 import java.util.Map ; 22 23 import org.aopalliance.intercept.MethodInterceptor; 24 25 import com.jdon.aop.joinpoint.Pointcut; 26 import com.jdon.container.pico.Startable; 27 import com.jdon.util.Debug; 28 29 30 38 public class InterceptorsChain implements Startable{ 39 private final static String module = InterceptorsChain.class.getName(); 40 public final static String NAME = "InterceptorsChain"; 41 42 46 private Map chain = new HashMap (); 47 48 public void start(){ 49 Debug.logVerbose("[JdonFramework]InterceptorsChain start..", module); 50 } 51 52 public void stop(){ 53 chain.clear(); 54 } 55 56 public void addInterceptor(String pointcut, MethodInterceptor interceptor ){ 57 List interceptors = getInterceptors(pointcut); 58 if ((interceptors == null) && isPointcut(pointcut)){ 59 interceptors = new ArrayList (); 60 chain.put(pointcut, interceptors); 61 } 62 interceptors.add(interceptor); 63 } 64 65 private boolean isPointcut(String pointcut){ 66 if ((pointcut.equals(Pointcut.TARGET_PROPS_SERVICES)) || 67 (pointcut.equals(Pointcut.EJB_TARGET_PROPS_SERVICES)) || 68 (pointcut.equals(Pointcut.POJO_TARGET_PROPS_SERVICES))) 69 return true; 70 else 71 return false; 72 } 73 74 75 78 public List getInterceptors(String pointcut) { 79 return (List )chain.get(pointcut); 80 } 81 82 public int size(){ 83 return chain.size(); 84 } 85 } 86 | Popular Tags |