correction: how to retrieve aspects at runtime
Jonas Bonér <[email protected]> Fri, 09 May 2003 12:48:05 +0200
| Newsgroups | gmane.comp.java.aspectwerkz |
|---|---|
| Message-ID | <[email protected]> |
Hi Joseph.
I made small mistake in the example i wrote.
You have three ways of retrieving an aspect for a class:
1. // get all the aspects for a certain class (full classname)
List aspects = AspectWerkz.getAspects("test.MyClass");
2. // get the aspect for a certain class pattern (must have been defined
using this pattern)
Aspect aspect = AspectWerkz.getAspect("test.*");
3. // get the aspect for a certain class pattern, a bit faster (if you
reuse the ClassPattern instance), (must have been defined using this
pattern)
ClassPattern classPattern = Pattern.compileClassPattern("test.*");
Aspect aspect = AspectWerkz.getAspect(classPattern);
Sincerely, Jonas.
Ps. I just committed the second way of handling it. Ds.
Joseph Milora wrote:
> Hi Jonas,
> Thanks for the quick reply, it cleared things up.
> The cvs repository seems to be working fine now.
>
> I think your new additions will fill in the few missing pieces for me.
> Thanks again,
> Joe Milora
>
> ----- Original Message -----
> From: "Jonas Bonér" <[email protected]>
> To: "Joseph Milora" <[email protected]>
> Cc: <[email protected]>
> Sent: Thursday, May 08, 2003 2:12 PM
> Subject: Re: [aspectwerkz-developer] hot deployment and multiple pointcuts
>
>
>
>>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
>
> _______________________________________________
> aspectwerkz-developer mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/aspectwerkz-developer
>
>
--
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