|
Modified: ofbiz/branches/executioncontext20090812/framework/security/src/org/ofbiz/security/SecurityFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/security/src/org/ofbiz/security/SecurityFactory.java?rev=894271&r1=894270&r2=894271&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/security/src/org/ofbiz/security/SecurityFactory.java (original) +++ ofbiz/branches/executioncontext20090812/framework/security/src/org/ofbiz/security/SecurityFactory.java Mon Dec 28 23:14:02 2009 @@ -50,8 +50,8 @@ * @param delegator the generic delegator * @return instance of security implementation (default: OFBizSecurity) */ - public static AuthorizationManager getInstance(GenericDelegator delegator) throws SecurityConfigurationException { - AuthorizationManager security = null; + public static Security getInstance(GenericDelegator delegator) throws SecurityConfigurationException { + Security security = null; // Make securityName a singleton if (securityName == null) { @@ -65,7 +65,7 @@ try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Class<?> c = loader.loadClass(getSecurityClass(securityName)); - security = (AuthorizationManager) c.newInstance(); + security = (Security) c.newInstance(); security.setDelegator(delegator); } catch (ClassNotFoundException cnf) { throw new SecurityConfigurationException("Cannot load security implementation class", cnf); @@ -112,7 +112,7 @@ if (securityInfo == null) { SecurityConfigUtil.SecurityInfo _securityInfo = SecurityConfigUtil.getSecurityInfo(securityName); - // Make sure, that the security context name is defined and present + // Make sure, that the security conetxt name is defined and present if (_securityInfo == null) { throw new SecurityConfigurationException("ERROR: no security definition was found with the name " + securityName + " in security.xml"); } @@ -121,10 +121,7 @@ // This is the default implementation and uses org.ofbiz.security.OFBizSecurity if (UtilValidate.isEmpty(securityInfo.className)) { - className = UtilProperties.getPropertyValue("api.properties", "authorizationManager.class"); - if (UtilValidate.isEmpty(className)) { - className = DEFAULT_SECURITY; - } + className = DEFAULT_SECURITY; } else { // Use a customized security className = securityInfo.className; Modified: ofbiz/branches/executioncontext20090812/framework/security/src/org/ofbiz/security/authz/AuthorizationFactory.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/security/src/org/ofbiz/security/authz/AuthorizationFactory.java?rev=894271&r1=894270&r2=894271&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/security/src/org/ofbiz/security/authz/AuthorizationFactory.java (original) +++ ofbiz/branches/executioncontext20090812/framework/security/src/org/ofbiz/security/authz/AuthorizationFactory.java Mon Dec 28 23:14:02 2009 @@ -66,7 +66,8 @@ synchronized (AuthorizationFactory.class) { try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); - Class c = loader.loadClass(getAuthorizationClass(securityName)); +// Class c = loader.loadClass(getAuthorizationClass(securityName)); + Class c = loader.loadClass(DEFAULT_AUTHORIZATION); security = (Authorization) c.newInstance(); security.setDelegator(delegator); } catch (ClassNotFoundException cnf) { Modified: ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ExecutionContext.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ExecutionContext.java?rev=894271&r1=894270&r2=894271&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ExecutionContext.java (original) +++ ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ExecutionContext.java Mon Dec 28 23:14:02 2009 @@ -18,9 +18,6 @@ */ package org.ofbiz.service; -import java.util.Map; - -import org.ofbiz.security.SecurityConfigurationException; import org.ofbiz.service.LocalDispatcher; /** @@ -35,14 +32,6 @@ */ public LocalDispatcher getDispatcher(); - /** Initializes this ExecutionContext with artifacts found in - * <code>params</code>. - * - * @param params - * @throws SecurityConfigurationException - */ - public void initializeContext(Map<String, ? extends Object> params); - /** Sets the current <code>LocalDispatcher</code> instance. * * @param dispatcher The new <code>LocalDispatcher</code> instance Modified: ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ModelService.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ModelService.java?rev=894271&r1=894270&r2=894271&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ModelService.java (original) +++ ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ModelService.java Mon Dec 28 23:14:02 2009 @@ -56,8 +56,6 @@ import javolution.util.FastMap; import org.ofbiz.api.context.ExecutionArtifact; -import org.ofbiz.api.context.ExecutionContext; -import org.ofbiz.api.context.ExecutionContextFactory; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.ObjectType; @@ -862,23 +860,6 @@ } } - // Copy/create ExecutionContext - ExecutionContext executionContext = null; - if (source.containsKey("executionContext")) { - executionContext = (ExecutionContext) source.get("executionContext"); - } else { - try { - executionContext = ExecutionContextFactory.getInstance(); - executionContext.setLocale(locale); - executionContext.setTimeZone(timeZone); - } catch (Exception e) { - Debug.logError(e, "Error while getting ExecutionContext: ", module); - } - } - if (executionContext != null) { - target.put("executionContext", executionContext); - } - for (ModelParam param: contextParamList) { //boolean internalParam = param.internal; 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=894271&r1=894270&r2=894271&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 Mon Dec 28 23:14:02 2009 @@ -30,8 +30,6 @@ import javolution.util.FastMap; import org.ofbiz.api.authorization.AccessController; -import org.ofbiz.security.AuthorizationManager; -import org.ofbiz.api.context.ExecutionContextFactory; import org.ofbiz.api.context.GenericParametersArtifact; import org.ofbiz.base.config.GenericConfigException; import org.ofbiz.base.util.Debug; @@ -82,7 +80,7 @@ protected GenericDelegator delegator = null; protected GenericEngineFactory factory = null; protected Authorization authz = null; - protected AuthorizationManager security = null; + protected Security security = null; protected Map<String, DispatchContext> localContext = null; protected Map<String, List<GenericServiceCallback>> callbacks = null; protected JobManager jm = null; @@ -113,11 +111,12 @@ if (!this.delegator.getOriginalDelegatorName().equals(delegatorName)) { delegatorName = this.delegator.getOriginalDelegatorName(); } - ExecutionContext executionContext = (ExecutionContext) ExecutionContextFactory.getInstance(); - GenericDelegator newDelegator = DelegatorFactory.getGenericDelegator(delegatorName, executionContext); + ThreadContext.reset(); + GenericDelegator newDelegator = DelegatorFactory.getGenericDelegator(delegatorName); + ThreadContext.setDelegator(newDelegator); GenericValue userLogin = newDelegator.makeValue("UserLogin"); userLogin.set("userLoginId", "system"); - executionContext.setUserLogin(userLogin); + ThreadContext.setUserLogin(userLogin); this.jm = JobManager.getInstance(newDelegator, enableJM); } catch (Exception e) { Debug.logWarning(e.getMessage(), module); @@ -303,21 +302,11 @@ // for isolated transactions Transaction parentTransaction = null; - ExecutionContext executionContext = (ExecutionContext) context.get("executionContext"); - if (executionContext == null) { - try { - executionContext = (ExecutionContext) ExecutionContextFactory.getInstance(); - } catch (Exception e) { - throw new GenericServiceException(e); - } - context.put("executionContext", executionContext); - } GenericDelegator newDelegator = DelegatorFactory.getGenericDelegator(this.delegator.getDelegatorName()); - executionContext.setDelegator(newDelegator); - executionContext.setDispatcher(ctx.getDispatcher()); - executionContext.setSecurity(this.security); - executionContext.initializeContext(context); - executionContext.pushExecutionArtifact(new GenericParametersArtifact(modelService, context)); + ThreadContext.setDelegator(newDelegator); + ThreadContext.setDispatcher(ctx.getDispatcher()); + ThreadContext.initializeContext(context); + ThreadContext.pushExecutionArtifact(new GenericParametersArtifact(modelService, context)); // start the transaction boolean beganTrans = false; try { @@ -329,7 +318,7 @@ } } if (!permissionService) { - AccessController accessController = executionContext.getAccessController(); + AccessController accessController = ThreadContext.getAccessController(); accessController.checkPermission(Access); } //Debug.logInfo("=========================== " + modelService.name + " 1 tx status =" + TransactionUtil.getStatusString() + ", modelService.requireNewTransaction=" + modelService.requireNewTransaction + ", modelService.useTransaction=" + modelService.useTransaction + ", TransactionUtil.isTransactionInPlace()=" + TransactionUtil.isTransactionInPlace(), module); @@ -594,7 +583,7 @@ Debug.logError(te, "Problems with the transaction", module); throw new GenericServiceException("Problems with the transaction.", te.getNested()); } finally { - executionContext.popExecutionArtifact(); + ThreadContext.popExecutionArtifact(); // release the semaphore lock if (lock != null) { lock.release(); Added: ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ThreadContext.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ThreadContext.java?rev=894271&view=auto ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ThreadContext.java (added) +++ ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ThreadContext.java Mon Dec 28 23:14:02 2009 @@ -0,0 +1,41 @@ +/******************************************************************************* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + *******************************************************************************/ +package org.ofbiz.service; + + +/** A convenience class for accessing the current thread's <code>ExecutionContext</code>. + * @see {@link org.ofbiz.service.ExecutionContext} + */ +public class ThreadContext extends org.ofbiz.entity.ThreadContext { + + protected static final String module = ThreadContext.class.getName(); + + public static LocalDispatcher getDispatcher() { + return getExecutionContext().getDispatcher(); + } + + protected static ExecutionContext getExecutionContext() { + return (ExecutionContext) executionContext.get(); + } + + public static void setDispatcher(LocalDispatcher dispatcher) { + getExecutionContext().setDispatcher(dispatcher); + } + +} Propchange: ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ThreadContext.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ThreadContext.java ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ThreadContext.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/job/JobPoller.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/job/JobPoller.java?rev=894271&r1=894270&r2=894271&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/job/JobPoller.java (original) +++ ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/job/JobPoller.java Mon Dec 28 23:14:02 2009 @@ -24,7 +24,10 @@ import javolution.util.FastList; import javolution.util.FastMap; +import org.ofbiz.api.context.GenericExecutionArtifact; +import org.ofbiz.service.ThreadContext; import org.ofbiz.base.util.Debug; +import org.ofbiz.api.authorization.NullAuthorizationManager; import org.ofbiz.service.config.ServiceConfigUtil; /** @@ -84,6 +87,8 @@ java.lang.Thread.sleep(30000); } catch (InterruptedException e) { } + ThreadContext.setSecurity(new NullAuthorizationManager()); + ThreadContext.pushExecutionArtifact(new GenericExecutionArtifact("ofbiz/framework/service/job", "JobPoller")); while (isRunning) { try { // grab a list of jobs to run. @@ -103,6 +108,7 @@ stop(); } } + ThreadContext.popExecutionArtifact(); } /** 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=894271&r1=894270&r2=894271&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 Mon Dec 28 23:14:02 2009 @@ -28,7 +28,6 @@ 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; @@ -45,10 +44,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.ThreadContext; import org.ofbiz.service.calendar.RecurrenceInfo; import org.ofbiz.service.config.ServiceConfigUtil; import org.xml.sax.SAXException; @@ -306,15 +304,11 @@ 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); - } + ThreadContext.reset(); GenericDelegator newDelegator = DelegatorFactory.getGenericDelegator(this.delegator.getDelegatorName()); - executionContext.setDelegator(newDelegator); - executionContext.setDispatcher(this.dctx.getDispatcher()); - executionContext.initializeContext(context); + ThreadContext.setDelegator(newDelegator); + ThreadContext.setDispatcher(this.dctx.getDispatcher()); + ThreadContext.initializeContext(context); } catch (GenericEntityException e) { Debug.logError(e, "PersistedServiceJob.getContext(): Entity Exception", module); } catch (SerializeException e) { Modified: ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java?rev=894271&r1=894270&r2=894271&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java (original) +++ ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java Mon Dec 28 23:14:02 2009 @@ -31,7 +31,7 @@ import org.apache.bsf.BSFManager; -import org.ofbiz.api.context.ExecutionContextFactory; +import org.ofbiz.service.ThreadContext; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilJ2eeCompat; @@ -42,9 +42,8 @@ import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.transaction.GenericTransactionException; import org.ofbiz.entity.transaction.TransactionUtil; -import org.ofbiz.security.AuthorizationManager; +import org.ofbiz.api.authorization.AuthorizationManager; import org.ofbiz.security.authz.Authorization; -import org.ofbiz.service.ExecutionContext; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.webapp.stats.ServerHitBin; import org.ofbiz.webapp.stats.VisitHandler; @@ -141,23 +140,16 @@ if (Debug.verboseOn()) Debug.logVerbose("Control Path: " + request.getAttribute("_CONTROL_PATH_"), module); - // Set up the ExecutionContext - ExecutionContext executionContext = null; - try { - executionContext = (ExecutionContext) ExecutionContextFactory.getInstance(); - } catch (Exception e) { - throw new ServletException(e); - } - executionContext.setLocale(UtilHttp.getLocale(request)); - executionContext.setUserLogin(userLogin); - request.setAttribute("executionContext", executionContext); + ThreadContext.reset(); + ThreadContext.setLocale(UtilHttp.getLocale(request)); + ThreadContext.setUserLogin(userLogin); // for convenience, and necessity with event handlers, make security and delegator available in the request: // try to get it from the session first so that we can have a delegator/dispatcher/security for a certain user if desired GenericDelegator delegator = null; String delegatorName = (String) session.getAttribute("delegatorName"); if (UtilValidate.isNotEmpty(delegatorName)) { - delegator = DelegatorFactory.getGenericDelegator(delegatorName, executionContext); + delegator = DelegatorFactory.getGenericDelegator(delegatorName); } if (delegator == null) { delegator = (GenericDelegator) getServletContext().getAttribute("delegator"); @@ -168,7 +160,7 @@ request.setAttribute("delegator", delegator); // always put this in the session too so that session events can use the delegator session.setAttribute("delegatorName", delegator.getDelegatorName()); - executionContext.setDelegator(delegator); + ThreadContext.setDelegator(delegator); } LocalDispatcher dispatcher = (LocalDispatcher) session.getAttribute("dispatcher"); @@ -179,7 +171,7 @@ Debug.logError("[ControlServlet] ERROR: dispatcher not found in ServletContext", module); } else { request.setAttribute("dispatcher", dispatcher); - executionContext.setDispatcher(dispatcher); + ThreadContext.setDispatcher(dispatcher); } Authorization authz = (Authorization) session.getAttribute("authz"); @@ -199,7 +191,7 @@ Debug.logError("[ControlServlet] ERROR: security not found in ServletContext", module); } else { request.setAttribute("security", security); - executionContext.setSecurity(security); + ThreadContext.setSecurity(security); } request.setAttribute("_REQUEST_HANDLER_", requestHandler); Modified: ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java?rev=894271&r1=894270&r2=894271&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java (original) +++ ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java Mon Dec 28 23:14:02 2009 @@ -61,7 +61,7 @@ import org.ofbiz.entity.transaction.TransactionUtil; import org.ofbiz.security.Security; import org.ofbiz.security.authz.Authorization; -import org.ofbiz.service.ExecutionContext; +import org.ofbiz.service.ThreadContext; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.service.ModelService; @@ -367,12 +367,9 @@ password = request.getParameter("newPassword"); } } - ExecutionContext executionContext = (ExecutionContext) request.getAttribute("executionContext"); - try { result = dispatcher.runSync("userLogin", UtilMisc.toMap("login.username", username, - "login.password", password, "visitId", visitId, "locale", UtilHttp.getLocale(request), - "executionContext", executionContext)); + "login.password", password, "visitId", visitId, "locale", UtilHttp.getLocale(request))); } catch (GenericServiceException e) { Debug.logError(e, "Error calling userLogin service", module); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); @@ -383,7 +380,7 @@ if (ModelService.RESPOND_SUCCESS.equals(result.get(ModelService.RESPONSE_MESSAGE))) { GenericValue userLogin = (GenericValue) result.get("userLogin"); - executionContext.setUserLogin(userLogin); + ThreadContext.setUserLogin(userLogin); Map<String, Object> userLoginSession = checkMap(result.get("userLoginSession"), String.class, Object.class); if (userLogin != null && "Y".equals(userLogin.getString("requirePasswordChange"))) { return "requirePasswordChange"; @@ -395,7 +392,7 @@ try { result = dispatcher.runSync("setUserPreference", UtilMisc.toMap("userPrefTypeId", "javaScriptEnabled", "userPrefGroupTypeId", "GLOBAL_PREFERENCES", "userPrefValue", javaScriptEnabled, - "userLogin", userLogin, "executionContext", executionContext)); + "userLogin", userLogin)); } catch (GenericServiceException e) { Debug.logError(e, "Error setting user preference", module); } Modified: ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java?rev=894271&r1=894270&r2=894271&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java (original) +++ ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java Mon Dec 28 23:14:02 2009 @@ -48,10 +48,10 @@ import org.ofbiz.base.util.UtilObject; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.service.ThreadContext; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; -import org.ofbiz.service.ExecutionContext; import org.ofbiz.webapp.event.EventFactory; import org.ofbiz.webapp.event.EventHandler; import org.ofbiz.webapp.event.EventHandlerException; @@ -145,9 +145,8 @@ throw new RequestHandlerException(requestMissingErrorMessage); } - ExecutionContext executionContext = (ExecutionContext) request.getAttribute("executionContext"); - Locale locale = executionContext.getLocale(); - executionContext.pushExecutionArtifact(new GenericParametersArtifact(UtilHttp.getFullRequestUrl(request).toString(), cname, UtilHttp.getParameterMap(request))); + Locale locale = ThreadContext.getLocale(); + ThreadContext.pushExecutionArtifact(new GenericParametersArtifact(UtilHttp.getFullRequestUrl(request).toString(), cname, UtilHttp.getParameterMap(request))); String eventReturn = null; boolean interruptRequest = false; @@ -280,7 +279,7 @@ if (visit != null) { for (ConfigXMLReader.Event event: controllerConfig.firstVisitEventList.values()) { try { - executionContext.pushExecutionArtifact(new GenericExecutionArtifact(event.path, event.invoke)); + ThreadContext.pushExecutionArtifact(new GenericExecutionArtifact(event.path, event.invoke)); String returnString = this.runEvent(request, response, event, null, "firstvisit"); if (returnString != null && !returnString.equalsIgnoreCase("success")) { throw new EventHandlerException("First-Visit event did not return 'success'."); @@ -290,7 +289,7 @@ } catch (EventHandlerException e) { Debug.logError(e, module); } finally { - executionContext.popExecutionArtifact(); + ThreadContext.popExecutionArtifact(); } } } @@ -299,7 +298,7 @@ // Invoke the pre-processor (but NOT in a chain) for (ConfigXMLReader.Event event: controllerConfig.preprocessorEventList.values()) { try { - executionContext.pushExecutionArtifact(new GenericExecutionArtifact(event.path, event.invoke)); + ThreadContext.pushExecutionArtifact(new GenericExecutionArtifact(event.path, event.invoke)); String returnString = this.runEvent(request, response, event, null, "preprocessor"); if (returnString != null && !returnString.equalsIgnoreCase("success")) { if (!returnString.contains(":_protect_:")) { @@ -325,7 +324,7 @@ } catch (EventHandlerException e) { Debug.logError(e, module); } finally { - executionContext.popExecutionArtifact(); + ThreadContext.popExecutionArtifact(); } } } @@ -334,7 +333,7 @@ // Warning: this could cause problems if more then one event attempts to return a response. if (interruptRequest) { if (Debug.infoOn()) Debug.logInfo("[Pre-Processor Interrupted Request, not running: [" + requestMap.uri + "], sessionId=" + UtilHttp.getSessionId(request), module); - executionContext.popExecutionArtifact(); + ThreadContext.popExecutionArtifact(); return; } @@ -351,12 +350,12 @@ String checkLoginReturnString = null; try { - executionContext.pushExecutionArtifact(new GenericExecutionArtifact(checkLoginEvent.path, checkLoginEvent.invoke)); + ThreadContext.pushExecutionArtifact(new GenericExecutionArtifact(checkLoginEvent.path, checkLoginEvent.invoke)); checkLoginReturnString = this.runEvent(request, response, checkLoginEvent, null, "security-auth"); } catch (EventHandlerException e) { throw new RequestHandlerException(e.getMessage(), e); } finally { - executionContext.popExecutionArtifact(); + ThreadContext.popExecutionArtifact(); } if (!"success".equalsIgnoreCase(checkLoginReturnString)) { // previous URL already saved by event, so just do as the return says... @@ -387,7 +386,7 @@ long eventStartTime = System.currentTimeMillis(); // run the request event - executionContext.pushExecutionArtifact(new GenericExecutionArtifact(requestMap.event.path, requestMap.event.invoke)); + ThreadContext.pushExecutionArtifact(new GenericExecutionArtifact(requestMap.event.path, requestMap.event.invoke)); eventReturn = this.runEvent(request, response, requestMap.event, requestMap, "request"); // save the server hit for the request event @@ -410,7 +409,7 @@ throw new RequestHandlerException("Error calling event and no error response was specified", e); } } finally { - executionContext.popExecutionArtifact(); + ThreadContext.popExecutionArtifact(); } } } @@ -489,7 +488,7 @@ // the old/uglier way: doRequest(request, response, previousRequest, userLogin, delegator); // this is needed as the request handled will be taking care of the view, etc - executionContext.popExecutionArtifact(); + ThreadContext.popExecutionArtifact(); return; } } @@ -538,7 +537,7 @@ // first invoke the post-processor events. for (ConfigXMLReader.Event event: controllerConfig.postprocessorEventList.values()) { try { - executionContext.pushExecutionArtifact(new GenericExecutionArtifact(event.path, event.invoke)); + ThreadContext.pushExecutionArtifact(new GenericExecutionArtifact(event.path, event.invoke)); String returnString = this.runEvent(request, response, event, requestMap, "postprocessor"); if (returnString != null && !returnString.equalsIgnoreCase("success")) { throw new EventHandlerException("Post-Processor event did not return 'success'."); @@ -546,7 +545,7 @@ } catch (EventHandlerException e) { Debug.logError(e, module); } finally { - executionContext.popExecutionArtifact(); + ThreadContext.popExecutionArtifact(); } } @@ -624,7 +623,7 @@ if (Debug.verboseOn()) Debug.logVerbose("[RequestHandler.doRequest]: Response is handled by the event." + " sessionId=" + UtilHttp.getSessionId(request), module); } } - executionContext.popExecutionArtifact(); + ThreadContext.popExecutionArtifact(); } /** Find the event handler and invoke an event. */ @@ -1090,10 +1089,9 @@ } public void runAfterLoginEvents(HttpServletRequest request, HttpServletResponse response) { - ExecutionContext executionContext = (ExecutionContext) request.getAttribute("executionContext"); for (ConfigXMLReader.Event event: getControllerConfig().afterLoginEventList.values()) { try { - executionContext.pushExecutionArtifact(new GenericExecutionArtifact(event.path, event.invoke)); + ThreadContext.pushExecutionArtifact(new GenericExecutionArtifact(event.path, event.invoke)); String returnString = this.runEvent(request, response, event, null, "after-login"); if (returnString != null && !returnString.equalsIgnoreCase("success")) { throw new EventHandlerException("Pre-Processor event did not return 'success'."); @@ -1101,16 +1099,15 @@ } catch (EventHandlerException e) { Debug.logError(e, module); } finally { - executionContext.popExecutionArtifact(); + ThreadContext.popExecutionArtifact(); } } } public void runBeforeLogoutEvents(HttpServletRequest request, HttpServletResponse response) { - ExecutionContext executionContext = (ExecutionContext) request.getAttribute("executionContext"); for (ConfigXMLReader.Event event: getControllerConfig().beforeLogoutEventList.values()) { try { - executionContext.pushExecutionArtifact(new GenericExecutionArtifact(event.path, event.invoke)); + ThreadContext.pushExecutionArtifact(new GenericExecutionArtifact(event.path, event.invoke)); String returnString = this.runEvent(request, response, event, null, "before-logout"); if (returnString != null && !returnString.equalsIgnoreCase("success")) { throw new EventHandlerException("Pre-Processor event did not return 'success'."); @@ -1118,7 +1115,7 @@ } catch (EventHandlerException e) { Debug.logError(e, module); } finally { - executionContext.popExecutionArtifact(); + ThreadContext.popExecutionArtifact(); } } } Modified: ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/form/ModelForm.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/form/ModelForm.java?rev=894271&r1=894270&r2=894271&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/form/ModelForm.java (original) +++ ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/form/ModelForm.java Mon Dec 28 23:14:02 2009 @@ -57,7 +57,7 @@ import org.ofbiz.entity.model.ModelReader; import org.ofbiz.entity.util.EntityListIterator; import org.ofbiz.service.DispatchContext; -import org.ofbiz.service.ExecutionContext; +import org.ofbiz.service.ThreadContext; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.service.ModelParam; @@ -785,9 +785,8 @@ * use the same form definitions for many types of form UIs */ public void renderFormString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException { - ExecutionContext executionContext = (ExecutionContext) context.get("executionContext"); - executionContext.pushExecutionArtifact(this); - AccessController accessController = executionContext.getAccessController(); + ThreadContext.pushExecutionArtifact(this); + AccessController accessController = ThreadContext.getAccessController(); accessController.checkPermission(View); // increment the paginator this.incrementPaginatorNumber(context); @@ -837,7 +836,7 @@ throw new IllegalArgumentException("The form type " + this.getType() + " is not supported for form with name " + this.getName()); } } - executionContext.popExecutionArtifact(); + ThreadContext.popExecutionArtifact(); } public void renderSingleFormString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer, int positions) throws IOException { 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=894271&r1=894270&r2=894271&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 Mon Dec 28 23:14:02 2009 @@ -31,7 +31,6 @@ 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; @@ -353,11 +352,6 @@ 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); if (!this.resultMapNameAcsr.isEmpty()) { Modified: ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java?rev=894271&r1=894270&r2=894271&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java (original) +++ ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java Mon Dec 28 23:14:02 2009 @@ -59,7 +59,7 @@ import org.ofbiz.entity.model.ModelReader; import org.ofbiz.entity.util.EntityUtil; import org.ofbiz.service.DispatchContext; -import org.ofbiz.service.ExecutionContext; +import org.ofbiz.service.ThreadContext; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.ModelParam; import org.ofbiz.service.ModelService; @@ -591,10 +591,9 @@ } public void renderFieldString(Appendable writer, Map<String, Object> context, FormStringRenderer formStringRenderer) throws IOException { - ExecutionContext executionContext = (ExecutionContext) context.get("executionContext"); - executionContext.pushExecutionArtifact(this); + ThreadContext.pushExecutionArtifact(this); this.fieldInfo.renderFieldString(writer, context, formStringRenderer); - executionContext.popExecutionArtifact(); + ThreadContext.popExecutionArtifact(); } public List<UpdateArea> getOnChangeUpdateAreas() { Modified: ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java?rev=894271&r1=894270&r2=894271&view=diff ============================================================================== --- ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java (original) +++ ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java Mon Dec 28 23:14:02 2009 @@ -39,7 +39,7 @@ import org.ofbiz.entity.GenericEntity; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.transaction.TransactionUtil; -import org.ofbiz.service.ExecutionContext; +import org.ofbiz.service.ThreadContext; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.webapp.control.ConfigXMLReader; import org.ofbiz.widget.ModelWidget; @@ -350,9 +350,8 @@ * use the same screen definitions for many types of screen UIs */ public void renderScreenString(Appendable writer, Map<String, Object> context, ScreenStringRenderer screenStringRenderer) throws ScreenRenderException { - ExecutionContext executionContext = (ExecutionContext) context.get("executionContext"); - executionContext.pushExecutionArtifact(this); - AccessController accessController = executionContext.getAccessController(); + ThreadContext.pushExecutionArtifact(this); + AccessController accessController = ThreadContext.getAccessController(); accessController.checkPermission(View); // make sure the "null" object is in there for entity ops context.put("null", GenericEntity.NULL_FIELD); @@ -428,7 +427,7 @@ // after rolling back, rethrow the exception throw new ScreenRenderException(errMsg, e); } finally { - executionContext.popExecutionArtifact(); + ThreadContext.popExecutionArtifact(); // only commit the transaction if we started one... this will throw an exception if it fails try { TransactionUtil.commit(beganTransaction); 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=894271&r1=894270&r2=894271&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 Mon Dec 28 23:14:02 2009 @@ -33,8 +33,6 @@ 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; @@ -484,11 +482,6 @@ 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); if (!this.resultMapNameAcsr.isEmpty()) { 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=894271&r1=894270&r2=894271&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 Mon Dec 28 23:14:02 2009 @@ -48,10 +48,9 @@ import org.ofbiz.entity.GenericEntity; import org.ofbiz.entity.GenericValue; import org.ofbiz.security.Security; -import org.ofbiz.security.SecurityConfigurationException; import org.ofbiz.security.authz.Authorization; import org.ofbiz.service.DispatchContext; -import org.ofbiz.service.ExecutionContext; +import org.ofbiz.service.ThreadContext; import org.ofbiz.service.GenericServiceException; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.webapp.control.LoginWorker; @@ -209,13 +208,7 @@ // set up the user's time zone context.put("timeZone", UtilHttp.getTimeZone(request)); - ExecutionContext executionContext = (ExecutionContext) request.getAttribute("executionContext"); - try { - executionContext.initializeContext(context); - } catch (Exception e) { - Debug.logError(e, module); - } - context.put("executionContext", executionContext); + ThreadContext.initializeContext(context); // ========== setup values that are specific to OFBiz webapps |
| Free forum by Nabble | Edit this page |
