svn commit: r1364222 - in /ofbiz/trunk/framework: service/src/org/ofbiz/service/ service/src/org/ofbiz/service/jms/ webapp/src/org/ofbiz/webapp/control/ webtools/src/org/ofbiz/webtools/artifactinfo/ webtools/src/org/ofbiz/webtools/labelmanager/

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

svn commit: r1364222 - in /ofbiz/trunk/framework: service/src/org/ofbiz/service/ service/src/org/ofbiz/service/jms/ webapp/src/org/ofbiz/webapp/control/ webtools/src/org/ofbiz/webtools/artifactinfo/ webtools/src/org/ofbiz/webtools/labelmanager/

jacopoc
Author: jacopoc
Date: Sun Jul 22 07:33:48 2012
New Revision: 1364222

URL: http://svn.apache.org/viewvc?rev=1364222&view=rev
Log:
First pass of a rather relevant cleanup of service related code:
* removed the support for serviceReaderUrls for local services specified in the WEB-INF folder; this feature was not used in years and OFBiz has better mechanisms to define services in components;
* as a consequence of the previous point, a lot of code has been cleaned in the DispatchContext class; in this refactoring, I have fixed some non thread safe code (but this is only a first step and this class needs to be enhanced under this aspect)
* greatly simplified the static instance creator and constructors of ServiceDispatcher and  GenericDispatcher to reflect the changes in DispatchContext but also removed old unused code, simplified code for readability, added some comments to better document it

Modified:
    ofbiz/trunk/framework/service/src/org/ofbiz/service/DispatchContext.java
    ofbiz/trunk/framework/service/src/org/ofbiz/service/GenericDispatcher.java
    ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java
    ofbiz/trunk/framework/service/src/org/ofbiz/service/jms/AbstractJmsListener.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java
    ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelReferences.java

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/DispatchContext.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/DispatchContext.java?rev=1364222&r1=1364221&r2=1364222&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/DispatchContext.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/DispatchContext.java Sun Jul 22 07:33:48 2012
@@ -19,9 +19,6 @@
 package org.ofbiz.service;
 
 import java.io.Serializable;
-import java.net.URL;
-import java.util.Collection;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -43,6 +40,8 @@ import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilXml;
 import org.ofbiz.base.util.cache.UtilCache;
 import org.ofbiz.entity.Delegator;
+import org.ofbiz.entity.config.DelegatorInfo;
+import org.ofbiz.entity.config.EntityConfigUtil;
 import org.ofbiz.security.Security;
 import org.ofbiz.service.config.ServiceConfigUtil;
 import org.ofbiz.service.eca.ServiceEcaUtil;
@@ -57,31 +56,26 @@ public class DispatchContext implements
 
     public static final String module = DispatchContext.class.getName();
 
-    protected static final String GLOBAL_KEY = "global.services";
-    private static final UtilCache<String, Map<String, ModelService>> modelServiceMapByDispatcher = UtilCache.createUtilCache("service.ModelServiceMapByDispatcher", 0, 0, false);
+    private static final UtilCache<String, Map<String, ModelService>> modelServiceMapByModel = UtilCache.createUtilCache("service.ModelServiceMapByModel", 0, 0, false);
 
     protected transient LocalDispatcher dispatcher;
     protected transient ClassLoader loader;
-    protected Collection<URL> localReaders;
     protected Map<String, Object> attributes;
     protected String name;
+    private String model;
 
     /**
      * Creates new DispatchContext
-     * @param localReaders a collection of reader URLs
-     * @param loader the classloader to use for dispatched services
      */
