Announcement Announcement Module
Collapse
No announcement yet.
Best practise to populate database after running Roo script Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Best practise to populate database after running Roo script

    I am having a quite extensive Roo script to set up a domain model.

    To use the application I need some initial data in the DB.

    Ideally Roo should be able to call an external (bash)-script or maybe execute an SQL file.

    How do you proceed if you need to automatically populate the DB after Roo ran its script?

  • #2
    I know there's such an "addon-oscommands" addon to let you run OS commands from within the Roo shell.
    I guess commands can be run from within a script as well.

    Cheers,
    Vito

    Comment


    • #3
      Thanks for the hint, I found it here: http://code.google.com/p/spring-roo-os-commands/

      I will check it out.

      Comment


      • #4
        An alternative

        Not quite running an os script, but a possible alternative which is less OS dependent.

        What we did in this situation was to have a class which implements ApplicationListener<ContextRefreshedEvent>. This allows us to do whatever setup we need when the application is starting up. Two caveats though. It ends up running several times during the start-up process so you need to handle the case where the DB is already initialized. It runs when starting the integration tests, for us this caused some tests to fail so we have a check in place in the code that checks if junit is in the call stack and skips the initialization if it is.

        Hope that helps.

        Comment


        • #5
          Originally posted by angelog View Post
          Not quite running an os script, but a possible alternative which is less OS dependent.

          What we did in this situation was to have a class which implements ApplicationListener<ContextRefreshedEvent>. ...

          Hope that helps.
          Thanks for this hint. But since this is not possible with plain roo-script, I still believe it would be nice to have a roo-command like "call" or "run" or "exec" which lets you run an os command directly.

          Comment


          • #6
            Originally posted by Vito Meuli View Post
            I know there's such an "addon-oscommands" addon to let you run OS commands from within the Roo shell.
            I guess commands can be run from within a script as well.

            Cheers,
            Vito
            Actually the addon is described here: https://jira.springsource.org/browse/ROO-2457 (included on how to install it directly from the roo shell)

            Comment

            Working...
            X