tags:

views:

23

answers:

1

How can I implement a timer on JBoss 4.2.2 in a vendor independent way.

Requirements:

  • trigger logic in a defined interval
  • start the timer at startup
  • no dependencies to JBoss specific libraries / functionality
  • do not use a servlet to start the timer

But I see only this possibilites:

  1. Implement the interface org.jboss.varia.scheduler.Schedulable

  2. Use ejb3 combined with a MBean (MBean for starting the timer)

  3. Use javax.management.timer.Timer as MBean

A: 

Ok my solution at the end was this:

@Service(objectName = "scheduler.test:service=CommonSchedulerTimer")
@Remote(Scheduler.class)
public class SchedulerTimerBean implements Scheduler, SchedulerManagement {

@Timeout
public void timeoutHandler(Timer timer) {

What is it:

  • Stateless Session Bean
  • Timer Bean
  • MBean

What is not vendor independent:

  • the service annotation

But I didn't found a vendor independent way to access the ejb from a separate MBean. The Problem was the order of initalitation of beans, i couldn't configure, that the MBean must be loaded after the EJB in clean way.

haschibaschi