-- Forwarded message --
From: jtuchsche...@gmail.com
Date: Sun, Apr 10, 2011 at 00:13
Subject: Trying to address issue 6234 (Support RequestFactory service
inheritance on the client) (issue1411802)
To: jtuchsche...@gmail.com
Cc: google-web-toolkit-contributors@googlegroups.com,
re...@gwt-code-reviews.appspotmail.com
Reviewers: ,
Description:
This is a crude attempt to get methold resolving to work in cases where
the RequestContext inherits from a generic super interface and does not
contain the request method itself.
I was not able to get a local environment setup in a reasonable amount
of time or to run the tests without running out of PermGen memory space.
I hope someone else can use this patch and take this on.
With this change we will look up the RequestContext class twice from the
classloader. From my basic understanding of this code this is not going
to matter, since all these calls get cached and therefore there is a
limited number of calls. In order to make it better, though, the
SimpleRequestProcessor could first try to resolve the class (line 425)
and then call the resolveRequestContextMethod with the Class instead of
its name. For that, you would need to change the signature of
resolveRequestContextMethod to take a Class instead of a string for the
RequestContextClass. That was too much refactoring for me without being
able run tests. If I had a working local environment, that would have
been the solution I had tried.
I tried to create a test for this. I have no idea if it works or not.
:-(
Please review this at http://gwt-code-reviews.appspot.com/1411802/
Affected files:
user/src/com/google/gwt/requestfactory/server/ResolverServiceLayer.java
user/src/com/google/gwt/requestfactory/server/ServiceLayer.java
user/src/com/google/gwt/requestfactory/server/ServiceLayerCache.java
user/src/com/google/gwt/requestfactory/server/ServiceLayerDecorator.java
user/src/com/google/gwt/requestfactory/server/SimpleRequestProcessor.java
user/test/com/google/gwt/requestfactory/shared/ServiceInheritanceTest.java
Index:
user/test/com/google/gwt/requestfactory/shared/ServiceInheritanceTest.java
===
---
user/test/com/google/gwt/requestfactory/shared/ServiceInheritanceTest.java
(revision 9969)
+++
user/test/com/google/gwt/requestfactory/shared/ServiceInheritanceTest.java
(working copy)
@@ -65,24 +65,34 @@
RequestInteger add(int n);
RequestInteger subtract(int n);
}
+ /**
+ * Base implementation of {@link SumServiceBase}
+ */
+ static abstract class GenericBaseImplT extends Number {
+protected T initialValue;
+public int add(int n) {
+ return initialValue.intValue() + n;
+}
+
+public int subtract(int n) {
+ return initialValue.intValue() - n;
+}
+
+public int mulitply(int n) {
+ return initialValue.intValue() * n;
+}
+ }
+
/**
* Base implementation of {@link SumServiceBase}
*/
- static class BaseImpl {
+ static class BaseImpl extends GenericBaseImplInteger {
protected int initialValue;
public BaseImpl() {
initialValue = 5;
}
-
-public Integer add(int n) {
- return initialValue + n;
-}
-
-public Integer subtract(int n) {
- return initialValue - n;
-}
}
/**
@@ -97,11 +107,6 @@
*/
initialValue = 8;
}
-
-@Override
-public Integer subtract(int n) {
- return 0;
-}
}
private static final int TEST_DELAY = 5000;
@@ -149,7 +154,7 @@
factory.subContext().subtract(3).fire(new ReceiverInteger() {
@Override
public void onSuccess(Integer response) {
-assertEquals((Integer) 0, response);
+assertEquals((Integer) 5, response);
finishTest();
}
});
Index:
user/src/com/google/gwt/requestfactory/server/ServiceLayerDecorator.java
===
--- user/src/com/google/gwt/requestfactory/server/ServiceLayerDecorator.java
(revision 9969)
+++ user/src/com/google/gwt/requestfactory/server/ServiceLayerDecorator.java
(working copy)
@@ -142,8 +142,8 @@
}
@Override
- public Method resolveDomainMethod(Method requestContextMethod) {
-return getNext().resolveDomainMethod(requestContextMethod);
+ public Method resolveDomainMethod(String requestContextClass, Method
requestContextMethod) {
+return getNext().resolveDomainMethod(requestContextClass,
requestContextMethod);
}
@Override
Index:
user/src/com/google/gwt/requestfactory/server/SimpleRequestProcessor.java
===
---
user/src/com/google/gwt/requestfactory/server/SimpleRequestProcessor.java
(revision 9969)
+++
user/src/com/google/gwt/requestfactory/server/SimpleRequestProcessor.java
(working copy)
@@ -428,7 +428,7 @@
throw new UnexpectedException(Cannot resolve operation
+ invocation.getOperation(), null);
}
-Method