Class ServiceLayerDecorator
java.lang.Object
com.google.web.bindery.requestfactory.server.ServiceLayer
com.google.web.bindery.requestfactory.server.ServiceLayerDecorator
- Direct Known Subclasses:
- FindServiceLayer,- LocatorServiceLayer,- ReflectiveServiceLayer,- ResolverServiceLayer,- ServiceLayerCache
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 SummaryFieldsModifier and TypeFieldDescription(package private) ServiceLayerA pointer to the next deepest layer.Fields inherited from class com.google.web.bindery.requestfactory.server.ServiceLayertop
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescription<T> TcreateDomainObject(Class<T> clazz) Create an instance of the requested domain type.<T extends Locator<?,?>> 
 TcreateLocator(Class<T> clazz) Create an instance of the requestedLocatortype.createServiceInstance(Class<? extends RequestContext> requestContext) Create an instance of a service object that can be used as the target for the given method invocation.<T extends ServiceLocator>
 TcreateServiceLocator(Class<T> clazz) Create an instance of the requestedServiceLocatortype.protected final <T> TThrow a fatal error up into the top-level processing code.Returns the ClassLoader that should be used when attempting to access domain classes or resources.Determine the method to invoke when retrieving the given property.Return the persistent id for a domain object.Class<?> Returns the type of object the domain type'sfindFoo()orLocator.getId()expects to receive.(package private) final ServiceLayergetNext()Retrieves the next service layer.getProperty(Object domainObject, String property) Retrieve the named property from the domain object.getRequestReturnType(Method contextMethod) Compute the return type for a method declared in a RequestContext by analyzing the generic method declaration.Determine the method to invoke when setting the given property.protected final ServiceLayergetTop()Returns the top-most service layer.getVersion(Object domainObject) May returnnullto indicate that the domain object has not been persisted.Invoke a domain service method.booleanReturnstrueif the given domain object is still live (i.e.<T> TloadDomainObject(Class<T> clazz, Object domainId) Load an object from the backing store.loadDomainObjects(List<Class<?>> classes, List<Object> domainIds) Load multiple objects from the backing store.protected final <T> Treport(InvocationTargetException userGeneratedException) Report an exception thrown by code that is under the control of the end-developer.protected final <T> TReturn a message to the client.booleanrequiresServiceLocator(Method contextMethod, Method domainMethod) Determines if the invocation of a domain method requires aServiceLocatoras the 0th parameter when passed intoServiceLayer.invoke(Method, Object...).resolveClass(String typeToken) Given a type token previously returned fromServiceLayer.resolveTypeToken(Class), return the Class literal associated with the token.<T> Class<? extends T> resolveClientType(Class<?> domainClass, Class<T> clientType, boolean required) Determine the type used by the client code to represent a given domain type.Class<?> resolveDomainClass(Class<?> clazz) Determine the domain (server-side) type that the given client type is mapped to.resolveDomainMethod(String operation) Return the domain service method associated with a RequestContext method declaration.resolveLocator(Class<?> domainType) Return the type ofLocatorthat should be used to access the given domain type.Class<? extends RequestContext> resolveRequestContext(String operation) Find a RequestContext that should be used to fulfill the requested operation.resolveRequestContextMethod(String operation) Find a RequestContext method declaration by name.Class<? extends RequestFactory> resolveRequestFactory(String binaryName) Loads and validates a RequestFactory interface.Class<?> resolveServiceClass(Class<? extends RequestContext> requestContextClass) Given aRequestContextmethod, find the service class referenced in theServiceorServiceNameannotation.Class<? extends ServiceLocator> resolveServiceLocator(Class<? extends RequestContext> requestContext) Given a RequestContext method declaration, resolve theServiceLocatorthat should be used when invoking the domain method.resolveTypeToken(Class<? extends BaseProxy> proxyType) Return a string used to represent the given type in the wire protocol.voidsetProperty(Object domainObject, String property, Class<?> expectedType, Object value) Sets a property on a domain object.<T> 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.ServiceLayercreate
