A patch from Peter Goron :"Allow user to give a name to the job he is scheduling" (https://issues.apache.org/jira/browse/OFBIZ-519)
git-svn-id: https://svn.apache.org/repos/asf/incubator/ofbiz/trunk@482807 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -45,8 +45,15 @@ public abstract class GenericAbstractDispatcher implements LocalDispatcher {
|
||||
* @see org.ofbiz.service.LocalDispatcher#schedule(java.lang.String, java.lang.String, java.util.Map, long, int, int, int, long, int)
|
||||
*/
|
||||
public void schedule(String poolName, String serviceName, Map context, long startTime, int frequency, int interval, int count, long endTime, int maxRetry) throws GenericServiceException {
|
||||
schedule(null, poolName, serviceName, context, startTime, frequency, interval, count, endTime, maxRetry);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.ofbiz.service.LocalDispatcher#schedule(java.lang.String, java.lang.String, java.lang.String, java.util.Map, long, int, int, int, long, int)
|
||||
*/
|
||||
public void schedule(String jobName, String poolName, String serviceName, Map context, long startTime, int frequency, int interval, int count, long endTime, int maxRetry) throws GenericServiceException {
|
||||
try {
|
||||
getJobManager().schedule(poolName, serviceName, context, startTime, frequency, interval, count, endTime, maxRetry);
|
||||
getJobManager().schedule(jobName, poolName, serviceName, context, startTime, frequency, interval, count, endTime, maxRetry);
|
||||
|
||||
if (Debug.verboseOn()) {
|
||||
Debug.logVerbose("[LocalDispatcher.schedule] : Current time : " + (new Date()).getTime(), module);
|
||||
|
||||
@@ -179,6 +179,24 @@ public interface LocalDispatcher {
|
||||
*/
|
||||
public void schedule(String poolName, String serviceName, Map context, long startTime, int frequency, int interval, int count, long endTime, int maxRetry) throws GenericServiceException;
|
||||
|
||||
/**
|
||||
* Schedule a service to run asynchronously at a specific start time.
|
||||
* @param jobName Name of the job
|
||||
* @param poolName Name of the service pool to send to.
|
||||
* @param serviceName Name of the service to invoke.
|
||||
* @param context The name/value pairs composing the context.
|
||||
* @param startTime The time to run this service.
|
||||
* @param frequency The frequency of the recurrence (RecurrenceRule.DAILY, etc).
|
||||
* @param interval The interval of the frequency recurrence.
|
||||
* @param count The number of times to repeat.
|
||||
* @param endTime The time in milliseconds the service should expire
|
||||
* @param maxRetry The number of times we should retry on failure
|
||||
* @throws ServiceAuthException
|
||||
* @throws ServiceValidationException
|
||||
* @throws GenericServiceException
|
||||
*/
|
||||
public void schedule(String jobName, String poolName, String serviceName, Map context, long startTime, int frequency, int interval, int count, long endTime, int maxRetry) throws GenericServiceException;
|
||||
|
||||
|
||||
/**
|
||||
* Schedule a service to run asynchronously at a specific start time.
|
||||
|
||||
@@ -309,11 +309,12 @@ public class JobManager {
|
||||
*@param endTime The time in milliseconds the service should expire
|
||||
*/
|
||||
public void schedule(String poolName, String serviceName, Map context, long startTime, int frequency, int interval, int count, long endTime) throws JobManagerException {
|
||||
schedule(null, serviceName, context, startTime, frequency, interval, count, endTime, -1);
|
||||
schedule(null, null, serviceName, context, startTime, frequency, interval, count, endTime, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule a job to start at a specific time with specific recurrence info
|
||||
*@param jobName The name of the job
|
||||
*@param poolName The name of the pool to run the service from
|
||||
*@param serviceName The name of the service to invoke
|
||||
*@param context The context for the service
|
||||
@@ -324,7 +325,7 @@ public class JobManager {
|
||||
*@param endTime The time in milliseconds the service should expire
|
||||
*@param maxRetry The max number of retries on failure (-1 for no max)
|
||||
*/
|
||||
public void schedule(String poolName, String serviceName, Map context, long startTime, int frequency, int interval, int count, long endTime, int maxRetry) throws JobManagerException {
|
||||
public void schedule(String jobName, String poolName, String serviceName, Map context, long startTime, int frequency, int interval, int count, long endTime, int maxRetry) throws JobManagerException {
|
||||
if (delegator == null) {
|
||||
Debug.logWarning("No delegator referenced; cannot schedule job.", module);
|
||||
return;
|
||||
@@ -347,7 +348,7 @@ public class JobManager {
|
||||
}
|
||||
|
||||
// schedule the job
|
||||
schedule(poolName, serviceName, dataId, startTime, frequency, interval, count, endTime, maxRetry);
|
||||
schedule(jobName, poolName, serviceName, dataId, startTime, frequency, interval, count, endTime, maxRetry);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -358,11 +359,12 @@ public class JobManager {
|
||||
*@param startTime The time in milliseconds the service should run
|
||||
*/
|
||||
public void schedule(String poolName, String serviceName, String dataId, long startTime) throws JobManagerException {
|
||||
schedule(poolName, serviceName, dataId, startTime, -1, 0, 1, 0, -1);
|
||||
schedule(null, poolName, serviceName, dataId, startTime, -1, 0, 1, 0, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule a job to start at a specific time with specific recurrence info
|
||||
*@param jobName The name of the job
|
||||
*@param poolName The name of the pool to run the service from
|
||||
*@param serviceName The name of the service to invoke
|
||||
*@param dataId The persisted context (RuntimeData.runtimeDataId)
|
||||
@@ -373,7 +375,7 @@ public class JobManager {
|
||||
*@param endTime The time in milliseconds the service should expire
|
||||
*@param maxRetry The max number of retries on failure (-1 for no max)
|
||||
*/
|
||||
public void schedule(String poolName, String serviceName, String dataId, long startTime, int frequency, int interval, int count, long endTime, int maxRetry) throws JobManagerException {
|
||||
public void schedule(String jobName, String poolName, String serviceName, String dataId, long startTime, int frequency, int interval, int count, long endTime, int maxRetry) throws JobManagerException {
|
||||
if (delegator == null) {
|
||||
Debug.logWarning("No delegator referenced; cannot schedule job.", module);
|
||||
return;
|
||||
@@ -391,7 +393,9 @@ public class JobManager {
|
||||
}
|
||||
|
||||
// set the persisted fields
|
||||
String jobName = new String(new Long((new Date().getTime())).toString());
|
||||
if (UtilValidate.isEmpty(jobName)) {
|
||||
jobName = new String(new Long((new Date().getTime())).toString());
|
||||
}
|
||||
String jobId = delegator.getNextSeqId("JobSandbox").toString();
|
||||
Map jFields = UtilMisc.toMap("jobId", jobId, "jobName", jobName, "runTime", new java.sql.Timestamp(startTime),
|
||||
"serviceName", serviceName, "recurrenceInfoId", infoId, "runtimeDataId", dataId);
|
||||
|
||||
@@ -199,6 +199,7 @@ public class CoreEvents {
|
||||
|
||||
Map params = UtilHttp.getParameterMap(request);
|
||||
// get the schedule parameters
|
||||
String jobName = (String) params.remove("JOB_NAME");
|
||||
String serviceName = (String) params.remove("SERVICE_NAME");
|
||||
String poolName = (String) params.remove("POOL_NAME");
|
||||
String serviceTime = (String) params.remove("SERVICE_TIME");
|
||||
@@ -396,7 +397,7 @@ public class CoreEvents {
|
||||
|
||||
// schedule service
|
||||
try {
|
||||
dispatcher.schedule(poolName, serviceName, serviceContext, startTime, frequency, interval, count, endTime, maxRetry);
|
||||
dispatcher.schedule(jobName, poolName, serviceName, serviceContext, startTime, frequency, interval, count, endTime, maxRetry);
|
||||
} catch (GenericServiceException e) {
|
||||
String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.service_dispatcher_exception", locale);
|
||||
request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg + e.getMessage());
|
||||
|
||||
@@ -19,6 +19,7 @@ under the License.
|
||||
xsi:noNamespaceSchemaLocation="http://www.ofbiz.org/dtds/widget-form.xsd">
|
||||
|
||||
<form name="scheduleJob" type="single" target="setServiceParameters" title="" default-title-style="tableheadtext" default-widget-style="inputBox" default-tooltip-style="tabletext">
|
||||
<field name="JOB_NAME" title="${uiLabelMap.WebtoolsJob}"><text/></field>
|
||||
<field name="SERVICE_NAME" title="${uiLabelMap.WebtoolsService}"><text/></field>
|
||||
<field name="POOL_NAME" title="${uiLabelMap.WebtoolsPool}"><text/></field>
|
||||
<field name="SERVICE_TIME" title="${uiLabelMap.CommonStartDateTime}"><date-time/></field>
|
||||
|
||||
Reference in New Issue
Block a user