Configure Spring to turn Quartz scheduler on/off

This is a way to use Spring’s PropertyPlaceholderConfigurer to turn Quartz Scheduler on and off based on a properties file.

This way an application can be configurable using only the properties file exclusive of changing xml documents.

XML File:

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>classpath:configuration/app.properties</value>
        </list>
    </property>
    <property name="ignoreUnresolvablePlaceholders" value="true"/>
</bean>

<!-- Scheduling START -->
<bean id="chrisJobDetailBean" class="org.springframework.scheduling.quartz.JobDetailBean">
    <property name="jobClass" value="sample.springquartz.chris.chrisJob" />
    <property name="jobDataAsMap">
        <map>
            <entry key="sampleBean" value-ref="sampleBean"/>
        </map>
    </property>
</bean>

<bean id="chrisCronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    <property name="jobDetail" ref="chrisJobDetailBean" />
    <property name="cronExpression" value="0 0/5 * * * ?" /><!-- Fire at every 5 minutes -->
</bean>

<bean id="chrisFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="autoStartup" value="${chrisScheduler.autoStartup}"/>
    <property name="jobFactory" ref="springBeanJobFactory" />
    <property name="taskExecutor" ref="workManager" />
    <property name="triggers">
        <list>
            <ref bean="chrisCronTrigger"/>
        </list>
    </property>
</bean>

<bean id="springBeanJobFactory" class="org.springframework.scheduling.quartz.SpringBeanJobFactory"/>

<bean id="workManager"
    class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor">
    <property name="workManagerName" value="wm/default" />
</bean>
<!-- Scheduling END -->

app.properties file:

chrisScheduler.autoStartup=false
 
70
Kudos
 
70
Kudos

Now read this

Using URL.createObjectURL()

This is a blog post about using the Web API URL.createObjectURL(). Here we will go through the use cases as well as the inner intricacies of what this Web API does. First up lets see how to use the API. URL.createObjectURL() # Syntax... Continue →