Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Trapping lookup method on InitialContext

 @Pointcut("execute(* javax.naming.Context+.lookup(
String)) &&
args(beanName)")
 public void initialContextLookup(String beanName) {
 }

 @Around("initialContextLookup(beanName)")
 public Object aroundInitialContextLookup(final ProceedingJoinPoint
thisJoinPoint, String beanName) throws Throwable
 {
       // code
 }

1) it should be execution() and not execute() - surprised you aren't getting an error reported for that ?
2) Is the code containing the join point you want to advise passed to AspectJ?  I am suspecting not as you are attempting to match on execution() of a javax packaged method.  Presumably you would be ok with call() rather than execution() from your example code, so this would work:

 @Pointcut("call(* javax.naming.Context+.lookup(String)) && args(beanName)") // uses call
 public void initialContextLookup(String beanName) {
 }

 @Around("initialContextLookup(beanName)")
 public Object aroundInitialContextLookup(final ProceedingJoinPoint thisJoinPoint, String beanName) throws Throwable {
       // code
 }

Andy.



2009/1/23 Parmar, Dipak (IS Consultant) <DParmar@xxxxxxxxxxxxxxxxxxx>
My advice is not getting executed.

Here is snippet of the code, where I should expect the advice should be
executed

     Context ic = new InitialContext();
     SOME_CLASS instance = (SOME_CLASS) ic
         .lookup("JNDI_NAME");

I'm using IntelliJ and it doesn't have Aspect marker.


-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Andrew Eisenberg
Sent: Friday, January 23, 2009 7:04 PM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] Trapping lookup method on InitialContext

When you say it is not working, what do you mean?  Is there a
compilation error, runtime error, or is the advice just not executing
when you think it should.

Please provide a snippet of the code you think it should match.

If you are using Eclipse, you should see gutter markers.  If you see
none, then that is a first sign that your pointcut is not matching
where you expect it to.
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top