[jboss-user] [JBoss AOP] - Cannot intercept a method

bbarin do-not-reply at jboss.com
Mon Jan 24 05:46:47 EST 2011


bbarin [http://community.jboss.org/people/bbarin] created the discussion

"Cannot intercept a method"

To view the discussion, visit: http://community.jboss.org/message/582723#582723

--------------------------------------------------------------
Hi

I've developed a simple aspect to measure the performance of my application, but althogh the deployment of the aspect in JBoss looks correct, the method that's aimed is not intercepted. I used the following approach:

- I have a performance.jar which contains the following aspect:


package com.agfa.ogpc.performance.aspects;
 
import com.agfa.ogpc.performance.dao.NeoDatisMessageProcessingDAO;
import com.agfa.ogpc.performance.dao.PerformanceDAO;
import org.jboss.aop.joinpoint.MethodInvocation;
 
import com.agfa.ogpc.performance.model.TimeElapsed;
 
public class MessageProcessingAspect {
 
    public Object intercept(final MethodInvocation invocation) throws Throwable {
        long startTime = System.currentTimeMillis();
        try {
            return invocation.invokeNext();
        } finally {
            long endTime = System.currentTimeMillis();
                        store(new TimeElapsed(startTime,endTime));
        }
    }
 
        private void store(final TimeElapsed timeElapsed) {
            PerformanceDAO<TimeElapsed> dao = new NeoDatisMessageProcessingDAO();
            dao.persist(timeElapsed);
        }
}


- I also have several .ears which are part of my application
- I deployed a file named performance-aop.xml in the deploy folder, that looks like:
<?xml version="1.0" encoding="UTF-8"?>
<aop>
<aspect class="com.agfa.ogpc.performance.aspects.MessageProcessingAspect"/>
<bind pointcut="execution(* com.agfa.hap.bpe.components.db.BasicStatelessDBComponent->*(..))">
    <around aspect="com.agfa.ogpc.performance.aspects.MessageProcessingAspect" name="intercept" />
</bind>    
</aop>


The application is deployed correctly and the -aop.xml is wellformed, but the application is not intercepted and I'm sure the method is being called (I debugged the code).

Then I have changed the syntax to intercept any method:

<?xml version="1.0" encoding="UTF-8"?>
<aop>
<aspect class="com.agfa.ogpc.performance.aspects.MessageProcessingAspect"/>
<bind pointcut="execution(* *->*(..))">
    <around aspect="com.agfa.ogpc.performance.aspects.MessageProcessingAspect" name="intercept" />
</bind>    
</aop>


But even after this change the aspect is not being called. I also tried to change the performance.jar to performance.aop and include a jboss-aop.xml within the META-INF folder, but without any success.

So, I ran out of options for the moment.... So, anyone has any idea how to solve it?

Thanks,

Bruno
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/582723#582723]

Start a new discussion in JBoss AOP at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2027]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110124/3ca43291/attachment.html 


More information about the jboss-user mailing list