Class DataDomain

java.lang.Object
org.apache.cayenne.access.DataDomain
All Implemented Interfaces:
DataChannel

public class DataDomain extends Object implements DataChannel
DataDomain performs query routing functions in Cayenne. It creates single "ORM data source" abstraction over multiple physical DataNodes.
  • Field Details

  • Constructor Details

  • Method Details

    • checkStopped

      protected void checkStopped() throws DomainStoppedException
      Throws DomainStoppedException if the domain was previously shut down.
      Throws:
      DomainStoppedException
      Since:
      3.0
    • getEntitySorter

      public EntitySorter getEntitySorter()
      Since:
      3.1
    • getEventManager

      public EventManager getEventManager()
      Returns EventManager used by this DataDomain.
      Specified by:
      getEventManager in interface DataChannel
      Since:
      1.2
    • getName

      public String getName()
      Returns "name" property value.
    • isSharedCacheEnabled

      public boolean isSharedCacheEnabled()
      Returns true if DataContexts produced by this DataDomain are using shared DataRowStore. Returns false if each DataContext would work with its own DataRowStore. Note that this setting can be overwritten per DataContext.
    • isValidatingObjectsOnCommit

      public boolean isValidatingObjectsOnCommit()
      Returns whether child DataContexts default behavior is to perform object validation before commit is executed.
      Since:
      1.1
    • getSharedSnapshotCache

      public DataRowStore getSharedSnapshotCache()
      Returns the snapshots cache shared by the DataContexts of this DataDomain, or null if the domain runs with per-DataContext caches.
    • addDataMap

      public void addDataMap(DataMap dataMap)
    • getDataMap

      public DataMap getDataMap(String mapName)
      Since:
      3.1
    • removeDataMap

      public void removeDataMap(String mapName)
      Removes named DataMap from this DataDomain and any underlying DataNodes that include it.
      Since:
      3.1
    • removeDataNode

      public void removeDataNode(String nodeName)
      Removes a DataNode from DataDomain. Any maps previously associated with this node within domain will still be kept around, however they wan't be mapped to any node.
    • getDataMaps

      public Collection<DataMap> getDataMaps()
      Returns a collection of registered DataMaps.
    • getDataNodes

      public Collection<DataNode> getDataNodes()
      Returns an unmodifiable collection of DataNodes associated with this domain.
    • addNode

      public void addNode(DataNode node)
      Adds new DataNode.
    • getDataNode

      public DataNode getDataNode(String nodeName)
      Returns registered DataNode whose name matches name parameter.
      Since:
      3.1
    • lookupDataNode

      public DataNode lookupDataNode(DataMap map)
      Returns a DataNode that should handle queries for all entities in a DataMap.
      Since:
      1.1
    • shutdown

      @BeforeScopeEnd public void shutdown()
      Shutdowns all owned data nodes and marks this domain as stopped.
    • getParent

      public DataChannel getParent()
      Returns null, as DataDomain is the root of the DataChannel stack.
      Specified by:
      getParent in interface DataChannel
      Since:
      5.0
    • onQuery

      public QueryResponse onQuery(ObjectContext originatingContext, Query query)
      Runs query returning generic QueryResponse.
      Specified by:
      onQuery in interface DataChannel
      Parameters:
      originatingContext - an ObjectContext that originated the query, used to register result objects.
      Returns:
      a generic response object that encapsulates result of the execution.
      Since:
      1.2
    • getEntityResolver

      public EntityResolver getEntityResolver()
      Returns an EntityResolver that stores mapping information for this domain.
      Specified by:
      getEntityResolver in interface DataChannel
    • onSync

      public GraphDiff onSync(ObjectContext originatingContext, GraphDiff changes, int syncType)
      Only handles commit-type synchronization, ignoring any other type.
      Specified by:
      onSync in interface DataChannel
      Parameters:
      originatingContext - an ObjectContext that initiated the sync. Can be null.
      changes - diff from the context that initiated the sync.
      syncType - One of DataChannel.FLUSH_NOCASCADE_SYNC, DataChannel.FLUSH_CASCADE_SYNC, DataChannel.ROLLBACK_CASCADE_SYNC.
      Since:
      1.2
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getQueryCache

      public QueryCache getQueryCache()
      Returns shared QueryCache used by this DataDomain.
      Since:
      3.0
    • getQueryFilters

      public List<DataChannelQueryFilter> getQueryFilters()
      Returns an unmodifiable list of query filters registered with this DataDomain.

      Filter ordering note: filters are applied in reverse order of their occurrence in the filter list. I.e. the last filter in the list called first in the chain.

      Since:
      4.1
    • getSyncFilters

      public List<DataChannelSyncFilter> getSyncFilters()
      Returns an unmodifiable list of sync filters registered with this DataDomain.

      Filter ordering note: filters are applied in reverse order of their occurrence in the filter list. I.e. the last filter in the list called first in the chain.

      Since:
      4.1
    • addQueryFilter

      public void addQueryFilter(DataChannelQueryFilter filter)
      Adds a new query filter. Also registers passed filter as an event listener, if any of its methods have event annotations.
      Since:
      4.1
    • addSyncFilter

      public void addSyncFilter(DataChannelSyncFilter filter)
      Adds a new sync filter. Also registers passed filter as an event listener, if any of its methods have event annotations.
      Since:
      4.1
    • removeQueryFilter

      public void removeQueryFilter(DataChannelQueryFilter filter)
      Removes a query filter from the filter chain.
      Since:
      4.1
    • removeSyncFilter

      public void removeSyncFilter(DataChannelSyncFilter filter)
      Removes a sync filter from the filter chain.
      Since:
      4.1
    • addListener

      public void addListener(Object listener)
      Adds a listener, mapping its methods to events based on annotations. This is a shortcut for 'getEntityResolver().getCallbackRegistry().addListener(listener)'.
      Since:
      4.0
    • getDefaultNode

      public DataNode getDefaultNode()
      An optional DataNode that is used for DataMaps that are not linked to a DataNode explicitly.
      Since:
      3.1
    • setDefaultNode

      public void setDefaultNode(DataNode defaultNode)
      Since:
      3.1
    • getMaxIdQualifierSize

      public int getMaxIdQualifierSize()
      Returns a maximum number of object IDs to match in a single query for queries that select objects based on collection of ObjectIds. This affects queries generated by Cayenne when processing paginated queries and DISJOINT_BY_ID prefetches and is intended to address database limitations on the size of SQL statements as well as to cap memory use in Cayenne when generating such queries. The default is 10000. It can be changed by setting the Constants.MAX_ID_QUALIFIER_SIZE_PROPERTY property.
      Since:
      3.1