1 22 package org.jboss.ejb3.timerservice; 23 24 import javax.ejb.EJBException ; 25 import javax.ejb.TimerService ; 26 import javax.management.ObjectName ; 27 28 34 public abstract class TimerServiceFactory 35 { 36 private static TimerServiceFactory instance; 37 38 private synchronized static TimerServiceFactory createInstance() 39 { 40 if(instance != null) 41 return instance; 42 43 String factoryClass = "org.jboss.ejb3.timerservice.jboss.JBossTimerServiceFactory"; 44 factoryClass = System.getProperty("org.jboss.ejb3.timerservice.factory", factoryClass); 45 46 try 47 { 48 Class cls = Class.forName(factoryClass); 49 instance = (TimerServiceFactory) cls.newInstance(); 50 51 return instance; 52 } 53 catch(ClassNotFoundException e) 54 { 55 throw new EJBException (e); 56 } 57 catch(InstantiationException e) 58 { 59 throw new EJBException (e); 60 } 61 catch(IllegalAccessException e) 62 { 63 throw new EJBException (e); 64 } 65 } 66 67 public abstract TimerService createTimerService(ObjectName objectName, TimedObjectInvoker invoker); 68 69 public static TimerServiceFactory getInstance() 70 { 71 if(instance == null) 72 { 73 createInstance(); 74 } 75 76 return instance; 77 } 78 79 public abstract void removeTimerService(TimerService timerService); 80 81 86 public abstract void restoreTimerService(TimerService timerService); 87 } 88 | Popular Tags |