- 
Field Details- 
nextServiceLayer nextA pointer to the next deepest layer.
 
- 
- 
Constructor Details- 
ServiceLayerDecoratorpublic ServiceLayerDecorator()
 
- 
- 
Method Details- 
createDomainObjectDescription copied from class:ServiceLayerCreate an instance of the requested domain type.- Specified by:
- createDomainObjectin class- ServiceLayer
- Type Parameters:
- T- the requested domain type
- Parameters:
- clazz- the requested domain type
- Returns:
- an instance of the requested domain type
 
- 
createLocatorDescription copied from class:ServiceLayerCreate an instance of the requestedLocatortype.- Specified by:
- createLocatorin class- ServiceLayer
- Type Parameters:
- T- the requested Locator type
- Parameters:
- clazz- the requested Locator type
- Returns:
- an instance of the requested Locator type
 
- 
createServiceInstanceDescription copied from class:ServiceLayerCreate an instance of a service object that can be used as the target for the given method invocation.- Specified by:
- createServiceInstancein class- ServiceLayer
- Parameters:
- requestContext- the RequestContext type for which a service object must be instantiated.
- Returns:
- an instance of the requested service object
 
- 
createServiceLocatorDescription copied from class:ServiceLayerCreate an instance of the requestedServiceLocatortype.- Specified by:
- createServiceLocatorin class- ServiceLayer
- Type Parameters:
- T- the requested ServiceLocator type
- Parameters:
- clazz- the requested ServiceLocator type
- Returns:
- an instance of the requested ServiceLocator type
 
- 
getDomainClassLoaderDescription copied from class:ServiceLayerReturns the ClassLoader that should be used when attempting to access domain classes or resources.The default implementation returns Thread.currentThread().getContextClassLoader().- Specified by:
- getDomainClassLoaderin class- ServiceLayer
 
- 
getGetterDescription copied from class:ServiceLayerDetermine the method to invoke when retrieving the given property.- Specified by:
- getGetterin class- ServiceLayer
- Parameters:
- domainType- a domain entity type
- property- 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
 
- 
getIdDescription 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.- Specified by:
- getIdin class- ServiceLayer
- Parameters:
- domainObject- a domain object
- Returns:
- the persistent id of the domain object or nullif the object is not persistent
 
- 
getIdTypeDescription copied from class:ServiceLayerReturns the type of object the domain type'sfindFoo()orLocator.getId()expects to receive.- Specified by:
- getIdTypein class- ServiceLayer
- Parameters:
- domainType- a domain entity type
- Returns:
- the type of the persistent id value used to represent the domain type
 
- 
getPropertyDescription copied from class:ServiceLayerRetrieve the named property from the domain object.- Specified by:
- getPropertyin class- ServiceLayer
- Parameters:
- domainObject- the domain object being examined
- property- the property name
- Returns:
- the value of the property
 
- 
getRequestReturnTypeDescription copied from class:ServiceLayerCompute the return type for a method declared in a RequestContext by analyzing the generic method declaration.- Specified by:
- getRequestReturnTypein class- ServiceLayer
 
- 
getSetterDescription copied from class:ServiceLayerDetermine the method to invoke when setting the given property.- Specified by:
- getSetterin class- ServiceLayer
- Parameters:
- domainType- a domain entity type
- property- 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
 
- 
getVersionDescription 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.- Specified by:
- getVersionin class- ServiceLayer
- Parameters:
- domainObject- a domain object
- Returns:
- the version of the domain object or nullif the object is not persistent
 
- 
invokeDescription copied from class:ServiceLayerInvoke a domain service method. The underlying eventually callsMethod.invoke(Object, Object...).- Specified by:
- invokein class- ServiceLayer
- Parameters:
- domainMethod- the method to invoke
- args- the arguments to pass to the method
- Returns:
- the value returned from the method invocation
 
