[jboss-user] [JBoss Seam] - Re: How to get EntityManager without @In?
nhieb
do-not-reply at jboss.com
Fri Aug 31 06:14:42 EDT 2007
Why don't u use EJB3 timers? You can create timer that will do ur "housekeeping" work, and it will survive redeploys and server shutdown. Besides, in this case EM will be accessible automatically.
try something like this
@Stateless
| @Name("jobsTimer")
| public class JobsTimerIMPL implements JobsTimer {
| @Resource
| javax.ejb.TimerService timerService;
|
| @In
| EntityManager entityManager;
|
| @Logger
| private Log log;
|
| public void createTimer() {
| Timer timer = timerService.createTimer(5, 5, "timer that fires every 5 sec and starts 5 sec after it was created");
| }
|
| @Timeout
| public void timeout(Timer timer) {
| //em must be automatically accessable here
| log.info(em);
| }
|
So create timer with createTimer method, and then timeout method wll be called every 5 sec
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4079915#4079915
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4079915
More information about the jboss-user
mailing list