[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] abstract "declare @method"

Hi Thomas,

I guess what you need are named signature patterns.  We have an open
request for named type patterns, which is a similar kind of situation.
When you want to talk about a type pattern in the abstract sense, but
define it elsewhere:

abstract aspect Foo {
  declare parents: MyTypePattern() implements Serializable;
}
aspect Bar extends Foo {
  typepattern MyTypePattern(): com.foo.mypackages..*;
}

Obviously it would be similar for named signature patterns. I'm afraid
you can't do either of these things at the moment.

An alternative would be the ability to more easily construct complete
aspects in aop.xml:

<concrete-aspect name="com.xyz.Demo">
  <declare_at_method pattern="* be.post..Olrik.conspire()"
annotation="@Scenario("conspiracy")"/>
</concrete-aspect>

In fact given that this latter mechanism doesn't require complex
grammar changes, like named type/signature patterns would, it is
perhaps preferable.  It could go as far as be used for wiring up
pointcuts and advice too:

  <before pointcut="execution(* *(..))"
advice="MyStaticHelperClass.someMethod()"/>

So the body of the code isn't written in XML (phew), but it is used to
wire a pointcut up with a static method that already exists.

Right now really you have to generate the complete aspect, but of
course that means it needs to be compiled.  Supporting
declare_at_method via the XML definition doesn't feel like a huge
amount of work though.

cheers
Andy

On 19 September 2011 06:30, Thomas Moerman <thomas.moerman@xxxxxxxxx> wrote:
> Hello,
> I have a question concerning annotation supplementation aspects.
> Suppose we have this:
> declare @method: * be.post..Olrik.conspire() : @Scenario("conspiracy");
> This puts the @Scenario annotation on the conspire() method of the Olrik
> class.
> Now, I would like to make the [* be.post..Olrik.conspire()]method signature
> pattern abstract and provide it in the aop.xml file.
> In general, i want to use AspectJ in a configurable way to put annotations
> on methods of target Java projects. The idea is to create a DSL that
> generates an aop.xml file that is the coupling between .aj files and target
> method signatures. This is roughly equivalent to making an abstract aspect
> concrete by defining a <concrete-aspect> with a <pointcut> in the aop.xml
> file.
> Is this possible at all? If not, is there another strategy to achieve an
> externalization of the method signature pattern in an annotation
> supplementation aspect?
> Help would be greatly appreciated,
> krgs,
> - Thomas
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>