Re: hot deployment and multiple pointcuts

Jonas BonĂ©r <[email protected]> Thu, 08 May 2003 23:12:14 +0200
Newsgroups gmane.comp.java.aspectwerkz
Message-ID <[email protected]>
Hi Joseph.

This holds for the coming release (and the latest snapshot in the CVS).

* I you add an advice dynamically using:

AspectWerkz.createAdvice("myadvice", "test.Advice", "perInstance", null);

* Then you can add it to a Pointcut using:

// get all the aspects for a certain class pattern
List aspects = AspectWerkz.getAspects("test.*");

// get the aspect we want (call it aspect)
...

// add the advice to the pointcut we want (need to use the same pattern 
as specified before)
aspect.getMethodPointcut("* to*(..)").addAdvice("myadvice");

* You can also retrieve a list of all the Pointcuts for a specific 
method or field using the MethodMetaData (or FieldMetaData) as a 
parameter. And then add the advice to the Pointcut you want.
Like this:

// get the pointcuts for a specific method
MethodPointcut[] pointcuts = AspectWerkz.getAspect("test.*").
	getMethodPointcut(MethodMetaData metaData);

// get the poincut we want (call it pointcut)
...

// add the advice to the pointcut
pointcut.addAdvice("myadvice");


Hope it clears out a few things.

Sincerely, Jonas.

Ps. What is the problem with accessing the CVS? Ds.


Joseph Milora wrote:
> Hi,
>  
> I have a question about the hot deployment.
> If I want to dynamically add an advice to an aspect, do I have to 
> specify every pointcut?
> For example, with the logging example, if I specify a pointcut pattern 
> of to.*, every toLog(n)
> call will be intercepted. If I try to add an advice dynamically, I'd 
> like to be able to specify the same
> pattern, without having to manually add each method explicitly.
> Also, the ability to add new advices dynamically looks great, but I'm 
> having a problem accessing the
> cvs repository to get the latest build.
>  
> BTW great tool!
> Thanks in advance,
> Joe Milora


-- 
Jonas
http://freeroller.net/page/jboner





-------------------------------------------------------
Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara
The only event dedicated to issues related to Linux enterprise solutions
www.enterpriselinuxforum.com