Revision: 8819
Author: [email protected]
Date: Sun Sep 19 10:42:32 2010
Log: Introduce RequestFactory#getEventBus, make RFEditorDriver use it, fix
some javadoc, and rename RequestFactory#init to initialize, for
consistency.
http://gwt-code-reviews.appspot.com/896801
Review by: [email protected]
http://code.google.com/p/google-web-toolkit/source/detail?r=8819
Modified:
/trunk/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/DynaTableRf.java
/trunk/samples/expenses/src/main/java/com/google/gwt/sample/expenses/client/Expenses.java
/trunk/samples/expenses/src/main/java/com/google/gwt/sample/expenses/client/ExpensesMobile.java
/trunk/user/src/com/google/gwt/requestfactory/client/RequestFactoryEditorDriver.java
/trunk/user/src/com/google/gwt/requestfactory/client/impl/AbstractRequestFactoryEditorDriver.java
/trunk/user/src/com/google/gwt/requestfactory/client/impl/RequestFactoryJsonImpl.java
/trunk/user/src/com/google/gwt/requestfactory/client/testing/MockRequestFactoryEditorDriver.java
/trunk/user/src/com/google/gwt/requestfactory/shared/RequestFactory.java
/trunk/user/test/com/google/gwt/requestfactory/client/EditorTest.java
/trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java
/trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryTestBase.java
/trunk/user/test/com/google/gwt/requestfactory/client/impl/DeltaValueStoreJsonImplTest.java
/trunk/user/test/com/google/gwt/requestfactory/client/impl/ValueStoreJsonImplTest.java
=======================================
---
/trunk/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/DynaTableRf.java
Wed Sep 15 17:53:58 2010
+++
/trunk/samples/dynatablerf/src/com/google/gwt/sample/dynatablerf/client/DynaTableRf.java
Sun Sep 19 10:42:32 2010
@@ -65,7 +65,7 @@
});
final DynaTableRequestFactory requests =
GWT.create(DynaTableRequestFactory.class);
- requests.init(eventBus);
+ requests.initialize(eventBus);
// Add remote logging handler
RequestFactoryLogHandler.LoggingRequestProvider provider =
=======================================
---
/trunk/samples/expenses/src/main/java/com/google/gwt/sample/expenses/client/Expenses.java
Sat Sep 18 09:13:37 2010
+++
/trunk/samples/expenses/src/main/java/com/google/gwt/sample/expenses/client/Expenses.java
Sun Sep 19 10:42:32 2010
@@ -141,7 +141,7 @@
final EventBus eventBus = new SimpleEventBus();
requestFactory = GWT.create(ExpensesRequestFactory.class);
- requestFactory.init(eventBus);
+ requestFactory.initialize(eventBus);
RootLayoutPanel root = RootLayoutPanel.get();
=======================================
---
/trunk/samples/expenses/src/main/java/com/google/gwt/sample/expenses/client/ExpensesMobile.java
Sat Sep 18 09:13:37 2010
+++
/trunk/samples/expenses/src/main/java/com/google/gwt/sample/expenses/client/ExpensesMobile.java
Sun Sep 19 10:42:32 2010
@@ -96,7 +96,7 @@
final EventBus eventBus = new SimpleEventBus();
final ExpensesRequestFactory requestFactory =
GWT.create(ExpensesRequestFactory.class);
- requestFactory.init(eventBus);
+ requestFactory.initialize(eventBus);
requestFactory.employeeRequest().findEmployee(employeeId).fire(
new Receiver<EmployeeProxy>() {
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/client/RequestFactoryEditorDriver.java
Fri Sep 17 07:40:00 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/client/RequestFactoryEditorDriver.java
Sun Sep 19 10:42:32 2010
@@ -90,10 +90,18 @@
boolean hasErrors();
/**
- * In order to support object subscriptions, the EventBus passed into the
- * RequestFactory should be provided.
+ * Overload of {...@link #initialize(RequestFactory, Editor)} to allow
+ * a modified {...@link EventBus} to be used.
+ *
+ * @see {...@link com.google.gwt.event.shared.ResettableEventBus}
*/
void initialize(EventBus eventBus, RequestFactory requestFactory, E
editor);
+
+ /**
+ * This or {...@link #initialize(EventBus, RequestFactory, Editor)} must be
+ * called before {...@link #edit(Object, RequestObject)}.
+ */
+ void initialize(RequestFactory requestFactory, E editor);
/**
* Show Violations returned from an attempt to submit a request. The
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/client/impl/AbstractRequestFactoryEditorDriver.java
Fri Sep 17 07:40:00 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/client/impl/AbstractRequestFactoryEditorDriver.java
Sun Sep 19 10:42:32 2010
@@ -100,6 +100,11 @@
traverseEditors(paths);
}
+
+ public void initialize(RequestFactory requestFactory,
+ E editor) {
+ initialize(requestFactory.getEventBus(), requestFactory, editor);
+ }
public boolean setViolations(Iterable<Violation> violations) {
checkDelegate();
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/client/impl/RequestFactoryJsonImpl.java
Sat Sep 18 16:55:23 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/client/impl/RequestFactoryJsonImpl.java
Sun Sep 19 10:42:32 2010
@@ -126,6 +126,10 @@
public Class<? extends EntityProxy> getClass(EntityProxyId proxyId) {
return ((EntityProxyIdImpl) proxyId).schema.getProxyClass();
}
+
+ public EventBus getEventBus() {
+ return eventBus;
+ }
public RequestTransport getRequestTransport() {
return transport;
@@ -148,11 +152,11 @@
return ProxyImpl.getWireFormatId(id, NOT_FUTURE, proxyIdImpl.schema);
}
- public void init(EventBus eventBus) {
- init(eventBus, new DefaultRequestTransport(eventBus));
- }
-
- public void init(EventBus eventBus, RequestTransport transport) {
+ public void initialize(EventBus eventBus) {
+ initialize(eventBus, new DefaultRequestTransport(eventBus));
+ }
+
+ public void initialize(EventBus eventBus, RequestTransport transport) {
this.valueStore = new ValueStoreJsonImpl();
this.eventBus = eventBus;
this.transport = transport;
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/client/testing/MockRequestFactoryEditorDriver.java
Fri Sep 17 07:40:00 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/client/testing/MockRequestFactoryEditorDriver.java
Sun Sep 19 10:42:32 2010
@@ -131,6 +131,10 @@
this.requestFactory = requestFactory;
this.editor = editor;
}
+
+ public void initialize(RequestFactory requestFactory, E editor) {
+ this.initialize(requestFactory.getEventBus(), requestFactory, editor);
+ }
/**
* A no-op method that always returns false.
=======================================
---
/trunk/user/src/com/google/gwt/requestfactory/shared/RequestFactory.java
Sat Sep 18 09:13:37 2010
+++
/trunk/user/src/com/google/gwt/requestfactory/shared/RequestFactory.java
Sun Sep 19 10:42:32 2010
@@ -34,7 +34,7 @@
<R extends EntityProxy> R create(Class<R> token);
/**
- * Provide a general purpose find request.
+ * Return a request to find a fresh instance of the referenced proxy.
*/
ProxyRequest<EntityProxy> find(EntityProxyId proxyId);
@@ -54,6 +54,12 @@
*/
Class<? extends EntityProxy> getClass(String token);
+ /**
+ * @return the eventbus this factory's events are posted on, which was
set via
+ * {...@link #initialize}
+ */
+ EventBus getEventBus();
+
/**
* Get a {...@link com.google.gwt.user.client.History} compatible token that
* represents the given proxy. It can be processed by
@@ -81,10 +87,10 @@
* Start this request factory with a
* {...@link com.google.gwt.requestfactory.client.DefaultRequestTransport}.
*/
- void init(EventBus eventBus);
+ void initialize(EventBus eventBus);
/**
* Start this request factory with a user-provided transport.
*/
- void init(EventBus eventBus, RequestTransport transport);
-}
+ void initialize(EventBus eventBus, RequestTransport transport);
+}
=======================================
--- /trunk/user/test/com/google/gwt/requestfactory/client/EditorTest.java
Sat Sep 18 09:13:37 2010
+++ /trunk/user/test/com/google/gwt/requestfactory/client/EditorTest.java
Sun Sep 19 10:42:32 2010
@@ -103,7 +103,7 @@
final SimpleFooEditor editor = new SimpleFooEditor();
final SimpleFooDriver driver = GWT.create(SimpleFooDriver.class);
- driver.initialize(eventBus, req, editor);
+ driver.initialize(req, editor);
req.simpleFooRequest().findSimpleFooById(0L).with(driver.getPaths()).fire(
new Receiver<SimpleFooProxy>() {
@@ -139,7 +139,7 @@
final SimpleFooEditorWithDelegate editor = new
SimpleFooEditorWithDelegate();
final SimpleFooDriver driver = GWT.create(SimpleFooDriver.class);
- driver.initialize(eventBus, req, editor);
+ driver.initialize(req, editor);
assertEquals(Arrays.asList("barField.userName", "barField"),
Arrays.asList(driver.getPaths()));
@@ -189,7 +189,7 @@
final SimpleFooEditor editor = new SimpleFooEditor();
final SimpleFooDriver driver = GWT.create(SimpleFooDriver.class);
- driver.initialize(eventBus, req, editor);
+ driver.initialize(req, editor);
req.simpleFooRequest().findSimpleFooById(0L).with(driver.getPaths()).fire(
new Receiver<SimpleFooProxy>() {
@@ -205,7 +205,8 @@
new Receiver<SimpleFooProxy>() {
@Override
public void onSuccess(SimpleFooProxy response) {
- fail("Expected errors");
+ fail("Expected errors. You may be missing jars, see "
+ + "the comment in
RequestFactoryTest.ShouldNotSucceedReceiver.onSuccess");
}
@Override
@@ -228,6 +229,4 @@
}
});
}
-
-}
-
+}
=======================================
---
/trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java
Sat Sep 18 16:55:23 2010
+++
/trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryTest.java
Sun Sep 19 10:42:32 2010
@@ -159,11 +159,15 @@
}
});
}
+
+ public void testGetEventBus() {
+ assertEquals(eventBus, req.getEventBus());
+ }
/*
* tests that (a) any method can have a side effect that is handled
correctly.
- * (b) instance methods are handled correctly and (c) you don't grow
horns or
- * anything if you reuse the request object
+ * (b) instance methods are handled correctly and (c) a request cannot
+ * be reused after a successful response is received. (Yet?)
*/
public void testMethodWithSideEffects() {
delayTestFinish(5000);
=======================================
---
/trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryTestBase.java
Sat Sep 18 09:13:37 2010
+++
/trunk/user/test/com/google/gwt/requestfactory/client/RequestFactoryTestBase.java
Sun Sep 19 10:42:32 2010
@@ -37,7 +37,7 @@
public void gwtSetUp() {
eventBus = new SimpleEventBus();
req = GWT.create(SimpleRequestFactory.class);
- req.init(eventBus);
+ req.initialize(eventBus);
}
protected void finishTestAndReset() {
=======================================
---
/trunk/user/test/com/google/gwt/requestfactory/client/impl/DeltaValueStoreJsonImplTest.java
Sat Sep 18 16:55:23 2010
+++
/trunk/user/test/com/google/gwt/requestfactory/client/impl/DeltaValueStoreJsonImplTest.java
Sun Sep 19 10:42:32 2010
@@ -59,7 +59,7 @@
public void gwtSetUp() {
valueStore = new ValueStoreJsonImpl();
requestFactory = (RequestFactoryJsonImpl)
SimpleRequestFactoryInstance.factory();
- requestFactory.init(new SimpleEventBus());
+ requestFactory.initialize(new SimpleEventBus());
// add a proxy
jso = ProxyJsoImpl.create(42L, 1,
SimpleRequestFactoryInstance.schema(),
=======================================
---
/trunk/user/test/com/google/gwt/requestfactory/client/impl/ValueStoreJsonImplTest.java
Fri Sep 10 17:56:09 2010
+++
/trunk/user/test/com/google/gwt/requestfactory/client/impl/ValueStoreJsonImplTest.java
Sun Sep 19 10:42:32 2010
@@ -33,7 +33,7 @@
ProxyJsoImpl minimalJso = ProxyJsoImplTest.getMinimalJso();
ProxyJsoImpl populatedJso = ProxyJsoImplTest.getPopulatedJso();
ProxyJsoImpl copyPopulatedJso = ProxyJsoImplTest.getPopulatedJso();
- minimalJso.getRequestFactory().init(new SimpleEventBus());
+ minimalJso.getRequestFactory().initialize(new SimpleEventBus());
assertNull(valueStore.putInValueStore(minimalJso));
assertNull(valueStore.putInValueStore(populatedJso));
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors