Results 1 to 10 of 10

Thread: How to modify gerarated .aj file

  1. #1
    Join Date
    Jul 2010
    Location
    BKK Thailand
    Posts
    12

    Default How to modify gerarated .aj file

    Some times i need to modify generate .aj file
    eg. to_string file i no need to show id and version
    but after i modify .aj file spring roo will convert to
    original generate file

    any body who face the same situation ?

    thanks for all answer

  2. #2
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    Do not modify the generated AspectJ source code. These files are intended to be maintained by Roo.

    If you want to change the toString() behaviour, implement toString() in the relevant Java source file. Spring Roo is smart enough to detect that and avoid generating its own generic toString() method.
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

  3. #3
    Join Date
    Jul 2010
    Location
    BKK Thailand
    Posts
    12

    Default

    thanks a lot for your answer

    you mean all roo generate .aj file is detected change by roo
    and if i modify it roo will convert it to original automatically.

    And i have another question it's cover to Controller ?
    if i need my own method i should coding it in to java instead
    .aj file rigth?

  4. #4
    Join Date
    Mar 2008
    Location
    Sydney, AU
    Posts
    974

    Default

    As Rod mentioned, the AspectJ (.aj) files are actively maintained by Spring Roo. You as the developer should not customize anything directly in an aj file since Roo will simply override it again if the shell is running.

    If you need to customize anything you can simply use the 'push-in' refactoring feature in the SpringSource Tool Suite to move the relevant method or field back into your normal Java type (.java) where you can freely customize it. You can also do this by hand. Roo will recognize any method in your java source which has the same signature and therefore not provide the method in the aj file.

    This applies to all java types which are accompanied by aspects, so yes the same principle applies to MVC Controllers.

    HTH,
    Stefan
    Stefan Schmidt
    Software Engineer, Spring Roo
    SpringSource - a division of VMware
    twitter @schmidtstefan

  5. #5
    Join Date
    Jul 2010
    Location
    BKK Thailand
    Posts
    12

    Default

    Thankz a lot.

  6. #6

    Default

    I modified my Myclass_Roo_JavaBean.aj file by searching within my IDE for one of the properties in Myclass.

    I was forced to do it because Roo was not adding the getter and setter for a field I just added to Myclass via the Roo command shell.

  7. #7
    Join Date
    Aug 2010
    Posts
    4

    Default

    hi there,well i will got it problem too.....

  8. #8

    Default

    I've decided to do a Refactor->Push In and get out of using Roo/AspectJ altogether.

    The failure of Roo to update the .aj files as I make changes to entity classes has cost me too much development time spent figuring out why a getter for an entity member could not be found, why an entityManager object was not injected, etc. I read somewhere else on this forum that Roo/AspectJ gets corrupted after repeated usage.

    Still, I credit Roo for getting me started on Spring 3 development faster than I would have otherwise.

  9. #9
    Join Date
    Sep 2007
    Posts
    20

    Default

    I was forced to do it because Roo was not adding the getter and setter for a field I just added to Myclass via the Roo command shell.
    Hi Paolo, Is you Roo engine running? Perhaps you can restart it. On startup Roo checks all roo artifacts and updates the corresponding .aj if necessary.

  10. #10

    Default

    Yes, the Roo Shell was running inside my STS environment. I restarted STS several times before I decided to do the Push In Refactor.

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
  •