You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Daniel Jones <da...@murieston.com> on 2009/03/30 18:25:00 UTC

T5 - Chenillekit Quartz & Services

I have followed the quartz example on the chenillekit site and I can run a
simple job.  How would I go about injecting a service into one of my jobs.

	public static void contributeSchedulerFactory(MappedConfiguration<String,
Resource> configuration) {
		Resource configResource = new ClasspathResource("quartz.properties");
		configuration.add("quartz.properties", configResource);
	}

	public static void
contributeQuartzSchedulerManager(OrderedConfiguration<JobSchedulingBundle>
configuration) {
		configuration.add("importEmailToArchive", new
ImportEmailToArchiveBundle(new EmailArchiveImporter()));
	}

I want to inject a service into EmailArchiveImporter.

Cheers,
Daniel
-- 
View this message in context: http://www.nabble.com/T5---Chenillekit-Quartz---Services-tp22787045p22787045.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


Re: T5 - Chenillekit Quartz & Services

Posted by Borut Bolčina <bo...@gmail.com>.
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 Sven Homburg <ho...@googlemail.com>.
possible it helps

public class ImportEmailToArchive implements Job
{
    private final Logger logger =
LoggerFactory.getLogger(ImportEmailToArchive.class);

    @CommitAfter
    public void execute(JobExecutionContext jobExecutionContext) throws
JobExecutionException
    {
        PerthreadManager perthreadManager = (PerthreadManager)
jobExecutionContext.getMergedJobDataMap().get("perthreadManager");
        EmailArchiveImporter importer = (EmailArchiveImporter)
jobExecutionContext.getMergedJobDataMap().get("importer");

        if (logger.isInfoEnabled())
            logger.info("starting email importer ...");

        try
        {
            importer.importMessages();
        }
        finally
        {
            perthreadManager.cleanup();
        }

        if (logger.isInfoEnabled())
            logger.info("email importer finished");
    }
}

    public EmailArchiveImporterImpl(Logger logger,
                                    SearcherService ldapSearchService,
                                    HibernateSessionManager
hibernateSessionManager,
                                    Resource configResource)
    {
        this.logger = logger;
        this.ldapSearchService = ldapSearchService;
        this.hibernateSessionManager = hibernateSessionManager;

        try
        {
            this.configuration = new
PropertiesConfiguration(configResource.toURL());
        }
        catch (ConfigurationException e)
        {
            throw new RuntimeException(e);
        }
    }


2009/3/31 Daniel Jones <da...@murieston.com>

>
> Is there a more elegant solution than this?  If so please share!
>
> Cheers,
> Dan
> --
> View this message in context:
> http://www.nabble.com/T5---Chenillekit-Quartz---Services-tp22787045p22805264.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
>
>


-- 
with regards
Sven Homburg
http://www.chenillekit.org
http://tapestry5-components.googlecode.com

Re: T5 - Chenillekit Quartz & Services

Posted by Jonathan Barker <jo...@gmail.com>.
Dan,

I can't call this elegant, but I prefer it to passing dao's in the
JobDataMap..

I use Spring with Tapestry, and the SpringAwareStatefulJob from Spring that
makes it easy to access the Spring application context.  So, I still need to
look up things that I'm accustomed to having injected, but I usually look up
a service in the Job, and Spring handles injecting the dependencies for that
service.

Jonathan

On Tue, Mar 31, 2009 at 2:16 PM, Daniel Jones <da...@murieston.com> wrote:

>
> Is there a more elegant solution than this?  If so please share!
>
> Cheers,
> Dan
> --
> View this message in context:
> http://www.nabble.com/T5---Chenillekit-Quartz---Services-tp22787045p22805264.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
>
>


-- 
Jonathan Barker
ITStrategic

Re: T5 - Chenillekit Quartz & Services

Posted by Daniel Jones <da...@murieston.com>.
Is there a more elegant solution than this?  If so please share!

Cheers,
Dan
-- 
View this message in context: http://www.nabble.com/T5---Chenillekit-Quartz---Services-tp22787045p22805264.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 Massimo Lusetti <ml...@gmail.com>.
On Tue, Mar 31, 2009 at 7:58 AM, Inge Solvoll <in...@gmail.com> wrote:

