|
GWT 2.7.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.web.bindery.requestfactory.server.ServiceLayer com.google.web.bindery.requestfactory.server.ServiceLayerDecorator
public class ServiceLayerDecorator
Users that intend to alter how RequestFactory interacts with the domain
environment can extend this type and provide it to
ServiceLayer.create(ServiceLayerDecorator...)
. The methods defined in
this type will automatically delegate to the next decorator or the root
service object after being processed bycreate()
.
Field Summary | |
---|---|
(package private) ServiceLayer |
next
A pointer to the next deepest layer. |
Fields inherited from class com.google.web.bindery.requestfactory.server.ServiceLayer |
---|
top |
Constructor Summary | |
---|---|
ServiceLayerDecorator()
|
Method Summary | ||
---|---|---|
|
createDomainObject(java.lang.Class<T> clazz)
Create an instance of the requested domain type. |
|
|
createLocator(java.lang.Class<T> clazz)
Create an instance of the requested Locator type. |
|
java.lang.Object |
createServiceInstance(java.lang.Class<? extends RequestContext> requestContext)
Create an instance of a service object that can be used as the target for the given method invocation. |
|
|
createServiceLocator(java.lang.Class<T> clazz)
Create an instance of the requested ServiceLocator type. |
|
protected
|
die(java.lang.Throwable e,
java.lang.String message,
java.lang.Object... args)
Throw a fatal error up into the top-level processing code. |
|
java.lang.ClassLoader |
getDomainClassLoader()
Returns the ClassLoader that should be used when attempting to access domain classes or resources. |
|
java.lang.reflect.Method |
getGetter(java.lang.Class<?> domainType,
java.lang.String property)
Determine the method to invoke when retrieving the given property. |
|
java.lang.Object |
getId(java.lang.Object domainObject)
Return the persistent id for a domain object. |
|
java.lang.Class<?> |
getIdType(java.lang.Class<?> domainType)
Returns the type of object the domain type's findFoo() or
Locator.getId() expects to receive. |
|
(package private) ServiceLayer |
getNext()
Retrieves the next service layer. |
|
java.lang.Object |
getProperty(java.lang.Object domainObject,
java.lang.String property)
Retrieve the named property from the domain object. |
|
java.lang.reflect.Type |
getRequestReturnType(java.lang.reflect.Method contextMethod)
Compute the return type for a method declared in a RequestContext by analyzing the generic method declaration. |
|
java.lang.reflect.Method |
getSetter(java.lang.Class<?> domainType,
java.lang.String property)
Determine the method to invoke when setting the given property. |
|
protected ServiceLayer |
getTop()
Returns the top-most service layer. |
|
java.lang.Object |
getVersion(java.lang.Object domainObject)
May return null to indicate that the domain object has not been
persisted. |
|
java.lang.Object |
invoke(java.lang.reflect.Method domainMethod,
java.lang.Object... args)
Invoke a domain service method. |
|
boolean |
isLive(java.lang.Object domainObject)
Returns true if the given domain object is still live (i.e. |
|
|
loadDomainObject(java.lang.Class<T> clazz,
java.lang.Object domainId)
Load an object from the backing store. |
|
java.util.List<java.lang.Object> |
loadDomainObjects(java.util.List<java.lang.Class<?>> classes,
java.util.List<java.lang.Object> domainIds)
Load multiple objects from the backing store. |
|
protected
|
report(java.lang.reflect.InvocationTargetException userGeneratedException)
Report an exception thrown by code that is under the control of the end-developer. |
|
protected
|
report(java.lang.String msg,
java.lang.Object... args)
Return a message to the client. |
|
boolean |
requiresServiceLocator(java.lang.reflect.Method contextMethod,
java.lang.reflect.Method domainMethod)
Determines if the invocation of a domain method requires a ServiceLocator as the 0th parameter when passed into
ServiceLayer.invoke(Method, Object...) . |
|
java.lang.Class<? extends BaseProxy> |
resolveClass(java.lang.String typeToken)
Given a type token previously returned from ServiceLayer.resolveTypeToken(Class) , return the Class literal associated with
the token. |
|
|
resolveClientType(java.lang.Class<?> domainClass,
java.lang.Class<T> clientType,
boolean required)
Determine the type used by the client code to represent a given domain type. |
|
java.lang.Class<?> |
resolveDomainClass(java.lang.Class<?> clazz)
Determine the domain (server-side) type that the given client type is mapped to. |
|
java.lang.reflect.Method |
resolveDomainMethod(java.lang.String operation)
Return the domain service method associated with a RequestContext method declaration. |
|
java.lang.Class<? extends Locator<?,?>> |
resolveLocator(java.lang.Class<?> domainType)
Return the type of Locator that should be used to access the given
domain type. |
|
java.lang.Class<? extends RequestContext> |
resolveRequestContext(java.lang.String operation)
Find a RequestContext that should be used to fulfill the requested operation. |
|
java.lang.reflect.Method |
resolveRequestContextMethod(java.lang.String operation)
Find a RequestContext method declaration by name. |
|
java.lang.Class<? extends RequestFactory> |
resolveRequestFactory(java.lang.String binaryName)
Loads and validates a RequestFactory interface. |
|
java.lang.Class<?> |
resolveServiceClass(java.lang.Class<? extends RequestContext> requestContextClass)
Given a RequestContext method, find the service class referenced in
the Service or
ServiceName annotation. |
|
java.lang.Class<? extends ServiceLocator> |
resolveServiceLocator(java.lang.Class<? extends RequestContext> requestContext)
Given a RequestContext method declaration, resolve the ServiceLocator that should be used when invoking the domain method. |
|
java.lang.String |
resolveTypeToken(java.lang.Class<? extends BaseProxy> proxyType)
Return a string used to represent the given type in the wire protocol. |
|
void |
setProperty(java.lang.Object domainObject,
java.lang.String property,
java.lang.Class<?> expectedType,
java.lang.Object value)
Sets a property on a domain object. |
|
|
validate(T domainObject)
Invoke a JSR 303 validator on the given domain object. |
Methods inherited from class com.google.web.bindery.requestfactory.server.ServiceLayer |
---|
create |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
ServiceLayer next
Constructor Detail |
---|
public ServiceLayerDecorator()
Method Detail |
---|
public <T> T createDomainObject(java.lang.Class<T> clazz)
ServiceLayer
createDomainObject
in class ServiceLayer
T
- the requested domain typeclazz
- the requested domain type
public <T extends Locator<?,?>> T createLocator(java.lang.Class<T> clazz)
ServiceLayer
Locator
type.
createLocator
in class ServiceLayer
T
- the requested Locator typeclazz
- the requested Locator type
public java.lang.Object createServiceInstance(java.lang.Class<? extends RequestContext> requestContext)
ServiceLayer
createServiceInstance
in class ServiceLayer
requestContext
- the RequestContext type for which a service object
must be instantiated.
public <T extends ServiceLocator> T createServiceLocator(java.lang.Class<T> clazz)
ServiceLayer
ServiceLocator
type.
createServiceLocator
in class ServiceLayer
T
- the requested ServiceLocator typeclazz
- the requested ServiceLocator type
public java.lang.ClassLoader getDomainClassLoader()
ServiceLayer
The default implementation returns
Thread.currentThread().getContextClassLoader()
.
getDomainClassLoader
in class ServiceLayer
public java.lang.reflect.Method getGetter(java.lang.Class<?> domainType, java.lang.String property)
ServiceLayer
getGetter
in class ServiceLayer
domainType
- a domain entity typeproperty
- the name of the property to be retrieved
null
if the method could not be locatedpublic java.lang.Object getId(java.lang.Object domainObject)
ServiceLayer
null
to
indicate that the domain object has not been persisted. The value returned
from this method must be a simple type (e.g. Integer, String) or a domain
type for which a mapping to an EntityProxy or Value proxy exists.
The values returned from this method may be passed to
ServiceLayer.loadDomainObject(Class, Object)
in the future.
getId
in class ServiceLayer
domainObject
- a domain object
null
if the
object is not persistentpublic java.lang.Class<?> getIdType(java.lang.Class<?> domainType)
ServiceLayer
findFoo()
or
Locator.getId()
expects to receive.
getIdType
in class ServiceLayer
domainType
- a domain entity type
public java.lang.Object getProperty(java.lang.Object domainObject, java.lang.String property)
ServiceLayer
getProperty
in class ServiceLayer
domainObject
- the domain object being examinedproperty
- the property name
public java.lang.reflect.Type getRequestReturnType(java.lang.reflect.Method contextMethod)
ServiceLayer
getRequestReturnType
in class ServiceLayer
public java.lang.reflect.Method getSetter(java.lang.Class<?> domainType, java.lang.String property)
ServiceLayer
getSetter
in class ServiceLayer
domainType
- a domain entity typeproperty
- the name of the property to be set
null
if the method could not be locatedpublic java.lang.Object getVersion(java.lang.Object domainObject)
ServiceLayer
null
to indicate that the domain object has not been
persisted. The value returned from this method must be a simple type (e.g.
Integer, String) or a domain type for which a mapping to an EntityProxy or
Value proxy exists.
getVersion
in class ServiceLayer
domainObject
- a domain object
null
if the object is
not persistentpublic java.lang.Object invoke(java.lang.reflect.Method domainMethod, java.lang.Object... args)
ServiceLayer
Method.invoke(Object, Object...)
.
invoke
in class ServiceLayer
domainMethod
- the method to invokeargs
- the arguments to pass to the method
public boolean isLive(java.lang.Object domainObject)
ServiceLayer
true
if the given domain object is still live (i.e. not
deleted) in the backing store.
isLive
in class ServiceLayer
domainObject
- a domain entity
true
if domainObject
could be retrieved at a later
point in timepublic <T> T loadDomainObject(java.lang.Class<T> clazz, java.lang.Object domainId)
ServiceLayer
null
to indicate that the requested object is no longer available.
loadDomainObject
in class ServiceLayer
T
- the type of object to loadclazz
- the type of object to loaddomainId
- an id previously returned from ServiceLayer.getId(Object)
null
if it is irretrievablepublic java.util.List<java.lang.Object> loadDomainObjects(java.util.List<java.lang.Class<?>> classes, java.util.List<java.lang.Object> domainIds)
ServiceLayer
The default implementation of this method will delegate to
ServiceLayer.loadDomainObject(Class, Object)
.
loadDomainObjects
in class ServiceLayer
classes
- type type of each object to loaddomainIds
- the ids previously returned from ServiceLayer.getId(Object)
null
if the
requested objects were irretrievablepublic boolean requiresServiceLocator(java.lang.reflect.Method contextMethod, java.lang.reflect.Method domainMethod)
ServiceLayer
ServiceLocator
as the 0th parameter when passed into
ServiceLayer.invoke(Method, Object...)
.
requiresServiceLocator
in class ServiceLayer
contextMethod
- a method defined in a RequestContextdomainMethod
- a domain method
true
if a ServiceLocator is requiredpublic java.lang.Class<? extends BaseProxy> resolveClass(java.lang.String typeToken)
ServiceLayer
ServiceLayer.resolveTypeToken(Class)
, return the Class literal associated with
the token.
resolveClass
in class ServiceLayer
typeToken
- a string token
public <T> java.lang.Class<? extends T> resolveClientType(java.lang.Class<?> domainClass, java.lang.Class<T> clientType, boolean required)
ServiceLayer
clientType
parameter is used to ensure assignability.
resolveClientType
in class ServiceLayer
domainClass
- the server-side type to be transported to the clientclientType
- the type to which the returned type must be assignablerequired
- if true
and no mapping is available, throw an
exception, otherwise the method will return null
domainClass
on the client which is
assignable to clientType
public java.lang.Class<?> resolveDomainClass(java.lang.Class<?> clazz)
ServiceLayer
resolveDomainClass
in class ServiceLayer
clazz
- a client-side type
clientType
representspublic java.lang.reflect.Method resolveDomainMethod(java.lang.String operation)
ServiceLayer
requestContextMethod
will have been previously
resolved by #resolveRequestContextMethod(String, String)
.
resolveDomainMethod
in class ServiceLayer
public java.lang.Class<? extends Locator<?,?>> resolveLocator(java.lang.Class<?> domainType)
ServiceLayer
Locator
that should be used to access the given
domain type.
resolveLocator
in class ServiceLayer
domainType
- a domain (server-side) type
null
if the type conforms to
the RequestFactory entity protocolpublic java.lang.Class<? extends RequestContext> resolveRequestContext(java.lang.String operation)
ServiceLayer
resolveRequestContext
in class ServiceLayer
operation
- the operation
null
if no RequestContext exists that
can fulfill the operationpublic java.lang.reflect.Method resolveRequestContextMethod(java.lang.String operation)
ServiceLayer
resolveRequestContextMethod
in class ServiceLayer
operation
- the operation's name
null
if the method does not
existpublic java.lang.Class<? extends RequestFactory> resolveRequestFactory(java.lang.String binaryName)
ServiceLayer
resolveRequestFactory
in class ServiceLayer
binaryName
- the RequestFactory's type token (usually the type's binary
name)
public java.lang.Class<?> resolveServiceClass(java.lang.Class<? extends RequestContext> requestContextClass)
ServiceLayer
RequestContext
method, find the service class referenced in
the Service
or
ServiceName
annotation.
resolveServiceClass
in class ServiceLayer
requestContextClass
- a RequestContext interface
public java.lang.Class<? extends ServiceLocator> resolveServiceLocator(java.lang.Class<? extends RequestContext> requestContext)
ServiceLayer
ServiceLocator
that should be used when invoking the domain method.
This method will only be called if
ServiceLayer.requiresServiceLocator(Method, Method)
returned true
for
the associated domain method.
resolveServiceLocator
in class ServiceLayer
requestContext
- the RequestContext for which a ServiceLocator must be
located
public java.lang.String resolveTypeToken(java.lang.Class<? extends BaseProxy> proxyType)
ServiceLayer
resolveTypeToken
in class ServiceLayer
proxyType
- a client-side EntityProxy or ValueProxy type
public void setProperty(java.lang.Object domainObject, java.lang.String property, java.lang.Class<?> expectedType, java.lang.Object value)
ServiceLayer
setProperty
in class ServiceLayer
domainObject
- the domain object to operate onproperty
- the name of the property to setexpectedType
- the type of the propertyvalue
- the new valuepublic <T> java.util.Set<ConstraintViolation<T>> validate(T domainObject)
ServiceLayer
validate
in class ServiceLayer
T
- the type of data being validateddomainObject
- the domain objcet to validate
protected final <T> T die(java.lang.Throwable e, java.lang.String message, java.lang.Object... args) throws UnexpectedException
e
- a throwable with more data, may be null
message
- a printf-style format stringargs
- arguments for the message
UnexpectedException
- this method never returns normallyreport(String, Object...)
protected final ServiceLayer getTop()
getTop()
when calling public
methods on the ServiceLayer API to allow higher-level decorators to
override behaviors built into lower-level decorators.
ServiceLayer.create(ServiceLayerDecorator...)
protected final <T> T report(java.lang.reflect.InvocationTargetException userGeneratedException) throws ReportableException
userGeneratedException
- an InvocationTargetException
thrown
by an invocation of user-provided code
ReportableException
- this method never returns normallyprotected final <T> T report(java.lang.String msg, java.lang.Object... args) throws ReportableException
msg
- a printf-style format stringargs
- arguments for the message
ReportableException
- this method never returns normallydie(Throwable, String, Object...)
final ServiceLayer getNext()
super.doSomething()
.
|
GWT 2.7.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |