Announcement Announcement Module
Collapse
No announcement yet.
Aspect not being called Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Aspect not being called

    Hi,

    started down the road to using AOP and have something but stuck on a couple of issues:

    1. I cannot seem to change the pointcut and have it work.
    2. I can get the method name but not sure how to get the args in a type safe manner (i want to log them in the db).

    Here's my current config (used the ref guide):

    I created a SystemArchitecture class to hold all the pointcuts:

    Code:
    // modules
        // ===========
        @Pointcut("within(com.acme.tsfi.service..*)")
        public void inServiceLayer() {
        }
    
        @Pointcut("within(com.acme.tsfi.web..*)")
        public void inWebLayer() {
        }
    I added the lines to my service layer xml config file (I have a set of them - could that be the problem?):

    Code:
    <!-- custom aspects configured here -->
    	<aop:aspectj-autoproxy />
    
    	<bean id="profilerAspect" class="com.acme.tsfi.aop.ProfilerAspect"/>
    and here my aspect code:

    Code:
    @Around("com.amex.ifst.aop.SystemArchitecture.inServiceLayer()")
        public Object doServiceLevelProfiling(ProceedingJoinPoint pjp)
            throws Throwable {
    		
    		_logger.debug("  SERVICE LAYER: Executing: {}", pjp.toString());
            // start stopwatch
    		StopWatch clock = new StopWatch();
    		clock.start("Service Task");
            Object retVal = pjp.proceed();
            // stop stopwatch
            clock.stop();
            
            _logger.debug("  SERVICE LAYER: Execution of {} completed in {}ms",pjp.toString(),clock.getTotalTimeMillis());
    
            return retVal;
        }
    Now the above WORKS. If i change the annotation to this however:

    Code:
    @Around("com.amex.ifst.aop.SystemArchitecture.inWebLayer()")
    nothing happens. Any idea why? Is it because my web beans are in another xml file and so not visible?

    I'm also not sure how to get the args that were passed in to the methods.

    Cheers

    R
Working...
X