> Is that thread safe, putting the service in a map in non-service class?

JobExecutionContext is made available by Quarz just to store job's
context information and while jobs are executed in an separate thread
i think that should be the case, didn't check right down the code.

Ciao.
-- 
Massimo
http://meridio.blogspot.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 Inge Solvoll <in...@gmail.com>.
Is that thread safe, putting the service in a map in non-service class?

On Tue, Mar 31, 2009 at 3:02 AM, Daniel Jones <da...@murieston.com> wrote:

>
> 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 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 "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 30 Mar 2009 16:18:18 -0300, Daniel Jones <da...@murieston.com>  
escreveu:

> Thanks for the quick reply Thiago!

You're welcome!

> student.tracking.quartz.EmailArchiveImporter
> 	at java.lang.Class.newInstance0(Class.java:340)
> 	at java.lang.Class.newInstance(Class.java:308)
> 	at org.quartz.simpl.SimpleJobFactory.newJob(SimpleJobFactory.java:55)
> 	... 2 more
> 30-Mar-2009 20:07:00 org.quartz.simpl.RAMJobStore triggeredJobComplete
> INFO: All triggers of Job DEFAULT.ImportEmailToArchive set to ERROR  
> state.
>
> Quartz is trying to instantiate my class it seems.  I'm following
> http://www.chenillekit.org/chenillekit-quartz/index.html

I have never used Quartz, but you can create a setDataSource method in  
EmailArchiveImporter and pass the data source through it in the contribute  
method instead of passing it by construtor.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

---------------------------------------------------------------------
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 Daniel Jones <da...@murieston.com>.
Thanks for the quick reply Thiago!

I have already tried what you suggested and I get a stack trace:

public static void
contributeQuartzSchedulerManager(OrderedConfiguration<JobSchedulingBundle>
configuration, @InjectService("DataSource") IDataSource pDataSource) {
		configuration.add("importEmailToArchive", new
ImportEmailToArchiveBundle(new EmailArchiveImporter(pDataSource)));
	}

Stack trace:

SEVERE: An error occured instantiating job to be executed. job=
'DEFAULT.ImportEmailToArchive'
org.quartz.SchedulerException: Problem instantiating class
'student.tracking.quartz.EmailArchiveImporter' [See nested exception:
java.lang.InstantiationException:
student.tracking.quartz.EmailArchiveImporter]
	at org.quartz.simpl.SimpleJobFactory.newJob(SimpleJobFactory.java:57)
	at org.quartz.core.JobRunShell.initialize(JobRunShell.java:132)
	at
org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:358)
Caused by: java.lang.InstantiationException:
student.tracking.quartz.EmailArchiveImporter
	at java.lang.Class.newInstance0(Class.java:340)
	at java.lang.Class.newInstance(Class.java:308)
	at org.quartz.simpl.SimpleJobFactory.newJob(SimpleJobFactory.java:55)
	... 2 more
30-Mar-2009 20:07:00 org.quartz.simpl.RAMJobStore triggeredJobComplete
INFO: All triggers of Job DEFAULT.ImportEmailToArchive set to ERROR state.

Quartz is trying to instantiate my class it seems.  I'm following
http://www.chenillekit.org/chenillekit-quartz/index.html

Any ideas?  It's just the service injection part thats tripping me up.

Cheers,
Daniel

-- 
View this message in context: http://www.nabble.com/T5---Chenillekit-Quartz---Services-tp22787045p22790830.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 "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 30 Mar 2009 13:25:00 -0300, Daniel Jones <da...@murieston.com>  
escreveu:

> I want to inject a service into EmailArchiveImporter.

If EmailArchiveImporter is a Tapestry service, normal service injection  
applies. If it isn't and you don't want to make it a service, just add the  
needed services as parameters to your method:

public static void  
contributeQuartzSchedulerManager(OrderedConfiguration<JobSchedulingBundle>  
configuration, SomeService someService) {
	configuration.add("importEmailToArchive", new  
ImportEmailToArchiveBundle(new EmailArchiveImporter(someService)));
}

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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