svn commit: r894271 [1/2] - in /ofbiz/branches/executioncontext20090812: ./ framework/api/src/org/ofbiz/api/authorization/ framework/api/src/org/ofbiz/api/context/ framework/context/src/org/ofbiz/context/ framework/entity/src/org/ofbiz/entity/ framewor...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r894271 [1/2] - in /ofbiz/branches/executioncontext20090812: ./ framework/api/src/org/ofbiz/api/authorization/ framework/api/src/org/ofbiz/api/context/ framework/context/src/org/ofbiz/context/ framework/entity/src/org/ofbiz/entity/ framewor...

adrianc
Author: adrianc
Date: Mon Dec 28 23:14:02 2009
New Revision: 894271

URL: http://svn.apache.org/viewvc?rev=894271&view=rev
Log:
Major rewrite. See BranchReadMe.txt for details.

Added:
    ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/NullAuthorizationManager.java   (with props)
    ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ThreadContext.java   (with props)
    ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/ThreadContext.java   (with props)
    ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ThreadContext.java   (with props)
Removed:
    ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ExecutionContextFactory.java
    ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/NullAccessController.java
    ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/NullAuthorizationManager.java
    ofbiz/branches/executioncontext20090812/framework/security/src/org/ofbiz/security/AuthorizationManager.java
Modified:
    ofbiz/branches/executioncontext20090812/BranchReadMe.txt
    ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AuthorizationManager.java
    ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/OfbizSecurityTransform.java
    ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ExecutionContext.java
    ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AccessControllerImpl.java
    ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AuthorizationManagerImpl.java
    ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/ExecutionContextImpl.java
    ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareEli.java
    ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareIterator.java
    ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareList.java
    ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareListIterator.java
    ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java
    ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/DelegatorImpl.java
    ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/GenericDelegator.java
    ofbiz/branches/executioncontext20090812/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java
    ofbiz/branches/executioncontext20090812/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java
    ofbiz/branches/executioncontext20090812/framework/security/config/security.xml
    ofbiz/branches/executioncontext20090812/framework/security/src/org/ofbiz/security/SecurityFactory.java
    ofbiz/branches/executioncontext20090812/framework/security/src/org/ofbiz/security/authz/AuthorizationFactory.java
    ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ExecutionContext.java
    ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ModelService.java
    ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/ServiceDispatcher.java
    ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/job/JobPoller.java
    ofbiz/branches/executioncontext20090812/framework/service/src/org/ofbiz/service/job/PersistedServiceJob.java
    ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/ControlServlet.java
    ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java
    ofbiz/branches/executioncontext20090812/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java
    ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/form/ModelForm.java
    ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java
    ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
    ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java
    ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/screen/ModelScreenAction.java
    ofbiz/branches/executioncontext20090812/framework/widget/src/org/ofbiz/widget/screen/ScreenRenderer.java

Modified: ofbiz/branches/executioncontext20090812/BranchReadMe.txt
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/BranchReadMe.txt?rev=894271&r1=894270&r2=894271&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/BranchReadMe.txt (original)
+++ ofbiz/branches/executioncontext20090812/BranchReadMe.txt Mon Dec 28 23:14:02 2009
@@ -33,8 +33,7 @@
 
 org.ofbiz.api.context.ExecutionContext
   org.ofbiz.entity.ExecutionContext
-    org.ofbiz.security.ExecutionContext
-      org.ofbiz.service.ExecutionContext
+    org.ofbiz.service.ExecutionContext
 
 When the cross-dependency issues are solved, all of the extended
 interfaces will be consolidated into one.
@@ -91,3 +90,13 @@
 I tried to do a merge from the trunk and there were too many conflicts to
 resolve. When the time comes to implement the security-aware artifacts in
 the trunk, the handful of affected classes can be ported over manually.
+
+---------------------------------------------------------------------
+
+2009-12-28: Major rewrite. I created a utility class of static methods
+(ThreadContext) to make using the ExecutionContext easier. Instead of
+trying to pass an ExecutionContext instance throughout the framework,
+you can use the ThreadContext static methods instead. The ThreadContext
+class keeps an ExecutionContext instance per thread. We just need to
+make sure all OFBiz entrance vectors call the reset() method, and
+then initialize the ExecutionContext to the desired values.

Modified: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AuthorizationManager.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AuthorizationManager.java?rev=894271&r1=894270&r2=894271&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AuthorizationManager.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/AuthorizationManager.java Mon Dec 28 23:14:02 2009
@@ -21,15 +21,13 @@
 import java.security.AccessControlException;
 import java.security.Permission;
 
-import org.ofbiz.api.context.ExecutionContext;
-
 /**
  * AuthorizationManager interface.
  */
 public interface AuthorizationManager {
 
  // Get the access controller for an artifact/user combination
- public AccessController getAccessController (ExecutionContext executionContext) throws AccessControlException;
+ public AccessController getAccessController () throws AccessControlException;
 
  // User methods
     public void createUser(String userLoginId, String password);

Added: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/NullAuthorizationManager.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/NullAuthorizationManager.java?rev=894271&view=auto
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/NullAuthorizationManager.java (added)
+++ ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/NullAuthorizationManager.java Mon Dec 28 23:14:02 2009
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * 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.api.authorization;
+
+import java.security.AccessControlException;
+import java.security.Permission;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.ofbiz.api.context.ThreadContext;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilProperties;
+
+/** An implementation of <code>AuthorizationManager</code> that allows
+ * unrestricted access to all security-aware artifacts. This class
+ * is intended to be used in situations where user permissions are
+ * not available or accessible (the initial data load for example).
+ * <p>Extreme care should be taken when using this class so that
+ * security holes are not introduced. A recommended strategy is:<br><br>
+ * <ul>
+ * <li>Save the current <code>AuthorizationManager</code> instance in
+ * a local variable - using <code>ExecutionContext.getSecurity()</code>.</li>
+ * <li>Call <code>ExecutionContext.setSecurity(...)</code> with a
+ * <code>NullAuthorizationManager</code> instance.</li>
+ * <li>Perform the unrestricted tasks.</li>
+ * <li>Restore the original <code>AuthorizationManager</code> by
+ * calling <code>ExecutionContext.setSecurity(...)</code> with the
+ * saved <code>AuthorizationManager</code> instance.</li>
+ * </ul></p>
+ *
+ */
+public class NullAuthorizationManager implements AuthorizationManager {
+
+    protected static final String module = NullAuthorizationManager.class.getName();
+    protected static final AccessController nullAccessController = new NullAccessController();
+
+    public void assignGroupPermission(String userGroupId, String artifactId,
+            Permission permission) {
+    }
+
+    public void assignGroupToGroup(String childGroupId, String parentGroupId) {
+    }
+
+    public void assignUserPermission(String userLoginId, String artifactId,
+            Permission permission) {
+    }
+
+    public void assignUserToGroup(String userLoginId, String userGroupId) {
+    }
+
+    public void createUser(String userLoginId, String password) {
+    }
+
+    public String createUserGroup(String description) {
+        return null;
+    }
+
+    public void deleteGroupFromGroup(String childGroupId, String parentGroupId) {
+    }
+
+    public void deleteGroupPermission(String userGroupId, String artifactId,
+            Permission permission) {
+    }
+
+    public void deleteUser(String userLoginId) {
+    }
+
+    public void deleteUserFromGroup(String userLoginId, String userGroupId) {
+    }
+
+    public void deleteUserGroup(String userGroupId) {
+    }
+
+    public void deleteUserPermission(String userLoginId, String artifactId,
+            Permission permission) {
+    }
+
+    public void updateUser(String userLoginId, String password) {
+    }
+
+    public void updateUserGroup(String userGroupId, String description) {
+    }
+
+    public AccessController getAccessController() throws AccessControlException {
+        return nullAccessController;
+    }
+
+    /** An implementation of the <code>AccessController</code> interface
+     * that allows unrestricted access.
+     */
+    protected static class NullAccessController implements AccessController {
+
+        // Temporary - will be removed later
+        protected boolean verbose = false;
+        protected NullAccessController() {
+            this.verbose = "true".equals(UtilProperties.getPropertyValue("api.properties", "authorizationManager.verbose"));
+        }
+
+        public <E> List<E> applyFilters(List<E> list) {
+            return list;
+        }
+
+        public <E> ListIterator<E> applyFilters(ListIterator<E> list) {
+            return list;
+        }
+
+        public void checkPermission(Permission permission) throws AccessControlException {
+            if (this.verbose) {
+                Debug.logInfo("Checking permission: " + ThreadContext.getExecutionPath() + "[" + permission + "]", module);
+                Debug.logInfo("Found permission(s): " +
+                        "system@" + ThreadContext.getExecutionPath() + "[admin=true]", module);
+            }
+        }
+    }
+
+}

Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/NullAuthorizationManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/NullAuthorizationManager.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/NullAuthorizationManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/OfbizSecurityTransform.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/OfbizSecurityTransform.java?rev=894271&r1=894270&r2=894271&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/OfbizSecurityTransform.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/authorization/OfbizSecurityTransform.java Mon Dec 28 23:14:02 2009
@@ -23,7 +23,7 @@
 import java.security.Permission;
 import java.util.Map;
 
-import org.ofbiz.api.context.ExecutionContext;
+import org.ofbiz.api.context.ThreadContext;
 import org.ofbiz.api.context.GenericExecutionArtifact;
 import org.ofbiz.base.util.Debug;
 
@@ -72,13 +72,12 @@
         }
         Template template = env.getTemplate();
         String location = template.getName();
