Results 1 to 1 of 1

Thread: testing spring roo and aspectj.

  1. #1
    Join Date
    Sep 2011
    Posts
    5

    Default testing spring roo and aspectj.

    Hello,

    I created a spring roo project (1.1.5.RELEASE [rev d3a68c3] ) using the following example on WinXp (java version "1.6.0_16").

    C:\springROO\InstallScripts>type TestAspectJ.roo


    project --topLevelPackage spring.roo.test
    persistence setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY
    entity --class ~.domain.Person
    field string --fieldName name --class ~.domain.Person
    controller all --package ~.web
    perform eclipse
    perform package
    exit

    I was able to deploy the war file that was produced using the above example roo file successfully in tomcat 6.0.26. Next, I created an example java program using STS IDE to test aspectj like this:

    type AspectSupport.java

    package test.aspectj;

    import org.aspectj.lang.ProceedingJoinPoint;
    import org.aspectj.lang.annotation.Aspect;
    import org.aspectj.lang.annotation.Pointcut;
    import org.aspectj.lang.annotation.Before;
    import org.aspectj.lang.annotation.AfterReturning;
    import org.aspectj.lang.annotation.Around;

    @Aspect
    public class AspectSupport {
    @Pointcut("execution(* spring.roo.test.*(..))")
    public void testPointCut() {}
    @Around("testPointCut()")
    public void testAround(ProceedingJoinPoint joinPoint) throws Throwable {
    System.out.println("AspectSupport.testAround - before: ");
    joinPoint.proceed();
    System.out.println("AspectSupport.testAround - after: ");
    }


    }

    I added <aop:aspectj-autoproxy /> to webmvc-config.xml file. Content of all these three files are attached to this thread. I was able to rebuild, redeploy and test the spring roo app in tomcat 6.0.26 successfully.

    Question: The string AspectSupport did not appear in the log file. It looks like testAround never got executed. What do I need to do so that testAround method will get called when I test the spring roo app?

    Thanks and regards,
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •