svn commit: r777333 - /ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContextMapper.java

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

svn commit: r777333 - /ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContextMapper.java

doogie-3
Author: doogie
Date: Fri May 22 00:20:47 2009
New Revision: 777333

URL: http://svn.apache.org/viewvc?rev=777333&view=rev
Log:
Integrate new changes from webslinger upstream; dispatcher is now
created properly each time.

Modified:
    ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContextMapper.java

Modified: ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContextMapper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContextMapper.java?rev=777333&r1=777332&r2=777333&view=diff
==============================================================================
--- ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContextMapper.java (original)
+++ ofbiz/trunk/framework/webslinger/src/org/ofbiz/webslinger/WebslingerContextMapper.java Fri May 22 00:20:47 2009
@@ -41,8 +41,10 @@
 import org.ofbiz.security.SecurityFactory;
 import org.ofbiz.security.authz.AuthorizationFactory;
 import org.ofbiz.service.GenericDispatcher;
-import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.service.ServiceDispatcher;
+import org.ofbiz.service.DispatchContext;
+
 import org.webslinger.AbstractMappingWebslingerServletContextFactory;
 import org.webslinger.WebslingerServletContext;
 import org.webslinger.collections.CollectionUtil;
@@ -100,25 +102,32 @@
         OfbizLayout ofbizLayout = (OfbizLayout) layout;
         GenericDelegator delegator = GenericDelegator.getGenericDelegator(ofbizLayout.delegatorName);
         context.setAttribute("delegator", delegator);
-        context.setAttribute("dispatcher", createLocalDispatcher(context, layout.getTarget(), delegator));
+        context.setAttribute("dispatcher", new WebslingerGenericDispatcher(context, layout.getTarget(), delegator, globalReaderURLs));
         context.setAttribute("authz", AuthorizationFactory.getInstance(delegator));
         context.setAttribute("security", SecurityFactory.getInstance(delegator));
     }
 
-    protected LocalDispatcher createLocalDispatcher(WebslingerServletContext context, String name, GenericDelegator delegator) throws IOException {
-        ArrayList<URL> readerURLs = new ArrayList<URL>(globalReaderURLs);
-        String readerFiles = context.getInitParameter("serviceReaderUrls");
-        if (readerFiles != null) {
-            for (String reader: CollectionUtil.split(readerFiles, ";")) {
-                URL url =  context.getResource(reader);
-                if (url != null) readerURLs.add(url);
+    protected static final class WebslingerGenericDispatcher extends GenericDispatcher {
+        protected WebslingerGenericDispatcher(WebslingerServletContext context, String name, GenericDelegator delegator, List<URL> globalReaderURLs) throws IOException {
+            ArrayList<URL> readerURLs = new ArrayList<URL>(globalReaderURLs);
+            String readerFiles = context.getInitParameter("serviceReaderUrls");
+            if (readerFiles != null) {
+                for (String reader: CollectionUtil.split(readerFiles, ";")) {
+                    URL url =  context.getResource(reader);
+                    if (url != null) readerURLs.add(url);
+                }
             }
-        }
-        System.err.println(readerURLs);
-        try {
-            return GenericDispatcher.newInstance(name, delegator, readerURLs, true, true, true);
-        } catch (GenericServiceException e) {
-            throw (IOException) new IOException(e.getMessage()).initCause(e);
+            System.err.println(readerURLs);
+            this.dispatcher = new ServiceDispatcher(delegator, true, true, true) {
+            };
+            ClassLoader loader = null;
+            try {
+                loader = Thread.currentThread().getContextClassLoader();
+            } catch (SecurityException e) {
+                loader = WebslingerContextMapper.class.getClassLoader();
+            }
+            DispatchContext dc = new DispatchContext(name, readerURLs, loader, null);
+            init(name, delegator, dc);
         }
     }