QueryRouter (cayenne-doc: Cayenne Documentation 5.0-M2 API)
Description: declaration: package: org.apache.cayenne.query, interface: QueryRouter

# Interface QueryRouter

public interface QueryRouter
An interface used by Queries to route themselves to an appropriate DataNode. As of 1.2 QueryRouter only supports routing by DataMap.

Since:
  1.2

- ## Method Summary

  Modifier and Type
  Method
  Description
  `default DataNode`
  `engineForDataMap(DataMap map)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  renamed to `nodeForDataMap(DataMap)`.
  `default DataNode`
  `engineForName(String name)`
  Deprecated, for removal: This API element is subject to removal in a future version.
  renamed to `nodeForName(String)`.
  `DataNode`
  `nodeForDataMap(DataMap map)`
  Returns a DataNode that is configured to handle a given DataMap.
  `DataNode`
  `nodeForName(String name)`
  Returns a DataNode for a given name.
  `void`
  `route(DataNode node, Query query, Query substitutedQuery)`
  A callback method that allows a query to set its preferred node during the routing phase.

- ## Method Details

  - ### route

    void route(DataNode node, Query query, Query substitutedQuery)
    A callback method that allows a query to set its preferred node during the routing phase. It allows query to further customize its routing, e.g. it is possible to implement query chains that pass multiple queries for execution.
    Parameters:
      `node` - node to use for query execution
      `query` - A query to execute.
      `substitutedQuery` - a query that was substituted for "query". Results must be mapped back to substituted query.

  - ### nodeForName

    DataNode nodeForName(String name)
    Returns a DataNode for a given name. If the name is null, a default DataNode is returned. If there's no default node, an exception is thrown.
    Since:
      5.0

  - ### nodeForDataMap

    DataNode nodeForDataMap(DataMap map)
    Returns a DataNode that is configured to handle a given DataMap.
    Since:
      5.0

  - ### engineForName

    @Deprecated(since="5.0", forRemoval=true) default DataNode engineForName(String name)
    Deprecated, for removal: This API element is subject to removal in a future version.
    renamed to `nodeForName(String)`.
    Since:
      4.0

  - ### engineForDataMap

    @Deprecated(since="5.0", forRemoval=true) default DataNode engineForDataMap(DataMap map)
    Deprecated, for removal: This API element is subject to removal in a future version.
    renamed to `nodeForDataMap(DataMap)`.