1 22 package org.jboss.aop.microcontainer.beans; 23 24 import org.jboss.aop.AspectManager; 25 import org.jboss.aop.advice.AdviceBinding; 26 import org.jboss.aop.advice.AdviceFactory; 27 import org.jboss.aop.advice.AspectDefinition; 28 import org.jboss.logging.Logger; 29 import org.jboss.util.id.GUID; 30 31 37 public class AspectBinding 38 { 39 private static final Logger log = Logger.getLogger(AspectBinding.class); 40 41 protected AspectManager manager; 42 43 protected String name = GUID.asString(); 44 45 protected String pointcut; 46 47 protected AspectDefinition aspect; 48 49 protected String method = "invoke"; 50 51 56 public AspectDefinition getAspect() 57 { 58 return aspect; 59 } 60 61 66 public void setAspect(AspectDefinition aspect) 67 { 68 this.aspect = aspect; 69 } 70 71 76 public AspectManager getManager() 77 { 78 return manager; 79 } 80 81 86 public void setManager(AspectManager manager) 87 { 88 this.manager = manager; 89 } 90 91 96 public String getMethod() 97 { 98 return method; 99 } 100 101 106 public void setMethod(String method) 107 { 108 this.method = method; 109 } 110 111 116 public String getPointcut() 117 { 118 return pointcut; 119 } 120 121 126 public void setPointcut(String pointcut) 127 { 128 this.pointcut = pointcut; 129 } 130 131 public void start() throws Exception 132 { 133 if (pointcut == null) 134 throw new IllegalArgumentException ("Null pointcut"); 135 if (manager == null) 136 throw new IllegalArgumentException ("Null manager"); 137 if (aspect == null) 138 throw new IllegalArgumentException ("Null aspect definition"); 139 AdviceBinding binding = new AdviceBinding(name, pointcut, null); 140 binding.addInterceptorFactory(new AdviceFactory(aspect, method)); 141 manager.addBinding(binding); 142 log.debug("Bound binding " + name); 143 } 144 145 public void stop() throws Exception 146 { 147 manager.removeBinding(name); 148 } 149 150 public void uninstall() throws Exception 151 { 152 stop(); 153 } 154 155 public void rebind(AspectDefinition aspect) throws Exception 156 { 157 this.aspect = aspect; 158 stop(); 159 start(); 160 } 161 } 162 | Popular Tags |