[jboss-user] [EJB/JBoss] - Re: Scheduler vs. EJB Timer Service

torf do-not-reply at jboss.com
Fri Jan 12 06:53:49 EST 2007


Hi,

this is our Schedulable implementation:

  | package de.mobilcom.messenger.scheduler;
  | 
  | public class TimedObjectSchedulableRemote implements Schedulable {
  | 	private String sRemoteHomeName;
  | 	private our.company.framework.timer.TimedObjectRemote rTimedObject;
  | 
  | 	// will be invoked by jboss with configured arg "ejb/MySchedulerTimer"
  | 	public TimedObjectSchedulableRemote(String sRemoteHomeName) {
  | 		this.sRemoteHomeName = sRemoteHomeName;
  | 	}
  | 
  | 	public void perform(Date rDate, long nValue) {
  | 		try {
  | 			if (rTimedObject == null) {
  | 				// get MySchedulerTimer SLSB's home
  | 				Context rInitialContext = new InitialContext();
  | 				Object rHome = rInitialContext.lookup(sRemoteHomeName);
  | 
  | 				// call rHome.create() via refection to obtain remote SLSB instance
  | 				Method rMethod = rHome.getClass().getDeclaredMethod("create", new Class[0]);
  | 				rTimedObject = (our.company.framework.timer.TimedObjectRemote)
  | 					rMethod.invoke(rHome, new Object[0]);
  | 			}
  | 
  | 			// call SLSB business method
  | 			rTimedObject.onTimeout();
  | 		}
  | 		catch (Exception eEx) {
  | 			... // logging
  | 			rTimedObject = null; // reset invalid timed object reference
  | 		}
  | 	}
  | }
  | 

Every SLSB intended for invocation via Scheduler implements interface our.company.framework.timer.TimedObjectRemote whose only method is void onTimeout() throws RemoteException.

HTH,
Christoph

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4000869#4000869

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4000869



More information about the jboss-user mailing list