1 25 package org.ofbiz.service; 26 27 import java.util.Date ; 28 import java.util.Map ; 29 30 import org.ofbiz.service.calendar.RecurrenceRule; 31 import org.ofbiz.entity.GenericDelegator; 32 import org.ofbiz.security.Security; 33 import org.ofbiz.service.jms.JmsListenerFactory; 34 import org.ofbiz.service.job.JobManager; 35 import org.ofbiz.service.job.JobManagerException; 36 import org.ofbiz.base.util.Debug; 37 38 45 public abstract class GenericAbstractDispatcher implements LocalDispatcher { 46 47 public static final String module = GenericAbstractDispatcher.class.getName(); 48 49 protected DispatchContext ctx = null; 50 protected ServiceDispatcher dispatcher = null; 51 protected String name = null; 52 53 public GenericAbstractDispatcher() {} 54 55 58 public void schedule(String poolName, String serviceName, Map context, long startTime, int frequency, int interval, int count, long endTime, int maxRetry) throws GenericServiceException { 59 try { 60 getJobManager().schedule(poolName, serviceName, context, startTime, frequency, interval, count, endTime, maxRetry); 61 62 if (Debug.verboseOn()) { 63 Debug.logVerbose("[LocalDispatcher.schedule] : Current time : " + (new Date ()).getTime(), module); 64 Debug.logVerbose("[LocalDispatcher.schedule] : Runtime : " + startTime, module); 65 Debug.logVerbose("[LocalDispatcher.schedule] : Frequency : " + frequency, module); 66 Debug.logVerbose("[LocalDispatcher.schedule] : Interval : " + interval, module); 67 Debug.logVerbose("[LocalDispatcher.schedule] : Count : " + count, module); 68 Debug.logVerbose("[LocalDispatcher.schedule] : EndTime : " + endTime, module); 69 Debug.logVerbose("[LocalDispatcher.schedule] : MazRetry : " + maxRetry, module); 70 } 71 72 } catch (JobManagerException e) { 73 throw new GenericServiceException(e.getMessage(), e); 74 } 75 } 76 77 80 public void schedule(String serviceName, Map context, long startTime, int frequency, int interval, int count, long endTime) throws GenericServiceException { 81 ModelService model = ctx.getModelService(serviceName); 82 schedule(null, serviceName, context, startTime, frequency, interval, count, endTime, model.maxRetry); 83 } 84 85 88 public void schedule(String serviceName, Map context, long startTime, int frequency, int interval, int count) throws GenericServiceException { 89 schedule(serviceName, context, startTime, frequency, interval, count, 0); 90 } 91 92 95 public void schedule(String serviceName, Map context, long startTime, int frequency, int interval, long endTime) throws GenericServiceException { 96 schedule(serviceName, context, startTime, frequency, interval, -1, endTime); 97 } 98 99 102 public void schedule(String serviceName, Map context, long startTime) throws GenericServiceException { 103 schedule(serviceName, context, startTime, RecurrenceRule.DAILY, 1, 1); 104 } 105 106 109 public JobManager getJobManager() { 110 return dispatcher.getJobManager(); 111 } 112 113 116 public JmsListenerFactory getJMSListeneFactory() { 117 return dispatcher.getJMSListenerFactory(); 118 } 119 120 123 public GenericDelegator getDelegator() { 124 return dispatcher.getDelegator(); 125 } 126 127 130 public Security getSecurity() { 131 return dispatcher.getSecurity(); 132 } 133 134 137 public String getName() { 138 return this.name; 139 } 140 141 144 public DispatchContext getDispatchContext() { 145 return ctx; 146 } 147 148 151 public void deregister() { 152 dispatcher.deregister(this); 153 } 154 155 158 public void registerCallback(String serviceName, GenericServiceCallback cb) { 159 dispatcher.registerCallback(serviceName, cb); 160 } 161 } 162 163 | Popular Tags |