Thanks!
jobDetail = new JobDetail("AccountRemoverJob",
Scheduler.DEFAULT_GROUP, AccountRemoverJob.class);
jobDetail.getJobDataMap().put("accountRemover", accountRemover);
trigger.setJobDataMap(jobDetail.getJobDataMap());
did the trick.
-Borut
2009/5/21 Christian Senk <[email protected]>
> Hi,
>
> i recently used this module by chenillekit also.
> I think you use the JobDataMap in a wrong way.
>
> Instantiate the JobDetail and then use the JobDataMap from the jobDetail.
>
> jobDetail = new JobDetail("AccountRemoverJob", Scheduler.DEFAULT_GROUP,
> AccountRemoverJob.class);
>
> jobDetail.getJobDataMap().put(...);
>
> It works for me.
> Greetings :)
>
> Borut Bolčina schrieb:
>
> Hi,
>>
>> I am trying to get a reference to one of my services in the class which
>> implements the Job interface, but getting NPE because
>>
>> AccountRemover accountRemover = (AccountRemover)
>> map.get("accountRemover");
>> accountRemover.removeOldNonVerifiedAccounts();
>>
>> accountRemover is null.
>>
>> AppModule.java
>> ============
>> public static void bind(ServiceBinder binder) {
>> binder.bind(AccountRemover.class);
>> }
>>
>> public static void contributeQuartzSchedulerManager(AccountRemover
>> accountRemover,
>> OrderedConfiguration<JobSchedulingBundle> configuration) {
>> configuration.add("removeOldNonverifiedAccounts", new
>> RemoveOldNonverifiedAccountsBundle(accountRemover));
>> }
>>
>> RemoveOldNonverifiedAccountsBundle.java
>> ===============================
>> public class RemoveOldNonverifiedAccountsBundle implements
>> JobSchedulingBundle {
>> private JobDetail jobDetail;
>> private Trigger trigger;
>> private final Logger logger =
>> LoggerFactory.getLogger(RemoveOldNonverifiedAccountsBundle.class);
>> private final AccountRemover accountRemover;
>>
>> public RemoveOldNonverifiedAccountsBundle(AccountRemover
>> accountRemover)
>> {
>> this.accountRemover = accountRemover;
>> createBundle();
>> }
>>
>> private void createBundle() {
>> logger.info("Creating bundle");
>> // long period = 3 * 24 * 60 * 60 * 1000;
>> long period = 5000;
>>
>> trigger = new SimpleTrigger("AccountRemoverJobTrigger",
>> Scheduler.DEFAULT_GROUP, new Date(), null,
>> SimpleTrigger.REPEAT_INDEFINITELY, period);
>>
>> JobDataMap jobDataMap = new JobDataMap();
>> logger.info("accountRemover:"+accountRemover);
>> jobDataMap.put("accountRemover", accountRemover);
>> trigger.setJobDataMap(jobDataMap);
>>
>> jobDetail = new JobDetail("AccountRemoverJob",
>> Scheduler.DEFAULT_GROUP, AccountRemoverJob.class);
>> }
>>
>> ...
>> }
>>
>>
>> The log file prints:
>> INFO [21 maj 2009 15:19:42.182] [RemoveOldNonverifiedAccountsBundle]
>> accountRemover:<Proxy for
>> AccountRemover(si.najdi.identity.server.services.AccountRemover)>
>>
>>
>> What have I wired wrong? I am using 5.0.18.
>>
>> Thanks,
>> Borut
>>
>>
>> 2009/3/31 Daniel Jones <[email protected]>
>>
>>
>>
>>> Got this working in the end.
>>>
>>> Put my service reference in the JobDataMap and accessed it like this from
>>> within the job.
>>>
>>> public void execute(JobExecutionContext pContext) throws
>>> JobExecutionException {
>>> IDataSource aDataSource = (IDataSource)
>>> pContext.getJobDetail().getJobDataMap().get("datasource");
>>> aDataSource.updateFromEmail();
>>> }
>>>
>>> Daniel
>>> --
>>> View this message in context:
>>>
>>> http://www.nabble.com/T5---Chenillekit-Quartz---Services-tp22787045p22796363.html
>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>>
>>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>