-    public DispatchContext(String name, Collection<URL> localReaders, ClassLoader loader, LocalDispatcher dispatcher) {
+    public DispatchContext(String name, ClassLoader loader) {
         this.name = name;
-        this.localReaders = localReaders;
+        this.model = name; // this will change when a dispatcher is set to match the model name associated to the delegator's dispatcher
         this.loader = loader;
-        this.dispatcher = dispatcher;
         this.attributes = FastMap.newInstance();
     }
 
     public void loadReaders() {
-        this.getLocalServiceMap();
-        this.getGlobalServiceMap();
+        getGlobalServiceMap();
     }
 
     /**
@@ -113,14 +107,6 @@ public class DispatchContext implements
     }
 
     /**
-     * Gets the collection of readers associated with this context
-     * @return Collection of reader URLs
-     */
-    public Collection<URL> getReaders() {
-        return localReaders;
-    }
-
-    /**
      * Gets the name of the local dispatcher
      * @return String name of the LocalDispatcher object
      */
@@ -138,7 +124,7 @@ public class DispatchContext implements
      * @throws GenericServiceException
      */
     public Map<String, Object> makeValidContext(String serviceName, String mode, Map<String, ? extends Object> context) throws GenericServiceException {
-        ModelService model = this.getModelService(serviceName);
+        ModelService model = getModelService(serviceName);
         return makeValidContext(model, mode, context);
 
     }
@@ -152,7 +138,7 @@ public class DispatchContext implements
      * @return Map contains any valid values
      * @throws GenericServiceException
      */
-    public Map<String, Object> makeValidContext(ModelService model, String mode, Map<String, ? extends Object> context) throws GenericServiceException {
+    public static Map<String, Object> makeValidContext(ModelService model, String mode, Map<String, ? extends Object> context) throws GenericServiceException {
         Map<String, Object> newContext;
 
         int modeInt = 0;
@@ -186,35 +172,17 @@ public class DispatchContext implements
      */
     public ModelService getModelService(String serviceName) throws GenericServiceException {
         //long timeStart = System.currentTimeMillis();
-        ModelService retVal = getLocalModelService(serviceName);
-        if (retVal == null) {
-            retVal = getGlobalModelService(serviceName);
-        }
+        ModelService retVal = getGlobalModelService(serviceName);
 
         if (retVal == null) {
             throw new GenericServiceException("Cannot locate service by name (" + serviceName + ")");
         }
-
         //Debug.logTiming("Got ModelService for name [" + serviceName + "] in [" + (System.currentTimeMillis() - timeStart) + "] milliseconds", module);
         return retVal;
     }
 
-    private ModelService getLocalModelService(String serviceName) throws GenericServiceException {
-        Map<String, ModelService> serviceMap = this.getLocalServiceMap();
-
-        ModelService retVal = null;
-        if (serviceMap != null) {
-            retVal = serviceMap.get(serviceName);
-            if (retVal != null && !retVal.inheritedParameters()) {
-                retVal.interfaceUpdate(this);
-            }
-        }
-
-        return retVal;
-    }
-
     private ModelService getGlobalModelService(String serviceName) throws GenericServiceException {
-        Map<String, ModelService> serviceMap = this.getGlobalServiceMap();
+        Map<String, ModelService> serviceMap = getGlobalServiceMap();
 
         ModelService retVal = null;
         if (serviceMap != null) {
@@ -239,8 +207,17 @@ public class DispatchContext implements
      * Sets the LocalDispatcher used with this context
      * @param dispatcher The LocalDispatcher to re-assign to this context
      */
-    public void setDispatcher(LocalDispatcher dispatcher) {
+    public synchronized void setDispatcher(LocalDispatcher dispatcher) {
         this.dispatcher = dispatcher;
+        if (this.dispatcher != null) {
+            Delegator delegator = dispatcher.getDelegator();
+            if (delegator != null) {
+                DelegatorInfo delegatorInfo = EntityConfigUtil.getDelegatorInfo(delegator.getDelegatorBaseName());
+                if (delegatorInfo != null) {
+                    this.model = delegatorInfo.entityModelReader;
+                }
+            }
+        }
     }
 
     /**
@@ -259,28 +236,6 @@ public class DispatchContext implements
         return dispatcher.getSecurity();
     }
 
-    private Map<String, ModelService> getLocalServiceMap() {
-        Map<String, ModelService> serviceMap = modelServiceMapByDispatcher.get(name);
-        if (serviceMap == null) {
-            if (this.localReaders != null) {
-                serviceMap = FastMap.newInstance();
-                for (URL readerURL: this.localReaders) {
-                    Map<String, ModelService> readerServiceMap = ModelServiceReader.getModelServiceMap(readerURL, this);
-                    if (readerServiceMap != null) {
-                        serviceMap.putAll(readerServiceMap);
-                    }
-                }
-                serviceMap = new HashMap<String, ModelService>(serviceMap);
-            }
-            if (serviceMap != null) {
-                serviceMap = modelServiceMapByDispatcher.putIfAbsentAndGet(name, serviceMap);
-                // NOTE: the current ECA per dispatcher for local services stuff is a bit broken, so now just doing this on the global def load: ServiceEcaUtil.reloadConfig();
-            }
-        }
-
-        return serviceMap;
-    }
-
     private Callable<Map<String, ModelService>> createServiceReaderCallable(final ResourceHandler handler) {
         return new Callable<Map<String, ModelService>>() {
             public Map<String, ModelService> call() throws Exception {
@@ -289,8 +244,8 @@ public class DispatchContext implements
         };
     }
 
-    private Map<String, ModelService> getGlobalServiceMap() {
-        Map<String, ModelService> serviceMap = modelServiceMapByDispatcher.get(GLOBAL_KEY);
+    private synchronized Map<String, ModelService> getGlobalServiceMap() {
+        Map<String, ModelService> serviceMap = modelServiceMapByModel.get(this.model);
         if (serviceMap == null) {
             serviceMap = FastMap.newInstance();
 
@@ -322,27 +277,22 @@ public class DispatchContext implements
             }
 
             if (serviceMap != null) {
-                Map<String, ModelService> cachedServiceMap = modelServiceMapByDispatcher.putIfAbsentAndGet(GLOBAL_KEY, serviceMap);
+                Map<String, ModelService> cachedServiceMap = modelServiceMapByModel.putIfAbsentAndGet(this.model, serviceMap);
                 if (cachedServiceMap == serviceMap) { // same object: this means that the object created by this thread was actually added to the cache
                     ServiceEcaUtil.reloadConfig();
                 }
             }
         }
-
         return serviceMap;
     }
 
-    public Set<String> getAllServiceNames() {
+    public synchronized Set<String> getAllServiceNames() {
         Set<String> serviceNames = new TreeSet<String>();
 
-        Map<String, ModelService> globalServices = modelServiceMapByDispatcher.get(GLOBAL_KEY);
-        Map<String, ModelService> localServices = modelServiceMapByDispatcher.get(name);
+        Map<String, ModelService> globalServices = modelServiceMapByModel.get(this.model);
         if (globalServices != null) {
             serviceNames.addAll(globalServices.keySet());
         }
-        if (localServices != null) {
-            serviceNames.addAll(localServices.keySet());
-        }
         return serviceNames;
     }
 

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/GenericDispatcher.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/GenericDispatcher.java?rev=1364222&r1=1364221&r2=1364222&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/GenericDispatcher.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/GenericDispatcher.java Sun Jul 22 07:33:48 2012
@@ -18,8 +18,6 @@
  *******************************************************************************/
 package org.ofbiz.service;
 
-import java.net.URL;
-import java.util.Collection;
 import java.util.Map;
 import java.util.Set;
 
@@ -40,23 +38,13 @@ public class GenericDispatcher extends G
     protected static Map<String, LocalDispatcher> dispatcherCache = FastMap.newInstance();
 
     public static LocalDispatcher getLocalDispatcher(String dispatcherName, Delegator delegator) {
-        return getLocalDispatcher(dispatcherName, delegator, null, null, null);
-    }
-
-    public static LocalDispatcher getLocalDispatcher(String dispatcherName, Delegator delegator, Collection<URL> readerURLs, ClassLoader loader) {
-        return getLocalDispatcher(dispatcherName, delegator, readerURLs, loader, null);
-    }
-
-    public static LocalDispatcher getLocalDispatcher(String dispatcherName, Delegator delegator, Collection<URL> readerURLs, ClassLoader loader, ServiceDispatcher serviceDispatcher) {
         if (dispatcherName == null) {
             dispatcherName = delegator.getDelegatorName();
             Debug.logWarning("Got a getGenericDispatcher call with a null dispatcherName, assuming default for the name.", module);
         }
 
-        if (UtilValidate.isNotEmpty(delegator)) {
-            if (UtilValidate.isNotEmpty(delegator.getDelegatorTenantId())) {
-                dispatcherName += "#" + delegator.getDelegatorTenantId();
-            }
+        if (UtilValidate.isNotEmpty(delegator.getDelegatorTenantId())) {
+            dispatcherName += "#" + delegator.getDelegatorTenantId();
         }
 
         LocalDispatcher dispatcher = dispatcherCache.get(dispatcherName);
@@ -67,23 +55,11 @@ public class GenericDispatcher extends G
                 dispatcher = dispatcherCache.get(dispatcherName);
                 if (dispatcher == null) {
                     if (Debug.infoOn()) Debug.logInfo("Creating new dispatcher [" + dispatcherName + "] (" + Thread.currentThread().getName() + ")", module);
-                    //Debug.logInfo(new Exception(), "Showing stack where new dispatcher is being created...", module);
-
-                    if (delegator == null && serviceDispatcher != null) {
-                        delegator = serviceDispatcher.getDelegator();
-                    }
-
-                    if (loader == null) {
-                        loader = GenericDispatcher.class.getClassLoader();
-                    }
-
-                    ServiceDispatcher sd = serviceDispatcher != null ? serviceDispatcher : ServiceDispatcher.getInstance(dispatcherName, delegator);
-
-                    if (sd != null) {
-                        dispatcher = sd.getLocalDispatcher(dispatcherName);
-                    }
+                    // attempts to retrieve an already registered DispatchContext with the name dispatcherName
+                    dispatcher = ServiceDispatcher.getLocalDispatcher(dispatcherName, delegator);
+                    // if not found then create a new GenericDispatcher object; the constructor will also register a new DispatchContext in the ServiceDispatcher with name "dispatcherName"
                     if (dispatcher == null) {
-                        dispatcher = new GenericDispatcher(dispatcherName, delegator, readerURLs, loader, sd);
+                        dispatcher = new GenericDispatcher(dispatcherName, delegator);
                     }
 
                     dispatcherCache.put(dispatcherName, dispatcher);
@@ -93,53 +69,30 @@ public class GenericDispatcher extends G
         return dispatcher;
     }
 
-    /** special method to obtain a new 'unique' reference with a variation on parameters */
-    public static LocalDispatcher newInstance(String name, Delegator delegator, boolean enableJM, boolean enableJMS, boolean enableSvcs) throws GenericServiceException {
-        return newInstance(name, delegator, null, enableJM, enableJMS, enableSvcs);
-    }
-
-    public static LocalDispatcher newInstance(String name, Delegator delegator, Collection<URL> readerURLs, boolean enableJM, boolean enableJMS, boolean enableSvcs) throws GenericServiceException {
-        ServiceDispatcher sd = new ServiceDispatcher(delegator, enableJM, enableJMS, enableSvcs);
-        ClassLoader loader = null;
-        try {
-            loader = Thread.currentThread().getContextClassLoader();
-        } catch (SecurityException e) {
-            loader = GenericDispatcher.class.getClassLoader();
-        }
-        return new GenericDispatcher(name, delegator, readerURLs, loader, sd);
-    }
-
     public static Set<String> getAllDispatcherNames() {
         return dispatcherCache.keySet();
     }
 
     protected GenericDispatcher() {}
 
-    protected GenericDispatcher(String name, Delegator delegator, Collection<URL> readerURLs, ClassLoader loader, ServiceDispatcher serviceDispatcher) {
-        if (serviceDispatcher != null) {
-            this.dispatcher = serviceDispatcher;
+    protected GenericDispatcher(String name, Delegator delegator) {
+        if (UtilValidate.isEmpty(name)) {
+            throw new IllegalArgumentException("The name of a LocalDispatcher cannot be a null or empty String");
         }
-        if (loader == null) {
-            try {
-                loader = Thread.currentThread().getContextClassLoader();
-            } catch (SecurityException e) {
-                loader = this.getClass().getClassLoader();
-            }
+        ClassLoader loader;
+        try {
+            loader = Thread.currentThread().getContextClassLoader();
+        } catch (SecurityException e) {
+            loader = this.getClass().getClassLoader();
         }
-        DispatchContext dc = new DispatchContext(name, readerURLs, loader, null);
-        init(name, delegator, dc);
-    }
-
-    protected void init(String name, Delegator delegator, DispatchContext ctx) {
-        if (UtilValidate.isEmpty(name))
-            throw new IllegalArgumentException("The name of a LocalDispatcher cannot be a null or empty String");
+        DispatchContext ctx = new DispatchContext(name, loader);
 
         this.name = name;
+        this.dispatcher = ServiceDispatcher.getInstance(delegator);
+        this.dispatcher.register(ctx);
         this.ctx = ctx;
-        this.dispatcher = ServiceDispatcher.getInstance(name, ctx, delegator);
-
-        ctx.setDispatcher(this);
-        ctx.loadReaders();
+        this.ctx.setDispatcher(this);
+        this.ctx.loadReaders();
         if (Debug.verboseOn()) Debug.logVerbose("[LocalDispatcher] : Created Dispatcher for: " + name, module);
     }
 

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java?rev=1364222&r1=1364221&r2=1364222&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java Sun Jul 22 07:33:48 2012
@@ -127,28 +127,28 @@ public class ServiceDispatcher {
 
     /**
      * Returns a pre-registered instance of the ServiceDispatcher associated with this delegator.
+     * @param name the name of the DispatchContext
      * @param delegator the local delegator
-     * @return A reference to this global ServiceDispatcher
+     * @return A reference to the LocalDispatcher associated with the DispatchContext
      */
-    public static ServiceDispatcher getInstance(String name, Delegator delegator) {
-        ServiceDispatcher sd = getInstance(null, null, delegator);
-
-        if (!sd.containsContext(name)) {
-            return null;
+    public static LocalDispatcher getLocalDispatcher(String name, Delegator delegator) {
+        // get the ServiceDispatcher associated to the delegator (if not found in the cache, it will be created and added to the cache)
+        ServiceDispatcher sd = getInstance(delegator);
+        // if a DispatchContext has already been already registered as "name" then return the LocalDispatcher associated with it
+        if (sd.containsContext(name)) {
+            return sd.getLocalDispatcher(name);
         }
-        return sd;
+        // otherwise return null
+        return null;
     }
 
     /**
-     * Returns an instance of the ServiceDispatcher associated with this delegator and registers the loader.
-     * @param name the local dispatcher
-     * @param context the context of the local dispatcher
+     * Returns an instance of the ServiceDispatcher associated with this delegator.
      * @param delegator the local delegator
      * @return A reference to this global ServiceDispatcher
      */
-    public static ServiceDispatcher getInstance(String name, DispatchContext context, Delegator delegator) {
+    public static ServiceDispatcher getInstance(Delegator delegator) {
         ServiceDispatcher sd;
-
         String dispatcherKey = delegator != null ? delegator.getDelegatorName() : "null";
         sd = dispatchers.get(dispatcherKey);
         if (sd == null) {
@@ -161,10 +161,6 @@ public class ServiceDispatcher {
                 }
             }
         }
-
-        if (name != null && context != null) {
-            sd.register(name, context);
-        }
         return sd;
     }
 
@@ -173,11 +169,10 @@ public class ServiceDispatcher {
      * @param name the local dispatcher
      * @param context the context of the local dispatcher
      */
-    public void register(String name, DispatchContext context) {
-        if (Debug.verboseOn()) Debug.logVerbose("Registered dispatcher: " + context.getName(), module);
-        this.localContext.put(name, context);
+    public void register(DispatchContext context) {
+        if (Debug.infoOn()) Debug.logInfo("Registering dispatcher: " + context.getName(), module);
+        this.localContext.put(context.getName(), context);
     }
-
     /**
      * De-Registers the loader with this ServiceDispatcher
      * @param local the LocalDispatcher to de-register
@@ -185,13 +180,13 @@ public class ServiceDispatcher {
     public void deregister(LocalDispatcher local) {
         if (Debug.infoOn()) Debug.logInfo("De-Registering dispatcher: " + local.getName(), module);
         localContext.remove(local.getName());
-         if (localContext.size() == 1) { // 1 == the JMSDispatcher
-             try {
+        if (localContext.size() == 1) { // TODO: this is a tweak that is currently not working (2 contexts are not deregistered)
+            try {
                  this.shutdown();
              } catch (GenericServiceException e) {
                  Debug.logError(e, "Trouble shutting down ServiceDispatcher!", module);
              }
-         }
+        }
     }
 
     public synchronized void registerCallback(String serviceName, GenericServiceCallback cb) {

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/jms/AbstractJmsListener.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/jms/AbstractJmsListener.java?rev=1364222&r1=1364221&r2=1364222&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/jms/AbstractJmsListener.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/jms/AbstractJmsListener.java Sun Jul 22 07:33:48 2012
@@ -50,7 +50,7 @@ public abstract class AbstractJmsListene
      * @param serviceDispatcher the service dispatcher
      */
     protected AbstractJmsListener(ServiceDispatcher serviceDispatcher) {
-        this.dispatcher = GenericDispatcher.getLocalDispatcher("entity-default", null, null, this.getClass().getClassLoader(), serviceDispatcher);
+        this.dispatcher = GenericDispatcher.getLocalDispatcher("JMSDispatcher", serviceDispatcher.getDelegator());
     }
 
     /**

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java?rev=1364222&r1=1364221&r2=1364222&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java Sun Jul 22 07:33:48 2012
@@ -342,22 +342,6 @@ public class ContextFilter implements Fi
             Debug.logError("[ContextFilter.init] ERROR: delegator not defined.", module);
             return null;
         }
-        Collection<URL> readers = null;
-        String readerFiles = servletContext.getInitParameter("serviceReaderUrls");
-
-        if (readerFiles != null) {
-            readers = FastList.newInstance();
-            for (String name: StringUtil.split(readerFiles, ";")) {
-                try {
-                    URL readerURL = servletContext.getResource(name);
-                    if (readerURL != null) readers.add(readerURL);
-                } catch (NullPointerException npe) {
-                    Debug.logInfo(npe, "[ContextFilter.init] ERROR: Null pointer exception thrown.", module);
-                } catch (MalformedURLException e) {
-                    Debug.logError(e, "[ContextFilter.init] ERROR: cannot get URL from String.", module);
-                }
-            }
-        }
         // get the unique name of this dispatcher
         String dispatcherName = servletContext.getInitParameter("localDispatcherName");
 
@@ -366,7 +350,7 @@ public class ContextFilter implements Fi
             dispatcherName = delegator.getDelegatorName();
         }
 
-        LocalDispatcher dispatcher = GenericDispatcher.getLocalDispatcher(dispatcherName, delegator, readers, null);
+        LocalDispatcher dispatcher = GenericDispatcher.getLocalDispatcher(dispatcherName, delegator);
         if (dispatcher == null) {
             Debug.logError("[ContextFilter.init] ERROR: dispatcher could not be initialized.", module);
         }

Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java?rev=1364222&r1=1364221&r2=1364222&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/artifactinfo/ArtifactInfoFactory.java Sun Jul 22 07:33:48 2012
@@ -39,6 +39,8 @@ import org.ofbiz.base.util.GeneralExcept
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.cache.UtilCache;
 import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.config.DelegatorInfo;
+import org.ofbiz.entity.config.EntityConfigUtil;
 import org.ofbiz.entity.model.ModelEntity;
 import org.ofbiz.entity.model.ModelReader;
 import org.ofbiz.entityext.eca.EntityEcaRule;
@@ -129,9 +131,16 @@ public class ArtifactInfoFactory {
     protected ArtifactInfoFactory(String delegatorName) throws GeneralException {
         this.delegatorName = delegatorName;
         this.entityModelReader = ModelReader.getModelReader(delegatorName);
-        this.dispatchContext = new DispatchContext("ArtifactInfoDispCtx", null, this.getClass().getClassLoader(), null);
         this.entityEcaCache = EntityEcaUtil.getEntityEcaCache(EntityEcaUtil.getEntityEcaReaderName(delegatorName));
         this.serviceEcaCache = ServiceEcaUtil.ecaCache;
+        DelegatorInfo delegatorInfo = EntityConfigUtil.getDelegatorInfo(delegatorName);
+        String modelName;
+        if (delegatorInfo != null) {
+            modelName = delegatorInfo.entityModelReader;
+        } else {
+            modelName = "main";
+        }
+        this.dispatchContext = new DispatchContext(modelName, this.getClass().getClassLoader());
 
         this.prepareAll();
     }

Modified: ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelReferences.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelReferences.java?rev=1364222&r1=1364221&r2=1364222&view=diff
==============================================================================
--- ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelReferences.java (original)
+++ ofbiz/trunk/framework/webtools/src/org/ofbiz/webtools/labelmanager/LabelReferences.java Sun Jul 22 07:33:48 2012
@@ -39,6 +39,8 @@ import org.ofbiz.base.util.UtilFormatOut
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.UtilXml;
 import org.ofbiz.entity.Delegator;
+import org.ofbiz.entity.config.DelegatorInfo;
+import org.ofbiz.entity.config.EntityConfigUtil;
 import org.ofbiz.entity.model.ModelEntity;
 import org.ofbiz.entity.model.ModelField;
 import org.ofbiz.service.DispatchContext;
@@ -67,7 +69,14 @@ public class LabelReferences {
     public LabelReferences(Delegator delegator, LabelManagerFactory factory) {
         this.delegator = delegator;
         this.labels = factory.getLabels();
-        this.dispatchContext = new DispatchContext("LabelManagerDispCtx:" + delegator.getDelegatorName(), null, this.getClass().getClassLoader(), null);
+        DelegatorInfo delegatorInfo = EntityConfigUtil.getDelegatorInfo(delegator.getDelegatorBaseName());
+        String modelName;
+        if (delegatorInfo != null) {
+            modelName = delegatorInfo.entityModelReader;
+        } else {
+            modelName = "main";
+        }
+        this.dispatchContext = new DispatchContext(modelName, this.getClass().getClassLoader());
         Collection<LabelInfo> infoList = this.labels.values();
         for (LabelInfo labelInfo : infoList) {
             this.labelSet.add(labelInfo.getLabelKey());