Schnittstelle CDOView

Alle Superschnittstellen:
AutoCloseable, CDOBranchPoint, CDOBranchProvider, CDOCommitHistory.Provider<CDOObject,CDOObjectHistory>, CDOCommonView, CDORevisionProvider, CDOTimeProvider, CDOUpdatable, org.eclipse.net4j.util.collection.Closeable, IAdaptable, org.eclipse.net4j.util.container.IContainer<CDOResourceNode>, org.eclipse.net4j.util.event.INotifier, org.eclipse.net4j.util.options.IOptionsContainer, org.eclipse.net4j.util.properties.IPropertiesContainer
Alle bekannten Unterschnittstellen:
CDOTransaction, InternalCDOTransaction, InternalCDOView
Alle bekannten Implementierungsklassen:
CDOPushTransaction

public interface CDOView extends CDOCommonView, CDOUpdatable, CDOCommitHistory.Provider<CDOObject,CDOObjectHistory>, org.eclipse.net4j.util.container.IContainer<CDOResourceNode>
A read-only view to the state of the object graph in the repository of the underlying session at a specific time at a specific branch.

If the time of a view is unspecified the objects provided and managed by that view always show the latest state the repository graph.

Objects that are accessed through this view are immutable for the client. Each attempt to call a mutator on one of these objects or one of their feature lists will result in a ReadOnlyException being thrown immediately. Mutable objects can be provided by a transaction.

A view is opened through API of the underlying session like this:

   CDOSession session = ...
   CDOView view = session.openView();
   ...
 

Views and their model objects are thread-safe. They can be used concurrently from different threads without additional synchronization. Note that this guarantee only applies to single accesses to the view or its objects. If multiple accesses need to be guarded against invalidation or other internal operations of the view, the critical section of the view must be used.

