And this one builds on the last one. I realized that we already had 2 wire protocols - one for iframe remoting and one for XHR remoting. This realization allowed me to remove some hacky code, but the refactor altered your stuff again.
If I'd fixed the URL processing duplication then this would have been transparent...
I thought about fixing the URL processing duplication but the obvious solution involves regexes and DWR currently runs on 1.3 where there is no regex lib.
I'm aware that DWR has a no-tabs rule, where rife uses tabs quite a bit so there is some bizarreness in the RIFE/DWR files. There is an easy fix in eclipse which I've avoided to keep the patch files small. Should I do the eclipse auto-format thing in future?
Joe.
On 3/15/06, Geert Bevin <[EMAIL PROTECTED]> wrote:
Hi Joe,
thanks a lot for this, I integrated the patch and upgraded DWR to the
latest HEAD.
I had to comment out the compilation of the demo classes from the Ant
build file, since they caused the build to fail with errors.
I also had to add the Marshaller to the DWR container, you probably
simply overlooked that.
Indeed, the URL processing is a bit heavy code-wise and I think that
it would be nice for this to be sharable. After all, many people will
want to adopt the default behavior of this.
Best regards,
Geert
On 14-mrt-06, at 22:16, Joe Walker wrote:
>
> Hi,
>
> I've just updated DWR HEAD against which Rife was compiled. A few
> things broke Rife, the biggest being the introduction of the
> concept of a Marshaller to abstract away the wire protocol. Now (in
> theory at least) DWR could work over SOAP or JSON-RPC. I have no
> intention of writing such, but it will keep quiet the people that
> would like it.
>
> So I'm attaching a patch to Rife Trunk that keeps you in sync.
>
> The only bit which should need explanation is the alteration
> to .classpath, which I updated to compile against 1.5 (so the
> Annotations would compile) and updated the mysql for 3.1.12.
>
> I noticed you have a sizable copy of UrlProcessor (was
> DefaultProcessor, a silly name) in DwrRifeProcessor. Would you like
> me to work on a better way to share this, or do you see the URL
> processing as a fundamental part of Rife's job?
>
> Thanks.
>
> Joe.
>
>
> _______________________________________________
> Rife-users mailing list
> [email protected]
> http://lists.uwyn.com/mailman/listinfo/rife-users
--
Geert Bevin Uwyn bvba GTalk: [EMAIL PROTECTED]
"Use what you need" Avenue de Scailmont 34 Skype: gbevin
http://www.uwyn.com 7170 Manage, Belgium AIM: geertbevin
gbevin at uwyn dot com Tel: +32 64 84 80 03 Mobile: +32 477 302 599
PGP Fingerprint : 4E21 6399 CD9E A384 6619 719A C8F4 D40D 309F D6A9
Public PGP key : available at servers pgp.mit.edu, wwwkeys.pgp.net
_______________________________________________
Rife-users mailing list
[email protected]
http://lists.uwyn.com/mailman/listinfo/rife-users
Index:
C:/Share/joe/uwyn/rife/src/framework/com/uwyn/rife/engine/elements/DwrServiceDeployer.java
===================================================================
---
C:/Share/joe/uwyn/rife/src/framework/com/uwyn/rife/engine/elements/DwrServiceDeployer.java
(revision 3120)
+++
C:/Share/joe/uwyn/rife/src/framework/com/uwyn/rife/engine/elements/DwrServiceDeployer.java
(working copy)
@@ -25,7 +25,8 @@
import uk.ltd.getahead.dwr.create.NewCreator;
import uk.ltd.getahead.dwr.dwrp.ConverterManager;
import uk.ltd.getahead.dwr.dwrp.DefaultConverterManager;
-import uk.ltd.getahead.dwr.dwrp.DwrpMarshaller;
+import uk.ltd.getahead.dwr.dwrp.DwrpHtmlJsMarshaller;
+import uk.ltd.getahead.dwr.dwrp.DwrpPlainJsMarshaller;
public class DwrServiceDeployer extends ElementDeployer
{
@@ -109,7 +110,8 @@
default_container.addParameter(AjaxFilterManager.class.getName(),
DefaultAjaxFilterManager.class.getName());
default_container.addParameter(Remoter.class.getName(),
DefaultRemoter.class.getName());
default_container.addParameter(DebugPageGenerator.class.getName(),
DefaultDebugPageGenerator.class.getName());
- default_container.addParameter(Marshaller.class.getName(),
DwrpMarshaller.class.getName());
+ default_container.addParameter(DwrpPlainJsMarshaller.class.getName(),
DwrpPlainJsMarshaller.class.getName());
+ default_container.addParameter(DwrpHtmlJsMarshaller.class.getName(),
DwrpHtmlJsMarshaller.class.getName());
default_container.addParameter("debug",
String.valueOf(Convert.toBoolean(getElementInfo().getProperty(PROPERTY_DEBUG),
false))); //$NON-NLS-1$ //$NON-NLS-2$
default_container.addParameter("allowImpossibleTests",
String.valueOf(Convert.toBoolean(getElementInfo().getProperty(PROPERTY_ALLOW_IMPOSSIBLE_TESTS),
false))); //$NON-NLS-1$ //$NON-NLS-2$
Index:
C:/Share/joe/uwyn/rife/src/framework/com/uwyn/rife/engine/elements/DwrRifeProcessor.java
===================================================================
---
C:/Share/joe/uwyn/rife/src/framework/com/uwyn/rife/engine/elements/DwrRifeProcessor.java
(revision 3120)
+++
C:/Share/joe/uwyn/rife/src/framework/com/uwyn/rife/engine/elements/DwrRifeProcessor.java
(working copy)
@@ -15,10 +15,14 @@
import javax.servlet.http.HttpServletResponse;
import uk.ltd.getahead.dwr.*;
+import uk.ltd.getahead.dwr.dwrp.DwrpConstants;
+import uk.ltd.getahead.dwr.dwrp.DwrpHtmlJsMarshaller;
+import uk.ltd.getahead.dwr.dwrp.DwrpPlainJsMarshaller;
import uk.ltd.getahead.dwr.servlet.HttpConstants;
import uk.ltd.getahead.dwr.util.JavascriptUtil;
import uk.ltd.getahead.dwr.util.LocalUtil;
import uk.ltd.getahead.dwr.util.Logger;
+import uk.ltd.getahead.dwr.util.MimeConstants;
import com.uwyn.rife.engine.ElementSupport;
import com.uwyn.rife.tools.StringUtils;
@@ -83,9 +87,14 @@
private Remoter mRemoter = null;
/**
- * The bean to marshall remote parameters
+ * The 'HTML Javascript' method by which objects are marshalled
*/
- private Marshaller mMarshaller = null;
+ private DwrpPlainJsMarshaller mPlainJsMarshaller = null;
+
+ /**
+ * The 'Plain Javascript' method by which objects are marshalled
+ */
+ private DwrpHtmlJsMarshaller mHtmlJsMarshaller = null;
public void handle(final ElementSupport element) throws IOException,
ServletException
{
@@ -95,7 +104,7 @@
if (path_info == null)
{
// pathInfo = request.getServletPath();
-// servletPath = HtmlConstants.PATH_ROOT;
+// servletPath = MimeConstants.PATH_ROOT;
LOG.debug("Default servlet suspected. pathInfo=" + path_info + ";
servletPath=" + element_url); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
@@ -105,70 +114,64 @@
// appear to be logic to it, just hack-till-its-not-broken which feels
// like a good way to create latent bugs
if (path_info.length() == 0 ||
- path_info.equals(HtmlConstants.PATH_ROOT) ||
- path_info.startsWith(HtmlConstants.FILE_INDEX))
+ path_info.equals(DwrpConstants.PATH_ROOT) ||
+ path_info.startsWith(DwrpConstants.FILE_INDEX))
{
reply = mDebugPageGenerator.generateIndexPage(webapp_root_url +
element_url);
}
- else if (path_info.startsWith(HtmlConstants.PATH_TEST))
+ else if (path_info.startsWith(DwrpConstants.PATH_TEST))
{
String scriptName = path_info;
- scriptName = LocalUtil.replace(scriptName,
HtmlConstants.PATH_TEST, HtmlConstants.BLANK);
- scriptName = LocalUtil.replace(scriptName,
HtmlConstants.PATH_ROOT, HtmlConstants.BLANK);
+ scriptName = LocalUtil.replace(scriptName,
DwrpConstants.PATH_TEST, "");
+ scriptName = LocalUtil.replace(scriptName,
DwrpConstants.PATH_ROOT, "");
reply = mDebugPageGenerator.generateTestPage(webapp_root_url +
element_url, scriptName);
}
- else if (path_info.startsWith(HtmlConstants.PATH_INTERFACE))
+ else if (path_info.startsWith(DwrpConstants.PATH_INTERFACE))
{
String scriptName = path_info;
- scriptName = LocalUtil.replace(scriptName,
HtmlConstants.PATH_INTERFACE, HtmlConstants.BLANK);
- scriptName = LocalUtil.replace(scriptName,
HtmlConstants.EXTENSION_JS, HtmlConstants.BLANK);
+ scriptName = LocalUtil.replace(scriptName,
DwrpConstants.PATH_INTERFACE, "");
+ scriptName = LocalUtil.replace(scriptName,
DwrpConstants.EXTENSION_JS, "");
String path = webapp_root_url + element_url;
reply = mRemoter.generateInterfaceScript(scriptName, path);
}
- else if (path_info.startsWith(HtmlConstants.PATH_EXEC))
+ else if (path_info.startsWith(DwrpConstants.PATH_PLAINJS))
{
- HttpRequest request = new HttpRequest() {
-
- public String getMethod()
- {
- return
element.getHttpServletRequest().getMethod().toString();
- }
-
- public InputStream getInputStream() throws
IOException
- {
- return
element.getHttpServletRequest().getInputStream();
- }
-
- public Map getParameters()
- {
- return
element.getHttpServletRequest().getParameterMap();
- }
- };
-
try
{
- Calls calls = mMarshaller.marshallInbound(request);
- Replies replies = mRemoter.execute(calls);
- reply = mMarshaller.marshallOutbound(replies);
+ Calls calls = mPlainJsMarshaller.marshallInbound(new
ElementSupportHttpRequest(element));
+ Replies replies = mRemoter.execute(calls);
+ reply = mPlainJsMarshaller.marshallOutbound(replies);
}
catch (MarshallException ex)
{
- // Not totally sure what you'd want to do here. A conversion
- // exception is probably because we were asked to configure
- // something that we don't have permission for.
+ // Probably because we don't have permission for the conversion
throw new ServletException(ex);
}
}
- else if (path_info.equalsIgnoreCase(HtmlConstants.FILE_ENGINE))
+ else if (path_info.startsWith(DwrpConstants.PATH_HTMLJS))
{
- doFile(element, HtmlConstants.FILE_ENGINE, HtmlConstants.MIME_JS);
+ try
+ {
+ Calls calls = mHtmlJsMarshaller.marshallInbound(new
ElementSupportHttpRequest(element));
+ Replies replies = mRemoter.execute(calls);
+ reply = mHtmlJsMarshaller.marshallOutbound(replies);
+ }
+ catch (MarshallException ex)
+ {
+ // Probably because we don't have permission for the conversion
+ throw new ServletException(ex);
+ }
+ }
+ else if (path_info.equalsIgnoreCase(DwrpConstants.FILE_ENGINE))
+ {
+ doFile(element, DwrpConstants.FILE_ENGINE, MimeConstants.MIME_JS);
return;
}
- else if (path_info.equalsIgnoreCase(HtmlConstants.FILE_UTIL))
+ else if (path_info.equalsIgnoreCase(DwrpConstants.FILE_UTIL))
{
- doFile(element, HtmlConstants.FILE_UTIL, HtmlConstants.MIME_JS);
+ doFile(element, DwrpConstants.FILE_UTIL, MimeConstants.MIME_JS);
return;
}
else
@@ -231,7 +234,7 @@
output = buffer.toString();
- if (mimeType.equals(HtmlConstants.MIME_JS) &&
mScriptCompressed)
+ if (mimeType.equals(MimeConstants.MIME_JS) &&
mScriptCompressed)
{
output = JavascriptUtil.compress(output,
mCompressionLevel);
}
@@ -350,15 +353,24 @@
}
/**
- * Setter for the marshaller
+ * Setter for the Plain Javascript Marshaller
* @param marshaller
*/
- public void setMarshaller(Marshaller marshaller)
+ public void setPlainJsMarshaller(DwrpPlainJsMarshaller marshaller)
{
- mMarshaller = marshaller;
+ mPlainJsMarshaller = marshaller;
}
/**
+ * Setter for the HTML Javascript Marshaller
+ * @param marshaller
+ */
+ public void setHtmlJsMarshaller(DwrpHtmlJsMarshaller marshaller)
+ {
+ mHtmlJsMarshaller = marshaller;
+ }
+
+ /**
*
* @param debugPageGenerator
*/
@@ -366,4 +378,29 @@
{
mDebugPageGenerator = debugPageGenerator;
}
+
+ public class ElementSupportHttpRequest implements HttpRequest
+ {
+ private ElementSupport mElement;
+
+ public ElementSupportHttpRequest(ElementSupport element)
+ {
+ this.mElement = element;
+ }
+
+ public String getMethod()
+ {
+ return
mElement.getHttpServletRequest().getMethod().toString();
+ }
+
+ public InputStream getInputStream() throws IOException
+ {
+ return
mElement.getHttpServletRequest().getInputStream();
+ }
+
+ public Map getParameters()
+ {
+ return
mElement.getHttpServletRequest().getParameterMap();
+ }
+ }
}
Index:
C:/Share/joe/uwyn/rife/src/framework/com/uwyn/rife/engine/elements/DwrService.java
===================================================================
---
C:/Share/joe/uwyn/rife/src/framework/com/uwyn/rife/engine/elements/DwrService.java
(revision 3120)
+++
C:/Share/joe/uwyn/rife/src/framework/com/uwyn/rife/engine/elements/DwrService.java
(working copy)
@@ -13,7 +13,7 @@
import com.uwyn.rife.tools.StringUtils;
import java.util.Properties;
import uk.ltd.getahead.dwr.DebugPageGenerator;
-import uk.ltd.getahead.dwr.HtmlConstants;
+import uk.ltd.getahead.dwr.dwrp.DwrpConstants;
public class DwrService extends Element
{
@@ -47,7 +47,7 @@
if
(Convert.toBoolean(props.getProperty("includeUtil"), false))
{
- print("<script type=\"text/javascript\"
src=\""+debug.generateLibraryUrl(dwr_root, HtmlConstants.FILE_UTIL)+"\">
</script>\n");
+ print("<script type=\"text/javascript\"
src=\""+debug.generateLibraryUrl(dwr_root, DwrpConstants.FILE_UTIL)+"\">
</script>\n");
}
}
else
Index: C:/Share/joe/uwyn/rife/.classpath
===================================================================
--- C:/Share/joe/uwyn/rife/.classpath (revision 3120)
+++ C:/Share/joe/uwyn/rife/.classpath (working copy)
@@ -3,6 +3,7 @@
<classpathentry excluding="**/.DS_Store|**/.svn/*" kind="src"
path="src/bsfsupport"/>
<classpathentry excluding="**/.DS_Store|**/.svn/*" kind="src"
path="src/framework"/>
<classpathentry excluding="**/.DS_Store|**/.svn/*"
output="build/unittests" kind="src" path="src/unittests"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk-1.5.0"/>
<classpathentry kind="lib" path="programs/gui/config"/>
<classpathentry kind="lib" path="programs/unittests/config"/>
<classpathentry kind="lib" path="programs/unittests/data"/>
@@ -66,7 +67,6 @@
<classpathentry kind="lib" path="lib/hsqldb-1.8.0.2.jar"/>
<classpathentry kind="lib" path="lib/spring-mock-1.2.6.jar"/>
<classpathentry kind="lib" path="lib/jmagick-6.2.4.jar"/>
- <classpathentry kind="lib" path="lib/dwr-2.0cvs-20060315.jar"/>
- <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/dwr"/>
<classpathentry kind="output" path="build/framework"/>
</classpath>_______________________________________________ Rife-users mailing list [email protected] http://lists.uwyn.com/mailman/listinfo/rife-users
