Results 1 to 2 of 2

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

  1. #1

    Default 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. #2
    Join Date
    Jul 2010
    Location
    Venice, Italy
    Posts
    709

    Default

    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.

Tags for this Thread

Posting Permissions

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