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)
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
append
in interface RequestContext
other
- a freshly-constructed RequestContext whose state should be
bound to this RequestContextother
public <T extends BaseProxy> T create(Class<T> clazz)
create
in interface RequestContext
clazz
- a Class object of type TBaseProxy
instance of type Tpublic <T extends BaseProxy> T edit(T object)
RequestContext
edit
in interface RequestContext
object
- 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)
RequestContext
find
in interface RequestContext
proxyId
- an EntityProxyId
instance of type PRequest
objectpublic void fire()
fire
in interface RequestContext
public void fire(Receiver<Void> receiver)
RequestContext
fire
in interface RequestContext
receiver
- a Receiver
instancepublic <Q extends BaseProxy> AutoBean<Q> getBeanForPayload(Splittable serializedProxyId)
getBeanForPayload
in interface EntityCodex.EntitySource
public AbstractRequestFactory getRequestFactory()
RequestContext
RequestFactory
that created the RequestContext.getRequestFactory
in interface RequestContext
public Splittable getSerializedProxyId(SimpleProxyId<?> stableId)
getSerializedProxyId
in interface EntityCodex.EntitySource
public boolean isChanged()
RequestContext
String name = bar.getName(); bar.setName("something else"); assertTrue(context.isChanged()); bar.setName(name); assertFalse(context.isChanged());
isChanged
in interface RequestContext
true
if any changes have been madepublic boolean isEntityType(Class<?> clazz)
isEntityType
in interface EntityCodex.EntitySource
public boolean isLocked()
public boolean isValueType(Class<?> clazz)
isValueType
in interface EntityCodex.EntitySource
public 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.