Announcement Announcement Module
No announcement yet.
How to modify gerarated .aj file Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

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


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



        • #5
          Thankz a lot.


          • #6
            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
              hi there,well i will got it problem too.....


              • #8
                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
                  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
                    Yes, the Roo Shell was running inside my STS environment. I restarted STS several times before I decided to do the Push In Refactor.