|
||||||||||
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(String name)
Creates a DataDomain and assigns it a name. |
|
DataDomain(String name,
Map properties)
Creates new DataDomain. |
Method Summary | |
---|---|
void |
addMap(DataMap map)
Registers new DataMap with this domain. |
void |
addNode(DataNode node)
Adds new DataNode. |
void |
clearDataMaps()
Clears the list of internal DataMaps. |
DataContext |
createDataContext()
Creates and returns a new DataContext. |
DataContext |
createDataContext(boolean useSharedCache)
Creates a new DataContext. |
Transaction |
createTransaction()
Creates and returns a new inactive transaction. |
DataContextFactory |
getDataContextFactory()
|
Collection |
getDataMaps()
Returns a collection of registered DataMaps. |
Collection |
getDataNodes()
Returns an unmodifiable collection of DataNodes associated with this domain. |
EntityResolver |
getEntityResolver()
Returns an EntityResolver that stores mapping information for this domain. |
EventManager |
getEventManager()
Returns EventManager used by this DataDomain. |
DataMap |
getMap(String mapName)
Returns DataMap matching name parameter. |
String |
getName()
Returns "name" property value. |
DataNode |
getNode(String nodeName)
Returns registered DataNode whose name matches name parameter. |
Map |
getProperties()
|
QueryCache |
getQueryCache()
Returns shared QueryCache used by this DataDomain, creating it on the fly
if needed. |
QueryCacheFactory |
getQueryCacheFactory()
Returns a non-null QueryCacheFactory . |
DataRowStore |
getSharedSnapshotCache()
Returns snapshots cache for this DataDomain, lazily initializing it on the first call if 'sharedCacheEnabled' flag is true. |
TransactionDelegate |
getTransactionDelegate()
|
void |
initWithProperties(Map 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 context,
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(Collection queries,
OperationObserver callback)
Routes queries to appropriate DataNodes for execution. |
void |
reindexNodes()
Updates internal index of DataNodes stored by the entity name. |
void |
removeDataNode(String nodeName)
Removes a DataNode from DataDomain. |
void |
removeMap(String mapName)
Removes named DataMap from this DataDomain and any underlying DataNodes that include it. |
void |
reset()
Closes all data nodes, removes them from the list of available nodes. |
protected void |
resetProperties()
|
void |
setDataContextFactory(DataContextFactory dataContextFactory)
|
void |
setEntityResolver(EntityResolver entityResolver)
Sets EntityResolver. |
void |
setEventManager(EventManager eventManager)
Sets EventManager used by this DataDomain. |
void |
setName(String name)
Sets "name" property to a new value. |
void |
setQueryCacheFactory(QueryCacheFactory queryCacheFactory)
|
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. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String SHARED_CACHE_ENABLED_PROPERTY
public static final boolean SHARED_CACHE_ENABLED_DEFAULT
public static final String VALIDATING_OBJECTS_ON_COMMIT_PROPERTY
public static final boolean VALIDATING_OBJECTS_ON_COMMIT_DEFAULT
public static final String USING_EXTERNAL_TRANSACTIONS_PROPERTY
public static final boolean USING_EXTERNAL_TRANSACTIONS_DEFAULT
public static final String DATA_CONTEXT_FACTORY_PROPERTY
public static final String QUERY_CACHE_FACTORY_PROPERTY
QueryCacheFactory
.
protected Map nodes
protected Map nodesByDataMapName
protected Map properties
protected EntityResolver entityResolver
protected DataRowStore sharedSnapshotCache
protected TransactionDelegate transactionDelegate
protected DataContextFactory dataContextFactory
protected QueryCacheFactory queryCacheFactory
protected String name
protected boolean sharedCacheEnabled
protected boolean validatingObjectsOnCommit
protected boolean usingExternalTransactions
protected EventManager eventManager
protected QueryCache queryCache
Constructor Detail |
---|
public DataDomain(String name)
public DataDomain(String name, 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 resetProperties()
public void initWithProperties(Map properties)
public EventManager getEventManager()
getEventManager
in interface DataChannel
public void setEventManager(EventManager eventManager)
public String getName()
public void setName(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 Map getProperties()
public TransactionDelegate getTransactionDelegate()
public void setTransactionDelegate(TransactionDelegate transactionDelegate)
public DataRowStore getSharedSnapshotCache()
public void setSharedSnapshotCache(DataRowStore snapshotCache)
public DataContextFactory getDataContextFactory()
public void setDataContextFactory(DataContextFactory dataContextFactory)
public void addMap(DataMap map)
public DataMap getMap(String mapName)
name
parameter.
public void removeMap(String mapName)
public void removeDataNode(String nodeName)
public Collection getDataMaps()
public Collection getDataNodes()
public void reset()
public void clearDataMaps()
public void addNode(DataNode node)
public DataContext createDataContext()
public DataContext createDataContext(boolean useSharedCache)
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(String nodeName)
name
parameter.
public void reindexNodes()
public DataNode lookupDataNode(DataMap map)
public void setEntityResolver(EntityResolver entityResolver)
public void shutdown()
public void performQueries(Collection queries, OperationObserver callback)
performQueries
in interface QueryEngine
public QueryResponse onQuery(ObjectContext context, Query query)
onQuery
in interface DataChannel
context
- 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 String toString()
toString
in class Object
public QueryCacheFactory getQueryCacheFactory()
QueryCacheFactory
.
public void setQueryCacheFactory(QueryCacheFactory queryCacheFactory)
public QueryCache getQueryCache()
QueryCache
used by this DataDomain, creating it on the fly
if needed. Uses factory obtained via getQueryCacheFactory()
to initialize
the cache for the first time.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |