Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] Using reflection to access join point...

With proceed(..), you don't need to worry about the actual arguments 
of the join point, only the declared arguments of your advice. So 
just leave the advice parameters out, since you are not binding args:

--------
Object around( ) :  // no args here
        cachedOperations() {        
    Object[] arguments = thisJoinPoint.getArgs();
    // ...
    return proceed();  // so no args here                   
}
--------

(I believe) the arg array is copied, so you won't affect the array itself,
but if you mutate an argument, the mutation should be visible to anything 
that runs after the proceed().  

See the programming guide documentation for proceed(..), around advice, and 
binding join point context.

HTH - Wes

> ------------Original Message------------
> From: Nemanja Kostic <n.kostic@xxxxxxxxxxxxxxxx>
> To: "AspectJ developer discussions" <aspectj-dev@xxxxxxxxxxx>
> Date: Sun, Aug-14-2005 2:08 PM
> Subject: Re: [aspectj-dev] Using reflection to access join point...
>
> Thanks Eric,
> 
>     what still puzzles me is what do I pass to around advice as 
> parameter?
> Here is a simplified code snippet from my aspect.
> 
> Object around( ??? ) : cachedOperations() {        
>     Object[] arguments = thisJoinPoint.getArgs();
>     Object  result = proceed(arguments);                  
>     return result;
> }
> 
> What to put insted of (???) or how to
> define pointcut to be independent of the method signature ?
> 
> I have methods which are advised by this aspect that can have arbitrary
> number/type of method parameters, such as:
> 
> public List getContentListByType(int type_id);
> public AcmsContent getContentByName(String name);
> public List getSubcontentList(int parent_id, int type_id);
> ... etc ...
> 
> 
> This is probably some trivial thing, but documentation wasn't really 
> helpful.
> 
> Nemanja.
> 
> 
> Eric Bodden wrote:
> 
> >Actually all you have to do is invoke thisJoinPoint.getArgs(), which 
> returns
> >an array of objects which were passed as arguments. Its as simple as 
> that.
> >You may want to have a look at the documentation of thisJoinPoint.
> >
> >Eric
> >
> _______________________________________________
> aspectj-dev mailing list
> aspectj-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-dev
> 



Back to the top