Difference between revisions of "CDO/New And Noteworthy for CDO 2.0"

From Eclipsepedia

< CDO
Jump to: navigation, search
 
(4 intermediate revisions by 3 users not shown)
Line 11: Line 11:
 
Specifies whether an object will be invalidated by others users' changes.
 
Specifies whether an object will be invalidated by others users' changes.
 
<source lang="java">
 
<source lang="java">
session.setPassiveUpdateEnabled(false);
+
session.options().setPassiveUpdateEnabled(false);
 
</source>
 
</source>
  
Line 29: Line 29:
 
To activate the policy, you must to do the following:
 
To activate the policy, you must to do the following:
 
<source lang="java">
 
<source lang="java">
transaction.setChangeSubscriptionPolicy(CDOChangeSubscriptionPolicy.ALL);
+
transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);
 
</source>
 
</source>
  
Line 40: Line 40:
 
you will receive all changes from others {@link CDOTransaction}.
 
you will receive all changes from others {@link CDOTransaction}.
  
By default, the value is set to {@link CDOChangeSubscriptionPolicy#NONE}.
+
By default, the value is set to {@link CDOAdapterPolicy#NONE}.
  
 
When this feature is activated, every object that has at least one adapter matching the current policy will be registered to the server and will be notified for every change happening in any other CDOTransaction.
 
When this feature is activated, every object that has at least one adapter matching the current policy will be registered to the server and will be notified for every change happening in any other CDOTransaction.
  
{@link CDOChangeSubscriptionPolicy#NONE} - Disabled.<br>
+
{@link CDOAdapterPolicy#NONE} - Disabled.<br>
{@link CDOChangeSubscriptionPolicy#ALL} - Enabled for all adapters used.<br>
+
{@link CDOAdapterPolicy#ALL} - Enabled for all adapters used.<br>
{@link CDOChangeSubscriptionPolicy#ONLY_CDOADAPTER} - Enabled only for adapters that implement {@link CDOAdapter}.<br>
+
{@link CDOAdapterPolicy#ONLY_CDOADAPTER} - Enabled only for adapters that implement {@link CDOAdapter}.<br>
  
Any other classes that implement {@link CDOChangeSubscriptionPolicy} will enable the feature for whatever rules defined in that class.  
+
Any other classes that implement {@link CDOAdapterPolicy} will enable the feature for whatever rules defined in that class.
  
 
== Query ==  
 
== Query ==  
Line 119: Line 119:
  
 
This feature provides the ability to have an object that is in resourceA and its container could be in another resource. The object and container are in different resource and it does support external references as well.This is to be in line with EMF. However, it needs to be define in your model.
 
This feature provides the ability to have an object that is in resourceA and its container could be in another resource. The object and container are in different resource and it does support external references as well.This is to be in line with EMF. However, it needs to be define in your model.
 +
 +
== Auto-Reload configurable in CDO Editor ==
 +
 +
A global preference option allows to ignore remote invalidated objects of your model in the CDOEditor.
 +
 +
Usually objects that are remotely modified by transactions from different sessions are locally "invalidated" (marked to be reloaded on next access). With this new option you can enable/disable eager re-loading of these objects, while it does not influence the invalidation of the model object graph itself. Objects using change subscriptions are not affected by this option: they are always visually updated.
 +
 +
[[Image:Autoreload1.png]]
 +
 +
The new preference option, to configure the behaviour of CDOEditor on invalidated objects

Latest revision as of 02:15, 19 December 2010


Contents

[edit] Create save point

Creates a save point in the CDOTransaction, that can be used to roll back a part of the transaction and specifies the save point.

Note: Save points do not involve the server side, everything is done on the client side.

[edit] Make remote invalidation configurable

Specifies whether an object will be invalidated by others users' changes.

session.options().setPassiveUpdateEnabled(false);

By default this property is enabled. If this property is disabled the latest versions of objects can still be obtained by calling {@link #refresh()}.

session.refresh();

Passive update can be disabled in cases where more performance is needed and/or more control over when objects will be refreshed.

When the feature is turned on, it will automatically performs a refresh to be in sync with the server.

[edit] Change subscription

Allows listeners to be notified when objects are modified from other CDOTransaction (remotely or not). It uses adapters for the notification process (see CDONotification).

To activate the policy, you must to do the following:

transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.ALL);

To register an object, you must add an adapter to the object in which you are interested.

eObject.eAdapters().add(anAdapter);

If anAdapter matches the current policy, eObject will be registered to the server and you will receive all changes from others {@link CDOTransaction}.

By default, the value is set to {@link CDOAdapterPolicy#NONE}.

When this feature is activated, every object that has at least one adapter matching the current policy will be registered to the server and will be notified for every change happening in any other CDOTransaction.

{@link CDOAdapterPolicy#NONE} - Disabled.
{@link CDOAdapterPolicy#ALL} - Enabled for all adapters used.
{@link CDOAdapterPolicy#ONLY_CDOADAPTER} - Enabled only for adapters that implement {@link CDOAdapter}.

Any other classes that implement {@link CDOAdapterPolicy} will enable the feature for whatever rules defined in that class.

[edit] Query

The query feature allows you to retrieve objects from the repository in a native way. It could support as many languages as the Store wants to support.

CDOQuery query = view.createQuery(<LANGUAGE>, <QUERY STRING>);

At this point, it can set parameters that are going to be transferred to the server. (Eclass, EObject or primitive)

query.setParameter(key, value);

Once all your parameters are set, you can retrieve the results in a standard way.

List<SalesOrder> salesOrders = query.getResult(SalesOrder.class);

or asynchronously

CloseableIterator<SalesOrder> salesOrders = query.getResultAsync(SalesOrder.class);

In asynchronous mode, objects are returned as soon as they are retrieved from the Server. The query feature does not keep any reference to the results. This means that you could possibly return millions of objects.

The iterator could be closed at any time, resulting in the query being cancelled at the server side.

salesOrders.close();

[edit] Support getURIFragment and getEObject

CDOResource now supports the getURIFragment and getEObject methods.

Note: The URIs of temporary objects will change when the CDOTransaction is committed. Objects will no longer be accessible using their temporary URI once the CDOTransaction is committed.

[edit] Support external references

CDO supports many resources from different sources in the same resource set. Objects can refer to each other even if they are not from the same store or source.

  • An object from XMIResource can refer to objects from CDOResource.
  • An object from CDOResource can refer to objects from XMIResource.
  • An object from CDOResourceA (repositoryA) can refer to objects from another CDOResourceB(repositoryB)

Each resource set has a CDOViewSet. A CDOViewSet could have many CDOViews but each CDOView refers to one CDOViewSet only.

To use that feature, the same resource set must be used when opening CDOView.

ResourceSet resourceSet = new ResourceSetImpl();
CDOTransaction transactionA1 = sessionA.openTransaction(resourceSet);
CDOTransaction transactionB1 = sessionB.openTransaction(resourceSet);

Note: Two CDOViews from the same repository cannot belong to the same resource set.


[edit] XATransaction

This feature provides the ability to use many transactions from many repositories as a whole instead of individually. Its three-phase commit allows the clients to commit circular graphs and complex graphs that are from multiple repositories or CDOTransactions.

CDOXATransaction xaTransaction = CDOUtil.createXATransaction();
CDOUtil.prepareResourceSet(resourceSet);
xaTransaction.add(CDOUtil.getViewSet(resourceSet));
xaTransaction.setSavepoint();
xaTransaction.rollback();
xaTransaction.commit();

[edit] Support containment proxies

This feature provides the ability to have an object that is in resourceA and its container could be in another resource. The object and container are in different resource and it does support external references as well.This is to be in line with EMF. However, it needs to be define in your model.

[edit] Auto-Reload configurable in CDO Editor

A global preference option allows to ignore remote invalidated objects of your model in the CDOEditor.

Usually objects that are remotely modified by transactions from different sessions are locally "invalidated" (marked to be reloaded on next access). With this new option you can enable/disable eager re-loading of these objects, while it does not influence the invalidation of the model object graph itself. Objects using change subscriptions are not affected by this option: they are always visually updated.

Autoreload1.png

The new preference option, to configure the behaviour of CDOEditor on invalidated objects