[aspectwerkz-user] Getting attribute parameter in an advice
"Sameer Pokarna" <[email protected]> Thu, 20 Apr 2006 14:32:12 +0530
| Newsgroups | gmane.comp.java.aspectwerkz.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I am trying to pass parameters to the aspects, however, I would like to get
finer granularity than the "param" support in aspects, i.e. I have multiple
advices declared in a single aspect, and I would like to get different
values of parameters for each invocation of advice.
Aspectwerkz2.dtd specifies an "attribute" attribute to the advice XML
element. I was trying to write a code to enable me to do this.
I am trying to use the AdviceDefinition object to retrieve the attribute
using the getAttribute(). So, the code snippet that I am trying to use is:
SystemDefinition sd =
SystemDefinitionContainer.getDefinitionFor
(Thread.currentThread().getContextClassLoader(),
"systemname");
Collection coll = sd.getAdviceDefinitions();
Iterator itr = coll.iterator();
while (itr.hasNext())
{
AdviceDefinition ad = (AdviceDefinition)itr.next();
if ("advicename".equals(ad.getName()))
{
System.out.println("ad.getAttribute() = " +
ad.getAttribute());
System.out.println("ad.getExpressionInfo().toString() = " +
ad.getExpressionInfo().toString());
}
}
I am getting the expression correctly, but the advice "attribute" as null.
The aop.xml looks something like this:
<system id="systemname">
<package name=".">
<aspect class="BootstrapAspect" deployment-model="perJVM">
<pointcut name="." expression="."/>
<advice name="advicename" type="around"
bind-to="."
attribute="attribValue"/>
.
I cannot see the method setAttribute() being called from anywhere in the
aspectwerkz codebase.
Is this feature supported/working?
Thanks and regards,
Sameer