-
1. Re: How to persist an object in Asynchronous method in a cron job
pgmjsd Jun 22, 2011 6:12 AM (in response to lsqfjbn)I think you probably meant to use the Seam-Managed EntityManager with @Inject. I'm not sure if @PersistenceContext works outside of an EJB.
-
2. Re: How to persist an object in Asynchronous method in a cron job
pgmjsd Jun 22, 2011 6:24 AM (in response to lsqfjbn)Ah, I was mistaken: @PersistenceContext can be used outside of an EJB. But, I'm sure that the transaction management won't be handled. I still think using the persistence module is the way to go.
-
3. Re: How to persist an object in Asynchronous method in a cron job
ssachtleben.ssachtleben.gmail.com Jun 22, 2011 6:28 AM (in response to lsqfjbn)@PersistenceContext works fine without EJB.
But I think you Problem is here:
Executor e = new Executor();
The entity manager will not inject if you create your class due constructor.
Try to use this which should inject the bean properly:
public void schedule(@Observes @Every(nth=10, value=Interval.SECOND) Trigger t, Executor e){ for (TestRunner runner: pendingRunners){ e.run(runner); } }
or
@Inject Executor e;
-
4. Re: How to persist an object in Asynchronous method in a cron job
lsqfjbn Jun 22, 2011 9:01 AM (in response to lsqfjbn)If I use
@Inject Executor e;
there will be only one Executor instance, right?
But what I want is in the 'for' statement, each runner can have one Executor instance and execute in parallel.
-
5. Re: How to persist an object in Asynchronous method in a cron job
lightguard Jun 22, 2011 3:17 PM (in response to lsqfjbn)Try @Inject Instance<Executor> and use the Instance API.
-
6. Re: How to persist an object in Asynchronous method in a cron job
lsqfjbn Jun 22, 2011 9:50 PM (in response to lsqfjbn)
Jason Porter wrote on Jun 22, 2011 15:17:
Try @Inject Instance<Executor> and use the Instance API.That works perfectly!
Thank you!