1 22 23 import org.jboss.aop.Advisor; 24 import org.jboss.aop.InstanceAdvisor; 25 import org.jboss.aop.joinpoint.Invocation; 26 import org.jboss.aop.joinpoint.Joinpoint; 27 28 33 public class ConfigAspectPerVm 34 { 35 String [] attr1; 36 Advisor advisor; 37 InstanceAdvisor instanceAdvisor; 38 Joinpoint jp; 39 40 public ConfigAspectPerVm() 41 { 42 } 43 44 public void setAttr(String [] attr1) 45 { 46 this.attr1 = attr1; 47 } 48 49 public void setMyAdvisor(Advisor advisor) 50 { 51 this.advisor = advisor; 52 } 53 54 public void setMyInstanceAdvisor(InstanceAdvisor instanceAdvisor) 55 { 56 this.instanceAdvisor = instanceAdvisor; 57 } 58 59 public void setMyJoinpoint(Joinpoint jp) 60 { 61 this.jp = jp; 62 } 63 64 public Object methodAdvice(Invocation invocation) throws Throwable 65 { 66 try 67 { 68 System.out.println(">>> Enter ConfigAspectPerVm"); 69 70 StringBuffer sb = new StringBuffer (); 71 for (int i = 0 ; i < attr1.length ; i++) 72 { 73 if (i > 0) 74 { 75 sb.append(", "); 76 } 77 sb.append("index " + i + "=" + attr1[i]); 78 } 79 String attr1ArrayAsString = sb.toString(); 80 81 System.out.println(" attr1: " + attr1ArrayAsString); 82 System.out.println(" has advisor: " + (advisor != null)); 83 System.out.println(" has instanceAdvisor: " + (instanceAdvisor != null)); 84 System.out.println(" has joinpoint: " + (jp != null)); 85 return invocation.invokeNext(); 86 } 87 finally 88 { 89 System.out.println(">>> Leave ConfigAspectPerVm"); 90 } 91 } 92 93 } 94 | Popular Tags |