Package org.apache.cayenne.access
Class DataDomain
java.lang.Object
org.apache.cayenne.access.DataDomain
- All Implemented Interfaces:
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 Summary
Modifier and TypeFieldDescriptionprotected DataRowStoreFactory
protected DataNode
protected EntityResolver
protected EntitySorter
protected EventManager
protected List
<DataChannelFilter> Deprecated.since 4.1 this field is unusedprotected DataDomainFlushActionFactory
protected JdbcEventLogger
protected int
protected String
protected AdhocObjectFactory
protected QueryCache
protected List
<DataChannelQueryFilter> static final boolean
static final String
protected boolean
protected DataRowStore
protected boolean
protected List
<DataChannelSyncFilter> protected TransactionManager
static final boolean
static final String
protected boolean
Fields inherited from interface org.apache.cayenne.DataChannel
FLUSH_CASCADE_SYNC, FLUSH_NOCASCADE_SYNC, GRAPH_CHANGED_SUBJECT, GRAPH_FLUSHED_SUBJECT, GRAPH_ROLLEDBACK_SUBJECT, ROLLBACK_CASCADE_SYNC
-
Constructor Summary
ConstructorDescriptionDataDomain
(String name) Creates a DataDomain and assigns it a name.DataDomain
(String name, Map<String, String> properties) Deprecated.since 4.0 unused -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDataMap
(DataMap dataMap) void
addFilter
(DataChannelFilter filter) Deprecated.since 4.1 useaddQueryFilter(DataChannelQueryFilter)
andaddSyncFilter(DataChannelSyncFilter)
insteadvoid
addListener
(Object listener) Adds a listener, mapping its methods to events based on annotations.void
Adds new DataNode.void
addQueryFilter
(DataChannelQueryFilter filter) Adds a new query filter.void
addSyncFilter
(DataChannelSyncFilter filter) Adds a new sync filter.protected void
Checks that Domain is not stopped.getDataMap
(String mapName) Returns a collection of registered DataMaps.getDataNode
(String nodeName) Returns registered DataNode whose name matchesname
parameter.Returns an unmodifiable collection of DataNodes associated with this domain.An optional DataNode that is used for DataMaps that are not linked to a DataNode explicitly.Returns an EntityResolver that stores mapping information for this domain.Returns EventManager used by this DataDomain.Deprecated.since 4.1 usegetQueryFilters()
andgetSyncFilters()
int
Returns a maximum number of object IDs to match in a single query for queries that select objects based on collection of ObjectIds.getName()
Returns "name" property value.Returns sharedQueryCache
used by this DataDomain.Returns an unmodifiable list of query filters registered with this DataDomain.Returns snapshots cache for this DataDomain, lazily initializing it on the first call if 'sharedCacheEnabled' flag is true.Returns an unmodifiable list of sync filters registered with this DataDomain.void
initWithProperties
(Map<String, String> properties) Deprecated.since 4.0 properties are processed by the DI provider.boolean
Returnstrue
if DataContexts produced by this DataDomain are using shared DataRowStore.boolean
Returns whether child DataContexts default behavior is to perform object validation before commit is executed.lookupDataNode
(DataMap map) Returns a DataNode that should handle queries for all entities in a DataMap.onQuery
(ObjectContext originatingContext, Query query) Runs query returning generic QueryResponse.onSync
(ObjectContext originatingContext, GraphDiff changes, int syncType) Only handles commit-type synchronization, ignoring any other type.void
performQueries
(Collection<? extends Query> queries, OperationObserver callback) Routes queries to appropriate DataNodes for execution.void
removeDataMap
(String mapName) Removes named DataMap from this DataDomain and any underlying DataNodes that include it.void
removeDataNode
(String nodeName) Removes a DataNode from DataDomain.void
removeFilter
(DataChannelFilter filter) Deprecated.since 4.1 useremoveQueryFilter(DataChannelQueryFilter)
andremoveSyncFilter(DataChannelSyncFilter)
insteadvoid
Removes a query filter from the filter chain.void
Removes a sync filter from the filter chain.protected void
void
setDataRowStoreFactory
(DataRowStoreFactory dataRowStoreFactory) void
setDefaultNode
(DataNode defaultNode) void
setEntityResolver
(EntityResolver entityResolver) Sets EntityResolver.void
setEntitySorter
(EntitySorter entitySorter) void
setEventManager
(EventManager eventManager) Sets EventManager used by this DataDomain.void
setMaxIdQualifierSize
(int maxIdQualifierSize) void
Sets "name" property to a new value.void
setQueryCache
(QueryCache queryCache) void
setSharedCacheEnabled
(boolean sharedCacheEnabled) 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.void
setValidatingObjectsOnCommit
(boolean flag) Sets the property defining whether child DataContexts should perform object validation before commit is executed.void
shutdown()
Shutdowns all owned data nodes and marks this domain as stopped.toString()
-
Field Details
-
SHARED_CACHE_ENABLED_PROPERTY
- See Also:
-
SHARED_CACHE_ENABLED_DEFAULT
public static final boolean SHARED_CACHE_ENABLED_DEFAULT- See Also:
-
VALIDATING_OBJECTS_ON_COMMIT_PROPERTY
- See Also:
-
VALIDATING_OBJECTS_ON_COMMIT_DEFAULT
public static final boolean VALIDATING_OBJECTS_ON_COMMIT_DEFAULT- See Also:
-
jdbcEventLogger
- Since:
- 3.1
-
transactionManager
- Since:
- 4.0
-
dataRowStoreFactory
- Since:
- 4.0
-
maxIdQualifierSize
protected int maxIdQualifierSize- Since:
- 3.1
-
filters
Deprecated.since 4.1 this field is unused- Since:
- 3.1
-
queryFilters
- Since:
- 4.1
-
syncFilters
- Since:
- 4.1
-
flushActionFactory
- Since:
- 4.2
-
objectFactory
- Since:
- 4.2
-
nodes
-
nodesByDataMapName
-
defaultNode
-
properties
-
entityResolver
-
name
-
queryCache
-
validatingObjectsOnCommit
protected boolean validatingObjectsOnCommit -
eventManager
- Since:
- 1.2
-
entitySorter
- Since:
- 1.2
-
stopped
protected boolean stopped
-
-
Constructor Details
-
DataDomain
Creates a DataDomain and assigns it a name. -
DataDomain
Deprecated.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
-
checkStopped
Checks that Domain is not stopped. Throws DomainStoppedException otherwise.- Throws:
DomainStoppedException
- Since:
- 3.0
-
getEntitySorter
- Since:
- 3.1
-
setEntitySorter
- Since:
- 3.1
-
resetProperties
protected void resetProperties()- Since:
- 1.1
-
initWithProperties
Deprecated.since 4.0 properties are processed by the DI provider.Reinitializes domain state with a new set of properties.- Since:
- 1.1
-
getEventManager
Returns EventManager used by this DataDomain.- Specified by:
getEventManager
in interfaceDataChannel
- Since:
- 1.2
-
setEventManager
Sets EventManager used by this DataDomain.- Since:
- 1.2
-
getName
Returns "name" property value. -
setName
Sets "name" property to a new value. -
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
- Returns:
- a Map of properties for this DataDomain.
- Since:
- 1.1
-
addDataMap
-
getDataMap
- Since:
- 3.1
-
removeDataMap
Removes named DataMap from this DataDomain and any underlying DataNodes that include it.- Since:
- 3.1
-
removeDataNode
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
Returns a collection of registered DataMaps. -
getDataNodes
Returns an unmodifiable collection of DataNodes associated with this domain. -
addNode
Adds new DataNode. -
getDataNode
Returns registered DataNode whose name matchesname
parameter.- Since:
- 3.1
-
lookupDataNode
Returns a DataNode that should handle queries for all entities in a DataMap.- Since:
- 1.1
-
setEntityResolver
Sets EntityResolver. If not set explicitly, DataDomain creates a default EntityResolver internally on demand.- Since:
- 1.1
-
shutdown
Shutdowns all owned data nodes and marks this domain as stopped. -
performQueries
Routes queries to appropriate DataNodes for execution.- Specified by:
performQueries
in interfaceQueryEngine
-
onQuery
Runs query returning generic QueryResponse.- Specified by:
onQuery
in interfaceDataChannel
- 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
Returns an EntityResolver that stores mapping information for this domain.- Specified by:
getEntityResolver
in interfaceDataChannel
- Specified by:
getEntityResolver
in interfaceQueryEngine
-
onSync
Only handles commit-type synchronization, ignoring any other type.- Specified by:
onSync
in interfaceDataChannel
- Parameters:
originatingContext
- an ObjectContext that initiated the sync. Can be null.changes
- diff from the context that initiated the sync.syncType
- One ofDataChannel.FLUSH_NOCASCADE_SYNC
,DataChannel.FLUSH_CASCADE_SYNC
,DataChannel.ROLLBACK_CASCADE_SYNC
.- Since:
- 1.2
-
toString
-
getQueryCache
Returns sharedQueryCache
used by this DataDomain.- Since:
- 3.0
-
setQueryCache
-
getDataRowStoreFactory
- Since:
- 4.0
-
setDataRowStoreFactory
- Since:
- 4.0
-
getFilters
Deprecated.since 4.1 usegetQueryFilters()
andgetSyncFilters()
Since 4.1 returns empty list.- Since:
- 3.1
-
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
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
-
addFilter
Deprecated.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
-
addQueryFilter
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
Adds a new sync filter. Also registers passed filter as an event listener, if any of its methods have event annotations.- Since:
- 4.1
-
removeFilter
Deprecated.since 4.1 useremoveQueryFilter(DataChannelQueryFilter)
andremoveSyncFilter(DataChannelSyncFilter)
insteadRemoves a filter from the filter chain.- Since:
- 3.1
-
removeQueryFilter
Removes a query filter from the filter chain.- Since:
- 4.1
-
removeSyncFilter
Removes a sync filter from the filter chain.- Since:
- 4.1
-
addListener
Adds a listener, mapping its methods to events based on annotations. This is a shortcut for 'getEntityResolver().getCallbackRegistry().addListener(listener)'.- Since:
- 4.0
-
getDefaultNode
An optional DataNode that is used for DataMaps that are not linked to a DataNode explicitly.- Since:
- 3.1
-
setDefaultNode
- 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 callingsetMaxIdQualifierSize(int)
or changing the value for propertyConstants.SERVER_MAX_ID_QUALIFIER_SIZE_PROPERTY
.- Since:
- 3.1
-
setMaxIdQualifierSize
public void setMaxIdQualifierSize(int maxIdQualifierSize) - Since:
- 3.1
-