Author: jaz
Date: Wed May 16 10:36:19 2007 New Revision: 538659 URL: http://svn.apache.org/viewvc?view=rev&rev=538659 Log: fixed Job Manager so that disabled setting still loads the manager and performs async tasks, just does not enable the poller Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GenericAsyncEngine.java ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobManager.java ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobPoller.java Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java?view=diff&rev=538659&r1=538658&r2=538659 ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java Wed May 16 10:36:19 2007 @@ -94,15 +94,14 @@ } } - // make sure we haven't disabled these features from running - if (enableJM) { - try { - this.jm = new JobManager(this.delegator); - } catch (GeneralRuntimeException e) { - Debug.logWarning(e.getMessage(), module); - } + // job manager needs to always be running, but the poller thread does not + try { + this.jm = new JobManager(this.delegator, enableJM); + } catch (GeneralRuntimeException e) { + Debug.logWarning(e.getMessage(), module); } + // make sure we haven't disabled these features from running if (enableJMS) { this.jlf = new JmsListenerFactory(this); } Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GenericAsyncEngine.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GenericAsyncEngine.java?view=diff&rev=538659&r1=538658&r2=538659 ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GenericAsyncEngine.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GenericAsyncEngine.java Wed May 16 10:36:19 2007 @@ -42,6 +42,7 @@ import org.ofbiz.service.job.GenericServiceJob; import org.ofbiz.service.job.Job; import org.ofbiz.service.job.JobManagerException; +import org.ofbiz.service.job.JobManager; /** * Generic Asynchronous Engine @@ -141,13 +142,18 @@ Debug.logInfo("Persisted job queued : " + jobV.getString("jobName"), module); } } else { - String name = Long.toString(new Date().getTime()); - String jobId = modelService.name + "." + name; - job = new GenericServiceJob(dctx, jobId, name, modelService.name, context, requester); - try { - dispatcher.getJobManager().runJob(job); - } catch (JobManagerException jse) { - throw new GenericServiceException("Cannot run job.", jse); + JobManager jMgr = dispatcher.getJobManager(); + if (jMgr != null) { + String name = Long.toString(new Date().getTime()); + String jobId = modelService.name + "." + name; + job = new GenericServiceJob(dctx, jobId, name, modelService.name, context, requester); + try { + dispatcher.getJobManager().runJob(job); + } catch (JobManagerException jse) { + throw new GenericServiceException("Cannot run job.", jse); + } + } else { + throw new GenericServiceException("Cannot get JobManager instance to invoke the job"); } } } Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobManager.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobManager.java?view=diff&rev=538659&r1=538658&r2=538659 ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobManager.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobManager.java Wed May 16 10:36:19 2007 @@ -69,6 +69,10 @@ /** Creates a new JobManager object. */ public JobManager(GenericDelegator delegator) { + this(delegator, true); + } + + public JobManager(GenericDelegator delegator, boolean enabled) { if (delegator == null) { throw new GeneralRuntimeException("ERROR: null delegator passed, cannot create JobManager"); } @@ -77,7 +81,7 @@ } this.delegator = delegator; - jp = new JobPoller(this); + jp = new JobPoller(this, enabled); JobManager.registeredManagers.put(delegator.getDelegatorName(), this); } Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobPoller.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobPoller.java?view=diff&rev=538659&r1=538658&r2=538659 ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobPoller.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/job/JobPoller.java Wed May 16 10:36:19 2007 @@ -47,26 +47,28 @@ * Creates a new JobScheduler * @param jm JobManager associated with this scheduler */ - public JobPoller(JobManager jm) { + public JobPoller(JobManager jm, boolean enabled) { this.jm = jm; this.run = new LinkedList(); // create the thread pool this.pool = createThreadPool(); - // re-load crashed jobs - this.jm.reloadCrashedJobs(); + if (enabled) { + // re-load crashed jobs + this.jm.reloadCrashedJobs(); - // start the thread only if polling is enabled - if (pollEnabled()) { + // start the thread only if polling is enabled + if (pollEnabled()) { - // create the poller thread - thread = new Thread(this, this.toString()); - thread.setDaemon(false); + // create the poller thread + thread = new Thread(this, this.toString()); + thread.setDaemon(false); - // start the poller - this.isRunning = true; - thread.start(); + // start the poller + this.isRunning = true; + thread.start(); + } } } |
Free forum by Nabble | Edit this page |