Announcement Announcement Module
No announcement yet.
Add 'declare @' rules to an AspectJ file Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Add 'declare @' rules to an AspectJ file


    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)).

    declare @method: [email protected] * 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
    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.



    • #3
      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:


      Declare annotation - augmentation/overriding and precedence:


      That i've posted in JIRA:

      Thank you !