Package org.jboss.aop.advice

Examples of org.jboss.aop.advice.AdviceBinding.addInterceptor()


   public void testMethodExecutionWithInstanceAdvisorAccess() throws Exception
   {
      System.out.println("TEST METHOD WITH INSTANCEADVISOR ACCESS");
      AdviceBinding binding = new AdviceBinding("execution(* org.jboss.test.aop.dynamicgenadvisor.POJO->someMethod(..))", null);
      binding.addInterceptor(MetadataInterceptor.class);
      AspectManager.instance().addBinding(binding);

      POJO pojo = new POJO();
      MetadataInterceptor.clear();
      pojo.someMethod(123);
View Full Code Here


   public void testFields() throws Exception
   {
      System.out.println("TEST FIELDS");
      AdviceBinding binding = new AdviceBinding("set(* org.jboss.test.aop.dynamicgenadvisor.POJO->i)", null);
      String name = binding.getName();
      binding.addInterceptor(MyInterceptor.class);
      AspectManager.instance().addBinding(binding);
     
      Interceptions.clear();
      POJO pojo = new POJO();
      pojo.i = 5;
View Full Code Here

      assertEquals(1, Interceptions.size());
      assertEquals(Interceptions.getFieldWriteName("MyInterceptor", "POJO", "i"), Interceptions.get(0));

      AdviceBinding binding2 = new AdviceBinding("get(* org.jboss.test.aop.dynamicgenadvisor.POJO->i)", null);
      String name2 = binding2.getName();
      binding2.addInterceptor(MyInterceptor.class);
      AspectManager.instance().addBinding(binding2);
     
      Interceptions.clear();
      pojo.i = 5;
      assertEquals(5, pojo.i);
View Full Code Here

      AdviceBinding binding3 = new AdviceBinding("field(* org.jboss.test.aop.dynamicgenadvisor.POJO->i)", null);
      String name3 = binding3.getName();
      AspectDefinition myAspect = AspectManager.instance().getAspectDefinition("org.jboss.test.aop.dynamicgenadvisor.MyAspect");
      binding3.addInterceptorFactory(new AdviceFactory(myAspect, "intercept"));
      binding3.addInterceptor(MyInterceptor.class);
      AspectManager.instance().addBinding(binding3);
     
      Interceptions.clear();
      pojo.i = 20;
      assertEquals(3, Interceptions.size());
View Full Code Here

      AspectManager.instance().removeBinding(name);
      AspectManager.instance().removeBinding(name2);

      AdviceBinding binding4 = new AdviceBinding("field(static * org.jboss.test.aop.dynamicgenadvisor.POJO->j)", null);
      String name4 = binding4.getName();
      binding4.addInterceptor(MyInterceptor.class);
      AspectManager.instance().addBinding(binding4);
     
      Interceptions.clear();
      pojo.i=15;
      assertEquals(15, pojo.i);
View Full Code Here

      POJO pojo1 = new POJO();
      POJO pojo2 = new POJO();
     
      AdviceBinding binding = new AdviceBinding("execution(* org.jboss.test.aop.dynamicgenadvisor.POJO->someMethod(..))", null);
      String name = binding.getName();
      binding.addInterceptor(MyInterceptor.class);
      getInstanceDomain(pojo2).addBinding(binding);
     
      Interceptions.clear();
      pojo1.someMethod(123);
      assertTrue(Interceptions.isEmpty());
View Full Code Here

      try
      {
         System.out.println("TEST INSTANCE USING DOMAIN FOR METHOD");
         AdviceBinding bindingTopA = new AdviceBinding("execution(* org.jboss.test.aop.dynamicgenadvisor.POJO->someMethod(..))", null);
         nameTopA = bindingTopA.getName();
         bindingTopA.addInterceptor(MyInterceptor.class);
         AspectManager.instance().addBinding(bindingTopA);
        
         POJO pojo1 = new POJO();
         POJO pojo2 = new POJO();
        
View Full Code Here

         assertEquals(Interceptions.getMethodName("MyInterceptor", "POJO", "someMethod"), Interceptions.get(1));
        
         //Add instance advices
         AdviceBinding bindingA = new AdviceBinding("execution(* org.jboss.test.aop.dynamicgenadvisor.POJO->someMethod(..))", null);
         String nameA = bindingA.getName();
         bindingA.addInterceptor(MyInterceptor.class);
         getInstanceDomain(pojo1).addBinding(bindingA);
        
         AdviceBinding bindingB = new AdviceBinding("execution(* org.jboss.test.aop.dynamicgenadvisor.POJO->someMethod(..))", null);
         String nameB = bindingB.getName();
         AspectDefinition myAspect = AspectManager.instance().getAspectDefinition("org.jboss.test.aop.dynamicgenadvisor.MyAspect");
View Full Code Here

       
         //Add top level advice
         POJO pojo3 = new POJO();
         AdviceBinding bindingTopB = new AdviceBinding("execution(* org.jboss.test.aop.dynamicgenadvisor.POJO->someMethod(..))", null);
         nameTopB = bindingTopB.getName();
         bindingTopB.addInterceptor(YourInterceptor.class);
         AspectManager.instance().addBinding(bindingTopB);
        
         System.out.println("Added top level advice");
        
         Interceptions.clear();
View Full Code Here

      assertEquals(1, Interceptions.size());
      assertEquals(Interceptions.getFieldWriteName("MyAspect", "POJO", "i"), Interceptions.get(0));

      AdviceBinding binding2 = new AdviceBinding("get(* org.jboss.test.aop.dynamicgenadvisor.POJO->i)", null);
      String name2 = binding2.getName();
      binding2.addInterceptor(MyInterceptor.class);
      getInstanceDomain(pojo2).addBinding(binding2);
     
      Interceptions.clear();
      pojo2.i = 30;
      assertEquals(30, pojo2.i);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.