com.google.web.bindery.requestfactory.server

## 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 and Description
    `ReflectiveServiceLayer()`

  - ### Method Summary

    Methods
    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.

    - ### 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`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ReflectiveServiceLayer

          ReflectiveServiceLayer()

  - ### Method Detail

    - #### createDomainObject

          public <T> T createDomainObject(java.lang.Class<T> clazz)

      Description copied from class: `ServiceLayer`
      Create an instance of the requested domain type.
      Overrides:
        `createDomainObject` in class `ServiceLayerDecorator`
      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: `ServiceLayer`
      Determine the method to invoke when retrieving the given property.
      Overrides:
        `getGetter` in class `ServiceLayerDecorator`
      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 `null` if the method could not be located

    - #### getId

          public java.lang.Object getId(java.lang.Object domainObject)

      Description copied from class: `ServiceLayer`
      Return the persistent id for a domain object. May return `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.

      Overrides:
        `getId` in class `ServiceLayerDecorator`
      Parameters:
        `domainObject` - a domain object
      Returns:
        the persistent id of the domain object or `null` if the object is not persistent

    - #### getIdType

          public java.lang.Class<?> getIdType(java.lang.Class<?> domainType)

      Description copied from class: `ServiceLayer`
      Returns the type of object the domain type's `findFoo()` or `Locator.getId()` expects to receive.
      Overrides:
        `getIdType` in class `ServiceLayerDecorator`
      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: `ServiceLayer`
      Retrieve the named property from the domain object.
      Overrides:
        `getProperty` in class `ServiceLayerDecorator`
      Parameters:
        `domainObject` - the domain object being examined
        `property` - 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: `ServiceLayer`
      Compute the return type for a method declared in a RequestContext by analyzing the generic method declaration.
      Overrides:
        `getRequestReturnType` in class `ServiceLayerDecorator`

    - #### getSetter

          public java.lang.reflect.Method getSetter(java.lang.Class<?> domainType,
                                           java.lang.String property)

      Description copied from class: `ServiceLayer`
      Determine the method to invoke when setting the given property.
      Overrides:
        `getSetter` in class `ServiceLayerDecorator`
      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 `null` if the method could not be located

    - #### getVersion

          public java.lang.Object getVersion(java.lang.Object domainObject)

      Description copied from class: `ServiceLayer`
      May return `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.
      Overrides:
        `getVersion` in class `ServiceLayerDecorator`
      Parameters:
        `domainObject` - a domain object
      Returns:
        the version of the domain object or `null` if the object is not persistent

    - #### invoke

          public java.lang.Object invoke(java.lang.reflect.Method domainMethod,
                                java.lang.Object... args)

      Description copied from class: `ServiceLayer`
      Invoke a domain service method. The underlying eventually calls `Method.invoke(Object, Object...)`.
      Overrides:
        `invoke` in class `ServiceLayerDecorator`
      Parameters:
        `domainMethod` - the method to invoke
        `args` - 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:
        `isLive` in class `ServiceLayerDecorator`
      Parameters:
        `domainObject` - a domain entity
      Returns:
        `true` if `domainObject` could 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: `ServiceLayer`
      Load an object from the backing store. This method may return `null` to indicate that the requested object is no longer available.
      Overrides:
        `loadDomainObject` in class `ServiceLayerDecorator`
      Type Parameters:
        `T` - the type of object to load
      Parameters:
        `clazz` - the type of object to load
        `id` - an id previously returned from `ServiceLayer.getId(Object)`
      Returns:
        the requested object or `null` if 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: `ServiceLayer`
      Load 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:
        `loadDomainObjects` in class `ServiceLayerDecorator`
      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 `null` if 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: `ServiceLayer`
      Sets a property on a domain object.
      Overrides:
        `setProperty` in class `ServiceLayerDecorator`
      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

    - #### validate

          public <T> java.util.Set<ConstraintViolation<T>> validate(T domainObject)

      Description copied from class: `ServiceLayer`
      Invoke a JSR 303 validator on the given domain object. If no validator is available, this method is a no-op.
      Overrides:
        `validate` in class `ServiceLayerDecorator`
      Type Parameters:
        `T` - the type of data being validated
      Parameters:
        `domainObject` - the domain objcet to validate
      Returns:
        the violations associated with the domain object