Class ServiceLayerCache
java.lang.Object
com.google.web.bindery.requestfactory.server.ServiceLayer
com.google.web.bindery.requestfactory.server.ServiceLayerDecorator
com.google.web.bindery.requestfactory.server.ServiceLayerCache
A cache for idempotent methods in
ServiceLayer
. The caching is
separate from ReflectiveServiceLayer
so that the cache can be applied
to any decorators injected by the user.-
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
-
Method Summary
Modifier and TypeMethodDescription<T extends Locator<?,
?>>
TcreateLocator
(Class<T> clazz) Create an instance of the requestedLocator
type.createServiceInstance
(Class<? extends RequestContext> requestContext) Create an instance of a service object that can be used as the target for the given method invocation.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.Class<?>
Returns the type of object the domain type'sfindFoo()
orLocator.getId()
expects to receive.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.boolean
requiresServiceLocator
(Method contextMethod, Method domainMethod) Determines if the invocation of a domain method requires aServiceLocator
as 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 ofLocator
that 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 aRequestContext
method, find the service class referenced in theService
orServiceName
annotation.Class<? extends ServiceLocator>
resolveServiceLocator
(Class<? extends RequestContext> requestContext) Given a RequestContext method declaration, resolve theServiceLocator
that should be used when invoking the domain method.resolveTypeToken
(Class<? extends BaseProxy> domainClass) Return a string used to represent the given type in the wire protocol.Methods inherited from class com.google.web.bindery.requestfactory.server.ServiceLayerDecorator
createDomainObject, createServiceLocator, die, getId, getNext, getProperty, getTop, getVersion, invoke, isLive, loadDomainObject, loadDomainObjects, report, report, setProperty, validate
Methods inherited from class com.google.web.bindery.requestfactory.server.ServiceLayer
create
-
Constructor Details
-
ServiceLayerCache
ServiceLayerCache()
-
-
Method Details
-
createLocator
Description copied from class:ServiceLayer
Create an instance of the requestedLocator
type.- Overrides:
createLocator
in classServiceLayerDecorator
- Type Parameters:
T
- the requested Locator type- Parameters:
clazz
- the requested Locator type- Returns:
- an instance of the requested Locator type
-
createServiceInstance
Description copied from class:ServiceLayer
Create an instance of a service object that can be used as the target for the given method invocation.- Overrides:
createServiceInstance
in classServiceLayerDecorator
- Parameters:
requestContext
- the RequestContext type for which a service object must be instantiated.- Returns:
- an instance of the requested service object
-
getDomainClassLoader
Description copied from class:ServiceLayer
Returns the ClassLoader that should be used when attempting to access domain classes or resources.The default implementation returns
Thread.currentThread().getContextClassLoader()
.- Overrides:
getDomainClassLoader
in classServiceLayerDecorator
-
getGetter
Description copied from class:ServiceLayer
Determine the method to invoke when retrieving the given property.- Overrides:
getGetter
in 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
null
if the method could not be located
-
getIdType
Description copied from class:ServiceLayer
Returns the type of object the domain type'sfindFoo()
orLocator.getId()
expects to receive.- Overrides:
getIdType
in classServiceLayerDecorator
- Parameters:
domainType
- a domain entity type- Returns:
- the type of the persistent id value used to represent the domain type
-
getRequestReturnType
Description copied from class:ServiceLayer
Compute the return type for a method declared in a RequestContext by analyzing the generic method declaration.- Overrides:
getRequestReturnType
in classServiceLayerDecorator
-
getSetter
Description copied from class:ServiceLayer
Determine the method to invoke when setting the given property.- Overrides:
getSetter
in 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
null
if the method could not be located
-
requiresServiceLocator
Description copied from class:ServiceLayer
Determines if the invocation of a domain method requires aServiceLocator
as the 0th parameter when passed intoServiceLayer.invoke(Method, Object...)
.- Overrides:
requiresServiceLocator
in classServiceLayerDecorator
- Parameters:
contextMethod
- a method defined in a RequestContextdomainMethod
- a domain method- Returns:
true
if a ServiceLocator is required
-
resolveClass
Description copied from class:ServiceLayer
Given a type token previously returned fromServiceLayer.resolveTypeToken(Class)
, return the Class literal associated with the token.- Overrides:
resolveClass
in classServiceLayerDecorator
- Parameters:
typeToken
- a string token- Returns:
- the type represented by the token
-
resolveClientType
public <T> Class<? extends T> resolveClientType(Class<?> domainClass, Class<T> clientType, boolean required) Description copied from class:ServiceLayer
Determine 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, theclientType
parameter is used to ensure assignability.- Overrides:
resolveClientType
in classServiceLayerDecorator
- Parameters:
domainClass
- the server-side type to be transported to the clientclientType
- the type to which the returned type must be assignablerequired
- iftrue
and no mapping is available, throw an exception, otherwise the method will returnnull
- Returns:
- a class that represents
domainClass
on the client which is assignable toclientType
-
resolveDomainClass
Description copied from class:ServiceLayer
Determine the domain (server-side) type that the given client type is mapped to.- Overrides:
resolveDomainClass
in classServiceLayerDecorator
- Parameters:
clazz
- a client-side type- Returns:
- the domain type that
clientType
represents
-
resolveDomainMethod
Description copied from class:ServiceLayer
Return the domain service method associated with a RequestContext method declaration. TherequestContextMethod
will have been previously resolved by#resolveRequestContextMethod(String, String)
.- Overrides:
resolveDomainMethod
in classServiceLayerDecorator
- Returns:
- the domain service method that should be invoked
-
resolveLocator
Description copied from class:ServiceLayer
Return the type ofLocator
that should be used to access the given domain type.- Overrides:
resolveLocator
in classServiceLayerDecorator
- Parameters:
domainType
- a domain (server-side) type- Returns:
- the type of Locator to use, or
null
if the type conforms to the RequestFactory entity protocol
-
resolveRequestContext
Description copied from class:ServiceLayer
Find a RequestContext that should be used to fulfill the requested operation.- Overrides:
resolveRequestContext
in classServiceLayerDecorator
- Parameters:
operation
- the operation- Returns:
- the RequestContext or
null
if no RequestContext exists that can fulfill the operation
-
resolveRequestContextMethod
Description copied from class:ServiceLayer
Find a RequestContext method declaration by name.- Overrides:
resolveRequestContextMethod
in classServiceLayerDecorator
- Parameters:
operation
- the operation's name- Returns:
- the method declaration, or
null
if the method does not exist
-
resolveRequestFactory
Description copied from class:ServiceLayer
Loads and validates a RequestFactory interface.- Overrides:
resolveRequestFactory
in classServiceLayerDecorator
- Parameters:
binaryName
- the RequestFactory's type token (usually the type's binary name)- Returns:
- the RequestFactory type
-
resolveServiceClass
Description copied from class:ServiceLayer
Given aRequestContext
method, find the service class referenced in theService
orServiceName
annotation.- Overrides:
resolveServiceClass
in classServiceLayerDecorator
- Parameters:
requestContextClass
- a RequestContext interface- Returns:
- the type of service to use
-
resolveServiceLocator
public Class<? extends ServiceLocator> resolveServiceLocator(Class<? extends RequestContext> requestContext) Description copied from class:ServiceLayer
Given a RequestContext method declaration, resolve theServiceLocator
that should be used when invoking the domain method. This method will only be called ifServiceLayer.requiresServiceLocator(Method, Method)
returnedtrue
for the associated domain method.- Overrides:
resolveServiceLocator
in classServiceLayerDecorator
- Parameters:
requestContext
- the RequestContext for which a ServiceLocator must be located- Returns:
- the type of ServiceLocator to use
-
resolveTypeToken
Description copied from class:ServiceLayer
Return a string used to represent the given type in the wire protocol.- Overrides:
resolveTypeToken
in classServiceLayerDecorator
- Parameters:
domainClass
- a client-side EntityProxy or ValueProxy type- Returns:
- the type token used to represent the proxy type
-