Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Beginner Question adviceDidNotMatch

For both execution and initialization, the declaring type (that's com.primavera.infr.db.DBConnectionPool) in this case must be "exposed to the weaver" in order for AspectJ to successfully weave the advice. If the connection pool class is simply on your classpath, then no weaving will happen (and you'll get the "adviceDidNotMatch" warning). See http://www.eclipse.org/aspectj/doc/released/progguide/implementation.html for more details.

To make this program work as is you could: (a) compile DBConnectionPool from source as part of the project build, or (b) put the jar containing DBConnectionPool on the inpath during compilation/weaving.

However, when advising code you don't control, it's often better to advise call join points (because the *call* happens within your own code).

Try :

pointcut initConnectionPool(SysServiceab
le services, String dbID) : call(com.primavera.infr.db.DBConnectionPool.new(SysServiceable, String)) && args(services, dbID);

This assumes of course that your code really does call that constructor.

Regards, Adrian.

On 02/10/06, Bhaskar Maddala <maddalab@xxxxxxxxx> wrote:
Hello,

   I am a beginner in using aspectj and AOP in general, and would really appreciate any I help I can receive. In the event of an obvious error please pardon me, I have looked for messages/help related to adviceDidNotMatch. I understand that the pointcut I have defined does not identify any applicable join points in my program. However I am at a loss as to the reason for this

I am trying to write an advice following the construction of an object, the constructor signature is as below

ConnectionPool(SysServiceable services, String dbID)

I have defined pointcuts as follows (I am trying both execution and intialization )

pointcut initConnectionPool(SysServiceable services, String dbID) : execution(com.primavera.infr.db.DBConnectionPool.new(SysServiceable, String)) && args(services, dbID);

pointcut initConnectionPoola(SysServiceable services, String dbID) : initialization( com.primavera.infr.db.DBConnectionPool.new(SysServiceable, String))  && args(services, dbID);

(Should I be using exection/call/initialization in this case?)
and my advice is as following

after(SysServiceable services, String dbID) : initConnectionPool(services, dbID)
{
    System.out.println("Connection pool is inited");
}
   
after(SysServiceable services, String dbID) : initConnectionPoola(services, dbID)
{
    System.out.println("Connection pool is inited");
}

On compilation, I receive the warning message "advice defined in .... has not been applied [Xlint:adviceDidNotMatch]

I am both compiling and weaving my code at the same time and expect the advice to be applied and therefore cannot proceed without resolving this issue. Once again any help is appreciated and Thank you

- Bhaskar

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users





--
-- Adrian
adrian.colyer@xxxxxxxxx

Back to the top