views:

1135

answers:

1

Hi,

I've 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 cause the clearCache() method of the templateMailService bean to be invoked every 5000ms, but nothing appears to be happening. Am I missing something?

Cheers, Don

+4  A: 

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.

digitalsanctum