|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cayenne.access.DataDomain
public class DataDomain
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.
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 | |
---|---|
DataDomain(java.lang.String name)
Creates a DataDomain and assigns it a name. |
|
DataDomain(java.lang.String name,
java.util.Map properties)
Creates new DataDomain. |
Method Summary | |
---|---|
void |
addDataMap(DataMap dataMap)
|
void |
addFilter(DataChannelFilter filter)
Adds a new filter, calling its 'init' method. |
void |
addMap(DataMap map)
Deprecated. since 3.1 use a more consistently named addDataMap(DataMap) . |
void |
addNode(DataNode node)
Adds new DataNode. |
protected void |
checkStopped()
Checks that Domain is not stopped. |
void |
clearDataMaps()
Deprecated. since 3.1 unused and unneeded |
DataContext |
createDataContext()
Deprecated. since 3.1 as context creation is done via ObjectContextFactory
and injection. |
DataContext |
createDataContext(boolean useSharedCache)
Deprecated. since 3.1 as context creation is done via ObjectContextFactory
and injection. |
Transaction |
createTransaction()
Creates and returns a new inactive transaction. |
DataMap |
getDataMap(java.lang.String mapName)
|
java.util.Collection<DataMap> |
getDataMaps()
Returns a collection of registered DataMaps. |
DataNode |
getDataNode(java.lang.String nodeName)
Returns registered DataNode whose name matches name parameter. |
java.util.Collection<DataNode> |
getDataNodes()
Returns an unmodifiable collection of DataNodes associated with this domain. |
DataNode |
getDefaultNode()
An optional DataNode that is used for DataMaps that are not linked to a DataNode explicitly. |
EntityResolver |
getEntityResolver()
Returns an EntityResolver that stores mapping information for this domain. |
EntitySorter |
getEntitySorter()
|
EventManager |
getEventManager()
Returns EventManager used by this DataDomain. |
java.util.List<DataChannelFilter> |
getFilters()
Returns an unmodifiable list of filters registered with this DataDomain. |
DataMap |
getMap(java.lang.String mapName)
Deprecated. since 3.1 use a more consistently named getDataMap(String) . |
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. |
java.lang.String |
getName()
Returns "name" property value. |
DataNode |
getNode(java.lang.String nodeName)
Deprecated. since 3.1, use a more consistently named getDataNode(String) . |
java.util.Map<java.lang.String,java.lang.String> |
getProperties()
|
BatchQueryBuilderFactory |
getQueryBuilderFactory()
Deprecated. since 3.1 BatchQueryBuilderFactory is injected into JdbcAdapter. |
QueryCache |
getQueryCache()
Returns shared QueryCache used by this DataDomain. |
DataRowStore |
getSharedSnapshotCache()
Returns snapshots cache for this DataDomain, lazily initializing it on the first call if 'sharedCacheEnabled' flag is true. |
TransactionDelegate |
getTransactionDelegate()
|
void |
initWithProperties(java.util.Map<java.lang.String,java.lang.String> properties)
Reinitializes domain state with a new set of properties. |
boolean |
isSharedCacheEnabled()
Returns true if DataContexts produced by this DataDomain are using
shared DataRowStore. |
boolean |
isUsingExternalTransactions()
Returns whether this DataDomain should internally commit all transactions, or let container do that. |
boolean |
isValidatingObjectsOnCommit()
Returns whether child DataContexts default behavior is to perform object validation before commit is executed. |
DataNode |
lookupDataNode(DataMap map)
Returns a DataNode that should handle queries for all entities in a DataMap. |
QueryResponse |
onQuery(ObjectContext originatingContext,
Query query)
Runs query returning generic QueryResponse. |
GraphDiff |
onSync(ObjectContext originatingContext,
GraphDiff changes,
int syncType)
Only handles commit-type synchronization, ignoring any other type. |
void |
performQueries(java.util.Collection<? extends Query> queries,
OperationObserver callback)
Routes queries to appropriate DataNodes for execution. |
void |
reindexNodes()
Deprecated. since 3.1 - unneeded and unused. |
void |
removeDataMap(java.lang.String mapName)
Removes named DataMap from this DataDomain and any underlying DataNodes that include it. |
void |
removeDataNode(java.lang.String nodeName)
Removes a DataNode from DataDomain. |
void |
removeFilter(DataChannelFilter filter)
Removes a filter from the filter chain. |
void |
removeMap(java.lang.String mapName)
Deprecated. since 3.1 use a more consistently named removeDataMap(String) . |
void |
reset()
Deprecated. since 3.1 unused and unneeded |
protected void |
resetProperties()
|
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 |
setName(java.lang.String name)
Sets "name" property to a new value. |
void |
setQueryBuilderFactory(BatchQueryBuilderFactory queryBuilderFactory)
Deprecated. since 3.1 BatchQueryBuilderFactory is injected into JdbcAdapter. |
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 |
setTransactionDelegate(TransactionDelegate transactionDelegate)
Initializes TransactionDelegate used by all DataContexts associated with this DataDomain. |
void |
setUsingExternalTransactions(boolean flag)
Sets a property defining whether this DataDomain should internally commit all transactions, or let container do that. |
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. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String SHARED_CACHE_ENABLED_PROPERTY
public static final boolean SHARED_CACHE_ENABLED_DEFAULT
public static final java.lang.String VALIDATING_OBJECTS_ON_COMMIT_PROPERTY
public static final boolean VALIDATING_OBJECTS_ON_COMMIT_DEFAULT
public static final java.lang.String USING_EXTERNAL_TRANSACTIONS_PROPERTY
public static final boolean USING_EXTERNAL_TRANSACTIONS_DEFAULT
protected JdbcEventLogger jdbcEventLogger
protected int maxIdQualifierSize
protected java.util.List<DataChannelFilter> filters
protected java.util.Map<java.lang.String,DataNode> nodes
protected java.util.Map<java.lang.String,DataNode> nodesByDataMapName
protected DataNode defaultNode
protected java.util.Map<java.lang.String,java.lang.String> properties
protected EntityResolver entityResolver
protected DataRowStore sharedSnapshotCache
protected TransactionDelegate transactionDelegate
protected java.lang.String name
protected QueryCache queryCache
protected boolean sharedCacheEnabled
protected boolean validatingObjectsOnCommit
protected boolean usingExternalTransactions
protected EventManager eventManager
protected EntitySorter entitySorter
protected boolean stopped
Constructor Detail |
---|
public DataDomain(java.lang.String name)
public DataDomain(java.lang.String name, java.util.Map properties)
name
- DataDomain name. Domain can be located using its name in the
Configuration object.properties
- A Map containing domain configuration properties.Method Detail |
---|
protected void checkStopped() throws DomainStoppedException
DomainStoppedException
public EntitySorter getEntitySorter()
public void setEntitySorter(EntitySorter entitySorter)
protected void resetProperties()
public void initWithProperties(java.util.Map<java.lang.String,java.lang.String> properties)
public EventManager getEventManager()
getEventManager
in interface DataChannel
public void setEventManager(EventManager eventManager)
public java.lang.String getName()
public void setName(java.lang.String name)
public boolean isSharedCacheEnabled()
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.
See createDataContext(boolean)
.
public void setSharedCacheEnabled(boolean sharedCacheEnabled)
public boolean isValidatingObjectsOnCommit()
public void setValidatingObjectsOnCommit(boolean flag)
public boolean isUsingExternalTransactions()
public void setUsingExternalTransactions(boolean flag)
public java.util.Map<java.lang.String,java.lang.String> getProperties()
public TransactionDelegate getTransactionDelegate()
public void setTransactionDelegate(TransactionDelegate transactionDelegate)
public DataRowStore getSharedSnapshotCache()
public void setSharedSnapshotCache(DataRowStore snapshotCache)
public void addMap(DataMap map)
addDataMap(DataMap)
.
public void addDataMap(DataMap dataMap)
public DataMap getMap(java.lang.String mapName)
getDataMap(String)
.
name
parameter.
public DataMap getDataMap(java.lang.String mapName)
public void removeMap(java.lang.String mapName)
removeDataMap(String)
.
public void removeDataMap(java.lang.String mapName)
public void removeDataNode(java.lang.String nodeName)
public java.util.Collection<DataMap> getDataMaps()
public java.util.Collection<DataNode> getDataNodes()
@Deprecated public void reset()
@Deprecated public void clearDataMaps()
public void addNode(DataNode node)
@Deprecated public DataContext createDataContext()
ObjectContextFactory
and injection.
@Deprecated public DataContext createDataContext(boolean useSharedCache)
ObjectContextFactory
and injection.
useSharedCache
- determines whether resulting DataContext should use shared
vs. local cache. This setting overrides default behavior configured for
this DataDomain via SHARED_CACHE_ENABLED_PROPERTY
.public Transaction createTransaction()
If there is a TransactionDelegate, adds the delegate to the newly created Transaction. Behavior of the returned Transaction depends on "usingInternalTransactions" property setting.
public DataNode getNode(java.lang.String nodeName)
getDataNode(String)
.
name
parameter.
public DataNode getDataNode(java.lang.String nodeName)
name
parameter.
@Deprecated public void reindexNodes()
public DataNode lookupDataNode(DataMap map)
public void setEntityResolver(EntityResolver entityResolver)
@BeforeScopeEnd public void shutdown()
public void performQueries(java.util.Collection<? extends Query> queries, OperationObserver callback)
performQueries
in interface QueryEngine
public QueryResponse onQuery(ObjectContext originatingContext, Query query)
onQuery
in interface DataChannel
originatingContext
- an ObjectContext that originated the query, used to
register result objects.
public EntityResolver getEntityResolver()
getEntityResolver
in interface QueryEngine
getEntityResolver
in interface DataChannel
public GraphDiff onSync(ObjectContext originatingContext, GraphDiff changes, int syncType)
onSync
in interface DataChannel
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
.public java.lang.String toString()
toString
in class java.lang.Object
public QueryCache getQueryCache()
QueryCache
used by this DataDomain.
public void setQueryCache(QueryCache queryCache)
public void setQueryBuilderFactory(BatchQueryBuilderFactory queryBuilderFactory)
public BatchQueryBuilderFactory getQueryBuilderFactory()
public java.util.List<DataChannelFilter> getFilters()
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.
public void addFilter(DataChannelFilter filter)
public void removeFilter(DataChannelFilter filter)
public DataNode getDefaultNode()
public void setDefaultNode(DataNode defaultNode)
public int getMaxIdQualifierSize()
setMaxIdQualifierSize(int)
or changing
the value for property Constants.SERVER_MAX_ID_QUALIFIER_SIZE_PROPERTY
.
public void setMaxIdQualifierSize(int maxIdQualifierSize)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |