Announcement Announcement Module
Collapse
No announcement yet.
problem trying to set up aop (with annotation) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • drim
    started a topic problem trying to set up aop (with annotation)

    problem trying to set up aop (with annotation)

    I am trying to set up an AOP configuration on my spring project.

    In the xml context file, I added :
    Code:
    <aop:aspectj-autoproxy>
    <aop:include name="myBean" />
    </aop:aspectj-autoproxy>
    My bean is clear from annotation. There are many public methods.

    Code:
    @Service("myBean")
    public class MyBean{
    public void method() {
    ...
    }
    I made a class to manage the Aop :

    Code:
    @Aspect
    public class AopClass{
    	@Pointcut("execution(public * *(..))")
    	public void createAction() {
    		System.out.println("testing aop");
    	}
    }
    When I call a public method from myBean, it doesn't call createAction() method.

    Thank you.
    Last edited by drim; Feb 26th, 2009, 03:35 PM.

  • drim
    replied
    It's worked.
    I modified my code like this :
    Code:
    @Aspect
    @Component
    public class AopClass{
    	
    	@Pointcut("execution(public * *(..))")
        private void anyPublicOperation() {}
    	
    	 
    	@AfterReturning(anyPublicOperation()")
    	public void createAction() {
    		System.out.println("BLABLA");
    	}
    }
    I added @Component.

    Hope it can be helpfull.

    Leave a comment:


  • drim
    replied
    I modified my bean like this :

    Code:
    @Aspect
    public class AopClass{
    	
    	@Pointcut("execution(public * *(..))")
        private void anyPublicOperation() {}
    	
    	 
    	@AfterReturning(package.AopClass.anyPublicOperation()")
    	public void createAction() {
    		System.out.println("BLABLA");
    	}
    }

    But the problem persists ; when I called a public method, didn't call my createAction method.

    Leave a comment:


  • Marten Deinum
    replied
    Only defining a pointcut isn't going to do much. You specified the WHERE (Pointcut) to apply something but not the WHEN (before, after, ... ).

    Leave a comment:

Working...
X