Well, I'm using Quartz to schedule some jobs that I need in my application. But, I need some way to access a Stateful SessionBean on my Job. I knew that I can't inject it with @EJB. Can anyone help me? Thanks.
相关问题
- How to configure quartz scheduler with spring-styl
- How to override quartz's property value
- JBoss 7.1.1 and the EJB 3.1 Timer Service
- Quartz.Net cron trigger to schedule a job every 45
- Best way to expose business logic to restful servi
相关文章
- @Singleton @Startup @PostConstruct method guarante
- Quartz vs Java EE 7 scheduler
- Grails and Quartz: Bad value for type long
- Dynamically scheduling jobs: using cron trigger in
- use verify on mocked (with Mockito) objects inject
- what is the purpose of including empty beans.xml i
- Maven 2 & Packaging ejb vs jar
- Scheduled processes running twice simultaneously i
A simple solution would be to lookup the EJB via JNDI in the Job implementation.
I have done this in a current application I am developing on Glassfish 3.1.
I used the EJB3InvokerJob to invoke the methods of my EJB. Then I created my jobs that extends the EJB3InvokerJob, put the parameters of what EJB and method it should call and then call the super.execute().
The EJB3InvokerJob can be found here: http://jira.opensymphony.com/secure/attachment/13356/EJB3InvokerJob.java
My Job is looking like this:
And my EJB is like this:
I expect to help someone.
you can do that simply by lookup the EJB via JNDI in the Job implementation. In particular, the JNDI name will be:
where
name_of_businessInterface
is the fully qualified name of the business interface of this session bean. For example, if you specifymappedName="bank"
and the fully qualified name of the business interface iscom.CheckingAccount
, then the JNDI of the business interface isbank#com.CheckingAccount
.Code Example: