Modified: ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ServiceDispatcher.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ServiceDispatcher.java?rev=808951&r1=808950&r2=808951&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ServiceDispatcher.java (original) +++ ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ServiceDispatcher.java Fri Aug 28 16:48:37 2009 @@ -34,7 +34,6 @@ import org.ofbiz.api.context.GenericParametersArtifact; import org.ofbiz.base.config.GenericConfigException; import org.ofbiz.base.util.Debug; -import org.ofbiz.base.util.GeneralRuntimeException; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilTimer; import org.ofbiz.base.util.UtilValidate; @@ -114,9 +113,13 @@ if (!this.delegator.getOriginalDelegatorName().equals(delegatorName)) { delegatorName = this.delegator.getOriginalDelegatorName(); } - GenericDelegator newDelegator = DelegatorFactory.getGenericDelegator(delegatorName); + ExecutionContext executionContext = (ExecutionContext) ExecutionContextFactory.getInstance(); + GenericDelegator newDelegator = DelegatorFactory.getGenericDelegator(delegatorName, executionContext); + GenericValue userLogin = newDelegator.makeValue("UserLogin"); + userLogin.set("userLoginId", "system"); + executionContext.setUserLogin(userLogin); this.jm = JobManager.getInstance(newDelegator, enableJM); - } catch (GeneralRuntimeException e) { + } catch (Exception e) { Debug.logWarning(e.getMessage(), module); } @@ -303,6 +306,7 @@ ExecutionContext executionContext = (ExecutionContext) context.get("executionContext"); if (executionContext == null) { try { + Debug.logInfo(new Exception(), modelService.name + ": No executionContext, creating new one", module); executionContext = (ExecutionContext) ExecutionContextFactory.getInstance(); } catch (Exception e) { throw new GenericServiceException(e); Modified: ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/job/JobManager.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/job/JobManager.java?rev=808951&r1=808950&r2=808951&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/job/JobManager.java (original) +++ ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/job/JobManager.java Fri Aug 28 16:48:37 2009 @@ -167,7 +167,7 @@ Debug.logError("Unable to locate DispatchContext object; not running job!", module); continue; } - Job job = new PersistedServiceJob(dctx, v, null); // TODO fix the requester + Job job = new PersistedServiceJob(dctx, v, null, this.delegator); // TODO fix the requester try { job.queue(); localPoll.add(job); Modified: ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/job/PersistedServiceJob.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/job/PersistedServiceJob.java?rev=808951&r1=808950&r2=808951&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/job/PersistedServiceJob.java (original) +++ ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/job/PersistedServiceJob.java Fri Aug 28 16:48:37 2009 @@ -28,6 +28,7 @@ import javolution.util.FastMap; +import org.ofbiz.api.context.ExecutionContextFactory; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilGenerics; @@ -35,6 +36,7 @@ import org.ofbiz.base.util.UtilValidate; import org.ofbiz.service.calendar.TemporalExpression; import org.ofbiz.service.calendar.TemporalExpressionWorker; +import org.ofbiz.entity.DelegatorFactory; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; @@ -43,7 +45,9 @@ import org.ofbiz.entity.serialize.SerializeException; import org.ofbiz.entity.serialize.XmlSerializer; import org.ofbiz.service.DispatchContext; +import org.ofbiz.service.ExecutionContext; import org.ofbiz.service.GenericRequester; +import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.ServiceUtil; import org.ofbiz.service.calendar.RecurrenceInfo; import org.ofbiz.service.config.ServiceConfigUtil; @@ -79,6 +83,16 @@ this.maxRetry = jobValue.get("maxRetry") != null ? jobValue.getLong("maxRetry").longValue() : -1; } + public PersistedServiceJob(DispatchContext dctx, GenericValue jobValue, GenericRequester req, GenericDelegator delegator) { + super(jobValue.getString("jobId"), jobValue.getString("jobName")); + this.delegator = delegator; + this.requester = req; + this.dctx = dctx; + this.storedDate = jobValue.getTimestamp("runTime"); + this.runtime = storedDate.getTime(); + this.maxRetry = jobValue.get("maxRetry") != null ? jobValue.getLong("maxRetry").longValue() : -1; + } + @Override public void queue() throws InvalidJobException { super.queue(); @@ -292,6 +306,15 @@ if (!UtilValidate.isEmpty(jobObj.get("runAsUser"))) { context.put("userLogin", ServiceUtil.getUserLogin(dctx, context, jobObj.getString("runAsUser"))); } + ExecutionContext executionContext = (ExecutionContext) context.get("executionContext"); + if (executionContext == null) { + executionContext = (ExecutionContext) ExecutionContextFactory.getInstance(); + context.put("executionContext", executionContext); + } + GenericDelegator newDelegator = DelegatorFactory.getGenericDelegator(this.delegator.getDelegatorName()); + executionContext.setDelegator(newDelegator); + executionContext.setDispatcher(this.dctx.getDispatcher()); + executionContext.initializeContext(context); } catch (GenericEntityException e) { Debug.logError(e, "PersistedServiceJob.getContext(): Entity Exception", module); } catch (SerializeException e) { @@ -302,6 +325,8 @@ Debug.logError(e, "PersistedServiceJob.getContext(): SAXException", module); } catch (IOException e) { Debug.logError(e, "PersistedServiceJob.getContext(): IOException", module); + } catch (Exception e) { + Debug.logError(e, "PersistedServiceJob.getContext(): Exception ", module); } if (context == null) { Debug.logError("Job context is null", module); Modified: ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java?rev=808951&r1=808950&r2=808951&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java (original) +++ ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java Fri Aug 28 16:48:37 2009 @@ -31,6 +31,7 @@ import javolution.util.FastList; import javolution.util.FastMap; +import org.ofbiz.api.context.ExecutionContext; import org.ofbiz.base.util.BshUtil; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; @@ -352,6 +353,10 @@ if (this.fieldMap != null) { EntityFinderUtil.expandFieldMapToContext(this.fieldMap, context, serviceContext); } + ExecutionContext executionContext = (ExecutionContext) context.get("executionContext"); + if (executionContext != null) { + serviceContext.put("executionContext", executionContext); + } Map<String, Object> result = this.modelForm.getDispatcher(context).runSync(serviceNameExpanded, serviceContext); Modified: ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java?rev=808951&r1=808950&r2=808951&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java (original) +++ ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java Fri Aug 28 16:48:37 2009 @@ -33,6 +33,8 @@ import javolution.util.FastList; import javolution.util.FastMap; +import org.ofbiz.api.context.ExecutionContext; +import org.ofbiz.api.context.ExecutionContextFactory; import org.ofbiz.base.util.BshUtil; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; @@ -482,6 +484,10 @@ if (this.fieldMap != null) { EntityFinderUtil.expandFieldMapToContext(this.fieldMap, context, serviceContext); } + ExecutionContext executionContext = (ExecutionContext) context.get("executionContext"); + if (executionContext != null) { + serviceContext.put("executionContext", executionContext); + } Map<String, Object> result = this.modelScreen.getDispatcher(context).runSync(serviceNameExpanded, serviceContext); Modified: ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java?rev=808951&r1=808950&r2=808951&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java (original) +++ ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java Fri Aug 28 16:48:37 2009 @@ -164,7 +164,9 @@ context.put("userLogin", userLogin); context.put("nowTimestamp", UtilDateTime.nowTimestamp()); try { - Map<String, Object> result = dispatcher.runSync("getUserPreferenceGroup", UtilMisc.toMap("userLogin", userLogin, "userPrefGroupTypeId", "GLOBAL_PREFERENCES")); + Map<String, Object> result = dispatcher.runSync("getUserPreferenceGroup", + UtilMisc.toMap("userLogin", userLogin, "userPrefGroupTypeId", "GLOBAL_PREFERENCES", + "executionContext", context.get("executionContext"))); context.put("userPreferences", result.get("userPrefMap")); } catch (GenericServiceException e) { Debug.logError(e, "Error while getting user preferences: ", module); @@ -192,11 +194,11 @@ GenericValue userLogin = (GenericValue) session.getAttribute("userLogin"); + context.put("executionContext", request.getAttribute("executionContext")); populateBasicContext(context, screens, parameterMap, (GenericDelegator) request.getAttribute("delegator"), (LocalDispatcher) request.getAttribute("dispatcher"), (Authorization) request.getAttribute("authz"), (Security) request.getAttribute("security"), UtilHttp.getLocale(request), userLogin); - context.put("executionContext", request.getAttribute("executionContext")); context.put("autoUserLogin", session.getAttribute("autoUserLogin")); context.put("person", session.getAttribute("person")); context.put("partyGroup", session.getAttribute("partyGroup")); |
Free forum by Nabble | Edit this page |