Seit:
2.0
Autor:
Eike Stepper
No Implement
This interface is not intended to be implemented by clients.
No Extend
This interface is not intended to be extended by clients.
  • Felddetails

    • PROP_TIME_MACHINE_DISABLED

      static final String PROP_TIME_MACHINE_DISABLED
      Seit:
      4.5
      Siehe auch:
    • PROP_LIFECYCLE_EXCEPTION_HANDLER

      static final String PROP_LIFECYCLE_EXCEPTION_HANDLER
      Seit:
      4.19
      Siehe auch:
  • Methodendetails

    • getSession

      CDOSession getSession()
      Returns the session this view was opened by.
      Angegeben von:
      getSession in Schnittstelle CDOCommonView
      Gibt zurück:
      The session this view was opened by, or null if this view is closed.
      Siehe auch:
    • getProvider

      CDOViewProvider getProvider()
      Returns the provider that has opened this view.
      Seit:
      4.4
    • getURI

      URI getURI()
      Seit:
      4.24
    • getViewSet

      CDOViewSet getViewSet()
      Returns the view set this view is associated with.
      Gibt zurück:
      The view set this view is associated with, never null.
      Siehe auch:
    • sync

      org.eclipse.net4j.util.concurrent.CriticalSection sync()
      Returns a critical section that can be used to execute a block of code that needs to be synchronized with the internal operations of this view and its objects.

      Here is an example:

       CDOView view = ...;
       CriticalSection sync = view.sync();
      
       MyResult result = sync.call(() -> {
         // Access the view and its objects safely here.
         CDOObject object1 = view.getObject(id1);
         CDOObject object2 = view.getObject(id2);
         CDOObject object3 = view.getObject(id3);
         ...
         return new MyResult(...);
       });
       
      The critical section ensures that no invalidation or other internal operation of the view can occur while the block of code is executed. This is particularly important if the block of code accesses the view or objects of the view multiple times, because these objects can be invalidated by network threads at any time in between these accesses otherwise. This can lead to wrong computation results in the block of code being executed.

      Note that single accesses to the view or its objects are always safe, even without using the critical section.

      There are some other useful methods in CriticalSection that can be used to execute a block of code, such as run(Runnable) or supply(Supplier).

      By default the critical section uses the monitor lock of this view to synchronize. If you need a different locking strategy you can override this by calling CDOUtil.setNextViewLock(Lock) before opening the view.

      In particular you can use a DelegableReentrantLock, which allows to delegate the lock ownership to a different thread. This is useful in scenarios where you need to hold the lock while waiting for an asynchronous operation to complete in a different thread.

      A typical example is the Display.syncExec() method in SWT/JFace UI applications. With the default locking strategy this can lead to deadlocks:

      1. Thread A (not the UI thread) holds the view lock and calls Display.syncExec() to execute some code in the UI thread.
      2. The Runnable passed to syncExec() is scheduled for execution in the UI thread. Thread A waits for the Runnable to complete.
      3. The UI thread executes the Runnable, which tries to access the view or an object of the view. This requires the view lock, which is already held by thread A.
      4. Deadlock: Thread A waits for the Runnable to complete and the UI thread waits for the view lock to be released.

      Note that, in this scenario, Thread A is holding the view lock while waiting for the Runnable to complete. This is kind of an anti-pattern, because it blocks other threads from accessing the view for an indeterminate amount of time. In addition, it is not necessary to hold the view lock while waiting for the Runnable to complete, because Thread A can not access the view in that time.

      A DelegableReentrantLock can be used to avoid the deadlock. It uses so called lock delegation to temporarily transfer the ownership of the lock to a different thread. In the scenario described above, Thread A can delegate the lock ownership to the UI thread while waiting for the Runnable to complete. When the Runnable completes, the lock ownership is transferred back to Thread A. This way, the UI thread can access the view while executing the Runnable and no deadlock occurs.

      DelegableReentrantLock uses DelegableReentrantLock.DelegateDetectors to determine whether the current thread is allowed to delegate the lock ownership to a different thread. A DelegateDetector can be registered with the lock by calling DelegableReentrantLock.addDelegateDetector(DelegateDetector). The org.eclipse.net4j.util.ui plugin provides a DisplayDelegateDetector for the SWT/JFace UI thread that detects calls to Display.syncExec().

      Seit:
      4.29
      Siehe auch:
    • getViewLock

      @Deprecated Lock getViewLock()
      Veraltet.
      As of 4.29 use sync().
      Seit:
      4.5
    • syncExec

      @Deprecated void syncExec(Runnable runnable)
      Veraltet.
      As of 4.29 use sync().
      Seit:
      4.5
    • syncExec

      @Deprecated <V> V syncExec(Callable<V> callable) throws Exception
      Veraltet.
      As of 4.29 use sync().
      Löst aus:
      Exception
      Seit:
      4.5
    • getResourceSet

      ResourceSet getResourceSet()
      Returns the resource set this view is associated with.

      Same as calling getViewSet().getResourceSet().

      Siehe auch:
    • getURIHandler

      URIHandler getURIHandler()
    • getUnitManager

      CDOUnitManager getUnitManager()
      Seit:
      4.5
    • setBranchPoint

      boolean setBranchPoint(CDOBranch branch, long timeStamp)
      Sets the branch and the point in (repository) time this view should refer to. Objects provided by this view will be valid at this time. The special value UNSPECIFIED_DATE denotes a "floating view" that always shows the latest state of the repository.
      Gibt zurück:
      true if the branch point was changed, false otherwise.
      Seit:
      3.0
    • setBranchPoint

      boolean setBranchPoint(CDOBranch branch, long timeStamp, IProgressMonitor monitor)
      Seit:
      4.4
    • setBranchPoint

      boolean setBranchPoint(CDOBranchPoint branchPoint)
      Seit:
      3.0
    • setBranchPoint

      boolean setBranchPoint(CDOBranchPoint branchPoint, IProgressMonitor monitor)
      Seit:
      4.4
    • setBranch

      boolean setBranch(CDOBranch branch)
      Seit:
      3.0
    • setBranch

      boolean setBranch(CDOBranch branch, IProgressMonitor monitor)
      Seit:
      4.4
    • setTimeStamp

      boolean setTimeStamp(long timeStamp)
      Seit:
      3.0
    • setTimeStamp

      boolean setTimeStamp(long timeStamp, IProgressMonitor monitor)
      Seit:
      4.4
    • isInvalidating

      boolean isInvalidating()
      Seit:
      4.8
    • isInvalidationRunnerActive

      @Deprecated boolean isInvalidationRunnerActive()
      Veraltet.
      As of 4.7 use isInvalidating().
      Seit:
      4.0
    • isLegacyModeEnabled

      @Deprecated boolean isLegacyModeEnabled()
      Veraltet.
      As of 4.2 the legacy mode is always enabled.
      Seit:
      3.0
      Siehe auch:
    • isDirty

      boolean isDirty()
      Returns always false.

      This method has a special implementation in CDOTransaction as well.

      Siehe auch:
    • hasConflict

      boolean hasConflict()
      Returns always false.

      This method has a special implementation in CDOTransaction as well.

      Siehe auch:
    • hasResource

      boolean hasResource(String path)
      Returns true if a resource with the given path exists in the repository, false. Applies to file resources, as well.
      Siehe auch:
    • getResource

      CDOResource getResource(String path, boolean loadOnDemand) throws CDOResourceNodeNotFoundException
      Löst aus:
      CDOResourceNodeNotFoundException
      Siehe auch:
    • getResource

      Löst aus:
      CDOResourceNodeNotFoundException
      Siehe auch:
    • getTextResource

      Löst aus:
      CDOResourceNodeNotFoundException
      Seit:
      4.2
    • getBinaryResource

      Löst aus:
      CDOResourceNodeNotFoundException
      Seit:
      4.2
    • getResourceNode

      Returns the resource node with the given path.
      Gibt zurück:
      never null.
      Löst aus:
      CDOException - if no such resource node exists.
      CDOResourceNodeNotFoundException
    • getResourceFolder

      Löst aus:
      CDOResourceNodeNotFoundException
      Seit:
      4.2
    • getRootResource

      CDOResource getRootResource()
      Returns the root resource of the repository.

      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.

    • setResourcePathCache

      void setResourcePathCache(Map<String,CDOID> resourcePathCache)
      Sets the new map to be used as a cache for various get*Resource*(String path) methods.

      Can be used to reset/clear the resource path cache by passing a new HashMap<String, CDOID>(). Smarter maps could implement a LRU eviction policy to limit the map capacity. Passing null disables resource path caching.

      The default value is new HashMap<String, CDOID>().

      Seit:
      4.2
      Siehe auch:
    • createResourceURI

      URI createResourceURI(String path)
      Returns a URI that can be used in ResourceSet.getResource(URI, boolean) to load the resource with the specified path.
      Seit:
      4.4
    • queryResources

      List<CDOResourceNode> queryResources(CDOResourceFolder folder, 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.
      Parameter:
      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.
    • queryResourcesAsync

      org.eclipse.net4j.util.collection.CloseableIterator<CDOResourceNode> queryResourcesAsync(CDOResourceFolder folder, 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. The underlying query will be executed asynchronously.
      Parameter:
      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.
    • queryInstances

      <T extends EObject> List<T> queryInstances(EClass type)
      Returns a list of the instances of the given type.
      Seit:
      4.3
    • queryInstancesAsync

      <T extends EObject> org.eclipse.net4j.util.collection.CloseableIterator<T> queryInstancesAsync(EClass type)
      Returns an iterator over the instances of the given type. The underlying query will be executed asynchronously.
      Seit:
      4.3
    • queryInstancesAsync

      <T extends EObject> org.eclipse.net4j.util.collection.CloseableIterator<T> queryInstancesAsync(EClass type, boolean exact)
      Returns an iterator over the instances of the given type. The underlying query will be executed asynchronously.
      Seit:
      4.6
    • queryXRefs

      List<CDOObjectReference> queryXRefs(CDOObject targetObject, EReference... sourceReferences)
      Returns a list of object references that represent the cross references to the specified target object.
      Parameter:
      targetObject - The target object that referencing objects are requested for. An external target object can be used with the help of CDOUtil.wrapExternalObject().
      sourceReferences - The reference features that referencing objects are requested for, or an empty array if all reference features are to be used in the request.
      Seit:
      4.0
      Siehe auch:
    • queryXRefs

      List<CDOObjectReference> queryXRefs(Set<CDOObject> targetObjects, EReference... sourceReferences)
      Returns a list of object references that represent the cross references to the specified target objects.
      Parameter:
      targetObjects - The set of target objects that referencing objects are requested for. External target objects can be used with the help of CDOUtil.wrapExternalObject().
      sourceReferences - The reference features that referencing objects are requested for, or an empty array if all reference features are to be used in the request.
      Seit:
      3.0
      Siehe auch:
    • queryXRefsAsync

      org.eclipse.net4j.util.collection.CloseableIterator<CDOObjectReference> queryXRefsAsync(Set<CDOObject> targetObjects, EReference... sourceReferences)
      Returns an iterator over the object references that represent the cross references to the specified target objects. The underlying query will be executed asynchronously.
      Parameter:
      targetObjects - The set of target objects that referencing objects are requested for. External target objects can be used with the help of CDOUtil.wrapExternalObject().
      sourceReferences - The reference features that referencing objects are requested for, or an empty array if all reference features are to be used in the request.
      Seit:
      3.0
      Siehe auch:
    • getObjects

      Map<CDOID,CDOObject> getObjects(Collection<CDOID> ids)
      Returns the objects with the given CDOIDs.

      If objects are missing from the local cache they are loaded from the server in one round-trip.

      Parameter:
      ids - the collection of CDOIDs that identify the CDOObjects to return.
      Gibt zurück:
      a map that contains the CDOObjects with the given CDOIDs.
      Seit:
      4.13
    • getObject

      CDOObject getObject(CDOID id, boolean loadOnDemand)
      Returns the object for the given CDOID.
      Parameter:
      loadOnDemand - whether to create and load the object, if it doesn't already exist.
      Gibt zurück:
      the object resolved by the CDOID if the id is not null, or null if there isn't one and loadOnDemand is false.
    • getObject

      CDOObject getObject(CDOID id)
      Returns the object for the given CDOID.

      Same as getObject(id, true).

      Siehe auch:
    • getObject

      <T extends EObject> T getObject(T objectFromDifferentView)
      Takes an object from a (possibly) different view and contextifies it for the usage with this view.
      • If the given object is contained in this view it is returned unmodified.
      • If the given object can not be cast to CDOObject it is returned unmodified.
      • If the view of the given object is contained in a different session an IllegalArgumentException is thrown.
      • If null is passed null is returned.
    • isObjectRegistered

      boolean isObjectRegistered(CDOID id)
      Returns true if an object with the given id is currently registered in this view, false otherwise.
    • reload

      @Deprecated int reload(CDOObject... objects)
      Veraltet.
      As of 4.3 no longer supported because it is unsafe to reload single objects.
      Reloads the given objects from the repository.
    • refreshLockStates

      void refreshLockStates(Consumer<CDOLockState> consumer)
      Refreshes the lock states of this view with the latest states from the repository. If a lock state consumer is passed it is called for each resulting new lock state.
      Seit:
      4.12
    • getLockStates

      CDOLockState[] getLockStates(Collection<CDOID> ids)
      Get an array of lock states corresponding to the specified collection of ids. If the collection of ids is empty, lock states of all objects are returned.
      Seit:
      4.6
    • getLockStates

      CDOLockState[] getLockStates(Collection<CDOID> ids, boolean loadOnDemand)
      Get an array of lock states corresponding to the specified collection of ids. If the collection of ids is empty, lock states of all objects are returned.
      Seit:
      4.19
    • getLockStatesOfObjects

      CDOLockState[] getLockStatesOfObjects(Collection<? extends CDOObject> objects)
      Get an array of lock states corresponding to the specified collection of objects. If the collection of objects is empty, lock states of all locked objects are returned.
      Seit:
      4.6
    • lockObjects

      void lockObjects(Collection<? extends CDOObject> objects, org.eclipse.net4j.util.concurrent.IRWLockManager.LockType lockType, long timeout) throws InterruptedException
      Locks the given objects. Once the objects are locked, they will not be changed remotely or go in conflict state.
      Löst aus:
      InterruptedException
      Seit:
      3.0
    • lockObjects

      void lockObjects(Collection<? extends CDOObject> objects, org.eclipse.net4j.util.concurrent.IRWLockManager.LockType lockType, long timeout, boolean recursive) throws InterruptedException
      Löst aus:
      InterruptedException
    • unlockObjects

      void unlockObjects(Collection<? extends CDOObject> objects, org.eclipse.net4j.util.concurrent.IRWLockManager.LockType lockType)
      Unlocks the given locked objects of this view.
    • unlockObjects

      void unlockObjects(Collection<? extends CDOObject> objects, org.eclipse.net4j.util.concurrent.IRWLockManager.LockType lockType, boolean recursive)
    • unlockObjects

      void unlockObjects()
      Unlocks all locked objects of this view.
      Seit:
      2.0
    • enableDurableLocking

      @Deprecated String enableDurableLocking(boolean enable)
      Veraltet.
      Seit:
      4.0
    • enableDurableLocking

      String enableDurableLocking()
      Enables the storage of all information that's needed to reopen this view at a later point in time. This information includes the branch point, the user ID of the session, whether it's a read-only view or a transaction and all the locks that are acquired or will be acquired while durable locking is enabled.
      Seit:
      4.1
      Siehe auch:
    • disableDurableLocking

      void disableDurableLocking(boolean releaseLocks)
      Disables the storage of all information that's needed to reopen this view at a later point in time. If such information is stored when this method is called it is removed. Note that locks acquired by this view are only released if true is passed to the releaseLocks parameter.
      Seit:
      4.1
      Siehe auch:
    • addObjectHandler

      void addObjectHandler(CDOObjectHandler handler)
      Seit:
      3.0
    • removeObjectHandler

      void removeObjectHandler(CDOObjectHandler handler)
      Seit:
      3.0
    • getObjectHandlers

      CDOObjectHandler[] getObjectHandlers()
      Seit:
      3.0
    • addRegistrationHandler

      void addRegistrationHandler(CDORegistrationHandler handler)
      Seit:
      4.6
    • removeRegistrationHandler

      void removeRegistrationHandler(CDORegistrationHandler handler)
      Seit:
      4.6
    • getRegistrationHandlers

      CDORegistrationHandler[] getRegistrationHandlers()
      Seit:
      4.6
    • createQuery

      CDOQuery createQuery(String language, String queryString)
      Same as createQuery(language, queryString, null).
      Seit:
      2.0
      Siehe auch:
    • createQuery

      CDOQuery createQuery(String language, String queryString, Object context)
      Seit:
      4.0
    • compareRevisions

      CDOChangeSetData compareRevisions(CDOBranchPoint source)
      Seit:
      4.0
    • options

      CDOView.Options options()
      Beschreibung aus Schnittstelle kopiert: CDOCommonView
      Returns the options of this view.
      Angegeben von:
      options in Schnittstelle CDOCommonView
      Angegeben von:
      options in Schnittstelle org.eclipse.net4j.util.options.IOptionsContainer
      Seit:
      2.0