-        ExecutionContext executionContext = (ExecutionContext) contextBean.getWrappedObject();
-        executionContext.pushExecutionArtifact(new GenericExecutionArtifact(location, artifactId));
-        AccessController accessController = executionContext.getAccessController();
+        ThreadContext.pushExecutionArtifact(new GenericExecutionArtifact(location, artifactId));
+        AccessController accessController = ThreadContext.getAccessController();
         try {
             accessController.checkPermission(permission);
             body.render(env.getOut());
         } catch (AccessControlException e) {}
-        executionContext.popExecutionArtifact();
+        ThreadContext.popExecutionArtifact();
     }
 }

Modified: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ExecutionContext.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ExecutionContext.java?rev=894271&r1=894270&r2=894271&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ExecutionContext.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ExecutionContext.java Mon Dec 28 23:14:02 2009
@@ -25,6 +25,7 @@
 import org.ofbiz.api.authorization.AccessController;
 import org.ofbiz.api.authorization.AuthorizationManager;
 
+
 /** ExecutionContext interface. The <code>ExecutionContext</code> is a container
  * for frequently used objects, plus it keeps track of the program's
  * execution path. <p>As an object container, the <code>ExecutionContext</code>
@@ -96,6 +97,13 @@
      */
     public TimeZone getTimeZone();
 
+    /** Initializes this ExecutionContext with artifacts found in
+     * <code>params</code>.
+     *
+     * @param params
+     */
+    public void initializeContext(Map<String, ? extends Object> params);
+
     /** Pop an <code>ExecutionArtifact</code> off the stack. */
     public void popExecutionArtifact();
 

Added: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ThreadContext.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ThreadContext.java?rev=894271&view=auto
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ThreadContext.java (added)
+++ ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ThreadContext.java Mon Dec 28 23:14:02 2009
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * 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.api.context;
+
+import java.util.Locale;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.ofbiz.api.authorization.AccessController;
+import org.ofbiz.api.authorization.AuthorizationManager;
+import org.ofbiz.api.context.ExecutionArtifact;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilProperties;
+
+/** A convenience class for accessing the current thread's <code>ExecutionContext</code>.
+ * @see {@link org.ofbiz.service.ExecutionContext}
+ */
+public class ThreadContext {
+
+    protected static final String module = ThreadContext.class.getName();
+
+    protected static final ThreadLocal<ExecutionContext> executionContext = new ThreadLocal<ExecutionContext>() {
+        protected synchronized ExecutionContext initialValue() {
+            ExecutionContext result = null;
+            ClassLoader loader = Thread.currentThread().getContextClassLoader();
+            String className = UtilProperties.getPropertyValue("api.properties", "executionContext.class");
+            try {
+                result = (ExecutionContext) loader.loadClass(className).newInstance();
+            } catch (Exception e) {
+                Debug.logError(e, module);
+            }
+            return result;
+        }
+    };
+
+    public static AccessController getAccessController() {
+        return executionContext.get().getAccessController();
+    }
+
+    public static String getCurrencyUom() {
+        return executionContext.get().getCurrencyUom();
+    }
+
+    public static String getExecutionPath() {
+        return executionContext.get().getExecutionPath();
+    }
+
+    public static Locale getLocale() {
+        return executionContext.get().getLocale();
+    }
+
+    public static Map<String, ? extends Object> getParameters() {
+        return executionContext.get().getParameters();
+    }
+
+    public static Object getProperty(String key) {
+        return executionContext.get().getProperty(key);
+    }
+
+    public static AuthorizationManager getSecurity() {
+        return executionContext.get().getSecurity();
+    }
+
+    public static TimeZone getTimeZone() {
+        return executionContext.get().getTimeZone();
+    }
+
+    public static void initializeContext(Map<String, ? extends Object> params) {
+        executionContext.get().initializeContext(params);
+    }
+
+    public static void popExecutionArtifact() {
+        executionContext.get().popExecutionArtifact();
+    }
+
+    public static void pushExecutionArtifact(ExecutionArtifact artifact) {
+        executionContext.get().pushExecutionArtifact(artifact);
+    }
+
+    public static void reset() {
+        executionContext.get().reset();
+    }
+
+    public static void setCurrencyUom(String currencyUom) {
+        executionContext.get().setCurrencyUom(currencyUom);
+    }
+
+    public static void setLocale(Locale locale) {
+        executionContext.get().setLocale(locale);
+    }
+
+    public static Object setProperty(String key, Object value) {
+        return executionContext.get().setProperty(key, value);
+    }
+
+    public static void setSecurity(AuthorizationManager security) {
+        executionContext.get().setSecurity(security);
+    }
+
+    public static void setTimeZone(TimeZone timeZone) {
+        executionContext.get().setTimeZone(timeZone);
+    }
+
+}

Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ThreadContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ThreadContext.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/branches/executioncontext20090812/framework/api/src/org/ofbiz/api/context/ThreadContext.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AccessControllerImpl.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AccessControllerImpl.java?rev=894271&r1=894270&r2=894271&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AccessControllerImpl.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AccessControllerImpl.java Mon Dec 28 23:14:02 2009
@@ -31,7 +31,7 @@
 import org.ofbiz.base.util.UtilProperties;
 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.LocalDispatcher;
 import org.ofbiz.service.ModelService;
 
@@ -40,30 +40,31 @@
 
     public static final String module = AccessControllerImpl.class.getName();
 
-    protected final ExecutionContext executionContext;
     protected final OFBizPermission permission;
     protected final PathNode node;
     // Temporary - will be removed later
     protected boolean verbose = false;
     protected boolean disabled = false;
 
