Package org.apache.cayenne.access
Class DataDomain
java.lang.Object
org.apache.cayenne.access.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.
- 
Field SummaryFields inherited from interface org.apache.cayenne.DataChannelFLUSH_CASCADE_SYNC, FLUSH_NOCASCADE_SYNC, GRAPH_CHANGED_SUBJECT, GRAPH_FLUSHED_SUBJECT, GRAPH_ROLLEDBACK_SUBJECT, ROLLBACK_CASCADE_SYNC
- 
Constructor SummaryConstructors Constructor Description DataDomain(String name)Creates a DataDomain and assigns it a name.DataDomain(String name, Map<String,String> properties)Deprecated.since 4.0 unused
- 
Method SummaryModifier and Type Method Description voidaddDataMap(DataMap dataMap)voidaddFilter(DataChannelFilter filter)Deprecated.since 4.1 useaddQueryFilter(DataChannelQueryFilter)andaddSyncFilter(DataChannelSyncFilter)insteadvoidaddListener(Object listener)Adds a listener, mapping its methods to events based on annotations.voidaddNode(DataNode node)Adds new DataNode.voidaddQueryFilter(DataChannelQueryFilter filter)Adds a new query filter.voidaddSyncFilter(DataChannelSyncFilter filter)Adds a new sync filter.protected voidcheckStopped()Checks that Domain is not stopped.DataMapgetDataMap(String mapName)Collection<DataMap>getDataMaps()Returns a collection of registered DataMaps.DataNodegetDataNode(String nodeName)Returns registered DataNode whose name matchesnameparameter.Collection<DataNode>getDataNodes()Returns an unmodifiable collection of DataNodes associated with this domain.DataRowStoreFactorygetDataRowStoreFactory()DataNodegetDefaultNode()An optional DataNode that is used for DataMaps that are not linked to a DataNode explicitly.EntityResolvergetEntityResolver()Returns an EntityResolver that stores mapping information for this domain.EntitySortergetEntitySorter()EventManagergetEventManager()Returns EventManager used by this DataDomain.List<DataChannelFilter>getFilters()Deprecated.since 4.1 usegetQueryFilters()andgetSyncFilters()intgetMaxIdQualifierSize()Returns a maximum number of object IDs to match in a single query for queries that select objects based on collection of ObjectIds.StringgetName()Returns "name" property value.Map<String,String>getProperties()QueryCachegetQueryCache()Returns sharedQueryCacheused by this DataDomain.List<DataChannelQueryFilter>getQueryFilters()Returns an unmodifiable list of query filters registered with this DataDomain.DataRowStoregetSharedSnapshotCache()Returns snapshots cache for this DataDomain, lazily initializing it on the first call if 'sharedCacheEnabled' flag is true.List<DataChannelSyncFilter>getSyncFilters()Returns an unmodifiable list of sync filters registered with this DataDomain.voidinitWithProperties(Map<String,String> properties)Deprecated.since 4.0 properties are processed by the DI provider.booleanisSharedCacheEnabled()Returnstrueif DataContexts produced by this DataDomain are using shared DataRowStore.booleanisValidatingObjectsOnCommit()Returns whether child DataContexts default behavior is to perform object validation before commit is executed.DataNodelookupDataNode(DataMap map)Returns a DataNode that should handle queries for all entities in a DataMap.QueryResponseonQuery(ObjectContext originatingContext, Query query)Runs query returning generic QueryResponse.GraphDiffonSync(ObjectContext originatingContext, GraphDiff changes, int syncType)Only handles commit-type synchronization, ignoring any other type.voidperformQueries(Collection<? extends Query> queries, OperationObserver callback)Routes queries to appropriate DataNodes for execution.voidremoveDataMap(String mapName)Removes named DataMap from this DataDomain and any underlying DataNodes that include it.voidremoveDataNode(String nodeName)Removes a DataNode from DataDomain.voidremoveFilter(DataChannelFilter filter)Deprecated.since 4.1 useremoveQueryFilter(DataChannelQueryFilter)andremoveSyncFilter(DataChannelSyncFilter)insteadvoidremoveQueryFilter(DataChannelQueryFilter filter)Removes a query filter from the filter chain.voidremoveSyncFilter(DataChannelSyncFilter filter)Removes a sync filter from the filter chain.protected voidresetProperties()voidsetDataRowStoreFactory(DataRowStoreFactory dataRowStoreFactory)voidsetDefaultNode(DataNode defaultNode)voidsetEntityResolver(EntityResolver entityResolver)Sets EntityResolver.voidsetEntitySorter(EntitySorter entitySorter)voidsetEventManager(EventManager eventManager)Sets EventManager used by this DataDomain.voidsetMaxIdQualifierSize(int maxIdQualifierSize)voidsetName(String name)Sets "name" property to a new value.voidsetQueryCache(QueryCache queryCache)voidsetSharedCacheEnabled(boolean sharedCacheEnabled)voidsetSharedSnapshotCache(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.voidsetValidatingObjectsOnCommit(boolean flag)Sets the property defining whether child DataContexts should perform object validation before commit is executed.voidshutdown()Shutdowns all owned data nodes and marks this domain as stopped.StringtoString()
- 
Field Details- 
SHARED_CACHE_ENABLED_PROPERTY- See Also:
- Constant Field Values
 
- 
SHARED_CACHE_ENABLED_DEFAULTpublic static final boolean SHARED_CACHE_ENABLED_DEFAULT- See Also:
- Constant Field Values
 
- 
VALIDATING_OBJECTS_ON_COMMIT_PROPERTY- See Also:
- Constant Field Values
 
- 
VALIDATING_OBJECTS_ON_COMMIT_DEFAULTpublic static final boolean VALIDATING_OBJECTS_ON_COMMIT_DEFAULT- See Also:
- Constant Field Values
 
- 
jdbcEventLogger- Since:
- 3.1
 
- 
transactionManager- Since:
- 4.0
 
- 
dataRowStoreFactory- Since:
- 4.0
 
- 
maxIdQualifierSizeprotected int maxIdQualifierSize- Since:
- 3.1
 
- 
filtersDeprecated.since 4.1 this field is unused- Since:
- 3.1
 
- 
queryFilters- Since:
- 4.1
 
- 
syncFilters- Since:
- 4.1
 
- 
nodes
- 
nodesByDataMapName
- 
defaultNode
- 
properties
- 
entityResolver
- 
name
- 
queryCache
- 
validatingObjectsOnCommitprotected boolean validatingObjectsOnCommit
- 
eventManager- Since:
- 1.2
 
- 
entitySorter- Since:
- 1.2
 
- 
stoppedprotected boolean stopped
 
- 
- 
Constructor Details- 
DataDomainCreates a DataDomain and assigns it a name.
- 
DataDomainDeprecated.since 4.0 unusedCreates 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 Details- 
checkStoppedChecks that Domain is not stopped. Throws DomainStoppedException otherwise.- Throws:
- DomainStoppedException
- Since:
- 3.0
 
- 
getEntitySorter- Since:
- 3.1
 
- 
setEntitySorter- Since:
- 3.1
 
- 
resetPropertiesprotected void resetProperties()- Since:
- 1.1
 
- 
initWithPropertiesDeprecated.since 4.0 properties are processed by the DI provider.Reinitializes domain state with a new set of properties.- Since:
- 1.1
 
- 
getEventManagerReturns EventManager used by this DataDomain.- Specified by:
- getEventManagerin interface- DataChannel
- Since:
- 1.2
 
- 
setEventManagerSets EventManager used by this DataDomain.- Since:
- 1.2
 
- 
getNameReturns "name" property value.
- 
setNameSets "name" property to a new value.
- 
isValidatingObjectsOnCommitpublic boolean isValidatingObjectsOnCommit()Returns whether child DataContexts default behavior is to perform object validation before commit is executed.- Since:
- 1.1
 
- 
setValidatingObjectsOnCommitpublic void setValidatingObjectsOnCommit(boolean flag)Sets the property defining whether child DataContexts should perform object validation before commit is executed.- Since:
- 1.1
 
- 
getProperties- Returns:
- a Map of properties for this DataDomain.
- Since:
- 1.1
 
- 
addDataMap
- 
getDataMap- Since:
- 3.1
 
- 
removeDataMapRemoves named DataMap from this DataDomain and any underlying DataNodes that include it.- Since:
- 3.1
 
- 
removeDataNodeRemoves 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.
- 
getDataMapsReturns a collection of registered DataMaps.
- 
getDataNodesReturns an unmodifiable collection of DataNodes associated with this domain.
- 
addNodeAdds new DataNode.
- 
getDataNodeReturns registered DataNode whose name matchesnameparameter.- Since:
- 3.1
 
- 
lookupDataNodeReturns a DataNode that should handle queries for all entities in a DataMap.- Since:
- 1.1
 
- 
setEntityResolverSets EntityResolver. If not set explicitly, DataDomain creates a default EntityResolver internally on demand.- Since:
- 1.1
 
- 
shutdownShutdowns all owned data nodes and marks this domain as stopped.
- 
performQueriesRoutes queries to appropriate DataNodes for execution.- Specified by:
- performQueriesin interface- QueryEngine
 
- 
onQueryRuns query returning generic QueryResponse.- Specified by:
- onQueryin 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
 
- 
getEntityResolverReturns an EntityResolver that stores mapping information for this domain.- Specified by:
- getEntityResolverin interface- DataChannel
- Specified by:
- getEntityResolverin interface- QueryEngine
 
- 
onSyncOnly handles commit-type synchronization, ignoring any other type.- Specified by:
- onSyncin 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
- 
getQueryCacheReturns sharedQueryCacheused by this DataDomain.- Since:
- 3.0
 
- 
setQueryCache
- 
getDataRowStoreFactory- Since:
- 4.0
 
- 
setDataRowStoreFactory- Since:
- 4.0
 
- 
getFiltersDeprecated.since 4.1 usegetQueryFilters()andgetSyncFilters()Since 4.1 returns empty list.- Since:
- 3.1
 
- 
getQueryFiltersReturns 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
 
- 
getSyncFiltersReturns 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
 
- 
addFilterDeprecated.since 4.1 useaddQueryFilter(DataChannelQueryFilter)andaddSyncFilter(DataChannelSyncFilter)insteadAdds a new filter, immediately calling its 'init' method. Since 4.0 this method also registers passed filter as an event listener, if any of its methods have event annotations.- Since:
- 3.1
 
- 
addQueryFilterAdds a new query filter. Also registers passed filter as an event listener, if any of its methods have event annotations.- Since:
- 4.1
 
- 
addSyncFilterAdds a new sync filter. Also registers passed filter as an event listener, if any of its methods have event annotations.- Since:
- 4.1
 
- 
removeFilterDeprecated.since 4.1 useremoveQueryFilter(DataChannelQueryFilter)andremoveSyncFilter(DataChannelSyncFilter)insteadRemoves a filter from the filter chain.- Since:
- 3.1
 
- 
removeQueryFilterRemoves a query filter from the filter chain.- Since:
- 4.1
 
- 
removeSyncFilterRemoves a sync filter from the filter chain.- Since:
- 4.1
 
- 
addListenerAdds a listener, mapping its methods to events based on annotations. This is a shortcut for 'getEntityResolver().getCallbackRegistry().addListener(listener)'.- Since:
- 4.0
 
- 
getDefaultNodeAn optional DataNode that is used for DataMaps that are not linked to a DataNode explicitly.- Since:
- 3.1
 
- 
setDefaultNode- Since:
- 3.1
 
- 
getMaxIdQualifierSizepublic 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 callingsetMaxIdQualifierSize(int)or changing the value for propertyConstants.SERVER_MAX_ID_QUALIFIER_SIZE_PROPERTY.- Since:
- 3.1
 
- 
setMaxIdQualifierSizepublic void setMaxIdQualifierSize(int maxIdQualifierSize)- Since:
- 3.1
 
 
-