Announcement Announcement Module
Collapse
No announcement yet.
Dynamically read config/context when WAR is deployed Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dynamically read config/context when WAR is deployed

    I am using the spring Task Execution and scheduling framework. I would like to setup one scheduler in my application-context.xml:

    Code:
    <task:scheduler id="scheduler" pool-size="10"/>
    I have a couple of JARs (one.jar, two.jar) that are deployed in my WAR that are going to wire to the scheduler. I would like to make the existence of the JARs setup the scheduled tasks for my scheduler. I.E. if I one deploy one.jar then I only want the timers to fire for that jar.

    I can use the @Scheduled annotation to accomplish this, but then the problem is that my timer fire values are hard coded in the code.

    Is there any way that I can put config in each jar

    jar.one
    -- > one-scheduler.xml
    Code:
    <task:scheduled-tasks scheduler="myScheduler">
        <task:scheduled ref="oneObject" method="someMethod" fixed-delay="5000"/>
    </task:scheduled-tasks>
    two.jar
    -- > two-scheduler.xml
    Code:
    <task:scheduled-tasks scheduler="myScheduler">
        <task:scheduled ref="twoObject" method="someMethod" fixed-delay="10000"/>
    </task:scheduled-tasks>
    Such that spring will pick up on the fact that a jar is deployed and read its .xml file to setup the scheduled tasks?

    I think that I can 'import' those files but that is not dynamic.

    I like the idea of xml files as at build time I can run substitution to make my timers a little more configurable at build time.
    Code:
    <task:scheduled-tasks scheduler="myScheduler">
        <task:scheduled ref="twoObject" method="someMethod" fixed-delay="${some.property.value}"/>
    </task:scheduled-tasks>
    Thanks.

  • #2
    Which version are you using? If Spring 3.1 or later, you can resort to the Profiles feature.
    Beside that option, if you build your app with ant, you could finish the substitution task in ant. Maven also has its means to do this.

    Comment

    Working...
    X