
public abstract class AbstractRequestContext extends Object implements RequestContext, EntityCodex.EntitySource
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractRequestContext.Dialect
Allows the payload dialect to be injected into the AbstractRequestContext without the caller
needing to be concerned with how the implementation object is instantiated.
|
protected static class |
AbstractRequestContext.State
Encapsulates all state contained by the AbstractRequestContext.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractRequestContext(AbstractRequestFactory factory,
AbstractRequestContext.Dialect dialect) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addInvocation(AbstractRequest<?,?> request)
Called by generated subclasses to enqueue a method invocation.
|
<T extends RequestContext> |
append(T other)
Joins another RequestContext to this RequestContext.
|
<T extends BaseProxy> |
create(Class<T> clazz)
Create a new object, with an ephemeral id.
|
protected <T extends BaseProxy> |
createProxy(Class<T> clazz,
SimpleProxyId<T> id,
boolean useAppendedContexts)
Creates a new proxy with an assigned ID.
|
<T extends BaseProxy> |
edit(T object)
Returns a mutable version of the proxy, whose mutations will accumulate in
this context.
|
<T extends BaseProxy> |
editProxy(T object)
Take ownership of a proxy instance and make it editable.
|
protected void |
fail(Receiver<Void> receiver,
ServerFailure failure)
Invoke the appropriate
onFailure callbacks, possibly throwing an
UmbrellaException if one or more callbacks fails. |
<P extends EntityProxy> |
find(EntityProxyId<P> proxyId)
Return a request to find a fresh instance of the referenced proxy.
|
void |
fire()
Make sure there's a default receiver so errors don't get dropped.
|
void |
fire(Receiver<Void> receiver)
For receiving errors or validation failures only.
|
protected abstract AutoBeanFactory |
getAutoBeanFactory()
Returns an AutoBeanFactory that can produce the types reachable only from this RequestContext.
|
<Q extends BaseProxy> |
getBeanForPayload(Splittable serializedProxyId)
EntityCodex support.
|
AbstractRequestFactory |
getRequestFactory()
Returns the
RequestFactory that created the RequestContext. |
Splittable |
getSerializedProxyId(SimpleProxyId<?> stableId)
EntityCodex support.
|
boolean |
isChanged()
Returns true if any changes have been made to proxies mutable under this
context.
|
boolean |
isEntityType(Class<?> clazz)
EntityCodex support.
|
boolean |
isLocked() |
boolean |
isValueType(Class<?> clazz)
EntityCodex support.
|
void |
setFireDisabled(boolean disabled) |
protected void |
violation(Receiver<Void> receiver,
Set<javax.validation.ConstraintViolation<?>> errors)
Invoke the appropriate
onViolation callbacks, possibly throwing an
UmbrellaException if one or more callbacks fails. |
protected AbstractRequestContext(AbstractRequestFactory factory, AbstractRequestContext.Dialect dialect)
public <T extends RequestContext> T append(T other)
RequestContextSomeContext 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
append in interface RequestContextother - a freshly-constructed RequestContext whose state should be
bound to this RequestContextotherpublic <T extends BaseProxy> T create(Class<T> clazz)
create in interface RequestContextclazz - a Class object of type TBaseProxy instance of type Tpublic <T extends BaseProxy> T edit(T object)
RequestContextedit in interface RequestContextobject - an instance of type TEntityProxy or ValueProxy instance of type Tpublic <T extends BaseProxy> T editProxy(T object)
public <P extends EntityProxy> Request<P> find(EntityProxyId<P> proxyId)
RequestContextfind in interface RequestContextproxyId - an EntityProxyId instance of type PRequest objectpublic void fire()
fire in interface RequestContextpublic void fire(Receiver<Void> receiver)
RequestContextfire in interface RequestContextreceiver - a Receiver instancepublic <Q extends BaseProxy> AutoBean<Q> getBeanForPayload(Splittable serializedProxyId)
getBeanForPayload in interface EntityCodex.EntitySourcepublic AbstractRequestFactory getRequestFactory()
RequestContextRequestFactory that created the RequestContext.getRequestFactory in interface RequestContextpublic Splittable getSerializedProxyId(SimpleProxyId<?> stableId)
getSerializedProxyId in interface EntityCodex.EntitySourcepublic boolean isChanged()
RequestContext
String name = bar.getName();
bar.setName("something else");
assertTrue(context.isChanged());
bar.setName(name);
assertFalse(context.isChanged());
isChanged in interface RequestContexttrue if any changes have been madepublic boolean isEntityType(Class<?> clazz)
isEntityType in interface EntityCodex.EntitySourcepublic boolean isLocked()
public boolean isValueType(Class<?> clazz)
isValueType in interface EntityCodex.EntitySourcepublic void setFireDisabled(boolean disabled)
protected void addInvocation(AbstractRequest<?,?> request)
protected <T extends BaseProxy> AutoBean<T> createProxy(Class<T> clazz, SimpleProxyId<T> id, boolean useAppendedContexts)
clazz - The proxy typeid - The id to be assigned to the new proxyuseAppendedContexts - if true use the AutoBeanFactory types associated with any
contexts that have been passed into append(RequestContext). If false,
this method will only create proxy types reachable from the implemented RequestContext
interface.IllegalArgumentException - if the requested proxy type cannot be createdprotected void fail(Receiver<Void> receiver, ServerFailure failure)
onFailure callbacks, possibly throwing an
UmbrellaException if one or more callbacks fails.protected abstract AutoBeanFactory getAutoBeanFactory()
protected void violation(Receiver<Void> receiver, Set<javax.validation.ConstraintViolation<?>> errors)
onViolation callbacks, possibly throwing an
UmbrellaException if one or more callbacks fails.Copyright © 2016. All rights reserved.