Re: [aspectwerkz-user] Getting attribute parameter in an advice

"Alexandre Vasseur" <[email protected]> Sun, 23 Apr 2006 12:16:28 +0200
Newsgroups gmane.comp.java.aspectwerkz.user
Message-ID <[email protected]>
You should use <aspect ..><param name= value= /> instead.
See http://aspectwerkz.codehaus.org/xml_definition.html#Passing_parameters_to_aspects

I guess this advice level attribute in the dtd is a deprecated thing.
Alex

On 4/20/06, Sameer Pokarna <[email protected]> wrote:
>
>
>
> 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
>
>