Package org.apache.cayenne.access
Class DataDomain
java.lang.Object
org.apache.cayenne.access.DataDomain
- All Implemented Interfaces:
DataChannel
DataDomain performs query routing functions in Cayenne. It creates single "ORM data source" abstraction over multiple
physical DataNodes.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DataNodeprotected final EntityResolverprotected final EntitySorterprotected final EventManagerprotected final DataDomainFlushActionFactoryprotected final intprotected final Stringprotected final AdhocObjectFactoryprotected final QueryCacheprotected final List<DataChannelQueryFilter> protected final DataRowStoreprotected booleanprotected final List<DataChannelSyncFilter> protected final TransactionFactoryprotected final TransactionManagerprotected final booleanFields 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
ConstructorsConstructorDescriptionDataDomain(String name, TransactionManager transactionManager, TransactionFactory transactionFactory, DataDomainFlushActionFactory flushActionFactory, AdhocObjectFactory objectFactory, EventManager eventManager, QueryCache queryCache, DataRowStore sharedSnapshotCache, int maxIdQualifierSize, boolean validatingObjectsOnCommit, EntityResolver entityResolver, EntitySorter entitySorter) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDataMap(DataMap dataMap) voidaddListener(Object listener) Adds a listener, mapping its methods to events based on annotations.voidAdds new DataNode.voidaddQueryFilter(DataChannelQueryFilter filter) Adds a new query filter.voidaddSyncFilter(DataChannelSyncFilter filter) Adds a new sync filter.protected voidThrows DomainStoppedException if the domain was previously shut down.getDataMap(String mapName) Returns a collection of registered DataMaps.getDataNode(String nodeName) Returns registered DataNode whose name matchesnameparameter.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.intReturns 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 null, as DataDomain is the root of the DataChannel stack.Returns sharedQueryCacheused by this DataDomain.Returns an unmodifiable list of query filters registered with this DataDomain.Returns the snapshots cache shared by the DataContexts of this DataDomain, or null if the domain runs with per-DataContext caches.Returns an unmodifiable list of sync filters registered with this DataDomain.booleanReturnstrueif DataContexts produced by this DataDomain are using shared DataRowStore.booleanReturns 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.voidremoveDataMap(String mapName) Removes named DataMap from this DataDomain and any underlying DataNodes that include it.voidremoveDataNode(String nodeName) Removes a DataNode from DataDomain.voidRemoves a query filter from the filter chain.voidRemoves a sync filter from the filter chain.voidsetDefaultNode(DataNode defaultNode) voidshutdown()Shutdowns all owned data nodes and marks this domain as stopped.toString()
-
Field Details
-
name
-
transactionManager
-
transactionFactory
-
flushActionFactory
-
objectFactory
-
eventManager
-
entitySorter
-
queryCache
-
entityResolver
-
maxIdQualifierSize
protected final int maxIdQualifierSize -
validatingObjectsOnCommit
protected final boolean validatingObjectsOnCommit -
queryFilters
-
syncFilters
-
nodes
-
nodesByDataMapName
-
defaultNode
-
stopped
protected boolean stopped
-
-
Constructor Details
-
DataDomain
public DataDomain(String name, TransactionManager transactionManager, TransactionFactory transactionFactory, DataDomainFlushActionFactory flushActionFactory, AdhocObjectFactory objectFactory, EventManager eventManager, QueryCache queryCache, DataRowStore sharedSnapshotCache, int maxIdQualifierSize, boolean validatingObjectsOnCommit, EntityResolver entityResolver, EntitySorter entitySorter)
-
-
Method Details
-
checkStopped
Throws DomainStoppedException if the domain was previously shut down.- Throws:
DomainStoppedException- Since:
- 3.0
-
getEntitySorter
- Since:
- 3.1
-
getEventManager
Returns EventManager used by this DataDomain.- Specified by:
getEventManagerin interfaceDataChannel- Since:
- 1.2
-
getName
Returns "name" property value. -
isValidatingObjectsOnCommit
public boolean isValidatingObjectsOnCommit()Returns whether child DataContexts default behavior is to perform object validation before commit is executed.- 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 matchesnameparameter.- Since:
- 3.1
-
lookupDataNode
Returns a DataNode that should handle queries for all entities in a DataMap.- Since:
- 1.1
-
shutdown
Shutdowns all owned data nodes and marks this domain as stopped. -
getParent
Returns null, as DataDomain is the root of the DataChannel stack.- Specified by:
getParentin interfaceDataChannel- Since:
- 5.0
-
onQuery
Runs query returning generic QueryResponse.- Specified by:
onQueryin 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:
getEntityResolverin interfaceDataChannel
-
onSync
Only handles commit-type synchronization, ignoring any other type.- Specified by:
onSyncin 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 sharedQueryCacheused by this DataDomain.- Since:
- 3.0
-
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
-
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
-
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 by setting theConstants.MAX_ID_QUALIFIER_SIZE_PROPERTYproperty.- Since:
- 3.1
-