Results 1 to 3 of 3

Thread: Container not setting ApplicationEventPublisher

  1. #1
    Join Date
    Jun 2007
    Posts
    4

    Default Container not setting ApplicationEventPublisher

    Hi,

    I have a class which implements ApplicationEventPublisherAware and is supposed to periodically publish an ApplicationEvent.

    The problem is my application context does not appear to be automatically setting the ApplicationEventPublisher in this object as it should.

    Below is the bean configuration which should give you an idea as to what im trying to do.

    Any help greatly appreciated!

    <!-- System Status Heartbeat -->
    <bean name="heartBeatJob" class="org.springframework.scheduling.quartz.JobDe tailBean">
    <property name="jobClass" value="com.utilities.heartbeat.HeartBeatTask" />
    </bean>

    <bean id="heartBeatTrigger" class="org.springframework.scheduling.quartz.Simpl eTriggerBean">
    <!-- see the example of method invoking job above -->
    <property name="jobDetail" ref="heartBeatJob" />

    <!-- 10 seconds -->
    <property name="startDelay" value="5000" />

    <!-- repeat every 50 seconds -->
    <property name="repeatInterval" value="1000" />
    </bean>

    <bean id="scheduler" class="org.springframework.scheduling.quartz.Sched ulerFactoryBean">
    <property name="triggers">
    <list>
    <ref bean="heartBeatTrigger" />
    </list>
    </property>
    </bean>


    <bean id="heartBeatForwarder" class="com.utilities.HeartBeat" />

  2. #2
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Which class implements the ApplicationEventPublisherAware interface? Is it possible to see the code for what you are doing? It always helps to use [code] [ /code] tags as well!
    Last edited by karldmoore; Aug 29th, 2007 at 11:08 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  3. #3
    Join Date
    Mar 2005
    Location
    The Netherlands
    Posts
    121

    Default

    Please read the APIDocs for the JobDetailBean:
    In the setApplicationContextJobDataKey docs the following is stated:
    Note that BeanFactory callback interfaces like ApplicationContextAware are not automatically applied to Quartz Job instances, because Quartz itself is responsible for the lifecycle of its Jobs.
    So, configure this property (applicationContextJobDataKey) and set it to "applicationEventPublisher": I think that will do the trick, since the ApplicationContext extends ApplicationEventPublisher. Like the API docs state, set it on the SchedulerContext instead if you're using a persistent job that stores its state in a database.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •