Announcement Announcement Module
Collapse
No announcement yet.
Anyway to use a Request scoped bean inside of a quartz job? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Anyway to use a Request scoped bean inside of a quartz job?

    Hi,

    I've got a request scoped bean that I would like to use inside of a quartz job. I realize that I would not have access to the request objects, which is fine. To run Junit tests on my beans, I already declare custom scopes using:

    Code:
        <bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
            <property name="scopes">
                <map>
                    <entry key="request">
                        <bean class="org.springframework.context.support.SimpleThreadScope" />
                    </entry>
                </map>
            </property>
        </bean>
    Is there anyway I can inject a similar scope configurer into a bean used as a quartz job? My Job is currently defined as:
    Code:
    	<bean id="fwl.service.TrendLeaderArticleService.trigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    	 	<property name="cronExpression" value="0/30 * * * * ? *" />
    		<property name="jobDetail">
    			<bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    				<property name="name" value="fwl.service.TrendLeaderArticleService" />
    				<property name="group" value="news" />
    				<property name="targetObject" ref="trendLeaderArticleServiceImpl"/>
    				<property name="targetMethod" value="createTrendLeaderArticle"/>
    				<property name="concurrent" value="false" />
    			</bean>
    		</property>
    	</bean>
    Thanks!

    Eric

  • #2
    Quartz jobs are controlled separate threads, and knowing the dynamics of web applications and how threading is managed by the application server, I think the answer to your question is no, you can't.

    Comment

    Working...
    X