-    protected AccessControllerImpl(ExecutionContext executionContext, PathNode node) {
-        this.executionContext = executionContext;
+    protected AccessControllerImpl(PathNode node) {
         this.node = node;
-        this.permission = new OFBizPermission(executionContext.getUserLogin().getString("userLoginId"));
+        this.permission = new OFBizPermission(ThreadContext.getUserLogin().getString("userLoginId"));
         this.verbose = "true".equals(UtilProperties.getPropertyValue("api.properties", "authorizationManager.verbose"));
         this.disabled = "true".equals(UtilProperties.getPropertyValue("api.properties", "authorizationManager.disabled"));
     }
 
     public void checkPermission(Permission permission) throws AccessControlException {
         if (this.verbose) {
-            Debug.logInfo("Checking permission: " + this.executionContext.getExecutionPath() + "[" + permission + "]", module);
+            Debug.logInfo("Checking permission: " + ThreadContext.getExecutionPath() + "[" + permission + "]", module);
         }
         this.permission.reset();
-        this.node.getPermissions(this.executionContext.getExecutionPath(), this.permission);
+        this.node.getPermissions(ThreadContext.getExecutionPath(), this.permission);
         if (this.verbose) {
-            Debug.logInfo("Found permission(s): " + this.executionContext.getUserLogin().getString("userLoginId") +
-                    "@" + this.executionContext.getExecutionPath() + "[" + this.permission + "]", module);
+            Debug.logInfo("Found permission(s): " + ThreadContext.getUserLogin().getString("userLoginId") +
+                    "@" + ThreadContext.getExecutionPath() + "[" + this.permission + "]", module);
+/*            if ("NOT_LOGGED_IN".equals(ThreadContext.getUserLogin().getString("userLoginId"))) {
+                Debug.logInfo(new Exception(), module);
+            } */
         }
         if (this.disabled) {
             return;
@@ -71,20 +72,20 @@
         if (this.permission.implies(permission) && this.hasServicePermission()) {
             return;
         }
-        throw new AccessControlException(this.executionContext.getUserLogin().getString("userLoginId") +
-                "@" + this.executionContext.getExecutionPath() + "[" + permission + "]");
+        throw new AccessControlException(ThreadContext.getUserLogin().getString("userLoginId") +
+                "@" + ThreadContext.getExecutionPath() + "[" + permission + "]");
     }
 
     public <E> List<E> applyFilters(List<E> list) {
         if (this.permission.getFilterNames().size() > 0) {
-            return new SecurityAwareList<E>(list, this.permission.getFilterNames(), this.executionContext);
+            return new SecurityAwareList<E>(list, this.permission.getFilterNames());
         }
         return list;
     }
 
     public <E> ListIterator<E> applyFilters(ListIterator<E> listIterator) {
         if (this.permission.getFilterNames().size() > 0) {
-            return new SecurityAwareListIterator<E>(listIterator, this.permission.getFilterNames(), this.executionContext);
+            return new SecurityAwareListIterator<E>(listIterator, this.permission.getFilterNames());
         }
         return listIterator;
     }
@@ -102,9 +103,9 @@
             if (this.permission.getServiceNames().size() == 0) {
                 return true;
             }
-            LocalDispatcher dispatcher = this.executionContext.getDispatcher();
+            LocalDispatcher dispatcher = ThreadContext.getDispatcher();
             DispatchContext ctx = dispatcher.getDispatchContext();
-            Map<String, ? extends Object> params = this.executionContext.getParameters();
+            Map<String, ? extends Object> params = ThreadContext.getParameters();
             for (String serviceName : this.permission.getServiceNames()) {
                 ModelService modelService = ctx.getModelService(serviceName);
                 Map<String, Object> context = FastMap.newInstance();
@@ -112,13 +113,13 @@
                     context.putAll(params);
                 }
                 if (!context.containsKey("userLogin")) {
-                    context.put("userLogin", this.executionContext.getUserLogin());
+                    context.put("userLogin", ThreadContext.getUserLogin());
                 }
                 if (!context.containsKey("locale")) {
-                    context.put("locale", this.executionContext.getLocale());
+                    context.put("locale", ThreadContext.getLocale());
                 }
                 if (!context.containsKey("timeZone")) {
-                    context.put("timeZone", this.executionContext.getTimeZone());
+                    context.put("timeZone", ThreadContext.getTimeZone());
                 }
                 context = modelService.makeValid(context, ModelService.IN_PARAM);
                 Map<String, Object> result = dispatcher.runSync(serviceName, context);

Modified: ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AuthorizationManagerImpl.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AuthorizationManagerImpl.java?rev=894271&r1=894270&r2=894271&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AuthorizationManagerImpl.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/AuthorizationManagerImpl.java Mon Dec 28 23:14:02 2009
@@ -24,16 +24,17 @@
 
 import org.ofbiz.api.authorization.AccessController;
 import org.ofbiz.api.authorization.BasicPermissions;
+import org.ofbiz.api.authorization.AuthorizationManager;
+import org.ofbiz.api.authorization.NullAuthorizationManager;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.condition.EntityCondition;
-import org.ofbiz.base.util.Debug;
+//import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.cache.UtilCache;
-import org.ofbiz.security.AuthorizationManager;
 import org.ofbiz.security.OFBizSecurity;
-import org.ofbiz.service.ExecutionContext;
+import org.ofbiz.service.ThreadContext;
 
 /**
  * An implementation of the AuthorizationManager interface that uses the OFBiz database
@@ -45,7 +46,7 @@
 
     public static final String module = AuthorizationManagerImpl.class.getName();
     protected static final UtilCache<String, PathNode> userPermCache = new UtilCache<String, PathNode>("authorization.UserPermissions");
-    public static final AccessController nullAccessController = new NullAccessController();
+    protected static final AuthorizationManager nullAuthorizationManager = new NullAuthorizationManager();
     protected static boolean underConstruction = false;
 
     public AuthorizationManagerImpl() {
@@ -127,33 +128,31 @@
         userPermCache.remove(userLogin.getString("userLogin"));
     }
 
-    public AccessController getAccessController(org.ofbiz.api.context.ExecutionContext executionContext) throws AccessControlException {
-        String userLoginId = ((ExecutionContext) executionContext).getUserLogin().getString("userLoginId");
+    public AccessController getAccessController() throws AccessControlException {
+        String userLoginId = ThreadContext.getUserLogin().getString("userLoginId");
         PathNode node = userPermCache.get(userLoginId);
         if (node == null) {
             synchronized (userPermCache) {
                 if (underConstruction) {
-                    return nullAccessController;
+                    return nullAuthorizationManager.getAccessController();
                 }
                 node = userPermCache.get(userLoginId);
                 if (node == null) {
-                    node = getUserPermissionsNode((ExecutionContext) executionContext);
+                    node = getUserPermissionsNode();
                     userPermCache.put(userLoginId, node);
                 }
             }
         }
-        return new AccessControllerImpl((ExecutionContext) executionContext, node);
+        return new AccessControllerImpl(node);
  }
 
- @SuppressWarnings("unchecked")
-    protected static PathNode getUserPermissionsNode(ExecutionContext executionContext) throws AccessControlException {
+    protected static PathNode getUserPermissionsNode() throws AccessControlException {
     underConstruction = true;
         // Set up the ExecutionContext for unrestricted access to security-aware artifacts
-    ExecutionContext localContext = (ExecutionContext) executionContext;
-        AuthorizationManager originalSecurity = (AuthorizationManager) localContext.getSecurity();
-        localContext.setSecurity(new NullAuthorizationManager());
-    String userLoginId = executionContext.getUserLogin().getString("userLoginId");
-    GenericDelegator delegator = executionContext.getDelegator();
+        AuthorizationManager originalSecurity = (AuthorizationManager) ThreadContext.getSecurity();
+        ThreadContext.setSecurity(nullAuthorizationManager);
+    String userLoginId = ThreadContext.getUserLogin().getString("userLoginId");
+    GenericDelegator delegator = ThreadContext.getDelegator();
     PathNode node = new PathNode();
     try {
         // Process group membership permissions first
@@ -167,7 +166,7 @@
     } catch (GenericEntityException e) {
         throw new AccessControlException(e.getMessage());
     } finally {
-        localContext.setSecurity(originalSecurity);
+        ThreadContext.setSecurity(originalSecurity);
             underConstruction = false;
     }
     return node;

Modified: ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/ExecutionContextImpl.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/ExecutionContextImpl.java?rev=894271&r1=894270&r2=894271&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/ExecutionContextImpl.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/ExecutionContextImpl.java Mon Dec 28 23:14:02 2009
@@ -25,11 +25,11 @@
 import org.ofbiz.api.authorization.AccessController;
 import org.ofbiz.api.authorization.AuthorizationManager;
 import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.entity.DelegatorFactory;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
-import org.ofbiz.security.SecurityFactory;
 import org.ofbiz.service.ExecutionContext;
 import org.ofbiz.service.GenericDispatcher;
 import org.ofbiz.service.LocalDispatcher;
@@ -44,12 +44,12 @@
     protected GenericValue userLogin = null;
 
  public AccessController getAccessController() {
-        return (AccessController) this.getSecurity().getAccessController(this);
+        return (AccessController) this.getSecurity().getAccessController();
  }
 
  public GenericDelegator getDelegator() {
  if (this.delegator == null) {
- this.delegator = DelegatorFactory.getGenericDelegator("default", this);
+ this.delegator = DelegatorFactory.getGenericDelegator("default");
  }
  return this.delegator;
  }
@@ -62,13 +62,16 @@
  }
 
  public AuthorizationManager getSecurity() {
- if (this.security == null) {
+    if (this.security == null) {
+            ClassLoader loader = Thread.currentThread().getContextClassLoader();
+            String className = UtilProperties.getPropertyValue("api.properties", "authorizationManager.class");
             try {
- this.security = SecurityFactory.getInstance(this.getDelegator());
- } catch (Exception e) {
- }
- }
- return this.security;
+                this.security = (AuthorizationManager) loader.loadClass(className).newInstance();
+            } catch (Exception e) {
+                Debug.logError(e, module);
+            }
+    }
+    return this.security;
  }
 
  public GenericValue getUserLogin() {
@@ -107,7 +110,6 @@
 
  public void setDelegator(GenericDelegator delegator) {
  if (delegator != null) {
- delegator.setExecutionContext(this);
  this.delegator = delegator;
  }
  }

Modified: ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareEli.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareEli.java?rev=894271&r1=894270&r2=894271&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareEli.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareEli.java Mon Dec 28 23:14:02 2009
@@ -27,7 +27,6 @@
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.entity.util.EntityListIterator;
-import org.ofbiz.service.ExecutionContext;
 
 /**
  * SecurityAwareEli class.  This class decorates an <code>
@@ -45,8 +44,8 @@
     protected final EntityListIterator listIterator;
     protected GenericValue previousValue = null;
 
-    public SecurityAwareEli(EntityListIterator iterator, Set<String> serviceNameList, ExecutionContext executionContext) {
-        super(iterator, serviceNameList, executionContext);
+    public SecurityAwareEli(EntityListIterator iterator, Set<String> serviceNameList) {
+        super(iterator, serviceNameList);
         this.listIterator = iterator;
     }
 

Modified: ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareIterator.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareIterator.java?rev=894271&r1=894270&r2=894271&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareIterator.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareIterator.java Mon Dec 28 23:14:02 2009
@@ -25,7 +25,7 @@
 import javolution.util.FastMap;
 
 import org.ofbiz.base.util.Debug;
-import org.ofbiz.service.ExecutionContext;
+import org.ofbiz.service.ThreadContext;
 import org.ofbiz.service.LocalDispatcher;
 import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.ModelService;
@@ -45,13 +45,11 @@
     public static final String module = SecurityAwareIterator.class.getName();
     protected final Iterator<E> iterator;
     protected final Set<String> serviceNameList;
-    protected final ExecutionContext executionContext;
     protected E nextValue = null;
 
-    public SecurityAwareIterator(Iterator<E> iterator, Set<String> serviceNameList, ExecutionContext executionContext) {
+    public SecurityAwareIterator(Iterator<E> iterator, Set<String> serviceNameList) {
         this.iterator = iterator;
         this.serviceNameList = serviceNameList;
-        this.executionContext = executionContext;
         getNext();
     }
 
@@ -89,14 +87,14 @@
     }
 
     protected boolean hasPermission(E value) {
-        if (this.executionContext.getUserLogin() == null) {
+        if (ThreadContext.getUserLogin() == null) {
             // This is here for development purposes
             return true;
         }
         try {
-            LocalDispatcher dispatcher = this.executionContext.getDispatcher();
+            LocalDispatcher dispatcher = ThreadContext.getDispatcher();
             DispatchContext ctx = dispatcher.getDispatchContext();
-            Map<String, ? extends Object> params = this.executionContext.getParameters();
+            Map<String, ? extends Object> params = ThreadContext.getParameters();
             for (String serviceName : this.serviceNameList) {
                 ModelService modelService = ctx.getModelService(serviceName);
                 Map<String, Object> context = FastMap.newInstance();
@@ -104,13 +102,13 @@
                     context.putAll(params);
                 }
                 if (!context.containsKey("userLogin")) {
-                    context.put("userLogin", this.executionContext.getUserLogin());
+                    context.put("userLogin", ThreadContext.getUserLogin());
                 }
                 if (!context.containsKey("locale")) {
-                    context.put("locale", this.executionContext.getLocale());
+                    context.put("locale", ThreadContext.getLocale());
                 }
                 if (!context.containsKey("timeZone")) {
-                    context.put("timeZone", this.executionContext.getTimeZone());
+                    context.put("timeZone", ThreadContext.getTimeZone());
                 }
                 context.put("candidateObject", value);
                 context = modelService.makeValid(context, ModelService.IN_PARAM);

Modified: ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareList.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareList.java?rev=894271&r1=894270&r2=894271&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareList.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareList.java Mon Dec 28 23:14:02 2009
@@ -24,8 +24,6 @@
 import java.util.ListIterator;
 import java.util.Set;
 
-import org.ofbiz.service.ExecutionContext;
-
 /**
  * SecurityAwareList class.
  */
@@ -34,23 +32,21 @@
 
  protected final static String module = SecurityAwareList.class.getName();
     protected final Set<String> serviceNameList;
-    protected final ExecutionContext executionContext;
 
- public SecurityAwareList(List<E> valueList, Set<String> serviceNameList, ExecutionContext executionContext) {
+ public SecurityAwareList(List<E> valueList, Set<String> serviceNameList) {
  super(valueList.size());
  this.addAll(valueList);
  this.trimToSize();
  this.serviceNameList = serviceNameList;
- this.executionContext = executionContext;
  }
 
  @Override
     public Iterator<E> iterator() {
-        return new SecurityAwareIterator<E>(super.iterator(), this.serviceNameList, this.executionContext);
+        return new SecurityAwareIterator<E>(super.iterator(), this.serviceNameList);
     }
 
     @Override
     public ListIterator<E> listIterator() {
-        return new SecurityAwareListIterator<E>(super.listIterator(), this.serviceNameList, this.executionContext);
+        return new SecurityAwareListIterator<E>(super.listIterator(), this.serviceNameList);
     }
 }

Modified: ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareListIterator.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareListIterator.java?rev=894271&r1=894270&r2=894271&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareListIterator.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/context/src/org/ofbiz/context/SecurityAwareListIterator.java Mon Dec 28 23:14:02 2009
@@ -21,8 +21,6 @@
 import java.util.ListIterator;
 import java.util.Set;
 
-import org.ofbiz.service.ExecutionContext;
-
 /**
  * SecurityAwareListIterator class.  This class decorates a <code>
  * ListIterator</code> instance and filters a list of
@@ -40,8 +38,8 @@
     protected E previousValue = null;
     protected int index = 0;
 
-    public SecurityAwareListIterator(ListIterator<E> iterator, Set<String> serviceNameList, ExecutionContext executionContext) {
-        super(iterator, serviceNameList, executionContext);
+    public SecurityAwareListIterator(ListIterator<E> iterator, Set<String> serviceNameList) {
+        super(iterator, serviceNameList);
         this.listIterator = iterator;
     }
 

Modified: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java?rev=894271&r1=894270&r2=894271&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/DelegatorFactory.java Mon Dec 28 23:14:02 2009
@@ -18,7 +18,6 @@
  */
 package org.ofbiz.entity;
 
-import org.ofbiz.api.context.ExecutionContextFactory;
 import org.ofbiz.base.util.Debug;
 
 /** GenericDelegator Factory Class. */
@@ -27,15 +26,6 @@
     public static final String module = DelegatorFactory.class.getName();
 
     public static GenericDelegator getGenericDelegator(String delegatorName) {
-     try {
- return getGenericDelegator(delegatorName, (ExecutionContext) ExecutionContextFactory.getInstance());
- } catch (Exception e) {
-            Debug.logError(e, "Could not get ExecutionContext instance: ", module);
- }
- return null;
-    }
-
-    public static GenericDelegator getGenericDelegator(String delegatorName, ExecutionContext executionContext) {
         if (delegatorName == null) {
             delegatorName = "default";
             Debug.logWarning(new Exception("Location where getting delegator with null name"), "Got a getGenericDelegator call with a null delegatorName, assuming default for the name.", module);
@@ -47,7 +37,7 @@
             Debug.logError(e, "Could not create delegator with name \"" + delegatorName + "\": ", module);
         }
         if (delegatorData != null) {
-            return new DelegatorImpl(delegatorData, executionContext);
+            return new DelegatorImpl(delegatorData);
         }
         return null;
     }

Modified: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/DelegatorImpl.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/DelegatorImpl.java?rev=894271&r1=894270&r2=894271&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/DelegatorImpl.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/DelegatorImpl.java Mon Dec 28 23:14:02 2009
@@ -148,8 +148,6 @@
 
     protected final DelegatorData delegatorData;
 
-    protected ExecutionContext executionContext;
-
     private boolean testMode = false;
 
     private List<TestOperation> testOperations = null;
@@ -160,8 +158,7 @@
 
     protected String userIdentifier = "";
 
-    protected DelegatorImpl(DelegatorData delegatorData, ExecutionContext executionContext) {
-     this.executionContext = executionContext;
+    protected DelegatorImpl(DelegatorData delegatorData) {
         this.delegatorData = delegatorData;
         if (!delegatorData.initialized) {
          initDelegatorData();
@@ -341,7 +338,7 @@
         // creates an exact clone of the delegator; except for the sequencer
         // note that this will not be cached and should be used only when
         // needed to change something for single instance (use).
-        DelegatorImpl newDelegator = new DelegatorImpl((DelegatorData) this.delegatorData.clone(), this.executionContext);
+        DelegatorImpl newDelegator = new DelegatorImpl((DelegatorData) this.delegatorData.clone());
         newDelegator.delegatorData.delegatorName = delegatorName;
         // In case this delegator is in testMode give it a reference to
         // the rollback list
@@ -368,8 +365,8 @@
     }
 
     public GenericValue create(GenericValue value, boolean doCacheClear) throws GenericEntityException {
-     this.executionContext.pushExecutionArtifact(value);
-     AccessController accessController = this.executionContext.getAccessController();
+     ThreadContext.pushExecutionArtifact(value);
+     AccessController accessController = ThreadContext.getAccessController();
         boolean beganTransaction = false;
         try {
          accessController.checkPermission(Create);
@@ -428,7 +425,7 @@
             // after rolling back, rethrow the exception
             throw e;
         } finally {
-         this.executionContext.popExecutionArtifact();
+         ThreadContext.popExecutionArtifact();
             // only commit the transaction if we started one... this will throw
             // an exception if it fails
             TransactionUtil.commit(beganTransaction);
@@ -522,8 +519,8 @@
     }
 
     public GenericValue createOrStore(GenericValue value, boolean doCacheClear) throws GenericEntityException {
-     this.executionContext.pushExecutionArtifact(value);
-     AccessController accessController = this.executionContext.getAccessController();
+     ThreadContext.pushExecutionArtifact(value);
+     AccessController accessController = ThreadContext.getAccessController();
         boolean beganTransaction = false;
         try {
             GenericValue checkValue = this.findOne(value.getEntityName(), value.getPrimaryKey(), false);
@@ -557,7 +554,7 @@
             // after rolling back, rethrow the exception
             throw e;
         } finally {
-         this.executionContext.popExecutionArtifact();
+         ThreadContext.popExecutionArtifact();
             // only commit the transaction if we started one... this will throw
             // an exception if it fails
             TransactionUtil.commit(beganTransaction);
@@ -780,10 +777,10 @@
         eli.setDelegator(this);
 
         ecaRunner.evalRules(EntityEcaHandler.EV_RETURN, EntityEcaHandler.OP_FIND, dummyValue, false);
-        this.executionContext.pushExecutionArtifact(modelEntity);
-        AccessController accessController = this.executionContext.getAccessController();
+        ThreadContext.pushExecutionArtifact(modelEntity);
+        AccessController accessController = ThreadContext.getAccessController();
         ListIterator<GenericValue> li = accessController.applyFilters((ListIterator<GenericValue>) eli);
-        this.executionContext.popExecutionArtifact();
+        ThreadContext.popExecutionArtifact();
         return (EntityListIterator) li;
     }
 
@@ -836,7 +833,7 @@
             }
 
             this.decryptFields(results);
-            AccessController accessController = this.executionContext.getAccessController();
+            AccessController accessController = ThreadContext.getAccessController();
             results = accessController.applyFilters(results);
             return results;
         } catch (GenericEntityException e) {
@@ -905,7 +902,7 @@
             }
 
             this.decryptFields(results);
-            AccessController accessController = this.executionContext.getAccessController();
+            AccessController accessController = ThreadContext.getAccessController();
             results = accessController.applyFilters(results);
             return results;
         } catch (GenericEntityException e) {
@@ -992,10 +989,10 @@
 
             EntityListIterator eli = this.find(entityName, whereEntityCondition, havingEntityCondition, UtilMisc.toSet(fieldsToSelect), orderBy, findOptions);
             eli.setDelegator(this);
-            this.executionContext.pushExecutionArtifact(new GenericExecutionArtifact("GenericDelegator.findByCondition", entityName));
-            AccessController accessController = this.executionContext.getAccessController();
+            ThreadContext.pushExecutionArtifact(new GenericExecutionArtifact("GenericDelegator.findByCondition", entityName));
+            AccessController accessController = ThreadContext.getAccessController();
             eli = (EntityListIterator) accessController.applyFilters((ListIterator<GenericValue>) eli);
-            this.executionContext.popExecutionArtifact();
+            ThreadContext.popExecutionArtifact();
             List<GenericValue> list = eli.getCompleteList();
             eli.close();
 
@@ -1241,10 +1238,10 @@
 
             List<GenericValue> cacheList = this.delegatorData.cache.get(entityName, entityCondition, orderBy);
             if (cacheList != null) {
-                this.executionContext.pushExecutionArtifact(new GenericExecutionArtifact("GenericDelegator.findList", entityName));
-                AccessController accessController = this.executionContext.getAccessController();
+                ThreadContext.pushExecutionArtifact(new GenericExecutionArtifact("GenericDelegator.findList", entityName));
+                AccessController accessController = ThreadContext.getAccessController();
                 cacheList = accessController.applyFilters(cacheList);
-                this.executionContext.popExecutionArtifact();
+                ThreadContext.popExecutionArtifact();
                 return cacheList;
             }
         }
@@ -1264,10 +1261,10 @@
                 ecaRunner.evalRules(EntityEcaHandler.EV_CACHE_PUT, EntityEcaHandler.OP_FIND, dummyValue, false);
                 this.delegatorData.cache.put(entityName, entityCondition, orderBy, list);
             }
-            this.executionContext.pushExecutionArtifact(new GenericExecutionArtifact("GenericDelegator.findList", entityName));
-            AccessController accessController = this.executionContext.getAccessController();
+            ThreadContext.pushExecutionArtifact(new GenericExecutionArtifact("GenericDelegator.findList", entityName));
+            AccessController accessController = ThreadContext.getAccessController();
             list = accessController.applyFilters(list);
-            this.executionContext.popExecutionArtifact();
+            ThreadContext.popExecutionArtifact();
             return list;
         } catch (GenericEntityException e) {
             String errMsg = "Failure in findByCondition operation for entity [" + entityName + "]: " + e.toString() + ". Rolling back transaction.";
@@ -1313,10 +1310,10 @@
         EntityListIterator eli = helper.findListIteratorByCondition(modelViewEntity, whereEntityCondition, havingEntityCondition, fieldsToSelect, orderBy, findOptions);
         eli.setDelegator(this);
         // TODO: add decrypt fields
-        this.executionContext.pushExecutionArtifact(new GenericExecutionArtifact("GenericDelegator.findListIteratorByCondition", modelViewEntity.getEntityName()));
-        AccessController accessController = this.executionContext.getAccessController();
+        ThreadContext.pushExecutionArtifact(new GenericExecutionArtifact("GenericDelegator.findListIteratorByCondition", modelViewEntity.getEntityName()));
+        AccessController accessController = ThreadContext.getAccessController();
         eli = (EntityListIterator) accessController.applyFilters((ListIterator<GenericValue>) eli);
-        this.executionContext.popExecutionArtifact();
+        ThreadContext.popExecutionArtifact();
         return eli;
     }
 
@@ -1486,7 +1483,7 @@
     }
 
     public Locale getLocale() {
-        return this.executionContext.getLocale();
+        return ThreadContext.getLocale();
     }
 
     public ModelEntity getModelEntity(String entityName) {
@@ -2183,8 +2180,8 @@
     }
 
     public int removeByCondition(String entityName, EntityCondition condition, boolean doCacheClear) throws GenericEntityException {
-     this.executionContext.pushExecutionArtifact(new GenericExecutionArtifact("GenericDelegator.removeByCondition", entityName));
-     AccessController accessController = this.executionContext.getAccessController();
+     ThreadContext.pushExecutionArtifact(new GenericExecutionArtifact("GenericDelegator.removeByCondition", entityName));
+     AccessController accessController = ThreadContext.getAccessController();
         boolean beganTransaction = false;
         try {
          accessController.checkPermission(Delete);
@@ -2225,7 +2222,7 @@
             // after rolling back, rethrow the exception
             throw e;
         } finally {
-         this.executionContext.popExecutionArtifact();
+         ThreadContext.popExecutionArtifact();
             // only commit the transaction if we started one... this will throw
             // an exception if it fails
             TransactionUtil.commit(beganTransaction);
@@ -2238,8 +2235,8 @@
     }
 
     public int removeByPrimaryKey(GenericPK primaryKey, boolean doCacheClear) throws GenericEntityException {
-     this.executionContext.pushExecutionArtifact(primaryKey);
-     AccessController accessController = this.executionContext.getAccessController();
+     ThreadContext.pushExecutionArtifact(primaryKey);
+     AccessController accessController = ThreadContext.getAccessController();
         boolean beganTransaction = false;
         try {
          accessController.checkPermission(Delete);
@@ -2292,7 +2289,7 @@
             // after rolling back, rethrow the exception
             throw e;
         } finally {
-         this.executionContext.popExecutionArtifact();
+         ThreadContext.popExecutionArtifact();
             // only commit the transaction if we started one... this will throw an
             // exception if it fails
             TransactionUtil.commit(beganTransaction);
@@ -2325,8 +2322,8 @@
     }
 
     public int removeValue(GenericValue value, boolean doCacheClear) throws GenericEntityException {
-     this.executionContext.pushExecutionArtifact(value);
-     AccessController accessController = this.executionContext.getAccessController();
+     ThreadContext.pushExecutionArtifact(value);
+     AccessController accessController = ThreadContext.getAccessController();
         // NOTE: this does not call the GenericDelegator.removeByPrimaryKey
         // method because it has more information to pass to the ECA rule hander
         boolean beganTransaction = false;
@@ -2382,7 +2379,7 @@
             // after rolling back, rethrow the exception
             throw e;
         } finally {
-         this.executionContext.popExecutionArtifact();
+         ThreadContext.popExecutionArtifact();
             // only commit the transaction if we started one... this will throw
             // an exception if it fails
             TransactionUtil.commit(beganTransaction);
@@ -2524,7 +2521,7 @@
     }
 
     public void setLocale(Locale locale) {
-        this.executionContext.setLocale(locale);
+        ThreadContext.setLocale(locale);
     }
 
     public void setSessionIdentifier(String identifier) {
@@ -2553,8 +2550,8 @@
     }
 
     public int store(GenericValue value, boolean doCacheClear) throws GenericEntityException {
-     this.executionContext.pushExecutionArtifact(value);
-     AccessController accessController = this.executionContext.getAccessController();
+     ThreadContext.pushExecutionArtifact(value);
+     AccessController accessController = ThreadContext.getAccessController();
         boolean beganTransaction = false;
         try {
          accessController.checkPermission(Update);
@@ -2612,7 +2609,7 @@
             // after rolling back, rethrow the exception
             throw e;
         } finally {
-         this.executionContext.popExecutionArtifact();
+         ThreadContext.popExecutionArtifact();
             // only commit the transaction if we started one... this will throw
             // an exception if it fails
             TransactionUtil.commit(beganTransaction);
@@ -2717,8 +2714,8 @@
     }
 
     public int storeByCondition(String entityName, Map<String, ? extends Object> fieldsToSet, EntityCondition condition, boolean doCacheClear) throws GenericEntityException {
-     this.executionContext.pushExecutionArtifact(new GenericExecutionArtifact("GenericDelegator.storeByCondition", entityName));
-     AccessController accessController = this.executionContext.getAccessController();
+     ThreadContext.pushExecutionArtifact(new GenericExecutionArtifact("GenericDelegator.storeByCondition", entityName));
+     AccessController accessController = ThreadContext.getAccessController();
         boolean beganTransaction = false;
         try {
          accessController.checkPermission(Update);
@@ -2759,7 +2756,7 @@
             // after rolling back, rethrow the exception
             throw e;
         } finally {
-         this.executionContext.popExecutionArtifact();
+         ThreadContext.popExecutionArtifact();
             // only commit the transaction if we started one... this will throw
             // an exception if it fails
             TransactionUtil.commit(beganTransaction);
@@ -2773,10 +2770,4 @@
         this.testOperations.add(testOperation);
     }
 
- public void setExecutionContext(ExecutionContext executionContext) {
- if (executionContext != null) {
- this.executionContext = executionContext;
- }
- }
-
 }

Modified: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/GenericDelegator.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/GenericDelegator.java?rev=894271&r1=894270&r2=894271&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/GenericDelegator.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/GenericDelegator.java Mon Dec 28 23:14:02 2009
@@ -1104,8 +1104,6 @@
 
     public void setEntityEcaHandler(EntityEcaHandler<?> entityEcaHandler);
 
-    public void setExecutionContext(ExecutionContext executionContext);
-
     public void setLocale(Locale locale);
 
     /** Look at existing values for a sub-entity with a sequenced secondary ID, and get the highest plus 1 */

Added: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/ThreadContext.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/ThreadContext.java?rev=894271&view=auto
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/ThreadContext.java (added)
+++ ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/ThreadContext.java Mon Dec 28 23:14:02 2009
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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.entity;
+
+/** A convenience class for accessing the current thread's <code>ExecutionContext</code>.
+ * @see {@link org.ofbiz.entity.ExecutionContext}
+ */
+public class ThreadContext extends org.ofbiz.api.context.ThreadContext {
+
+    protected static final String module = ThreadContext.class.getName();
+
+    public static GenericDelegator getDelegator() {
+        return getExecutionContext().getDelegator();
+    }
+
+    protected static ExecutionContext getExecutionContext() {
+        return (ExecutionContext) executionContext.get();
+    }
+
+    public static GenericValue getUserLogin() {
+        return getExecutionContext().getUserLogin();
+    }
+
+    public static void setDelegator(GenericDelegator delegator) {
+        getExecutionContext().setDelegator(delegator);
+    }
+
+    public static void setUserLogin(GenericValue userLogin) {
+        getExecutionContext().setUserLogin(userLogin);
+    }
+}

Propchange: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/ThreadContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/ThreadContext.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/branches/executioncontext20090812/framework/entity/src/org/ofbiz/entity/ThreadContext.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/branches/executioncontext20090812/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java?rev=894271&r1=894270&r2=894271&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/entityext/src/org/ofbiz/entityext/data/EntityDataLoadContainer.java Mon Dec 28 23:14:02 2009
@@ -28,7 +28,9 @@
 
 import javolution.util.FastList;
 
-import org.ofbiz.api.authorization.AccessController;
+import org.ofbiz.api.authorization.AuthorizationManager;
+import org.ofbiz.api.authorization.NullAuthorizationManager;
+import org.ofbiz.api.context.GenericExecutionArtifact;
 import org.ofbiz.base.container.Container;
 import org.ofbiz.base.container.ContainerConfig;
 import org.ofbiz.base.container.ContainerException;
@@ -36,8 +38,6 @@
 import org.ofbiz.base.util.StringUtil;
 import org.ofbiz.base.util.UtilURL;
 import org.ofbiz.base.util.UtilValidate;
-import org.ofbiz.context.AuthorizationManagerImpl;
-import org.ofbiz.context.ExecutionContextImpl;
 import org.ofbiz.entity.DelegatorFactory;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.GenericEntityException;
@@ -45,6 +45,7 @@
 import org.ofbiz.entity.model.ModelEntity;
 import org.ofbiz.entity.util.EntityDataLoader;
 import org.ofbiz.service.ServiceDispatcher;
+import org.ofbiz.service.ThreadContext;
 
 
 /**
@@ -228,7 +229,7 @@
 
         String delegatorNameToUse = overrideDelegator != null ? overrideDelegator : delegatorName;
         String groupNameToUse = overrideGroup != null ? overrideGroup : entityGroupName;
-        GenericDelegator delegator = DelegatorFactory.getGenericDelegator(delegatorNameToUse, new LoaderExecutionContext());
+        GenericDelegator delegator = DelegatorFactory.getGenericDelegator(delegatorNameToUse);
         if (delegator == null) {
             throw new ContainerException("Invalid delegator name!");
         }
@@ -246,73 +247,62 @@
         } catch (GenericEntityException e) {
             throw new ContainerException(e.getMessage(), e);
         }        
-        TreeSet<String> modelEntityNames = new TreeSet<String>(modelEntities.keySet());    
-        
-        // check for drop index/fks
-        if (dropConstraints) {                  
-            List<String> messages = FastList.newInstance();
-            
-            Debug.logImportant("Dropping foreign key indcies...", module);
-            for (String entityName : modelEntityNames) {
-                ModelEntity modelEntity = modelEntities.get(entityName);
-                if (modelEntity != null) {
-                    dbUtil.deleteForeignKeyIndices(modelEntity, messages);
-                }
-            }
-            
-            Debug.logImportant("Dropping declared indices...", module);
-            for (String entityName : modelEntityNames) {
-                ModelEntity modelEntity = modelEntities.get(entityName);
-                if (modelEntity != null) {
-                    dbUtil.deleteDeclaredIndices(modelEntity, messages);
-                }
-            }
-            
-            Debug.logImportant("Dropping foreign keys...", module);
-            for (String entityName : modelEntityNames) {
-                ModelEntity modelEntity = modelEntities.get(entityName);
-                if (modelEntity != null) {
-                    dbUtil.deleteForeignKeys(modelEntity, modelEntities, messages);
-                }
-            }
-            
-            if (messages.size() > 0) {
-                if (Debug.infoOn()) {
-                    for (String message : messages) {
-                        Debug.logInfo(message, module);
+        TreeSet<String> modelEntityNames = new TreeSet<String>(modelEntities.keySet());
+
+        // Set up the execution context
+        AuthorizationManager oldAuthorizationManager = ThreadContext.getSecurity();
+        ThreadContext.setSecurity(new NullAuthorizationManager());
+        ThreadContext.setDelegator(delegator);
+        ThreadContext.pushExecutionArtifact(new GenericExecutionArtifact(module, "EntityDataLoad"));
+        try {
+            // check for drop index/fks
+            if (dropConstraints) {                  
+                List<String> messages = FastList.newInstance();
+
+                Debug.logImportant("Dropping foreign key indcies...", module);
+                for (String entityName : modelEntityNames) {
+                    ModelEntity modelEntity = modelEntities.get(entityName);
+                    if (modelEntity != null) {
+                        dbUtil.deleteForeignKeyIndices(modelEntity, messages);
                     }
                 }
-            }
-        }
-        
-        // drop pks
-        if (dropPks) {
-            List<String> messages = FastList.newInstance();
-            Debug.logImportant("Dropping primary keys...", module);
-            for (String entityName : modelEntityNames) {
-                ModelEntity modelEntity = modelEntities.get(entityName);
-                if (modelEntity != null) {
-                    dbUtil.deletePrimaryKey(modelEntity, messages);
-                }
-            }
-            
-            if (messages.size() > 0) {
-                if (Debug.infoOn()) {
-                    for (String message : messages) {
-                        Debug.logInfo(message, module);
+
+                Debug.logImportant("Dropping declared indices...", module);
+                for (String entityName : modelEntityNames) {
+                    ModelEntity modelEntity = modelEntities.get(entityName);
+                    if (modelEntity != null) {
+                        dbUtil.deleteDeclaredIndices(modelEntity, messages);
+                    }
+                }
+
+                Debug.logImportant("Dropping foreign keys...", module);
+                for (String entityName : modelEntityNames) {
+                    ModelEntity modelEntity = modelEntities.get(entityName);
+                    if (modelEntity != null) {
+                        dbUtil.deleteForeignKeys(modelEntity, modelEntities, messages);
+                    }
+                }
+
+                if (messages.size() > 0) {
+                    if (Debug.infoOn()) {
+                        for (String message : messages) {
+                            Debug.logInfo(message, module);
+                        }
                     }
                 }
             }
-        }
-        
-        // repair columns
-        if (repairColumns) {
-            List<String> fieldsToRepair = FastList.newInstance();
-            List<String> messages = FastList.newInstance();
-            dbUtil.checkDb(modelEntities, fieldsToRepair, messages, false, false, false, false);
-            if (fieldsToRepair.size() > 0) {
-                messages = FastList.newInstance();
-                dbUtil.repairColumnSizeChanges(modelEntities, fieldsToRepair, messages);
+
+            // drop pks
+            if (dropPks) {
+                List<String> messages = FastList.newInstance();
+                Debug.logImportant("Dropping primary keys...", module);
+                for (String entityName : modelEntityNames) {
+                    ModelEntity modelEntity = modelEntities.get(entityName);
+                    if (modelEntity != null) {
+                        dbUtil.deletePrimaryKey(modelEntity, messages);
+                    }
+                }
+
                 if (messages.size() > 0) {
                     if (Debug.infoOn()) {
                         for (String message : messages) {
@@ -321,150 +311,170 @@
                     }
                 }
             }
-        }
-        
-        // get the reader name URLs first
-        List<URL> urlList = null;
-        if (readerNames != null) {
-            urlList = EntityDataLoader.getUrlList(helperName, component, readerNames);
-        } else if (!"none".equalsIgnoreCase(this.readers)) {
-            urlList = EntityDataLoader.getUrlList(helperName, component);
-        }
 
-        // need a list if it is empty
-        if (urlList == null) {
-            urlList = FastList.newInstance();
-        }
+            // repair columns
+            if (repairColumns) {
+                List<String> fieldsToRepair = FastList.newInstance();
+                List<String> messages = FastList.newInstance();
+                dbUtil.checkDb(modelEntities, fieldsToRepair, messages, false, false, false, false);
+                if (fieldsToRepair.size() > 0) {
+                    messages = FastList.newInstance();
+                    dbUtil.repairColumnSizeChanges(modelEntities, fieldsToRepair, messages);
+                    if (messages.size() > 0) {
+                        if (Debug.infoOn()) {
+                            for (String message : messages) {
+                                Debug.logInfo(message, module);
+                            }
+                        }
+                    }
+                }
+            }
 
-        // add in the defined extra files
-        for (String fileName: this.files) {
-            URL fileUrl = UtilURL.fromResource((String) fileName);
-            if (fileUrl != null) {
-                urlList.add(fileUrl);
+            // get the reader name URLs first
+            List<URL> urlList = null;
+            if (readerNames != null) {
+                urlList = EntityDataLoader.getUrlList(helperName, component, readerNames);
+            } else if (!"none".equalsIgnoreCase(this.readers)) {
+                urlList = EntityDataLoader.getUrlList(helperName, component);
+            }
+
+            // need a list if it is empty
+            if (urlList == null) {
+                urlList = FastList.newInstance();
+            }
+
+            // add in the defined extra files
+            for (String fileName: this.files) {
+                URL fileUrl = UtilURL.fromResource((String) fileName);
+                if (fileUrl != null) {
+                    urlList.add(fileUrl);
+                }
             }
-        }
 
-        // next check for a directory of files
-        if (this.directory != null) {
-            File dir = new File(this.directory);
-            if (dir.exists() && dir.isDirectory() && dir.canRead()) {
-                File[] fileArray = dir.listFiles();
-                if (fileArray != null && fileArray.length > 0) {
-                    for (File file: fileArray) {
-                        if (file.getName().toLowerCase().endsWith(".xml")) {
-                            try {
-                                urlList.add(file.toURI().toURL());
-                            } catch (MalformedURLException e) {
-                                Debug.logError(e, "Unable to load file (" + file.getName() + "); not a valid URL.", module);
+            // next check for a directory of files
+            if (this.directory != null) {
+                File dir = new File(this.directory);
+                if (dir.exists() && dir.isDirectory() && dir.canRead()) {
+                    File[] fileArray = dir.listFiles();
+                    if (fileArray != null && fileArray.length > 0) {
+                        for (File file: fileArray) {
+                            if (file.getName().toLowerCase().endsWith(".xml")) {
+                                try {
+                                    urlList.add(file.toURI().toURL());
+                                } catch (MalformedURLException e) {
+                                    Debug.logError(e, "Unable to load file (" + file.getName() + "); not a valid URL.", module);
+                                }
                             }
                         }
                     }
                 }
             }
-        }
 
-        // process the list of files
-        NumberFormat changedFormat = NumberFormat.getIntegerInstance();
-        changedFormat.setMinimumIntegerDigits(5);
-        changedFormat.setGroupingUsed(false);
-
-        List<Object> errorMessages = FastList.newInstance();
-        List<String> infoMessages = FastList.newInstance();
-        int totalRowsChanged = 0;
-        if (UtilValidate.isNotEmpty(urlList)) {
-            Debug.logImportant("=-=-=-=-=-=-= Doing a data load with the following files:", module);
-            for (URL dataUrl: urlList) {
-                Debug.logImportant(dataUrl.toExternalForm(), module);
-            }
-
-            Debug.logImportant("=-=-=-=-=-=-= Starting the data load...", module);
-
-            for (URL dataUrl: urlList) {
-                try {
-                    int rowsChanged = EntityDataLoader.loadData(dataUrl, helperName, delegator, errorMessages, txTimeout, useDummyFks, maintainTxs, tryInserts);
-                    totalRowsChanged += rowsChanged;
-                    infoMessages.add(changedFormat.format(rowsChanged) + " of " + changedFormat.format(totalRowsChanged) + " from " + dataUrl.toExternalForm());
-                } catch (GenericEntityException e) {
-                    Debug.logError(e, "Error loading data file: " + dataUrl.toExternalForm(), module);
+            // process the list of files
+            NumberFormat changedFormat = NumberFormat.getIntegerInstance();
+            changedFormat.setMinimumIntegerDigits(5);
+            changedFormat.setGroupingUsed(false);
+
+            List<Object> errorMessages = FastList.newInstance();
+            List<String> infoMessages = FastList.newInstance();
+            int totalRowsChanged = 0;
+            if (UtilValidate.isNotEmpty(urlList)) {
+                Debug.logImportant("=-=-=-=-=-=-= Doing a data load with the following files:", module);
+                for (URL dataUrl: urlList) {
+                    Debug.logImportant(dataUrl.toExternalForm(), module);
                 }
+
+                Debug.logImportant("=-=-=-=-=-=-= Starting the data load...", module);
+
+                for (URL dataUrl: urlList) {
+                    try {
+                        int rowsChanged = EntityDataLoader.loadData(dataUrl, helperName, delegator, errorMessages, txTimeout, useDummyFks, maintainTxs, tryInserts);
+                        totalRowsChanged += rowsChanged;
+                        infoMessages.add(changedFormat.format(rowsChanged) + " of " + changedFormat.format(totalRowsChanged) + " from " + dataUrl.toExternalForm());
+                    } catch (GenericEntityException e) {
+                        Debug.logError(e, "Error loading data file: " + dataUrl.toExternalForm(), module);
+                    }
+                }
+            } else {
+                Debug.logImportant("=-=-=-=-=-=-= No data load files found.", module);
             }
-        } else {
-            Debug.logImportant("=-=-=-=-=-=-= No data load files found.", module);
-        }
 
-        if (infoMessages.size() > 0) {
-            Debug.logImportant("=-=-=-=-=-=-= Here is a summary of the data load:", module);
-            for (String message: infoMessages) {
-              Debug.logImportant(message, module);
+            if (infoMessages.size() > 0) {
+                Debug.logImportant("=-=-=-=-=-=-= Here is a summary of the data load:", module);
+                for (String message: infoMessages) {
+                    Debug.logImportant(message, module);
+                }
             }
-        }
 
-        if (errorMessages.size() > 0) {
-            Debug.logImportant("The following errors occured in the data load:", module);
-            for (Object message: errorMessages) {
-              Debug.logImportant(message.toString(), module);
+            if (errorMessages.size() > 0) {
+                Debug.logImportant("The following errors occured in the data load:", module);
+                for (Object message: errorMessages) {
+                    Debug.logImportant(message.toString(), module);
+                }
             }
-        }
 
-        Debug.logImportant("=-=-=-=-=-=-= Finished the data load with " + totalRowsChanged + " rows changed.", module);
+            Debug.logImportant("=-=-=-=-=-=-= Finished the data load with " + totalRowsChanged + " rows changed.", module);
+
+            // create primary keys
+            if (createPks) {
+                List<String> messages = FastList.newInstance();
 
-        // create primary keys
-        if (createPks) {
-            List<String> messages = FastList.newInstance();
-            
-            Debug.logImportant("Creating primary keys...", module);
-            for (String entityName : modelEntityNames) {
-                ModelEntity modelEntity = modelEntities.get(entityName);
-                if (modelEntity != null) {
-                    dbUtil.createPrimaryKey(modelEntity, messages);
-                }
-            }
-            if (messages.size() > 0) {
-                if (Debug.infoOn()) {
-                    for (String message : messages) {
-                        Debug.logInfo(message, module);
+                Debug.logImportant("Creating primary keys...", module);
+                for (String entityName : modelEntityNames) {
+                    ModelEntity modelEntity = modelEntities.get(entityName);
+                    if (modelEntity != null) {
+                        dbUtil.createPrimaryKey(modelEntity, messages);
+                    }
+                }
+                if (messages.size() > 0) {
+                    if (Debug.infoOn()) {
+                        for (String message : messages) {
+                            Debug.logInfo(message, module);
+                        }
                     }
                 }
             }
-        }
-        
-        // create constraints
-        if (createConstraints) {                  
-            List<String> messages = FastList.newInstance();
-            
-            Debug.logImportant("Creating foreign keys...", module);
-            for (String entityName : modelEntityNames) {
-                ModelEntity modelEntity = modelEntities.get(entityName);
-                if (modelEntity != null) {
-                    dbUtil.createForeignKeys(modelEntity, modelEntities, messages);
-                }
-            }
-            
-            Debug.logImportant("Creating foreign key indcies...", module);
-            for (String entityName : modelEntityNames) {
-                ModelEntity modelEntity = modelEntities.get(entityName);
-                if (modelEntity != null) {
-                    dbUtil.createForeignKeyIndices(modelEntity, messages);
-                }
-            }
-            
-            Debug.logImportant("Creating declared indices...", module);
-            for (String entityName : modelEntityNames) {
-                ModelEntity modelEntity = modelEntities.get(entityName);
-                if (modelEntity != null) {
-                    dbUtil.createDeclaredIndices(modelEntity, messages);
-                }
-            }
-                                    
-            if (messages.size() > 0) {
-                if (Debug.infoOn()) {
-                    for (String message : messages) {
-                        Debug.logInfo(message, module);
+
+            // create constraints
+            if (createConstraints) {                  
+                List<String> messages = FastList.newInstance();
+
+                Debug.logImportant("Creating foreign keys...", module);
+                for (String entityName : modelEntityNames) {
+                    ModelEntity modelEntity = modelEntities.get(entityName);
+                    if (modelEntity != null) {
+                        dbUtil.createForeignKeys(modelEntity, modelEntities, messages);
+                    }
+                }
+
+                Debug.logImportant("Creating foreign key indcies...", module);
+                for (String entityName : modelEntityNames) {
+                    ModelEntity modelEntity = modelEntities.get(entityName);
+                    if (modelEntity != null) {
+                        dbUtil.createForeignKeyIndices(modelEntity, messages);
+                    }
+                }
+
+                Debug.logImportant("Creating declared indices...", module);
+                for (String entityName : modelEntityNames) {
+                    ModelEntity modelEntity = modelEntities.get(entityName);
+                    if (modelEntity != null) {
+                        dbUtil.createDeclaredIndices(modelEntity, messages);
+                    }
+                }
+
+                if (messages.size() > 0) {
+                    if (Debug.infoOn()) {
+                        for (String message : messages) {
+                            Debug.logInfo(message, module);
+                        }
                     }
                 }
             }
+        } finally {
+            ThreadContext.popExecutionArtifact();
+            ThreadContext.setSecurity(oldAuthorizationManager);
         }
-        
         return true;
     }
 
@@ -473,12 +483,4 @@
      */
     public void stop() throws ContainerException {
     }
-
-    // TODO: Find an implementation-agnostic way to do this
-    protected static class LoaderExecutionContext extends ExecutionContextImpl {
-        @Override
-        public AccessController getAccessController() {
-            return AuthorizationManagerImpl.nullAccessController;
-        }
-    }
 }

Modified: ofbiz/branches/executioncontext20090812/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java?rev=894271&r1=894270&r2=894271&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java (original)
+++ ofbiz/branches/executioncontext20090812/framework/minilang/src/org/ofbiz/minilang/method/callops/CallService.java Mon Dec 28 23:14:02 2009
@@ -25,7 +25,6 @@
 import javolution.util.FastList;
 import javolution.util.FastMap;
 
-import org.ofbiz.api.context.ExecutionContext;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilValidate;
@@ -229,14 +228,6 @@
         if (locale != null) {
             inMap.put("locale", locale);
         }
-        ExecutionContext executionContext = (ExecutionContext) methodContext.getParameter("executionContext");
-        if (executionContext == null) {
-            executionContext = (ExecutionContext) methodContext.getEnv("executionContext");
-        }
-        if (executionContext != null) {
-            inMap.put("executionContext", executionContext);
-        }
-
         try {
             if (UtilValidate.isEmpty(this.requireNewTransactionStr) && this.transactionTimeout < 0) {
                 result = methodContext.getDispatcher().runSync(serviceName, inMap);

Modified: ofbiz/branches/executioncontext20090812/framework/security/config/security.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/executioncontext20090812/framework/security/config/security.xml?rev=894271&r1=894270&r2=894271&view=diff
==============================================================================
--- ofbiz/branches/executioncontext20090812/framework/security/config/security.xml (original)
+++ ofbiz/branches/executioncontext20090812/framework/security/config/security.xml Mon Dec 28 23:14:02 2009
@@ -20,7 +20,7 @@
 
 <security-config>
     <!-- This is the default implementation and uses the OFBizSecurity implementation as its default -->
-    <security name="default"/>
+    <security name="default" class="org.ofbiz.context.AuthorizationManagerImpl"/>
 
     <!-- This is an example custom implementation and uses the class name specified as security implementation -->
     <!--