There are a few ways to do this:

1) The JobDetailBean has a method called setApplicationContextJobDataKey
which will set a reference to the ApplicationContext in the job data map.
This will make the JobDetailBean call the setter for the application context
on your bean.
2) (Probably the better method if you rely on Spring to wire up your job
beans):  Rather than the  JobDetailBean, use the
MethodInvokingJobDetailFactoryBean, which will call a method on a named bean
to fire the job.

Mike

On 1/21/07, jmowla <[EMAIL PROTECTED]> wrote:


Mike,
i got the problem during pasting the code ;)
really, i have a job that i tried to activate that every 1 min by using
quartz.
during configuration of the quartz to run this job, i had to send the name
of the class by value, like this:


>     <bean name="rejectOrderAction"
> class="org.springframework.scheduling.quartz.JobDetailBean">
>         <property name="name" value="rejectOrderAction"/>
>         <property name="jobClass"
> value="org.citd.peik.service.job.RejectOrderJob"/>
>     </bean>
>
>     <bean name="rejectOrderTrigger"
> class="org.springframework.scheduling.quartz.SimpleTriggerBean">
>         <property name="jobDetail" ref="rejectOrderAction"/>
>         <property name="startDelay" value="15000"/>
>         <property name="repeatInterval" value="60000"/>
>     </bean>
>
>     <bean name="rejectOrderSchedular"
> class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
>         <property name="triggers">
>             <list>
>                 <ref bean="rejectOrderTrigger"/>
>             </list>
>         </property>
>     </bean>
>

because of <property name="jobClass"
value="org.citd.peik.service.job.RejectOrderJob"/> the class newed every
time that timeout occured by quartz not by spring, because of that
applicationContext never initialized by container :)
and i can not use ref to bean rejectOrderJob, because jobClass expected a
type of Class, then i can not define a bean of type RejectOrderJob and
pass
the ref to jobClass :(
i need some beans in RejectOrderJob, how can i access deired beans? :(
thanks


Michael Horwitz wrote:
>
> Perhaps if you post the code of your service bean class we could help?
>
> On 1/20/07, jmowla <[EMAIL PROTECTED]> wrote:
>>
>>
>> Mike
>> i do that way, but applicationContext is still null, i'm just confused.
>> any
>> more advice?
>> thanks
>>
>>
>> Michael Horwitz wrote:
>> >
>> > One approach would be to declare your service layer been to be
>> application
>> > context aware: implements ApplicationContextAware. Spring will
>> > automatically
>> > pass in the application context to any bean that implements this
>> > interface.
>> >
>> > Mike
>> >
>> > On 1/20/07, jmowla <[EMAIL PROTECTED]> wrote:
>> >>
>> >>
>> >> hi all
>> >> i'm using appfuse 1.9.4 (springmvc+spirng+hibernate) and want to get
a
>> >> bean
>> >> programatically by using 'getBean()' method in simple java class in
>> >> service
>> >> layer. how can i get a valid ApplicationContext class? or how can i
do
>> >> that
>> >> ( except wiring )
>> >> thanks in advanced
>> >> --
>> >> View this message in context:
>> >>
>>
http://www.nabble.com/accesing-bean-in-servcie-layer-tf3044538s2369.html#a8463190
>> >> Sent from the AppFuse - User mailing list archive at Nabble.com.
>> >>
>> >>
---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >> For additional commands, e-mail: [EMAIL PROTECTED]
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>>
http://www.nabble.com/accesing-bean-in-servcie-layer-tf3044538s2369.html#a8465949
>> Sent from the AppFuse - User mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>

--
View this message in context:
http://www.nabble.com/accesing-bean-in-servcie-layer-tf3044538s2369.html#a8472072
Sent from the AppFuse - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Reply via email to