final class ReflectiveServiceLayer extends ServiceLayerDecorator
next
top
Constructor and Description |
---|
ReflectiveServiceLayer() |
Modifier and Type | Method and Description |
---|---|
<T> T |
createDomainObject(java.lang.Class<T> clazz)
Create an instance of the requested domain type.
|
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.Object |
getId(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's
findFoo() or
Locator.getId() expects to receive. |
java.lang.Object |
getProperty(java.lang.Object domainObject,
java.lang.String property)
Retrieve the named property from the domain object.
|
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.
|
java.lang.Object |
getVersion(java.lang.Object domainObject)
May return
null to indicate that the domain object has not been
persisted. |
java.lang.Object |
invoke(java.lang.reflect.Method domainMethod,
java.lang.Object... args)
Invoke a domain service method.
|
boolean |
isLive(java.lang.Object domainObject)
This implementation attempts to re-load the object from the backing store.
|
<T> T |
loadDomainObject(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.
|
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.
|
<T> java.util.Set<ConstraintViolation<T>> |
validate(T domainObject)
Invoke a JSR 303 validator on the given domain object.
|
createLocator, createServiceInstance, createServiceLocator, die, getDomainClassLoader, getNext, getTop, report, report, requiresServiceLocator, resolveClass, resolveClientType, resolveDomainClass, resolveDomainMethod, resolveLocator, resolveRequestContext, resolveRequestContextMethod, resolveRequestFactory, resolveServiceClass, resolveServiceLocator, resolveTypeToken
create
public <T> T createDomainObject(java.lang.Class<T> clazz)
ServiceLayer
createDomainObject
in class ServiceLayerDecorator
T
- the requested domain typeclazz
- the requested domain typepublic 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.Object getId(java.lang.Object domainObject)
ServiceLayer
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
ServiceLayer.loadDomainObject(Class, Object)
in the future.
getId
in class ServiceLayerDecorator
domainObject
- a domain objectnull
if the
object is not persistentpublic 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.Object getProperty(java.lang.Object domainObject, java.lang.String property)
ServiceLayer
getProperty
in class ServiceLayerDecorator
domainObject
- the domain object being examinedproperty
- the property namepublic 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 java.lang.Object getVersion(java.lang.Object domainObject)
ServiceLayer
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.getVersion
in class ServiceLayerDecorator
domainObject
- a domain objectnull
if the object is
not persistentpublic java.lang.Object invoke(java.lang.reflect.Method domainMethod, java.lang.Object... args)
ServiceLayer
Method.invoke(Object, Object...)
.invoke
in class ServiceLayerDecorator
domainMethod
- the method to invokeargs
- the arguments to pass to the methodpublic boolean isLive(java.lang.Object domainObject)
isLive
in class ServiceLayerDecorator
domainObject
- a domain entitytrue
if domainObject
could be retrieved at a later
point in timepublic <T> T loadDomainObject(java.lang.Class<T> clazz, java.lang.Object id)
ServiceLayer
null
to indicate that the requested object is no longer available.loadDomainObject
in class ServiceLayerDecorator
T
- the type of object to loadclazz
- the type of object to loadid
- an id previously returned from ServiceLayer.getId(Object)
null
if it is irretrievablepublic java.util.List<java.lang.Object> loadDomainObjects(java.util.List<java.lang.Class<?>> classes, java.util.List<java.lang.Object> domainIds)
ServiceLayer
The default implementation of this method will delegate to
ServiceLayer.loadDomainObject(Class, Object)
.
loadDomainObjects
in class ServiceLayerDecorator
classes
- type type of each object to loaddomainIds
- the ids previously returned from ServiceLayer.getId(Object)
null
if the
requested objects were irretrievablepublic void setProperty(java.lang.Object domainObject, java.lang.String property, java.lang.Class<?> expectedType, java.lang.Object value)
ServiceLayer
setProperty
in class ServiceLayerDecorator
domainObject
- the domain object to operate onproperty
- the name of the property to setexpectedType
- the type of the propertyvalue
- the new valuepublic <T> java.util.Set<ConstraintViolation<T>> validate(T domainObject)
ServiceLayer
validate
in class ServiceLayerDecorator
T
- the type of data being validateddomainObject
- the domain objcet to validate