Interface RequestContext
-
- All Known Subinterfaces:
LoggingRequest
- All Known Implementing Classes:
com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext,FakeRequestContext,InProcessRequestContext
public interface RequestContextThe base interface for RequestFactory service endpoints. Implementations of this interface are provided by the RequestFactory plumbing and this interface may be extended in the future.- See Also:
FakeRequestContext
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T extends RequestContext>
Tappend(T other)Joins another RequestContext to this RequestContext.<T extends BaseProxy>
Tcreate(java.lang.Class<T> clazz)Returns a new mutable proxy that this request can carry to the server, perhaps to be persisted.<T extends BaseProxy>
Tedit(T object)Returns a mutable version of the proxy, whose mutations will accumulate in this context.<P extends EntityProxy>
Request<P>find(EntityProxyId<P> proxyId)Return a request to find a fresh instance of the referenced proxy.voidfire()Send the accumulated changes and method invocations associated with the RequestContext.voidfire(Receiver<java.lang.Void> receiver)For receiving errors or validation failures only.RequestFactorygetRequestFactory()Returns theRequestFactorythat created the RequestContext.booleanisChanged()Returns true if any changes have been made to proxies mutable under this context.
-
-
-
Method Detail
-
append
<T extends RequestContext> T append(T other)
Joins another RequestContext to this RequestContext.SomeContext ctx = myFactory.someContext(); // Perform operations on ctx OtherContext other = ctx.append(myFactory.otherContext()); // Perform operations on both other and ctx ctx.fire() // or other.fire() are equivalent
- Parameters:
other- a freshly-constructed RequestContext whose state should be bound to this RequestContext- Returns:
other- Throws:
java.lang.IllegalStateException- if any methods have been called onotheror ifotherwas constructed by a different RequestFactory instance
-
create
<T extends BaseProxy> T create(java.lang.Class<T> clazz)
Returns a new mutable proxy that this request can carry to the server, perhaps to be persisted. If the object is successfully persisted, a PERSIST event will be posted including the EntityProxyId of this proxy.- Parameters:
clazz- a Class object of type T- Returns:
- an
BaseProxyinstance of type T
-
edit
<T extends BaseProxy> T edit(T object)
Returns a mutable version of the proxy, whose mutations will accumulate in this context. Proxies reached via getters on this mutable proxy will also be mutable.- Parameters:
object- an instance of type T- Returns:
- an
EntityProxyorValueProxyinstance of type T
-
find
<P extends EntityProxy> Request<P> find(EntityProxyId<P> proxyId)
Return a request to find a fresh instance of the referenced proxy.- Parameters:
proxyId- anEntityProxyIdinstance of type P- Returns:
- a
Requestobject
-
fire
void fire()
Send the accumulated changes and method invocations associated with the RequestContext.If
Request.to(Receiver)has not been called, this method will install a default receiver that will throw a RuntimeException if there is a server failure.
-
fire
void fire(Receiver<java.lang.Void> receiver)
For receiving errors or validation failures only.- Parameters:
receiver- aReceiverinstance- Throws:
java.lang.IllegalArgumentException- ifreceiverisnull
-
getRequestFactory
RequestFactory getRequestFactory()
Returns theRequestFactorythat created the RequestContext.
-
isChanged
boolean isChanged()
Returns true if any changes have been made to proxies mutable under this context. Note that vacuous changes — e.g. foo.setName(foo.getName() — will not trip the changed flag. Similarly, "unmaking" a change will clear the isChanged flagString name = bar.getName(); bar.setName("something else"); assertTrue(context.isChanged()); bar.setName(name); assertFalse(context.isChanged());- Returns:
trueif any changes have been made
-
-