com.google.web.bindery.requestfactory.shared

## Interface RequestFactory

- All Known Implementing Classes:
    com.google.web.bindery.requestfactory.shared.impl.AbstractRequestFactory, FakeRequestFactory, InProcessRequestFactory

      public interface RequestFactory

  Marker interface for the RequestFactory code generator.

  Limitations on the transferrability of types.
  RequestFactory currently supports the transfer of basic value types, entity types, and collections, with limitations. The basic value types supported are `String`, `Enum`, `Boolean`, `Character`, subtypes of `Number`, and `Date`. Any value type not included in this list may not be declared in the type signature of a service method, or `EntityProxy`. `Collection` types supported are `List` and `Set` with the restriction that a collection must be homogeneous and only hold one type of value.

  Polymorphism is not supported at this time. RequestFactory encoding and decoding requires exact knowledge of the concrete type. If a method declares a given type `T` as a parameter or return type, only `T`'s transferrable properties will be sent over the wire if it is a proxy, even if the underlying domain value contains extra fields, in effect, treating it as an instance of the supertype. Returning abstract supertypes of value types is not supported (e.g. Object, Enum, Number).

  See Also:
    `FakeRequestFactory`, `InProcessRequestTransport`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `JSON_CONTENT_TYPE_UTF8` The JSON content type String.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `<P extends EntityProxy> Request<P>` | `find(EntityProxyId<P> proxyId)` Return a request to find a fresh instance of the referenced proxy.
    `EventBus` | `getEventBus()` Returns the event bus this factory's events are posted on, which was set via `initialize(com.google.web.bindery.event.shared.EventBus)`.
    `java.lang.String` | `getHistoryToken(java.lang.Class<? extends EntityProxy> clazz)` Get a `History` compatible token that represents the given class.
    `java.lang.String` | `getHistoryToken(EntityProxyId<?> proxy)` Get a `History` compatible token that represents the given proxy class.
    `java.lang.Class<? extends EntityProxy>` | `getProxyClass(java.lang.String historyToken)` Return the class object which may be used to create new instances of the type of this token, via `RequestContext.create(java.lang.Class<T>)`.
    `<T extends EntityProxy> EntityProxyId<T>` | `getProxyId(java.lang.String historyToken)` Return the appropriate `EntityProxyId` using a string returned from `getHistoryToken(EntityProxyId)`.
    `RequestTransport` | `getRequestTransport()` Returns the RequestTransport set via `initialize(com.google.web.bindery.event.shared.EventBus)`.
    `ProxySerializer` | `getSerializer(ProxyStore store)` Returns a ProxySerializer that can encode and decode the various EntityProxy and ValueProxy types reachable from the RequestFactory.
    `void` | `initialize(EventBus eventBus)` Start this request factory with a `DefaultRequestTransport` .
    `void` | `initialize(EventBus eventBus, RequestTransport transport)` Start this request factory with a user-provided transport.

- - ### Field Detail

    - #### JSON_CONTENT_TYPE_UTF8

          static final java.lang.String JSON_CONTENT_TYPE_UTF8

      The JSON content type String.
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### find

          <P extends EntityProxy> Request<P> find(EntityProxyId<P> proxyId)

      Return a request to find a fresh instance of the referenced proxy. If it is necessary to load several proxy instances, use `RequestContext.find(EntityProxyId)`, which supports chained requests.
      Parameters:
        `proxyId` - an `EntityProxyId` instance of type P
      Returns:
        a `Request` object
      See Also:
        `RequestContext.find(EntityProxyId)`

    - #### getEventBus

          EventBus getEventBus()

      Returns the event bus this factory's events are posted on, which was set via `initialize(com.google.web.bindery.event.shared.EventBus)`.
      Returns:
        the `EventBus` associated with this instance

    - #### getHistoryToken

          java.lang.String getHistoryToken(java.lang.Class<? extends EntityProxy> clazz)

      Get a `History` compatible token that represents the given class. It can be processed by `getProxyClass(String)`
      Parameters:
        `clazz` - a Class object for an `EntityProxy` subclass
      Returns:
        a `History` compatible token

    - #### getHistoryToken

          java.lang.String getHistoryToken(EntityProxyId<?> proxy)

      Get a `History` compatible token that represents the given proxy class. It can be processed by `getProxyClass(String)`.

      The history token returned for an EntityProxyId associated with a newly-created (future) EntityProxy will differ from the token returned by this method after the EntityProxy has been persisted. Once an EntityProxy has been persisted, the return value for this method will always be stable, regardless of when the EntityProxyId was retrieved relative to the persist operation. In other words, the "future" history token returned for an as-yet-unpersisted EntityProxy is only valid for the duration of the RequestFactory's lifespan.

      Parameters:
        `proxy` - an `EntityProxyId` instance
      Returns:
        a `History` compatible token

    - #### getProxyClass

          java.lang.Class<? extends EntityProxy> getProxyClass(java.lang.String historyToken)

      Return the class object which may be used to create new instances of the type of this token, via `RequestContext.create(java.lang.Class<T>)`. The token may represent either a proxy instance (see `getHistoryToken(java.lang.Class<? extends com.google.web.bindery.requestfactory.shared.EntityProxy>)`) or a proxy class (see `getProxyClass(java.lang.String)`).
      Parameters:
        `historyToken` - a String token
      Returns:
        a Class object for an `EntityProxy` subclass

    - #### getProxyId

          <T extends EntityProxy> EntityProxyId<T> getProxyId(java.lang.String historyToken)

      Return the appropriate `EntityProxyId` using a string returned from `getHistoryToken(EntityProxyId)`.
      Parameters:
        `historyToken` - a String token
      Returns:
        an `EntityProxyId`

    - #### getRequestTransport

          RequestTransport getRequestTransport()

      Returns the RequestTransport set via `initialize(com.google.web.bindery.event.shared.EventBus)`.
      Returns:
        the `RequestTransport` associated with this instance

    - #### getSerializer

          ProxySerializer getSerializer(ProxyStore store)

      Returns a ProxySerializer that can encode and decode the various EntityProxy and ValueProxy types reachable from the RequestFactory.
      Parameters:
        `store` - a helper object for the ProxySerializer to provide low-level storage access
      Returns:
        a new ProxySerializer
      See Also:
        `DefaultProxyStore`

    - #### initialize

          void initialize(EventBus eventBus)

      Start this request factory with a `DefaultRequestTransport` .
      Parameters:
        `eventBus` - an `EventBus`

    - #### initialize

          void initialize(EventBus eventBus,
                          RequestTransport transport)

      Start this request factory with a user-provided transport.
      Parameters:
        `eventBus` - an `EventBus`
        `transport` - a `RequestTransport` instance