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 org.apache.cayenne.di.AdhocObjectFactoryprotected final QueryCacheprotected final List<DataChannelQueryFilter> protected final DataRowStoreprotected booleanprotected final List<DataChannelSyncFilter> protected final TransactionFactoryprotected final TransactionManagerprotected final booleanFields inherited from interface 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, org.apache.cayenne.di.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.onIdQuery(ObjectContext context, ObjectId id) Resolves an object from the snapshot cache, or from the database if the cache lookup fails.voidonInvalidate(ObjectContext originatingContext, Collection<ObjectId> objectIds) Evicts snapshots of the given objects from the snapshot cache, notifying all contexts that share it.onQuery(ObjectContext context, Query query, boolean iteratedResult) Runs a query, returning all of its results as a list ofQueryResults.onRelationshipQuery(ObjectContext context, ObjectId sourceId, String relationshipName) Resolves a relationship from the snapshot cache, or from the database if the cache lookup fails.onSync(ObjectContext context, 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()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface DataChannel
getDataDomain
-
Field Details
-
name
-
transactionManager
-
transactionFactory
-
flushActionFactory
-
objectFactory
protected final org.apache.cayenne.di.AdhocObjectFactory 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, org.apache.cayenne.di.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
-
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
-
lookupDataNode
-
shutdown
@BeforeScopeEnd public void 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 a query, returning all of its results as a list ofQueryResults.- Specified by:
onQueryin interfaceDataChannel- Parameters:
context- an ObjectContext that originated the query, used to register result objects.query- a query to execute.iteratedResult- if true, the result is returned as aResultIteratoritem, and the caller is responsible for closing it. If false, the result is fully read into a list.- Returns:
- all result sets, update counts, iterators and OUT parameters of the execution, in the order they were produced.
- Since:
- 1.2
-
onInvalidate
Evicts snapshots of the given objects from the snapshot cache, notifying all contexts that share it.- Specified by:
onInvalidatein interfaceDataChannel- Parameters:
originatingContext- an ObjectContext that originated the invalidation.objectIds- ids of the objects to invalidate.- Since:
- 5.0
-
onIdQuery
Resolves an object from the snapshot cache, or from the database if the cache lookup fails.- Specified by:
onIdQueryin interfaceDataChannel- Parameters:
context- an ObjectContext that originated the request and that the returned object belongs to.id- id of the object to resolve.- Returns:
- the object registered with the originating context, or null if no matching row exists.
- Since:
- 5.0
-
onRelationshipQuery
public List<Persistent> onRelationshipQuery(ObjectContext context, ObjectId sourceId, String relationshipName) Resolves a relationship from the snapshot cache, or from the database if the cache lookup fails.- Specified by:
onRelationshipQueryin interfaceDataChannel- Parameters:
context- an ObjectContext that originated the request and that the returned objects belong to.sourceId- id of the object on the source side of the relationship.relationshipName- name of the relationship to resolve.- Returns:
- related objects registered with the originating context. An empty list means that a to-one target is null, or a to-many relationship has no matching objects.
- Since:
- 5.0
-
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:
context- 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
-
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 theRuntimeProperties.MAX_ID_QUALIFIER_SIZE_PROPERTYproperty.- Since:
- 3.1
-