- 
isLiveDescription copied from class:ServiceLayerReturnstrueif the given domain object is still live (i.e. not deleted) in the backing store.- Specified by:
- isLivein class- ServiceLayer
- Parameters:
- domainObject- a domain entity
- Returns:
- trueif- domainObjectcould be retrieved at a later point in time
 
- 
loadDomainObjectDescription copied from class:ServiceLayerLoad an object from the backing store. This method may returnnullto indicate that the requested object is no longer available.- Specified by:
- loadDomainObjectin class- ServiceLayer
- Type Parameters:
- T- the type of object to load
- Parameters:
- clazz- the type of object to load
- domainId- an id previously returned from- ServiceLayer.getId(Object)
- Returns:
- the requested object or nullif it is irretrievable
 
- 
loadDomainObjectsDescription 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).- Specified by:
- loadDomainObjectsin class- ServiceLayer
- Parameters:
- classes- type type of each object to load
- domainIds- the ids previously returned from- ServiceLayer.getId(Object)
- Returns:
- the requested objects, elements of which may be nullif the requested objects were irretrievable
 
- 
requiresServiceLocatorDescription copied from class:ServiceLayerDetermines if the invocation of a domain method requires aServiceLocatoras the 0th parameter when passed intoServiceLayer.invoke(Method, Object...).- Specified by:
- requiresServiceLocatorin class- ServiceLayer
- Parameters:
- contextMethod- a method defined in a RequestContext
- domainMethod- a domain method
- Returns:
- trueif a ServiceLocator is required
 
- 
resolveClassDescription copied from class:ServiceLayerGiven a type token previously returned fromServiceLayer.resolveTypeToken(Class), return the Class literal associated with the token.- Specified by:
- resolveClassin class- ServiceLayer
- Parameters:
- typeToken- a string token
- Returns:
- the type represented by the token
 
- 
resolveClientTypepublic <T> Class<? extends T> resolveClientType(Class<?> domainClass, Class<T> clientType, boolean required) Description copied from class:ServiceLayerDetermine the type used by the client code to represent a given domain type. If multiple proxy types have been mapped to the same domain type, theclientTypeparameter is used to ensure assignability.- Specified by:
- resolveClientTypein class- ServiceLayer
- Parameters:
- domainClass- the server-side type to be transported to the client
- clientType- the type to which the returned type must be assignable
- required- if- trueand no mapping is available, throw an exception, otherwise the method will return- null
- Returns:
- a class that represents domainClasson the client which is assignable toclientType
 
- 
resolveDomainClassDescription copied from class:ServiceLayerDetermine the domain (server-side) type that the given client type is mapped to.- Specified by:
- resolveDomainClassin class- ServiceLayer
- Parameters:
- clazz- a client-side type
- Returns:
- the domain type that clientTyperepresents
 
- 
resolveDomainMethodDescription copied from class:ServiceLayerReturn the domain service method associated with a RequestContext method declaration. TherequestContextMethodwill have been previously resolved by.invalid reference#resolveRequestContextMethod(String, String)- Specified by:
- resolveDomainMethodin class- ServiceLayer
- Returns:
- the domain service method that should be invoked
 
- 
resolveLocatorDescription copied from class:ServiceLayerReturn the type ofLocatorthat should be used to access the given domain type.- Specified by:
- resolveLocatorin class- ServiceLayer
- Parameters:
- domainType- a domain (server-side) type
- Returns:
- the type of Locator to use, or nullif the type conforms to the RequestFactory entity protocol
 
- 
resolveRequestContextDescription copied from class:ServiceLayerFind a RequestContext that should be used to fulfill the requested operation.- Specified by:
- resolveRequestContextin class- ServiceLayer
- Parameters:
- operation- the operation
- Returns:
- the RequestContext or nullif no RequestContext exists that can fulfill the operation
 
