1 22 package org.jboss.aop.microcontainer.beans; 23 24 import java.util.Iterator ; 25 import java.util.List ; 26 27 import org.jboss.aop.AspectManager; 28 import org.jboss.aop.advice.AdviceBinding; 29 import org.jboss.aop.advice.AspectDefinition; 30 import org.jboss.aop.advice.ScopedInterceptorFactory; 31 import org.jboss.util.id.GUID; 32 33 public class StackBinding 34 { 35 protected String name = GUID.asString(); 36 37 protected AspectManager manager; 38 39 protected String pointcut; 40 41 protected List advices; 42 43 48 public AspectManager getManager() 49 { 50 return manager; 51 } 52 53 58 public void setManager(AspectManager manager) 59 { 60 this.manager = manager; 61 } 62 63 68 public String getPointcut() 69 { 70 return pointcut; 71 } 72 73 78 public void setPointcut(String pointcut) 79 { 80 this.pointcut = pointcut; 81 } 82 83 88 public List getAdvices() 89 { 90 return advices; 91 } 92 93 98 public void setAdvices(List advices) 99 { 100 this.advices = advices; 101 } 102 103 public void start() throws Exception 104 { 105 if (pointcut == null) 106 throw new IllegalArgumentException ("Null pointcut"); 107 if (manager == null) 108 throw new IllegalArgumentException ("Null manager"); 109 if (advices == null || advices.size() == 0) 110 throw new IllegalArgumentException ("No advices"); 111 AdviceBinding binding = new AdviceBinding(name, pointcut, null); 112 for (Iterator i = advices.iterator(); i.hasNext();) 113 { 114 AspectDefinition aspect = (AspectDefinition) i.next(); 115 binding.addInterceptorFactory(new ScopedInterceptorFactory(aspect)); 116 } 117 manager.addBinding(binding); 118 } 119 120 public void stop() throws Exception 121 { 122 manager.removeBinding(name); 123 } 124 } 125 | Popular Tags |