Announcement Announcement Module
No announcement yet.
load a list of groovy files instead of individual ones in app context? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • load a list of groovy files instead of individual ones in app context?

    I have the unique situation where I'm going to have an unknown number of groovy scripts in a directory. Our database will contain the name of the script to run and will be retrieved from the db at any point. The number of groovy scripts in that folder can change since we will be adding and removing them over time.

    So I can't really create a spring app context file that has a list of beans in it since I won't know that list. Is there a way to have have spring scan a directory and create beans for every groovy file in there (at startup), and also do the refresh-check-delay so that it will rescan for new files and updated ones?

    Or am I asking for too much?

    Something like this?

        <lang:groovy id="groovyBeans"
              refresh-check-delay="5000" <!-- switches refreshing on with 5 seconds between checks -->
    Last edited by oggie; Jul 2nd, 2013, 01:58 PM.

  • #2
    I just noticed someone asked something similar here:

    So I have no problem annotating the .groovy files.

    1 -But can I also have the files implement a java interface? I want the java code to call these scripts by the interface.
    2 - Do I have to have the .groovy files in the classpath? I want them to be external from the deployed app.
    3 - How do I have it so that new or updated groovy files are picked up? Do I have to kick off another thread to reload the context every once in a while?