Announcement Announcement Module
Collapse
No announcement yet.
Static Crosscutting - Introduction question Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Static Crosscutting - Introduction question

    I have declared the following aspect in aop.xml

    ControllerStatsAspect.java
    Code:
    @Aspect
    public class ControllerStatsAspect
    {
    	private Log log = LogFactory.getLog(getClass());
    
    	@DeclareMixin("com.simple.web.*Controller")
    	public Statsable statsableMixin(Object statsObj)
    	{
    		log.info("STATS: Mixin: " + statsObj);
    
    		return new StatsableDefaultImpl(statsObj);
    	}
    
    	@Before("execution(public * com.simple.web.*Controller.*(..)) && this(Statsable)")
    	public void increment(Statsable statsObj)
    	{
    		log.info("STATS: increment: " + statsObj);
    	}
    
    	@After("execution(public * com.simple.web.*Controller.*(..)) && this(Statsable)")
    	public void report(Statsable statsObj)
    	{
    		log.info("STATS: reports: " + statsObj);
    	}
    }
    aop.xml
    Code:
    <aspectj>
    
    	<aspects>
    
    	      <!-- declare three existing aspects to the weaver -->
    	      <aspect name="com.simple.aspect.stats.ControllerStatsAspect"/>
    
    	</aspects>
    
    	<weaver options="-verbose">
                  <include within="com.simple..*"/>
    
                  <!-- Do not weave types within the "CGLIB" generated package -->
                  <exclude within="*..*EnhancerByCGLIB*..*"/>
    
    	      <exclude within="*..*.*$$EnhancerByCGLIB$$*"/>
    
    	      <exclude within="*..*.*$$FastClassByCGLIB$$*"/>
           </weaver>
    
    </aspectj>
    I can see the log messages generated by ControllerStatsAspect.increment() and ControllerStatsAspect.reports() and both with null statsObj. But I never see any log message generated by the statsableMixin() method. I assume that explain why increment() and reports() log messages have a null statsObj object. I have two Controller classes under the com/simple/web folder and the web application is working without throwing any exceptions.

    Any idea why method statsableMixin() never get called?
    Last edited by zollen; Feb 21st, 2010, 08:57 PM.

  • #2
    I am little surprised that you didn't get errors for not binding statsObj in your advice. You will need to change this(Statsable) to this(statsObj).

    -Ramnivas

    Comment


    • #3
      Originally posted by ramnivas View Post
      I am little surprised that you didn't get errors for not binding statsObj in your advice. You will need to change this(Statsable) to this(statsObj).

      -Ramnivas
      Thanks. I didn't get any errors.

      Comment


      • #4
        Originally posted by ramnivas View Post
        I am little surprised that you didn't get errors for not binding statsObj in your advice. You will need to change this(Statsable) to this(statsObj).

        -Ramnivas
        Thanks for your help. It works magically!!!!
        Last edited by zollen; Feb 22nd, 2010, 07:19 PM.

        Comment

        Working...
        X