- 
resolveRequestContextMethodDescription copied from class:ServiceLayerFind a RequestContext method declaration by name.- Specified by:
- resolveRequestContextMethodin class- ServiceLayer
- Parameters:
- operation- the operation's name
- Returns:
- the method declaration, or nullif the method does not exist
 
- 
resolveRequestFactoryDescription copied from class:ServiceLayerLoads and validates a RequestFactory interface.- Specified by:
- resolveRequestFactoryin class- ServiceLayer
- Parameters:
- binaryName- the RequestFactory's type token (usually the type's binary name)
- Returns:
- the RequestFactory type
 
- 
resolveServiceClassDescription copied from class:ServiceLayerGiven aRequestContextmethod, find the service class referenced in theServiceorServiceNameannotation.- Specified by:
- resolveServiceClassin class- ServiceLayer
- Parameters:
- requestContextClass- a RequestContext interface
- Returns:
- the type of service to use
 
- 
resolveServiceLocatorpublic Class<? extends ServiceLocator> resolveServiceLocator(Class<? extends RequestContext> requestContext) Description copied from class:ServiceLayerGiven a RequestContext method declaration, resolve theServiceLocatorthat should be used when invoking the domain method. This method will only be called ifServiceLayer.requiresServiceLocator(Method, Method)returnedtruefor the associated domain method.- Specified by:
- resolveServiceLocatorin class- ServiceLayer
- Parameters:
- requestContext- the RequestContext for which a ServiceLocator must be located
- Returns:
- the type of ServiceLocator to use
 
- 
resolveTypeTokenDescription copied from class:ServiceLayerReturn a string used to represent the given type in the wire protocol.- Specified by:
- resolveTypeTokenin class- ServiceLayer
- Parameters:
- proxyType- a client-side EntityProxy or ValueProxy type
- Returns:
- the type token used to represent the proxy type
 
- 
setPropertyDescription copied from class:ServiceLayerSets a property on a domain object.- Specified by:
- setPropertyin class- ServiceLayer
- Parameters:
- domainObject- the domain object to operate on
- property- the name of the property to set
- expectedType- the type of the property
- value- the new value
 
- 
validateDescription copied from class:ServiceLayerInvoke a JSR 303 validator on the given domain object. If no validator is available, this method is a no-op.- Specified by:
- validatein class- ServiceLayer
- Type Parameters:
- T- the type of data being validated
- Parameters:
- domainObject- the domain objcet to validate
- Returns:
- the violations associated with the domain object
 
- 
dieThrow a fatal error up into the top-level processing code. This method should be used to provide diagnostic information that will help the end-developer track down problems when that data would expose implementation details of the server to the client.- Parameters:
- e- a throwable with more data, may be- null
- message- a printf-style format string
- args- arguments for the message
- Throws:
- UnexpectedException- this method never returns normally
- See Also:
 
- 
getTopReturns the top-most service layer. General-purpose ServiceLayer decorators should use the instance provided bygetTop()when calling public methods on the ServiceLayer API to allow higher-level decorators to override behaviors built into lower-level decorators.- Returns:
- the ServiceLayer returned by
         ServiceLayer.create(ServiceLayerDecorator...)
 
- 
reportprotected final <T> T report(InvocationTargetException userGeneratedException) throws ReportableException Report an exception thrown by code that is under the control of the end-developer.- Parameters:
- userGeneratedException- an- InvocationTargetExceptionthrown by an invocation of user-provided code
- Throws:
- ReportableException- this method never returns normally
 
- 
reportReturn a message to the client. This method should not include any data that was not sent to the server by the client to avoid leaking data.- Parameters:
- msg- a printf-style format string
- args- arguments for the message
- Throws:
- ReportableException- this method never returns normally
- See Also:
 
- 
getNextRetrieves the next service layer. Used only by the server-package code and accessed by used code viasuper.doSomething().
 
-