com.google.web.bindery.requestfactory.server

## Class LocatorServiceLayer

- java.lang.Object
- - com.google.web.bindery.requestfactory.server.ServiceLayer
  - - com.google.web.bindery.requestfactory.server.ServiceLayerDecorator
    - - com.google.web.bindery.requestfactory.server.LocatorServiceLayer

    final class LocatorServiceLayer
    extends ServiceLayerDecorator

Adds support to the ServiceLayer chain for using `Locator` and `ServiceLocator` helper 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
`LocatorServiceLayer()`

### Method Summary

All Methods Instance Methods Concrete Methods
`<T> T` `createDomainObject(java.lang.Class<T> clazz)` Create an instance of the requested domain type.
`<T extends Locator<?,?>> T` `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.
`<T extends ServiceLocator> T` `createServiceLocator(java.lang.Class<T> serviceLocatorType)` Create an instance of the requested `ServiceLocator` type.
`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` `getVersion(java.lang.Object domainObject)` May return `null` to indicate that the domain object has not been persisted.
`boolean` `isLive(java.lang.Object domainObject)` Returns `true` if the given domain object is still live (i.e.
`<T> T` `loadDomainObject(java.lang.Class<T> clazz, java.lang.Object domainId)` Load an object from the backing store.
`boolean` `requiresServiceLocator(java.lang.reflect.Method contextMethod, java.lang.reflect.Method domainMethod)` Returns true if the context method returns a `Request` and the domain method is non-static.
`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 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.

### Methods inherited from class com.google.web.bindery.requestfactory.server.ServiceLayerDecorator

`die, getDomainClassLoader, getGetter, getNext, getProperty, getRequestReturnType, getSetter, getTop, invoke, loadDomainObjects, report, report, resolveClass, resolveClientType, resolveDomainClass, resolveDomainMethod, resolveRequestContext, resolveRequestContextMethod, resolveRequestFactory, resolveServiceClass, resolveTypeToken, setProperty, validate`

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

#### LocatorServiceLayer

    LocatorServiceLayer()

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

#### createLocator

    public <T extends Locator<?,?>> T createLocator(java.lang.Class<T> clazz)

Description copied from class: `ServiceLayer`
Create an instance of the requested `Locator` type.

Overrides:
  `createLocator` in class `ServiceLayerDecorator`
Type Parameters:
  `T` - the requested Locator type
Parameters:
  `clazz` - the requested Locator type
Returns:
  an instance of the requested Locator type

#### createServiceInstance

    public java.lang.Object createServiceInstance(java.lang.Class<? extends RequestContext> requestContext)

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 class `ServiceLayerDecorator`
Parameters:
  `requestContext` - the RequestContext type for which a service object must be instantiated.
Returns:
  an instance of the requested service object

#### createServiceLocator

    public <T extends ServiceLocator> T createServiceLocator(java.lang.Class<T> serviceLocatorType)

Description copied from class: `ServiceLayer`
Create an instance of the requested `ServiceLocator` type.

Overrides:
  `createServiceLocator` in class `ServiceLayerDecorator`
Type Parameters:
  `T` - the requested ServiceLocator type
Parameters:
  `serviceLocatorType` - the requested ServiceLocator type
Returns:
  an instance of the requested ServiceLocator type

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

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

#### isLive

    public boolean isLive(java.lang.Object domainObject)

Description copied from class: `ServiceLayer`
Returns `true` if the given domain object is still live (i.e. not deleted) in 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 domainId)

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
  `domainId` - an id previously returned from `ServiceLayer.getId(Object)`
Returns:
  the requested object or `null` if it is irretrievable

#### requiresServiceLocator

    public boolean requiresServiceLocator(java.lang.reflect.Method contextMethod,
                                          java.lang.reflect.Method domainMethod)

Returns true if the context method returns a `Request` and the domain method is non-static.

Overrides:
  `requiresServiceLocator` in class `ServiceLayerDecorator`
Parameters:
  `contextMethod` - a method defined in a RequestContext
  `domainMethod` - a domain method
Returns:
  `true` if a ServiceLocator is required

#### resolveLocator

    public java.lang.Class<? extends Locator<?,?>> resolveLocator(java.lang.Class<?> domainType)

Description copied from class: `ServiceLayer`
Return the type of `Locator` that should be used to access the given domain type.

Overrides:
  `resolveLocator` in class `ServiceLayerDecorator`
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

#### resolveServiceLocator

    public java.lang.Class<? extends ServiceLocator> resolveServiceLocator(java.lang.Class<? extends RequestContext> requestContext)

Description copied from class: `ServiceLayer`
Given a RequestContext method declaration, resolve the `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.

Overrides:
  `resolveServiceLocator` in class `ServiceLayerDecorator`
Parameters:
  `requestContext` - the RequestContext for which a ServiceLocator must be located
Returns:
  the type of ServiceLocator to use