Package org.jboss.aop.advice

Examples of org.jboss.aop.advice.AdviceFactory


   public void testContainerProxyWithFinalMethods() throws Exception
   {
      InstanceDomain domain = new InstanceDomain(AspectManager.instance(), "test", false);
      AspectDefinition def = new AspectDefinition("aspect", Scope.PER_VM, new GenericAspectFactory(EchoInterceptor.class.getName(), null));
      domain.addAspectDefinition(def);
      AdviceFactory advice = new AdviceFactory(def, "invoke");
      domain.addInterceptorFactory(advice.getName(), advice);
      {
      PointcutExpression pointcut = new PointcutExpression("pointcut", "execution(* " + POJOWithFinalMethods.class.getName() + "->*(..))");
      domain.addPointcut(pointcut);
      InterceptorFactory[] interceptors = {advice};
      AdviceBinding binding = new AdviceBinding("pojo-binding", pointcut, null, null, interceptors);
View Full Code Here


  
   public void testProxyWithPerInstanceAspects() throws Exception
   {
      AspectManager manager = AspectManager.instance();
      AspectDefinition def = new AspectDefinition("perinstanceaspect", Scope.PER_INSTANCE, new GenericAspectFactory(TestInterceptor.class.getName(), null));
      AdviceFactory advice = new AdviceFactory(def, "invoke");
      PointcutExpression pointcut = new PointcutExpression("perinstancepointcut", "execution(* $instanceof{" + SomeInterface.class.getName() + "}->*(..))");
      InterceptorFactory[] interceptors = {advice};
      AdviceBinding binding = new AdviceBinding("perinstancebinding", pointcut, null, null, interceptors);
      try
      {
         manager.addAspectDefinition(def);
         manager.addInterceptorFactory(advice.getName(), advice);
         manager.addPointcut(pointcut);
         manager.addBinding(binding);
        
         AOPProxyFactoryParameters params = new AOPProxyFactoryParameters();
         params.setInterfaces(new Class[] {SomeInterface.class});
View Full Code Here

   public void testProxyWithPerJoinpointAspects() throws Exception
   {
      AspectManager manager = AspectManager.instance();
      AspectDefinition def = new AspectDefinition("perinstanceaspect", Scope.PER_JOINPOINT, new GenericAspectFactory(TestInterceptor.class.getName(), null));
      AdviceFactory advice = new AdviceFactory(def, "invoke");
      PointcutExpression pointcut = new PointcutExpression("perinstancepointcut", "execution(* $instanceof{" + SomeInterface.class.getName() + "}->*(..))");
      InterceptorFactory[] interceptors = {advice};
      AdviceBinding binding = new AdviceBinding("perinstancebinding", pointcut, null, null, interceptors);
      try
      {
         manager.addAspectDefinition(def);
         manager.addInterceptorFactory(advice.getName(), advice);
         manager.addPointcut(pointcut);
         manager.addBinding(binding);
        
         AOPProxyFactoryParameters params = new AOPProxyFactoryParameters();
         params.setInterfaces(new Class[] {SomeInterface.class});
View Full Code Here

  
   public void testProxyWithMetaData() throws Exception
   {
      AspectManager manager = AspectManager.instance();
      AspectDefinition def = new AspectDefinition("aspect", Scope.PER_INSTANCE, new GenericAspectFactory(TestInterceptor.class.getName(), null));
      AdviceFactory advice = new AdviceFactory(def, "invoke");
      PointcutExpression pointcut = new PointcutExpression("pointcut", "execution(* " + Annotation.class.getName() + "->*(..))");
      InterceptorFactory[] interceptors = {advice};
      AdviceBinding binding = new AdviceBinding("binding", pointcut, null, null, interceptors);
      try
      {
         manager.addAspectDefinition(def);
         manager.addInterceptorFactory(advice.getName(), advice);
         manager.addPointcut(pointcut);
         manager.addBinding(binding);
        
         AOPProxyFactoryParameters params = new AOPProxyFactoryParameters();
         params.setTarget(new POJO());
View Full Code Here

         String pointcutString,
         String cflow,
         ASTCFlowExpression cflowExpression)throws Exception
   {
      AspectDefinition def = loader.getAspectManager().getAspectDefinition(aspectDefName);
      AdviceFactory factory = null;
      if (internalAdviceType == org.jboss.aop.advice.AdviceType.AROUND)
      {
         factory = new AdviceFactory(def, methodName);
      }
      else
      {
         factory = new AdviceFactory(def, methodName, internalAdviceType);
      }
     
      loader.getAspectManager().addInterceptorFactory(factory.getName(), factory);
      InterceptorFactory[] fact = {factory};
      PointcutExpression pointcut = new PointcutExpression(bindingName, pointcutString);
      AdviceBinding abinding = new AdviceBinding(bindingName, pointcut, cflowExpression, cflow, fact);
      loader.getAspectManager().addBinding(abinding);
   }
View Full Code Here

      if(aspect == null || aspect.length() < 1)
         throw new RuntimeException("Aspect couldnt be found for element: "+element.getNodeName()+", typo perhaps?");
      AspectDefinition def = manager.getAspectDefinition(aspect);
      if (def == null) throw new RuntimeException("advice " + name + " cannot find aspect " + aspect);
     
      AdviceFactory factory = null;
      if (type == null)
      {
         // use default advice type
         factory = new AdviceFactory(def, name);
      }
      else
      {
         factory = new AdviceFactory(def, name, type);
      }
     
      manager.addInterceptorFactory(factory.getName(), factory);
      return factory;
   }
View Full Code Here

         String pointcutString,
         String cflow,
         ASTCFlowExpression cflowExpression)throws Exception
   {
      AspectDefinition def = loader.getAspectManager().getAspectDefinition(aspectDefName);
      AdviceFactory factory = null;
      if (internalAdviceType == org.jboss.aop.advice.AdviceType.AROUND)
      {
         factory = new AdviceFactory(def, methodName);
      }
      else
      {
         factory = new AdviceFactory(def, methodName, internalAdviceType);
      }
     
      loader.getAspectManager().addInterceptorFactory(factory.getName(), factory);
      InterceptorFactory[] fact = {factory};
      PointcutExpression pointcut = new PointcutExpression(bindingName, pointcutString);
      AdviceBinding abinding = new AdviceBinding(bindingName, pointcut, cflowExpression, cflow, fact);
      loader.getAspectManager().addBinding(abinding);
   }
View Full Code Here

/*     */     }
/*  98 */     if (this.aspect == null)
/*     */     {
/* 100 */       throw new IllegalArgumentException("Null aspect");
/*     */     }
/* 102 */     this.interceptorFactory = (this.aspectMethod == null ? new ScopedInterceptorFactory(this.aspect.getDefinition()) : new AdviceFactory(this.aspect.getDefinition(), this.aspectMethod));
/*     */
/* 105 */     this.manager.addInterceptorFactory(this.name, this.interceptorFactory);
/* 106 */     if (this.binding != null)
/*     */     {
/* 108 */       this.aspect.addBinding(this.binding);
View Full Code Here

/*  231 */     if ((aspect == null) || (aspect.length() < 1))
/*  232 */       throw new RuntimeException("Aspect couldnt be found for element: " + element.getNodeName() + ", typo perhaps?");
/*  233 */     AspectDefinition def = this.manager.getAspectDefinition(aspect);
/*  234 */     if (def == null) throw new RuntimeException("advice " + name + " cannot find aspect " + aspect);
/*      */
/*  236 */     AdviceFactory factory = null;
/*  237 */     if (type == null)
/*      */     {
/*  240 */       factory = new AdviceFactory(def, name);
/*      */     }
/*      */     else
/*      */     {
/*  244 */       factory = new AdviceFactory(def, name, type);
/*      */     }
/*      */
/*  247 */     this.manager.addInterceptorFactory(factory.getName(), factory);
/*  248 */     return factory;
/*      */   }
View Full Code Here

/*      */           {
/*  456 */             cflowExpression = new PointcutExpressionParser(new StringReader(cflow)).CFlowExpression();
/*      */           }
/*      */
/*  460 */           org.jboss.aop.advice.AdviceType internalAdviceType = getInternalAdviceType(binding.type());
/*  461 */           AdviceFactory factory = null;
/*  462 */           if (internalAdviceType == org.jboss.aop.advice.AdviceType.AROUND)
/*      */           {
/*  464 */             factory = new AdviceFactory(def, minfo.getName());
/*      */           }
/*      */           else
/*      */           {
/*  468 */             factory = new AdviceFactory(def, minfo.getName(), internalAdviceType);
/*      */           }
/*      */
/*  471 */           this.manager.addInterceptorFactory(factory.getName(), factory);
/*  472 */           InterceptorFactory[] fact = { factory };
/*  473 */           String name = getAspectMethodBindingName(cf, minfo);
/*  474 */           PointcutExpression pointcut = new PointcutExpression(name, pointcutString);
/*  475 */           AdviceBinding abinding = new AdviceBinding(name, pointcut, cflowExpression, cflow, fact);
/*  476 */           this.manager.addBinding(abinding);
View Full Code Here

TOP

Related Classes of org.jboss.aop.advice.AdviceFactory

Copyright © 2018 www.massapicom. 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.