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

"Alexandre Vasseur" <[email protected]> Mon, 24 Apr 2006 12:23:04 +0200
Newsgroups gmane.comp.java.aspectwerkz.user
Message-ID <[email protected]>
Think about aspect name as a class name. You can't have duplicates in
a system hierarchy.
You can probably mimic advice attribute with some naming convention
aspect A {
 advice adv() {}
 advice ice() {}
}
<aspect ...>
   <param name="adv.yourparam" ....
   <param name="ice.yourparam" ...
   <advice //adv
   <advice //ice
(pseudo code)

Alex

On 4/24/06, Sameer Pokarna <[email protected]> wrote:
> I want multiple advices in a single aspect, and each advice getting it's own
> value of the param/attribute, hence cannot use the param name, value option.
> My bootstrap aspect will be used to identify the context information of the
> call by looking at this value.
>
> AspectWerkz does not allow defining multiple aspects with same name in the
> same system, and hence, what this means is that I have to define a single
> aspect in each system.
>
> The ability to specify attribute seems to be a powerful feature, why was it
> deprecated?
>
>
> Thanks,
> Sameer
>
> > -----Original Message-----
> > From: Alexandre Vasseur [mailto:[email protected]]
> > Sent: Sunday, April 23, 2006 3:46 PM
> > To: [email protected]
> > Subject: Re: [aspectwerkz-user] Getting attribute parameter in an advice
> >
> > 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
> > >
> > >
>
>
>
>