Results 1 to 2 of 2

Thread: Overriding AspectJ-generated code

  1. #1
    Join Date
    Dec 2011
    Location
    Paris, France
    Posts
    58

    Default Overriding AspectJ-generated code

    Hello,

    how do you override code generated by AspectJ classes?

    Let's say that I wish to override the following function present in a .aj file:

    Photo.findPhotosBySlugLikeAndBudgetLikeAndProjectL ikeAndProjectStatusLike(String project, etc...

    to replace null "project" parameter values by empty strings.

    Where do I find the corresponding .java file, if there is any?

    The following comment at the top of the .aj file is a not laconic: where's the "target java. compilation unit"?

    // WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO.
    // You may push code into the target .java compilation unit if you wish to edit any member(s).

    Many thanks.

    Philroc

  2. #2
    Join Date
    May 2008
    Location
    Cape Town
    Posts
    17

    Default

    Hi

    If you use STS this is easy. The target class is usually part of the AJ filename, for example <TargetClass>_Roo_JavaBean.aj.

    To override the method you have to push it in from the aspect to the target class. Load the target class into the STS editor, and notice light brown markers on the right hand border. Click on it and it should show all the aspect members in the Cross References view. Now select the method you want to override and STS will load the aspect into the editor. Highlight the member, right-click and then select AspectJ Refactoring and then Push In. Once you select OK it should Push the member In to the targer class.

    BTW, the target and aspects are usually in the same folder/directory.

    Hope this helps.
    Last edited by henryve; Jun 21st, 2012 at 09:29 AM. Reason: Additional Info

Posting Permissions

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