Results 1 to 3 of 3

Thread: Add 'declare @' rules to an AspectJ file

Hybrid View

  1. #1

    Default Add 'declare @' rules to an AspectJ file

    Hi!

    I'm developing an Addon to generate Metadata depending on the annotations set in java code.

    I want to generate a Metadata (AspectJ) with a rule in wich all methods that aren't annotated with defined annotation (@AnnotatedMethod) in a class (TestRequirements) asign an especific annotation (@NewAnnotatedMethod(new = true)).

    Code:
    declare @method: !@AnnotatedMethod * TestRequirements.*(..) : @NewAnnotatedMethod(new = true);
    The DefaultItdTypeDetailsBuilder provides some methods to update a method, method annotations, types annotation, etc... but there is no method defined to create a custom rule like this.

    Any workaround to solve the problem ?

    I'll post a JIRA to make an improvement in next versions, I think it's a good way to make more use of AspectJ.

  2. #2
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    There is no method because ItdTypeDetailsBuilder (and particularly its addMethodAnnotation method) are being used to create a given ITD. By that point the decision to create an ITD for the type has been made. It would be the wrong location to basically indicate a pointcut. It would be more likely you need logic like AbstractItdMetadataProvider, as that handles trigger annotation detection and spawns the creation of metadata items that create ITDs. I am not convinced of the use case, though. An enforcement aspect might be more what you're looking for, or writing an aspect with a traditional pointcut. In other words, what is the annotation meant to eventually be read by? It is probably optimal to write a pointcut that triggers an aspect that causes that eventual behaviour to happen rather than go through the roundabout step of adding an annotation to have something else later discover and act upon it.

    Cheers
    Ben
    Ben Alex
    Project Founder, Spring UAA, Spring Roo and Spring Security

  3. #3

    Default

    Ok!
    I understand that I have to use of another Metadata to create an AspectJ with pointcuts or make a method declaration for each that doesn't have the annotation.

    Another question is there's any plan to generate metadata for these ApsectJ improvements in next versions of ROO.

    Declare annotation to a method param:

    * https://bugs.eclipse.org/bugs/show_bug.cgi?id=321820

    Declare annotation - augmentation/overriding and precedence:

    * https://bugs.eclipse.org/bugs/show_bug.cgi?id=313026

    That i've posted in JIRA:

    https://jira.springsource.org/browse/ROO-1390


    Thank you !

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •