Class DataDomain

  • All Implemented Interfaces:
    QueryEngine, DataChannel

    public class DataDomain
    extends Object
    implements QueryEngine, DataChannel
    DataDomain performs query routing functions in Cayenne. DataDomain creates single data source abstraction hiding multiple physical data sources from the user. When a child DataContext sends a query to the DataDomain, it is transparently routed to an appropriate DataNode.
    • Constructor Detail

      • DataDomain

        public DataDomain​(String name)
        Creates a DataDomain and assigns it a name.
      • DataDomain

        @Deprecated
        public DataDomain​(String name,
                          Map<String,​String> properties)
        Deprecated.
        since 4.0 unused
        Creates new DataDomain.
        Parameters:
        name - DataDomain name. Domain can be located using its name in the Configuration object.
        properties - A Map containing domain configuration properties.
    • Method Detail

      • getEntitySorter

        public EntitySorter getEntitySorter()
        Since:
        3.1
      • setEntitySorter

        public void setEntitySorter​(EntitySorter entitySorter)
        Since:
        3.1
      • resetProperties

        protected void resetProperties()
        Since:
        1.1
      • initWithProperties

        @Deprecated
        public void initWithProperties​(Map<String,​String> properties)
        Deprecated.
        since 4.0 properties are processed by the DI provider.
        Reinitializes domain state with a new set of properties.
        Since:
        1.1
      • setEventManager

        public void setEventManager​(EventManager eventManager)
        Sets EventManager used by this DataDomain.
        Since:
        1.2
      • getName

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

        public void setName​(String name)
        Sets "name" property to a new 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.
      • setSharedCacheEnabled

        public void setSharedCacheEnabled​(boolean sharedCacheEnabled)
      • isValidatingObjectsOnCommit

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

        public void setValidatingObjectsOnCommit​(boolean flag)
        Sets the property defining whether child DataContexts should perform object validation before commit is executed.
        Since:
        1.1
      • getProperties

        public Map<String,​String> getProperties()
        Returns:
        a Map of properties for this DataDomain.
        Since:
        1.1
      • getSharedSnapshotCache

        public DataRowStore getSharedSnapshotCache()
        Returns snapshots cache for this DataDomain, lazily initializing it on the first call if 'sharedCacheEnabled' flag is true.
      • setSharedSnapshotCache

        public void setSharedSnapshotCache​(DataRowStore snapshotCache)
        Shuts down the previous cache instance, sets cache to the new DataSowStore instance and updates two properties of the new DataSowStore: name and eventManager.
      • 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
      • setEntityResolver

        public void setEntityResolver​(EntityResolver entityResolver)
        Sets EntityResolver. If not set explicitly, DataDomain creates a default EntityResolver internally on demand.
        Since:
        1.1
      • shutdown

        @BeforeScopeEnd
        public void shutdown()
        Shutdowns all owned data nodes and marks this domain as stopped.
      • 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
      • getQueryCache

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

        public void setQueryCache​(QueryCache queryCache)
      • setDataRowStoreFactory

        public void setDataRowStoreFactory​(DataRowStoreFactory dataRowStoreFactory)
        Since:
        4.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 either by calling setMaxIdQualifierSize(int) or changing the value for property Constants.SERVER_MAX_ID_QUALIFIER_SIZE_PROPERTY.
        Since:
        3.1
      • setMaxIdQualifierSize

        public void setMaxIdQualifierSize​(int maxIdQualifierSize)
        Since:
        3.1