|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface CDOView
A read-only view to the current (i.e. latest) state of the object graph in the repository of the underlying
session.
Objects that are accessed through this view are unchangeable for the client. Each attempt to call a mutator on one of
these objects or one of their reference collections will result in a ReadOnlyException being thrown
immediately.
A view is opened through API of the underlying session like this:
CDOSession session = ... CDOView view = session.openView(); ...CDOView instances must not be accessed through concurrent client threads.
Since a CDOObject, in a non-TRANSIENT state, is only meaningful in combination with its
dedicated view they must also not be accessed through concurrent client threads. Please note that at arbitrary times
an arbitrary number of framework background threads are allowed to use and modify a CDOview and its CDOObjects.
Whenever you are iterating over a number of CDOObjects and need to ensure that they are not modified by the framework
at the same time it is strongly recommended to acquire the view lock and protect your code
appropriately.
| Nested Class Summary | |
|---|---|
static interface |
CDOView.Options
|
| Nested classes/interfaces inherited from interface org.eclipse.emf.cdo.common.CDOCommonView |
|---|
CDOCommonView.Type |
| Nested classes/interfaces inherited from interface org.eclipse.net4j.util.event.INotifier |
|---|
org.eclipse.net4j.util.event.INotifier.Introspection |
| Field Summary |
|---|
| Fields inherited from interface org.eclipse.emf.cdo.common.CDOCommonView |
|---|
UNSPECIFIED_DATE |
| Method Summary | ||
|---|---|---|
CDOQuery |
createQuery(java.lang.String language,
java.lang.String queryString)
|
|
java.util.concurrent.locks.ReentrantLock |
getLock()
Returns a reentrant lock that can be used to prevent the framework from writing to any object in this view (as it is caused, for example, by passive updates). |
|
CDOObject |
getObject(CDOID id)
Returns the object for the given CDOID. |
|
CDOObject |
getObject(CDOID id,
boolean loadOnDemand)
Returns the object for the given CDOID. |
|
|
getObject(T objectFromDifferentView)
Takes an object from a (possibly) different view and contextifies it for the usage with this view. |
|
CDOResource |
getResource(java.lang.String path)
Same as getResource(String, true). |
|
CDOResource |
getResource(java.lang.String path,
boolean loadOnDemand)
|
|
CDOResourceNode |
getResourceNode(java.lang.String path)
Returns the resource node with the given path, or null if no such resource node exists. |
|
org.eclipse.emf.ecore.resource.ResourceSet |
getResourceSet()
Returns the resource set this view is associated with. |
|
CDOResource |
getRootResource()
Returns the root resource of the repository. |
|
CDOSession |
getSession()
Returns the session this view was opened by. |
|
org.eclipse.emf.ecore.resource.URIHandler |
getURIHandler()
Deprecated. This API is provisional and subject to change or removal. |
|
CDOViewSet |
getViewSet()
Returns the view set this view is associated with. |
|
boolean |
hasConflict()
Returns always false. |
|
boolean |
hasResource(java.lang.String path)
Returns true if a resource with the given path exists in the repository, false. |
|
boolean |
isDirty()
Returns always false. |
|
boolean |
isObjectRegistered(CDOID id)
Returns true if an object with the given id is currently registered in
this view, false otherwise. |
|
void |
lockObjects(java.util.Collection<? extends CDOObject> objects,
org.eclipse.net4j.util.concurrent.RWLockManager.LockType lockType,
long timeout)
Locks the given objects. |
|
CDOView.Options |
options()
|
|
java.util.List<CDOResourceNode> |
queryResources(CDOResourceFolder folder,
java.lang.String name,
boolean exactMatch)
Returns a list of the resources in the given folder with a name equal to or starting with the value of the name parameter. |
|
org.eclipse.net4j.util.collection.CloseableIterator<CDOResourceNode> |
queryResourcesAsync(CDOResourceFolder folder,
java.lang.String name,
boolean exactMatch)
Returns an iterator over the resources in the given folder with a name equal to or starting with the value of the name parameter. |
|
int |
reload(CDOObject... objects)
Reloads the given objects from the repository. |
|
void |
unlockObjects()
Unlocks all locked objects of this view. |
|
void |
unlockObjects(java.util.Collection<? extends CDOObject> objects,
org.eclipse.net4j.util.concurrent.RWLockManager.LockType lockType)
Unlocks the given locked objects of this view. |
|
| Methods inherited from interface org.eclipse.emf.cdo.common.CDOCommonView |
|---|
getTimeStamp, getViewID, getViewType |
| Methods inherited from interface org.eclipse.net4j.util.collection.Closeable |
|---|
close, isClosed |
| Methods inherited from interface org.eclipse.net4j.util.event.INotifier |
|---|
addListener, removeListener |
| Method Detail |
|---|
CDOSession getSession()
session this view was opened by.
getSession in interface CDOCommonViewnull if this view is closed.Closeable.close(),
Closeable.isClosed(),
CDOSession.openView(),
CDOSession.openView(ResourceSet),
CDOSession.openAudit(long),
CDOSession.openAudit(ResourceSet, long),
CDOSession.openTransaction(),
CDOSession.openTransaction(ResourceSet)CDOViewSet getViewSet()
view set this view is associated with.
null.CDOViewSet.getViews()org.eclipse.emf.ecore.resource.ResourceSet getResourceSet()
resource set this view is associated with.
Same as calling getViewSet().getResourceSet().
CDOViewSet.getResourceSet()@Deprecated org.eclipse.emf.ecore.resource.URIHandler getURIHandler()
java.util.concurrent.locks.ReentrantLock getLock()
Acquiring this lock provides a means to safely iterate over multiple model elements without being affected by unanticipated remote updates, like in the following example:
CDOResource resource = view.getResource("/orders/order-4711");
PurchaseOrder order = (PurchaseOrder)resource.getContents().get(0);
ReentrantLock lock = view.getLock();
if (!lock.tryLock(5L, TimeUnit.SECONDS))
{
throw new TimeoutException();
}
try
{
float sum = 0;
for (OrderDetail detail : order.getOrderDetails())
{
sum += detail.getPrice();
}
System.out.println("Sum: " + sum);
}
finally
{
lock.unlock();
}
}
Note that this method really just returns the lock instance but does not acquire the lock! The above example
acquires the lock with a timeout that expires after five seconds.
boolean isDirty()
false.
This method has a special implementation in CDOTransaction as well.
CDOTransaction.isDirty()boolean hasConflict()
false.
This method has a special implementation in CDOTransaction as well.
CDOTransaction.hasConflict()boolean hasResource(java.lang.String path)
true if a resource with the given path exists in the repository, false.
getResource(String, boolean)
CDOResource getResource(java.lang.String path,
boolean loadOnDemand)
ResourceSet.getResource(URI, boolean)CDOResource getResource(java.lang.String path)
getResource(String, true).
ResourceSet.getResource(URI, boolean)CDOResourceNode getResourceNode(java.lang.String path)
null if no such resource node exists.
CDOResource getRootResource()
The root resource is a special resource with only CDOResourceNodes in its contents list.
You can use it as the main entry into the new resource and folder structure.
java.util.List<CDOResourceNode> queryResources(CDOResourceFolder folder,
java.lang.String name,
boolean exactMatch)
folder - The folder to search in, or null for top level resource nodes.name - the name or prefix of the resource nodes to return.exactMatch - true if the complete name of the resource must match, false if only a common
prefix of the name must match.
org.eclipse.net4j.util.collection.CloseableIterator<CDOResourceNode> queryResourcesAsync(CDOResourceFolder folder,
java.lang.String name,
boolean exactMatch)
folder - The folder to search in, or null for top level resource nodes.name - the name or prefix of the resource nodes to return.exactMatch - true if the complete name of the resource must match, false if only a common
prefix of the name must match.
CDOObject getObject(CDOID id,
boolean loadOnDemand)
loadOnDemand - whether to create and load the object, if it doesn't already exist.
null, or null if there isn't
one and loadOnDemand is false.CDOObject getObject(CDOID id)
Same as getObject(id, true).
getObject(CDOID, boolean)<T extends org.eclipse.emf.ecore.EObject> T getObject(T objectFromDifferentView)
CDOObject it is returned unmodified.
IllegalArgumentException is
thrown.
null is passed null is returned.
boolean isObjectRegistered(CDOID id)
true if an object with the given id is currently registered in
this view, false otherwise.
int reload(CDOObject... objects)
objects from the repository.
void lockObjects(java.util.Collection<? extends CDOObject> objects,
org.eclipse.net4j.util.concurrent.RWLockManager.LockType lockType,
long timeout)
throws java.lang.InterruptedException
java.lang.InterruptedException
void unlockObjects(java.util.Collection<? extends CDOObject> objects,
org.eclipse.net4j.util.concurrent.RWLockManager.LockType lockType)
void unlockObjects()
CDOQuery createQuery(java.lang.String language,
java.lang.String queryString)
CDOView.Options options()
options in interface org.eclipse.net4j.util.options.IOptionsContainer
|
Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others. All Rights Reserved. |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||