You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Borut Bolčina <bo...@gmail.com> on 2009/05/21 16:03:01 UTC

Re: T5 - Chenillekit Quartz & Services

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 <da...@murieston.com>

>
> 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: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: T5 - Chenillekit Quartz & Services

Posted by Christian Senk <se...@googlemail.com>.
Don't know how you use the JobDetail in the
Object implementing the Job interface by Quartz but in my
case the following call:

trigger.setJobDataMap(jobDetail.getJobDataMap());


was dispensable :) But this accidental i think.
Nice weekend to all readers ^.^

Borut Bolčina schrieb:
> 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 <se...@googlemail.com>
>
>   
>> 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 <da...@murieston.com>
>>>
>>>
>>>
>>>       
>>>> 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: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>         
>>>
>>>       
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>     
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5 - Chenillekit Quartz & Services

Posted by Borut Bolčina <bo...@gmail.com>.
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 <se...@googlemail.com>

> 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 <da...@murieston.com>
>>
>>
>>
>>> 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: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>
>>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: T5 - Chenillekit Quartz & Services

Posted by Christian Senk <se...@googlemail.com>.
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 <da...@murieston.com>
>
>   
>> 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: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>     
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org