class ServiceLayerCache extends ServiceLayerDecorator
ServiceLayer
. The caching is
separate from ReflectiveServiceLayer
so that the cache can be applied
to any decorators injected by the user.next
top
Constructor and Description |
---|
ServiceLayerCache() |
Modifier and Type | Method and Description |
---|---|
<T extends Locator<?,?>> |
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.
|
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.Class<?> |
getIdType(java.lang.Class<?> domainType)
Returns the type of object the domain type's
findFoo() or
Locator.getId() expects to receive. |
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.
|
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. |
<T> java.lang.Class<? extends T> |
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> domainClass)
Return a string used to represent the given type in the wire protocol.
|
createDomainObject, createServiceLocator, die, getId, getNext, getProperty, getTop, getVersion, invoke, isLive, loadDomainObject, loadDomainObjects, report, report, setProperty, validate
create
public <T extends Locator<?,?>> T createLocator(java.lang.Class<T> clazz)
ServiceLayer
Locator
type.createLocator
in class ServiceLayerDecorator
T
- the requested Locator typeclazz
- the requested Locator typepublic java.lang.Object createServiceInstance(java.lang.Class<? extends RequestContext> requestContext)
ServiceLayer
createServiceInstance
in class ServiceLayerDecorator
requestContext
- the RequestContext type for which a service object
must be instantiated.public java.lang.ClassLoader getDomainClassLoader()
ServiceLayer
The default implementation returns
Thread.currentThread().getContextClassLoader()
.
getDomainClassLoader
in class ServiceLayerDecorator
public java.lang.reflect.Method getGetter(java.lang.Class<?> domainType, java.lang.String property)
ServiceLayer
getGetter
in class ServiceLayerDecorator
domainType
- a domain entity typeproperty
- the name of the property to be retrievednull
if the method could not be locatedpublic java.lang.Class<?> getIdType(java.lang.Class<?> domainType)
ServiceLayer
findFoo()
or
Locator.getId()
expects to receive.getIdType
in class ServiceLayerDecorator
domainType
- a domain entity typepublic java.lang.reflect.Type getRequestReturnType(java.lang.reflect.Method contextMethod)
ServiceLayer
getRequestReturnType
in class ServiceLayerDecorator
public java.lang.reflect.Method getSetter(java.lang.Class<?> domainType, java.lang.String property)
ServiceLayer
getSetter
in class ServiceLayerDecorator
domainType
- a domain entity typeproperty
- the name of the property to be setnull
if the method could not be locatedpublic 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 ServiceLayerDecorator
contextMethod
- a method defined in a RequestContextdomainMethod
- a domain methodtrue
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 ServiceLayerDecorator
typeToken
- a string tokenpublic <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 ServiceLayerDecorator
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 ServiceLayerDecorator
clazz
- a client-side typeclientType
representspublic java.lang.reflect.Method resolveDomainMethod(java.lang.String operation)
ServiceLayer
requestContextMethod
will have been previously
resolved by #resolveRequestContextMethod(String, String)
.resolveDomainMethod
in class ServiceLayerDecorator
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 ServiceLayerDecorator
domainType
- a domain (server-side) typenull
if the type conforms to
the RequestFactory entity protocolpublic java.lang.Class<? extends RequestContext> resolveRequestContext(java.lang.String operation)
ServiceLayer
resolveRequestContext
in class ServiceLayerDecorator
operation
- the operationnull
if no RequestContext exists that
can fulfill the operationpublic java.lang.reflect.Method resolveRequestContextMethod(java.lang.String operation)
ServiceLayer
resolveRequestContextMethod
in class ServiceLayerDecorator
operation
- the operation's namenull
if the method does not
existpublic java.lang.Class<? extends RequestFactory> resolveRequestFactory(java.lang.String binaryName)
ServiceLayer
resolveRequestFactory
in class ServiceLayerDecorator
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 ServiceLayerDecorator
requestContextClass
- a RequestContext interfacepublic 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 ServiceLayerDecorator
requestContext
- the RequestContext for which a ServiceLocator must be
locatedpublic java.lang.String resolveTypeToken(java.lang.Class<? extends BaseProxy> domainClass)
ServiceLayer
resolveTypeToken
in class ServiceLayerDecorator
domainClass
- a client-side EntityProxy or ValueProxy type