Spring bean method call

I have declared the following bean in my Spring config

<bean id="templateCacheClearingTask" class="org.springframework.scheduling.timer.ScheduledTimerTask">
    <property name="delay" value="5000" />
    <property name="period" value="5000" />

    <property name="timerTask">
        <bean class="org.springframework.scheduling.timer.MethodInvokingTimerTaskFactoryBean">
            <property name="targetObject" ref="templateMailService" />
            <property name="targetMethod" value="clearCache" />
        </bean>
    </property>
</bean>

      

This should call the clearCache()

templateMailService

bean method to be called every 5000ms, but nothing happens. Did I miss something?

Cheers, Don

0


source to share


1 answer


I think you need:

<bean id="timerFactory" class="org.springframework.scheduling.timer.TimerFactoryBean">
  <property name="scheduledTimerTasks">
    <list>
      <ref bean="templateCacheClearingTask"/>
    </list>
  </property>
</bean>

      



In addition to what you already have.

+5


source







All Articles