This way here it worked:
|
| class Parameters{
| void getInterval();
|
| }
|
|
| class Scheduler{
|
| @IgnoreDependency
| @EJB
| Executor executor;
|
|
| void schedule(){
| executor.schedule();
| }
|
|
| }
|
|
| class Executor{
|
| @EJB Parameter parameters;
|
| @EJB Scheduler scheduler;
|
| @TransactionAttribute(REQUIRES_NEW)
| void schedule(){
| schedule(parameter.getInterval());
|
| }
|
| void schedule(long interval){
| timerService.createTimer(interval, "myTimer");
| }
|
|
| @Timeout
| execute(Timer timer){
|
| // do lots of things
|
| scheduler.schedule();
|
| }
|
|
| }
|
|
| class Servlet{
|
| // not managed by container
| void contextInitialized(){
|
| Executor executor = lookup(...);
| executor.schedule();
|
| }
|
|
| }
|
|
what I cant understand is:
why it doesnt work if I call the "schedule" method of Executor inside the
"execute" method ?
reading again the responses I thought that the answer could be:
anonymous wrote :
| You are calling the schedule() method using a raw Java method call
because the "execute" method call the "schedule" method like a raw
java method, so it wont see the "REQUIRES_NEW" attribute...
but the example I posted above works, and the "REQUIRES_NEW" attribute has to be
above the "schedule" method (I testes changing it to the other schedule method
or putting it on both, but only this way at the example works)
and inside the schedule method, I use the datasource1 at "getInterval" and then
I call the method schedule
so... its strange this behavior for me....
someone who knows why can explain it please?
another interesting thing is: I was upset with the fact that I would have to use a
non-default jar (jboss-annotations-ejb3.jar) which includes the IgnoreDependency
annotation, but I tested it without this jar and it worked (strange)...
thanks again for your help... the problem is solved... I just wanna understand now
regards,
RRR
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4139662#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...