Class ReflectiveServiceLayer
- java.lang.Object
-
- com.google.web.bindery.requestfactory.server.ServiceLayer
-
- com.google.web.bindery.requestfactory.server.ServiceLayerDecorator
-
- com.google.web.bindery.requestfactory.server.ReflectiveServiceLayer
-
final class ReflectiveServiceLayer extends ServiceLayerDecorator
Implements all methods that interact with domain objects.
-
-
Field Summary
-
Fields inherited from class com.google.web.bindery.requestfactory.server.ServiceLayerDecorator
next
-
Fields inherited from class com.google.web.bindery.requestfactory.server.ServiceLayer
top
-
-
Constructor Summary
Constructors Constructor Description ReflectiveServiceLayer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> TcreateDomainObject(java.lang.Class<T> clazz)Create an instance of the requested domain type.java.lang.reflect.MethodgetGetter(java.lang.Class<?> domainType, java.lang.String property)Determine the method to invoke when retrieving the given property.java.lang.ObjectgetId(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'sfindFoo()orLocator.getId()expects to receive.java.lang.ObjectgetProperty(java.lang.Object domainObject, java.lang.String property)Retrieve the named property from the domain object.java.lang.reflect.TypegetRequestReturnType(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.MethodgetSetter(java.lang.Class<?> domainType, java.lang.String property)Determine the method to invoke when setting the given property.java.lang.ObjectgetVersion(java.lang.Object domainObject)May returnnullto indicate that the domain object has not been persisted.java.lang.Objectinvoke(java.lang.reflect.Method domainMethod, java.lang.Object... args)Invoke a domain service method.booleanisLive(java.lang.Object domainObject)This implementation attempts to re-load the object from the backing store.<T> TloadDomainObject(java.lang.Class<T> clazz, java.lang.Object id)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.voidsetProperty(java.lang.Object domainObject, java.lang.String property, java.lang.Class<?> expectedType, java.lang.Object value)Sets a property on a domain object.<T> java.util.Set<ConstraintViolation<T>>validate(T domainObject)Invoke a JSR 303 validator on the given domain object.-
Methods inherited from class com.google.web.bindery.requestfactory.server.ServiceLayerDecorator
createLocator, createServiceInstance, createServiceLocator, die, getDomainClassLoader, getNext, getTop, report, report, requiresServiceLocator, resolveClass, resolveClientType, resolveDomainClass, resolveDomainMethod, resolveLocator, resolveRequestContext, resolveRequestContextMethod, resolveRequestFactory, resolveServiceClass, resolveServiceLocator, resolveTypeToken
-
Methods inherited from class com.google.web.bindery.requestfactory.server.ServiceLayer
create
-
-
-
-
Method Detail
-
createDomainObject
public <T> T createDomainObject(java.lang.Class<T> clazz)
Description copied from class:ServiceLayerCreate an instance of the requested domain type.- Overrides:
createDomainObjectin classServiceLayerDecorator- Type Parameters:
T- the requested domain type- Parameters:
clazz- the requested domain type- Returns:
- an instance of the requested domain type
-
getGetter
public java.lang.reflect.Method getGetter(java.lang.Class<?> domainType, java.lang.String property)Description copied from class:ServiceLayerDetermine the method to invoke when retrieving the given property.- Overrides:
getGetterin classServiceLayerDecorator- Parameters:
domainType- a domain entity typeproperty- the name of the property to be retrieved- Returns:
- the Method that should be invoked to retrieve the property or
nullif the method could not be located
-
getId
public java.lang.Object getId(java.lang.Object domainObject)
Description copied from class:ServiceLayerReturn the persistent id for a domain object. May returnnullto 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.- Overrides:
getIdin classServiceLayerDecorator- Parameters:
domainObject- a domain object- Returns:
- the persistent id of the domain object or
nullif the object is not persistent
-
getIdType
public java.lang.Class<?> getIdType(java.lang.Class<?> domainType)
Description copied from class:ServiceLayerReturns the type of object the domain type'sfindFoo()orLocator.getId()expects to receive.- Overrides:
getIdTypein classServiceLayerDecorator- Parameters:
domainType- a domain entity type- Returns:
- the type of the persistent id value used to represent the domain type
-
getProperty
public java.lang.Object getProperty(java.lang.Object domainObject, java.lang.String property)Description copied from class:ServiceLayerRetrieve the named property from the domain object.- Overrides:
getPropertyin classServiceLayerDecorator- Parameters:
domainObject- the domain object being examinedproperty- the property name- Returns:
- the value of the property
-
getRequestReturnType
public java.lang.reflect.Type getRequestReturnType(java.lang.reflect.Method contextMethod)
Description copied from class:ServiceLayerCompute the return type for a method declared in a RequestContext by analyzing the generic method declaration.- Overrides:
getRequestReturnTypein classServiceLayerDecorator
-
getSetter
public java.lang.reflect.Method getSetter(java.lang.Class<?> domainType, java.lang.String property)Description copied from class:ServiceLayerDetermine the method to invoke when setting the given property.- Overrides:
getSetterin classServiceLayerDecorator- Parameters:
domainType- a domain entity typeproperty- the name of the property to be set- Returns:
- the Method that should be invoked to set the property or
nullif the method could not be located
-
getVersion
public java.lang.Object getVersion(java.lang.Object domainObject)
Description copied from class:ServiceLayerMay returnnullto 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.- Overrides:
getVersionin classServiceLayerDecorator- Parameters:
domainObject- a domain object- Returns:
- the version of the domain object or
nullif the object is not persistent
-
invoke
public java.lang.Object invoke(java.lang.reflect.Method domainMethod, java.lang.Object... args)Description copied from class:ServiceLayerInvoke a domain service method. The underlying eventually callsMethod.invoke(Object, Object...).- Overrides:
invokein classServiceLayerDecorator- Parameters:
domainMethod- the method to invokeargs- the arguments to pass to the method- Returns:
- the value returned from the method invocation
-
isLive
public boolean isLive(java.lang.Object domainObject)
This implementation attempts to re-load the object from the backing store.- Overrides:
isLivein classServiceLayerDecorator- Parameters:
domainObject- a domain entity- Returns:
trueifdomainObjectcould be retrieved at a later point in time
-
loadDomainObject
public <T> T loadDomainObject(java.lang.Class<T> clazz, java.lang.Object id)Description copied from class:ServiceLayerLoad an object from the backing store. This method may returnnullto indicate that the requested object is no longer available.- Overrides:
loadDomainObjectin classServiceLayerDecorator- Type Parameters:
T- the type of object to load- Parameters:
clazz- the type of object to loadid- an id previously returned fromServiceLayer.getId(Object)- Returns:
- the requested object or
nullif it is irretrievable
-
loadDomainObjects
public java.util.List<java.lang.Object> loadDomainObjects(java.util.List<java.lang.Class<?>> classes, java.util.List<java.lang.Object> domainIds)Description copied from class:ServiceLayerLoad multiple objects from the backing store. This method is intended to allow more efficient access to the backing store by providing all objects referenced in an incoming payload.The default implementation of this method will delegate to
ServiceLayer.loadDomainObject(Class, Object).- Overrides:
loadDomainObjectsin classServiceLayerDecorator- Parameters:
classes- type type of each object to loaddomainIds- the ids previously returned fromServiceLayer.getId(Object)- Returns:
- the requested objects, elements of which may be
nullif the requested objects were irretrievable
-
setProperty
public void setProperty(java.lang.Object domainObject, java.lang.String property, java.lang.Class<?> expectedType, java.lang.Object value)Description copied from class:ServiceLayerSets a property on a domain object.- Overrides:
setPropertyin classServiceLayerDecorator- Parameters:
domainObject- the domain object to operate onproperty- the name of the property to setexpectedType- the type of the propertyvalue- the new value
-
validate
public <T> java.util.Set<ConstraintViolation<T>> validate(T domainObject)
Description copied from class:ServiceLayerInvoke a JSR 303 validator on the given domain object. If no validator is available, this method is a no-op.- Overrides:
validatein classServiceLayerDecorator- Type Parameters:
T- the type of data being validated- Parameters:
domainObject- the domain objcet to validate- Returns:
- the violations associated with the domain object
-
-