|
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
public abstract class ServiceLayer
The ServiceLayer mediates all interactions between the
SimpleRequestProcessor
and the domain environment. The core service
logic can be decorated by extending an ServiceLayerDecorator
.
This API is subject to change in future releases.
Field Summary | |
---|---|
(package private) ServiceLayer |
top
A pointer to the top-most ServiceLayer instance. |
Constructor Summary | |
---|---|
ServiceLayer()
Not generally-extensible. |
Method Summary | ||
---|---|---|
static ServiceLayer |
create(ServiceLayerDecorator... decorators)
Create a RequestFactory ServiceLayer that is optionally modified by the given decorators. |
|
abstract
|
createDomainObject(java.lang.Class<T> clazz)
Create an instance of the requested domain type. |
|
abstract
|
createLocator(java.lang.Class<T> clazz)
Create an instance of the requested Locator type. |
|
abstract 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. |
|
abstract
|
createServiceLocator(java.lang.Class<T> clazz)
Create an instance of the requested ServiceLocator type. |
|
abstract java.lang.ClassLoader |
getDomainClassLoader()
Returns the ClassLoader that should be used when attempting to access domain classes or resources. |
|
abstract java.lang.reflect.Method |
getGetter(java.lang.Class<?> domainType,
java.lang.String property)
Determine the method to invoke when retrieving the given property. |
|
abstract java.lang.Object |
getId(java.lang.Object domainObject)
Return the persistent id for a domain object. |
|
abstract java.lang.Class<?> |
getIdType(java.lang.Class<?> domainType)
Returns the type of object the domain type's findFoo() or
Locator.getId() expects to receive. |
|
abstract java.lang.Object |
getProperty(java.lang.Object domainObject,
java.lang.String property)
Retrieve the named property from the domain object. |
|
abstract 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. |
|
abstract java.lang.reflect.Method |
getSetter(java.lang.Class<?> domainType,
java.lang.String property)
Determine the method to invoke when setting the given property. |
|
abstract java.lang.Object |
getVersion(java.lang.Object domainObject)
May return null to indicate that the domain object has not been
persisted. |
|
abstract java.lang.Object |
invoke(java.lang.reflect.Method domainMethod,
java.lang.Object... args)
Invoke a domain service method. |
|
abstract boolean |
isLive(java.lang.Object domainObject)
Returns true if the given domain object is still live (i.e. |
|
abstract
|
loadDomainObject(java.lang.Class<T> clazz,
java.lang.Object domainId)
Load an object from the backing store. |
|
abstract 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. |
|
abstract 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
invoke(Method, Object...) . |
|
abstract java.lang.Class<? extends BaseProxy> |
resolveClass(java.lang.String typeToken)
Given a type token previously returned from resolveTypeToken(Class) , return the Class literal associated with
the token. |
|
abstract
|
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. |
|
abstract java.lang.Class<?> |
resolveDomainClass(java.lang.Class<?> clientType)
Determine the domain (server-side) type that the given client type is mapped to. |
|
abstract java.lang.reflect.Method |
resolveDomainMethod(java.lang.String operation)
Return the domain service method associated with a RequestContext method declaration. |
|
abstract 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. |
|
abstract java.lang.Class<? extends RequestContext> |
resolveRequestContext(java.lang.String operation)
Find a RequestContext that should be used to fulfill the requested operation. |
|
abstract java.lang.reflect.Method |
resolveRequestContextMethod(java.lang.String operation)
Find a RequestContext method declaration by name. |
|
abstract java.lang.Class<? extends RequestFactory> |
resolveRequestFactory(java.lang.String token)
Loads and validates a RequestFactory interface. |
|
abstract 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. |
|
abstract 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. |
|
abstract java.lang.String |
resolveTypeToken(java.lang.Class<? extends BaseProxy> proxyType)
Return a string used to represent the given type in the wire protocol. |
|
abstract 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. |
|
abstract
|
validate(T domainObject)
Invoke a JSR 303 validator on the given domain object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
ServiceLayer top
Constructor Detail |
---|
ServiceLayer()
Method Detail |
---|
public static ServiceLayer create(ServiceLayerDecorator... decorators)
decorators
- the decorators that will modify the behavior of the core
service layer implementation
public abstract <T> T createDomainObject(java.lang.Class<T> clazz)
T
- the requested domain typeclazz
- the requested domain type
public abstract <T extends Locator<?,?>> T createLocator(java.lang.Class<T> clazz)
Locator
type.
T
- the requested Locator typeclazz
- the requested Locator type
public abstract java.lang.Object createServiceInstance(java.lang.Class<? extends RequestContext> requestContext)
requestContext
- the RequestContext type for which a service object
must be instantiated.
public abstract <T extends ServiceLocator> T createServiceLocator(java.lang.Class<T> clazz)
ServiceLocator
type.
T
- the requested ServiceLocator typeclazz
- the requested ServiceLocator type
public abstract java.lang.ClassLoader getDomainClassLoader()
The default implementation returns
Thread.currentThread().getContextClassLoader()
.
public abstract java.lang.reflect.Method getGetter(java.lang.Class<?> domainType, java.lang.String property)
domainType
- a domain entity typeproperty
- the name of the property to be retrieved
null
if the method could not be locatedpublic abstract java.lang.Object getId(java.lang.Object domainObject)
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
loadDomainObject(Class, Object)
in the future.
domainObject
- a domain object
null
if the
object is not persistentpublic abstract java.lang.Class<?> getIdType(java.lang.Class<?> domainType)
findFoo()
or
Locator.getId()
expects to receive.
domainType
- a domain entity type
public abstract java.lang.Object getProperty(java.lang.Object domainObject, java.lang.String property)
domainObject
- the domain object being examinedproperty
- the property name
public abstract java.lang.reflect.Type getRequestReturnType(java.lang.reflect.Method contextMethod)
public abstract java.lang.reflect.Method getSetter(java.lang.Class<?> domainType, java.lang.String property)
domainType
- a domain entity typeproperty
- the name of the property to be set
null
if the method could not be locatedpublic abstract java.lang.Object getVersion(java.lang.Object domainObject)
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.
domainObject
- a domain object
null
if the object is
not persistentpublic abstract java.lang.Object invoke(java.lang.reflect.Method domainMethod, java.lang.Object... args)
Method.invoke(Object, Object...)
.
domainMethod
- the method to invokeargs
- the arguments to pass to the method
public abstract boolean isLive(java.lang.Object domainObject)
true
if the given domain object is still live (i.e. not
deleted) in the backing store.
domainObject
- a domain entity
true
if domainObject
could be retrieved at a later
point in timepublic abstract <T> T loadDomainObject(java.lang.Class<T> clazz, java.lang.Object domainId)
null
to indicate that the requested object is no longer available.
T
- the type of object to loadclazz
- the type of object to loaddomainId
- an id previously returned from getId(Object)
null
if it is irretrievablepublic abstract java.util.List<java.lang.Object> loadDomainObjects(java.util.List<java.lang.Class<?>> classes, java.util.List<java.lang.Object> domainIds)
The default implementation of this method will delegate to
loadDomainObject(Class, Object)
.
classes
- type type of each object to loaddomainIds
- the ids previously returned from getId(Object)
null
if the
requested objects were irretrievablepublic abstract boolean requiresServiceLocator(java.lang.reflect.Method contextMethod, java.lang.reflect.Method domainMethod)
ServiceLocator
as the 0th parameter when passed into
invoke(Method, Object...)
.
contextMethod
- a method defined in a RequestContextdomainMethod
- a domain method
true
if a ServiceLocator is requiredpublic abstract java.lang.Class<? extends BaseProxy> resolveClass(java.lang.String typeToken)
resolveTypeToken(Class)
, return the Class literal associated with
the token.
typeToken
- a string token
public abstract <T> java.lang.Class<? extends T> resolveClientType(java.lang.Class<?> domainClass, java.lang.Class<T> clientType, boolean required)
clientType
parameter is used to ensure assignability.
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 abstract java.lang.Class<?> resolveDomainClass(java.lang.Class<?> clientType)
clientType
- a client-side type
clientType
representspublic abstract java.lang.reflect.Method resolveDomainMethod(java.lang.String operation)
requestContextMethod
will have been previously
resolved by #resolveRequestContextMethod(String, String)
.
requestContext
- the RequestContext requested by the clientrequestContextMethod
- a RequestContext method declaration. Note that
this Method may be defined in a supertype of
requestContext
public abstract java.lang.Class<? extends Locator<?,?>> resolveLocator(java.lang.Class<?> domainType)
Locator
that should be used to access the given
domain type.
domainType
- a domain (server-side) type
null
if the type conforms to
the RequestFactory entity protocolpublic abstract java.lang.Class<? extends RequestContext> resolveRequestContext(java.lang.String operation)
operation
- the operation
null
if no RequestContext exists that
can fulfill the operationpublic abstract java.lang.reflect.Method resolveRequestContextMethod(java.lang.String operation)
operation
- the operation's name
null
if the method does not
existpublic abstract java.lang.Class<? extends RequestFactory> resolveRequestFactory(java.lang.String token)
token
- the RequestFactory's type token (usually the type's binary
name)
public abstract java.lang.Class<?> resolveServiceClass(java.lang.Class<? extends RequestContext> requestContextClass)
RequestContext
method, find the service class referenced in
the Service
or
ServiceName
annotation.
requestContextClass
- a RequestContext interface
public abstract java.lang.Class<? extends ServiceLocator> resolveServiceLocator(java.lang.Class<? extends RequestContext> requestContext)
ServiceLocator
that should be used when invoking the domain method.
This method will only be called if
requiresServiceLocator(Method, Method)
returned true
for
the associated domain method.
requestContext
- the RequestContext for which a ServiceLocator must be
located
public abstract java.lang.String resolveTypeToken(java.lang.Class<? extends BaseProxy> proxyType)
proxyType
- a client-side EntityProxy or ValueProxy type
public abstract void setProperty(java.lang.Object domainObject, java.lang.String property, java.lang.Class<?> expectedType, java.lang.Object value)
domainObject
- the domain object to operate onproperty
- the name of the property to setexpectedType
- the type of the propertyvalue
- the new valuepublic abstract <T> java.util.Set<ConstraintViolation<T>> validate(T domainObject)
T
- the type of data being validateddomainObject
- the domain objcet to validate
|
GWT 2.7.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |