diff options
author | Eike Stepper | 2011-07-07 08:27:25 +0000 |
---|---|---|
committer | Eike Stepper | 2011-07-07 08:27:25 +0000 |
commit | 790f4cef4375ee84aa1696a198cb49bbb71c4678 (patch) | |
tree | 1634c5286ad2ee531e829301a6c01b15d03b9d25 /plugins/org.eclipse.emf.cdo | |
parent | ff152a15474a4e44ae72b5a25613dc1f3aa74749 (diff) | |
download | cdo-790f4cef4375ee84aa1696a198cb49bbb71c4678.tar.gz cdo-790f4cef4375ee84aa1696a198cb49bbb71c4678.tar.xz cdo-790f4cef4375ee84aa1696a198cb49bbb71c4678.zip |
[351395] Refactor CDOSession to separate management of views and connection
https://bugs.eclipse.org/bugs/show_bug.cgi?id=351395
Diffstat (limited to 'plugins/org.eclipse.emf.cdo')
8 files changed, 692 insertions, 477 deletions
diff --git a/plugins/org.eclipse.emf.cdo/.settings/.api_filters b/plugins/org.eclipse.emf.cdo/.settings/.api_filters index 2004f1f5c8..3db21c43e8 100644 --- a/plugins/org.eclipse.emf.cdo/.settings/.api_filters +++ b/plugins/org.eclipse.emf.cdo/.settings/.api_filters @@ -17,6 +17,12 @@ </filter>
</resource>
<resource path="src/org/eclipse/emf/cdo/session/CDOSession.java" type="org.eclipse.emf.cdo.session.CDOSession">
+ <filter id="571473929">
+ <message_arguments>
+ <message_argument value="CDOCommonSession"/>
+ <message_argument value="CDOSession"/>
+ </message_arguments>
+ </filter>
<filter id="574619656">
<message_arguments>
<message_argument value="CDOCommonSession"/>
diff --git a/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF index cd070d15bc..cc31364d42 100644 --- a/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.emf.cdo; singleton:=true -Bundle-Version: 4.0.100.qualifier +Bundle-Version: 4.1.0.qualifier Bundle-ClassPath: . Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -13,72 +13,72 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)", org.eclipse.emf.ecore;bundle-version="[2.4.0,3.0.0)";visibility:=reexport, org.eclipse.emf.ecore.xmi;bundle-version="[2.4.0,3.0.0)";visibility:=reexport, org.eclipse.emf.cdo.common;bundle-version="[4.0.0,5.0.0)";visibility:=reexport -Export-Package: org.eclipse.emf.cdo;version="4.0.100", - org.eclipse.emf.cdo.eresource;version="4.0.100", - org.eclipse.emf.cdo.eresource.impl;version="4.0.100", - org.eclipse.emf.cdo.eresource.util;version="4.0.100", - org.eclipse.emf.cdo.eresource.validation;version="4.0.100", - org.eclipse.emf.cdo.etypes;version="4.0.100", - org.eclipse.emf.cdo.etypes.impl;version="4.0.100", - org.eclipse.emf.cdo.etypes.util;version="4.0.100", - org.eclipse.emf.cdo.session;version="4.0.100", - org.eclipse.emf.cdo.session.remote;version="4.0.100", - org.eclipse.emf.cdo.transaction;version="4.0.100", - org.eclipse.emf.cdo.util;version="4.0.100", - org.eclipse.emf.cdo.view;version="4.0.100", - org.eclipse.emf.internal.cdo;version="4.0.100", - org.eclipse.emf.internal.cdo.analyzer;version="4.0.100"; +Export-Package: org.eclipse.emf.cdo;version="4.1.0", + org.eclipse.emf.cdo.eresource;version="4.1.0", + org.eclipse.emf.cdo.eresource.impl;version="4.1.0", + org.eclipse.emf.cdo.eresource.util;version="4.1.0", + org.eclipse.emf.cdo.eresource.validation;version="4.1.0", + org.eclipse.emf.cdo.etypes;version="4.1.0", + org.eclipse.emf.cdo.etypes.impl;version="4.1.0", + org.eclipse.emf.cdo.etypes.util;version="4.1.0", + org.eclipse.emf.cdo.session;version="4.1.0", + org.eclipse.emf.cdo.session.remote;version="4.1.0", + org.eclipse.emf.cdo.transaction;version="4.1.0", + org.eclipse.emf.cdo.util;version="4.1.0", + org.eclipse.emf.cdo.view;version="4.1.0", + org.eclipse.emf.internal.cdo;version="4.1.0", + org.eclipse.emf.internal.cdo.analyzer;version="4.1.0"; x-friends:="org.eclipse.emf.cdo.net4j, org.eclipse.emf.cdo.server, org.eclipse.emf.cdo.tests, org.eclipse.emf.cdo.defs, org.eclipse.emf.cdo.ui", - org.eclipse.emf.internal.cdo.bundle;version="4.0.100";x-friends:="org.eclipse.emf.cdo.ui", - org.eclipse.emf.internal.cdo.messages;version="4.0.100";x-internal:=true, - org.eclipse.emf.internal.cdo.object;version="4.0.100"; + org.eclipse.emf.internal.cdo.bundle;version="4.1.0";x-friends:="org.eclipse.emf.cdo.ui", + org.eclipse.emf.internal.cdo.messages;version="4.1.0";x-internal:=true, + org.eclipse.emf.internal.cdo.object;version="4.1.0"; x-friends:="org.eclipse.emf.cdo.net4j, org.eclipse.emf.cdo.server, org.eclipse.emf.cdo.tests, org.eclipse.emf.cdo.defs, org.eclipse.emf.cdo.ui, org.eclipse.emf.cdo.ui.ide", - org.eclipse.emf.internal.cdo.query;version="4.0.100"; + org.eclipse.emf.internal.cdo.query;version="4.1.0"; x-friends:="org.eclipse.emf.cdo.net4j, org.eclipse.emf.cdo.server, org.eclipse.emf.cdo.tests, org.eclipse.emf.cdo.defs, org.eclipse.emf.cdo.ui, org.eclipse.emf.cdo.tests.objectivity", - org.eclipse.emf.internal.cdo.session;version="4.0.100"; + org.eclipse.emf.internal.cdo.session;version="4.1.0"; x-friends:="org.eclipse.emf.cdo.net4j, org.eclipse.emf.cdo.server, org.eclipse.emf.cdo.tests, org.eclipse.emf.cdo.defs, org.eclipse.emf.cdo.ui", - org.eclipse.emf.internal.cdo.session.remote;version="4.0.100"; + org.eclipse.emf.internal.cdo.session.remote;version="4.1.0"; x-friends:="org.eclipse.emf.cdo.net4j, org.eclipse.emf.cdo.server, org.eclipse.emf.cdo.tests, org.eclipse.emf.cdo.defs, org.eclipse.emf.cdo.ui", - org.eclipse.emf.internal.cdo.transaction;version="4.0.100"; + org.eclipse.emf.internal.cdo.transaction;version="4.1.0"; x-friends:="org.eclipse.emf.cdo.net4j, org.eclipse.emf.cdo.server, org.eclipse.emf.cdo.tests, org.eclipse.emf.cdo.defs, org.eclipse.emf.cdo.ui", - org.eclipse.emf.internal.cdo.util;version="4.0.100"; + org.eclipse.emf.internal.cdo.util;version="4.1.0"; x-friends:="org.eclipse.emf.cdo.net4j, org.eclipse.emf.cdo.server, org.eclipse.emf.cdo.tests, org.eclipse.emf.cdo.defs, org.eclipse.emf.cdo.ui", - org.eclipse.emf.internal.cdo.view;version="4.0.100"; + org.eclipse.emf.internal.cdo.view;version="4.1.0"; x-friends:="org.eclipse.emf.cdo.net4j, org.eclipse.emf.cdo.server, org.eclipse.emf.cdo.tests, org.eclipse.emf.cdo.defs, org.eclipse.emf.cdo.ui, org.eclipse.emf.cdo.ui.ide", - org.eclipse.emf.spi.cdo;version="4.0.100" + org.eclipse.emf.spi.cdo;version="4.1.0" Bundle-ActivationPolicy: lazy diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSession.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSession.java index 06ff5c66fc..b3b52d46dd 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSession.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/session/CDOSession.java @@ -26,21 +26,21 @@ import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.revision.CDORevisionManager; import org.eclipse.emf.cdo.session.remote.CDORemoteSessionManager; import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.transaction.CDOTransactionContainer; import org.eclipse.emf.cdo.util.CDOUpdatable; import org.eclipse.emf.cdo.view.CDOFetchRuleManager; import org.eclipse.emf.cdo.view.CDOView; -import org.eclipse.net4j.util.container.IContainer; import org.eclipse.net4j.util.options.IOptionsEvent; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EPackage.Registry; -import org.eclipse.emf.ecore.resource.ResourceSet; import org.eclipse.emf.spi.cdo.CDOSessionProtocol; /** - * Represents and controls the connection to a model repository. + * Represents and controls the connection to a model repository in addition to the inherited {@link CDOView view} + * management functions. * <p> * A session has the following responsibilities: * <ul> @@ -58,7 +58,7 @@ import org.eclipse.emf.spi.cdo.CDOSessionProtocol; * @noextend This interface is not intended to be extended by clients. * @noimplement This interface is not intended to be implemented by clients. */ -public interface CDOSession extends CDOCommonSession, CDOUpdatable, IContainer<CDOView> +public interface CDOSession extends CDOCommonSession, CDOUpdatable, CDOTransactionContainer { /** * Returns an instance of {@link CDORepositoryInfo} that describes the model repository this {@link CDOSession @@ -116,185 +116,6 @@ public interface CDOSession extends CDOCommonSession, CDOUpdatable, IContainer<C public CDOSession.ExceptionHandler getExceptionHandler(); /** - * Opens and returns a new {@link CDOTransaction transaction} on the given EMF {@link ResourceSet resource set}. - * - * @see #openTransaction() - * @since 4.0 - */ - public CDOTransaction openTransaction(CDOBranchPoint target, ResourceSet resourceSet); - - /** - * Opens and returns a new {@link CDOTransaction transaction} on a new EMF {@link ResourceSet resource set}. - * - * @see #openTransaction() - * @since 4.0 - */ - public CDOTransaction openTransaction(CDOBranchPoint target); - - /** - * Opens and returns a new {@link CDOTransaction transaction} on the given EMF {@link ResourceSet resource set}. - * - * @see #openTransaction() - * @since 3.0 - */ - public CDOTransaction openTransaction(CDOBranch branch, ResourceSet resourceSet); - - /** - * Opens and returns a new {@link CDOTransaction transaction} on the given EMF {@link ResourceSet resource set}. - * - * @see #openTransaction() - * @since 3.0 - */ - public CDOTransaction openTransaction(ResourceSet resourceSet); - - /** - * Opens and returns a new {@link CDOTransaction transaction} on a new EMF {@link ResourceSet resource set}. - * <p> - * Same as calling <code>openTransaction(new ResourceSetImpl())</code>. - * - * @see #openTransaction(ResourceSet) - * @since 3.0 - */ - public CDOTransaction openTransaction(CDOBranch branch); - - /** - * Opens and returns a new {@link CDOTransaction transaction} on a new EMF {@link ResourceSet resource set}. - * <p> - * Same as calling <code>openTransaction(new ResourceSetImpl())</code>. - * - * @see #openTransaction(ResourceSet) - */ - public CDOTransaction openTransaction(); - - /** - * Opens and returns a {@link CDOTransaction transaction} on a new EMF {@link ResourceSet resource set} by resuming a - * transaction that has previously been made durable by calling {@link CDOTransaction#enableDurableLocking(boolean) - * CDOTransaction.enableDurableLocking(true)}. - * <p> - * Same as calling <code>openTransaction(durableLockingID, new ResourceSetImpl())</code>. - * - * @see #openTransaction(String,ResourceSet) - * @since 4.0 - */ - public CDOTransaction openTransaction(String durableLockingID); - - /** - * Opens and returns a {@link CDOTransaction transaction} on the given EMF {@link ResourceSet resource set} by - * resuming a transaction that has previously been made durable by calling - * {@link CDOTransaction#enableDurableLocking(boolean) CDOTransaction.enableDurableLocking(true)}. - * - * @see #openTransaction(String) - * @since 4.0 - */ - public CDOTransaction openTransaction(String durableLockingID, ResourceSet resourceSet); - - /** - * Opens and returns a new {@link CDOView view} on the given EMF {@link ResourceSet resource set}. - * - * @see #openView() - * @since 4.0 - */ - public CDOView openView(CDOBranchPoint target, ResourceSet resourceSet); - - /** - * Opens and returns a new {@link CDOView view} on a new EMF {@link ResourceSet resource set}. - * - * @see #openView() - * @since 4.0 - */ - public CDOView openView(CDOBranchPoint target); - - /** - * Opens and returns a new {@link CDOView view} on the given EMF {@link ResourceSet resource set}. - * - * @see #openView() - * @since 3.0 - */ - public CDOView openView(CDOBranch branch, long timeStamp, ResourceSet resourceSet); - - /** - * Opens and returns a new {@link CDOView view} on a new EMF {@link ResourceSet resource set}. - * <p> - * Same as calling <code>openView(new ResourceSetImpl())</code>. - * - * @see #openView(CDOBranch, long, ResourceSet) - * @since 3.0 - */ - public CDOView openView(CDOBranch branch, long timeStamp); - - /** - * Opens and returns a new {@link CDOView view} on a new EMF {@link ResourceSet resource set}. - * <p> - * Same as calling <code>openView(new ResourceSetImpl())</code>. - * - * @see #openView(CDOBranch, long, ResourceSet) - * @since 3.0 - */ - public CDOView openView(CDOBranch branch); - - /** - * Opens and returns a new {@link CDOView view} on a new EMF {@link ResourceSet resource set}. - * <p> - * Same as calling <code>openView(new ResourceSetImpl())</code>. - * - * @see #openView(CDOBranch, long, ResourceSet) - * @since 3.0 - */ - public CDOView openView(long timeStamp); - - /** - * Opens and returns a new {@link CDOView view} on the given EMF {@link ResourceSet resource set}. - * - * @see #openView(CDOBranch, long, ResourceSet) - * @since 4.0 - */ - public CDOView openView(ResourceSet resourceSet); - - /** - * Opens and returns a new {@link CDOView view} on a new EMF {@link ResourceSet resource set}. - * <p> - * Same as calling <code>openView(new ResourceSetImpl())</code>. - * - * @see #openView(CDOBranch, long, ResourceSet) - */ - public CDOView openView(); - - /** - * Opens and returns a {@link CDOView view} on a new EMF {@link ResourceSet resource set} by resuming a view that has - * previously been made durable by calling {@link CDOView#enableDurableLocking(boolean) - * CDOView.enableDurableLocking(true)}. - * <p> - * Same as calling <code>openView(durableLockingID, new ResourceSetImpl())</code>. - * - * @see #openView(String,ResourceSet) - * @since 4.0 - */ - public CDOView openView(String durableLockingID); - - /** - * Opens and returns a {@link CDOView view} on the given EMF {@link ResourceSet resource set} by resuming a view that - * has previously been made durable by calling {@link CDOView#enableDurableLocking(boolean) - * CDOView.enableDurableLocking(true)}. - * - * @see #openView(String) - * @since 4.0 - */ - public CDOView openView(String durableLockingID, ResourceSet resourceSet); - - /** - * Returns an array of all open {@link CDOView views} and {@link CDOTransaction transactions} of this session. - * - * @see #openView() - * @see #openTransaction() - */ - public CDOView[] getViews(); - - /** - * @since 4.0 - */ - public CDOView getView(int viewID); - - /** * Refreshes the object caches of all (non-historical) {@link CDOView views}. * * @since 3.0 diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionContainer.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionContainer.java new file mode 100644 index 0000000000..d9c9871a95 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOTransactionContainer.java @@ -0,0 +1,118 @@ +/** + * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + * Simon McDuff - maintenance + * Victor Roldan Betancort - maintenance + * Andre Dietisheim - bug 256649 + */ +package org.eclipse.emf.cdo.transaction; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.view.CDOView; +import org.eclipse.emf.cdo.view.CDOViewContainer; + +import org.eclipse.emf.ecore.resource.ResourceSet; + +/** + * Can open new {@link CDOTransaction transactions} and provide access to openend transactions. + * + * @author Eike Stepper + * @since 4.1 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface CDOTransactionContainer extends CDOViewContainer +{ + /** + * Returns an array of all open {@link CDOView views} and {@link CDOTransaction transactions} of this session. + * + * @see #openView() + * @see #openTransaction() + */ + public CDOTransaction[] getTransactions(); + + /** + * @since 4.1 + */ + public CDOTransaction getTransaction(int viewID); + + /** + * Opens and returns a new {@link CDOTransaction transaction} on the given EMF {@link ResourceSet resource set}. + * + * @see #openTransaction() + * @since 4.1 + */ + public CDOTransaction openTransaction(CDOBranchPoint target, ResourceSet resourceSet); + + /** + * Opens and returns a new {@link CDOTransaction transaction} on a new EMF {@link ResourceSet resource set}. + * + * @see #openTransaction() + * @since 4.0 + */ + public CDOTransaction openTransaction(CDOBranchPoint target); + + /** + * Opens and returns a new {@link CDOTransaction transaction} on the given EMF {@link ResourceSet resource set}. + * + * @see #openTransaction() + * @since 3.0 + */ + public CDOTransaction openTransaction(CDOBranch branch, ResourceSet resourceSet); + + /** + * Opens and returns a new {@link CDOTransaction transaction} on the given EMF {@link ResourceSet resource set}. + * + * @see #openTransaction() + * @since 3.0 + */ + public CDOTransaction openTransaction(ResourceSet resourceSet); + + /** + * Opens and returns a new {@link CDOTransaction transaction} on a new EMF {@link ResourceSet resource set}. + * <p> + * Same as calling <code>openTransaction(new ResourceSetImpl())</code>. + * + * @see #openTransaction(ResourceSet) + * @since 3.0 + */ + public CDOTransaction openTransaction(CDOBranch branch); + + /** + * Opens and returns a new {@link CDOTransaction transaction} on a new EMF {@link ResourceSet resource set}. + * <p> + * Same as calling <code>openTransaction(new ResourceSetImpl())</code>. + * + * @see #openTransaction(ResourceSet) + */ + public CDOTransaction openTransaction(); + + /** + * Opens and returns a {@link CDOTransaction transaction} on a new EMF {@link ResourceSet resource set} by resuming a + * transaction that has previously been made durable by calling {@link CDOTransaction#enableDurableLocking(boolean) + * CDOTransaction.enableDurableLocking(true)}. + * <p> + * Same as calling <code>openTransaction(durableLockingID, new ResourceSetImpl())</code>. + * + * @see #openTransaction(String,ResourceSet) + * @since 4.0 + */ + public CDOTransaction openTransaction(String durableLockingID); + + /** + * Opens and returns a {@link CDOTransaction transaction} on the given EMF {@link ResourceSet resource set} by + * resuming a transaction that has previously been made durable by calling + * {@link CDOTransaction#enableDurableLocking(boolean) CDOTransaction.enableDurableLocking(true)}. + * + * @see #openTransaction(String) + * @since 4.0 + */ + public CDOTransaction openTransaction(String durableLockingID, ResourceSet resourceSet); +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOViewContainer.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOViewContainer.java new file mode 100644 index 0000000000..a59b993d27 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOViewContainer.java @@ -0,0 +1,138 @@ +/** + * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + * Simon McDuff - maintenance + * Victor Roldan Betancort - maintenance + * Andre Dietisheim - bug 256649 + */ +package org.eclipse.emf.cdo.view; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.transaction.CDOTransaction; + +import org.eclipse.net4j.util.container.IContainer; + +import org.eclipse.emf.ecore.resource.ResourceSet; + +/** + * Can open new {@link CDOView views} and provide access to openend views. + * + * @author Eike Stepper + * @since 4.1 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface CDOViewContainer extends IContainer<CDOView> +{ + /** + * Returns an array of all open {@link CDOView views} and {@link CDOTransaction transactions} of this session. + * + * @see #openView() + */ + public CDOView[] getViews(); + + /** + * @since 4.0 + */ + public CDOView getView(int viewID); + + /** + * Opens and returns a new {@link CDOView view} on the given EMF {@link ResourceSet resource set}. + * + * @see #openView() + * @since 4.0 + */ + public CDOView openView(CDOBranchPoint target, ResourceSet resourceSet); + + /** + * Opens and returns a new {@link CDOView view} on a new EMF {@link ResourceSet resource set}. + * + * @see #openView() + * @since 4.0 + */ + public CDOView openView(CDOBranchPoint target); + + /** + * Opens and returns a new {@link CDOView view} on the given EMF {@link ResourceSet resource set}. + * + * @see #openView() + * @since 3.0 + */ + public CDOView openView(CDOBranch branch, long timeStamp, ResourceSet resourceSet); + + /** + * Opens and returns a new {@link CDOView view} on a new EMF {@link ResourceSet resource set}. + * <p> + * Same as calling <code>openView(new ResourceSetImpl())</code>. + * + * @see #openView(CDOBranch, long, ResourceSet) + * @since 3.0 + */ + public CDOView openView(CDOBranch branch, long timeStamp); + + /** + * Opens and returns a new {@link CDOView view} on a new EMF {@link ResourceSet resource set}. + * <p> + * Same as calling <code>openView(new ResourceSetImpl())</code>. + * + * @see #openView(CDOBranch, long, ResourceSet) + * @since 3.0 + */ + public CDOView openView(CDOBranch branch); + + /** + * Opens and returns a new {@link CDOView view} on a new EMF {@link ResourceSet resource set}. + * <p> + * Same as calling <code>openView(new ResourceSetImpl())</code>. + * + * @see #openView(CDOBranch, long, ResourceSet) + * @since 3.0 + */ + public CDOView openView(long timeStamp); + + /** + * Opens and returns a new {@link CDOView view} on the given EMF {@link ResourceSet resource set}. + * + * @see #openView(CDOBranch, long, ResourceSet) + * @since 4.0 + */ + public CDOView openView(ResourceSet resourceSet); + + /** + * Opens and returns a new {@link CDOView view} on a new EMF {@link ResourceSet resource set}. + * <p> + * Same as calling <code>openView(new ResourceSetImpl())</code>. + * + * @see #openView(CDOBranch, long, ResourceSet) + */ + public CDOView openView(); + + /** + * Opens and returns a {@link CDOView view} on a new EMF {@link ResourceSet resource set} by resuming a view that has + * previously been made durable by calling {@link CDOView#enableDurableLocking(boolean) + * CDOView.enableDurableLocking(true)}. + * <p> + * Same as calling <code>openView(durableLockingID, new ResourceSetImpl())</code>. + * + * @see #openView(String,ResourceSet) + * @since 4.0 + */ + public CDOView openView(String durableLockingID); + + /** + * Opens and returns a {@link CDOView view} on the given EMF {@link ResourceSet resource set} by resuming a view that + * has previously been made durable by calling {@link CDOView#enableDurableLocking(boolean) + * CDOView.enableDurableLocking(true)}. + * + * @see #openView(String) + * @since 4.0 + */ + public CDOView openView(String durableLockingID, ResourceSet resourceSet); +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java index 31779a7b8b..cbafb992e7 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java @@ -81,8 +81,6 @@ import org.eclipse.emf.internal.cdo.bundle.OM; import org.eclipse.emf.internal.cdo.messages.Messages; import org.eclipse.emf.internal.cdo.object.CDOFactoryImpl; import org.eclipse.emf.internal.cdo.session.remote.CDORemoteSessionManagerImpl; -import org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl; -import org.eclipse.emf.internal.cdo.view.CDOViewImpl; import org.eclipse.net4j.util.ObjectUtil; import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump; @@ -91,7 +89,6 @@ import org.eclipse.net4j.util.collection.Pair; import org.eclipse.net4j.util.concurrent.IRWLockManager; import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType; import org.eclipse.net4j.util.concurrent.RWLockManager; -import org.eclipse.net4j.util.container.Container; import org.eclipse.net4j.util.event.Event; import org.eclipse.net4j.util.event.EventUtil; import org.eclipse.net4j.util.event.IEvent; @@ -108,15 +105,12 @@ import org.eclipse.emf.common.util.ECollections; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; import org.eclipse.emf.spi.cdo.CDOSessionProtocol; import org.eclipse.emf.spi.cdo.CDOSessionProtocol.RefreshSessionResult; import org.eclipse.emf.spi.cdo.InternalCDORemoteSessionManager; import org.eclipse.emf.spi.cdo.InternalCDOSession; import org.eclipse.emf.spi.cdo.InternalCDOTransaction; import org.eclipse.emf.spi.cdo.InternalCDOView; -import org.eclipse.emf.spi.cdo.InternalCDOViewSet; import java.io.File; import java.io.FileNotFoundException; @@ -139,7 +133,7 @@ import java.util.Set; /** * @author Eike Stepper */ -public abstract class CDOSessionImpl extends Container<CDOView> implements InternalCDOSession +public abstract class CDOSessionImpl extends CDOTransactionContainerImpl implements InternalCDOSession { private ExceptionHandler exceptionHandler; @@ -197,17 +191,12 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter private InternalCDORemoteSessionManager remoteSessionManager; - private Set<InternalCDOView> views = new HashSet<InternalCDOView>(); - /** * A map to track for every object that was committed since this session's last refresh, onto what CDOBranchPoint it * was committed. (Used only for sticky transactions, see bug 290032 - Sticky views.) */ private Map<CDOID, CDOBranchPoint> committedSinceLastRefresh = new HashMap<CDOID, CDOBranchPoint>(); - @ExcludeFromDump - private int lastViewID; - public CDOSessionImpl() { } @@ -536,213 +525,17 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter lockmanager.unlock(LockType.WRITE, key, singletonCollection); } - public CDOTransaction openTransaction(CDOBranchPoint target, ResourceSet resourceSet) - { - checkArg(target.getTimeStamp() == CDOBranchPoint.UNSPECIFIED_DATE, "Target is not head of a branch: " + target); - return null; - } - - public CDOTransaction openTransaction(CDOBranchPoint target) - { - return openTransaction(target, createResourceSet()); - } - - public InternalCDOTransaction openTransaction(CDOBranch branch, ResourceSet resourceSet) - { - checkActive(); - InternalCDOTransaction transaction = createTransaction(branch); - initView(transaction, resourceSet); - return transaction; - } - - public InternalCDOTransaction openTransaction(ResourceSet resourceSet) - { - return openTransaction(getBranchManager().getMainBranch(), resourceSet); - } - - public InternalCDOTransaction openTransaction(CDOBranch branch) - { - return openTransaction(branch, createResourceSet()); - } - - /** - * @since 2.0 - */ - public InternalCDOTransaction openTransaction() - { - return openTransaction(getBranchManager().getMainBranch()); - } - - public CDOTransaction openTransaction(String durableLockingID) - { - return openTransaction(durableLockingID, createResourceSet()); - } - - public CDOTransaction openTransaction(String durableLockingID, ResourceSet resourceSet) - { - checkActive(); - InternalCDOTransaction transaction = createTransaction(durableLockingID); - initView(transaction, resourceSet); - return transaction; - } - - /** - * @since 2.0 - */ - protected InternalCDOTransaction createTransaction(CDOBranch branch) - { - return new CDOTransactionImpl(branch); - } - - /** - * @since 4.0 - */ - protected InternalCDOTransaction createTransaction(String durableLockingID) - { - return new CDOTransactionImpl(durableLockingID); - } - - public CDOView openView(CDOBranchPoint target, ResourceSet resourceSet) - { - return openView(target.getBranch(), target.getTimeStamp(), resourceSet); - } - - public CDOView openView(CDOBranchPoint target) - { - return openView(target, createResourceSet()); - } - - public InternalCDOView openView(CDOBranch branch, long timeStamp, ResourceSet resourceSet) - { - checkActive(); - InternalCDOView view = createView(branch, timeStamp); - initView(view, resourceSet); - return view; - } - - public InternalCDOView openView(CDOBranch branch, long timeStamp) - { - return openView(branch, timeStamp, createResourceSet()); - } - - public InternalCDOView openView(CDOBranch branch) - { - return openView(branch, CDOBranchPoint.UNSPECIFIED_DATE); - } - - public InternalCDOView openView(long timeStamp) - { - return openView(getBranchManager().getMainBranch(), timeStamp); - } - - public InternalCDOView openView(ResourceSet resourceSet) - { - return openView(getBranchManager().getMainBranch(), CDOBranchPoint.UNSPECIFIED_DATE, resourceSet); - } - - /** - * @since 2.0 - */ - public InternalCDOView openView() - { - return openView(CDOBranchPoint.UNSPECIFIED_DATE); - } - - public CDOView openView(String durableLockingID) - { - return openView(durableLockingID, createResourceSet()); - } - - public CDOView openView(String durableLockingID, ResourceSet resourceSet) - { - checkActive(); - InternalCDOView view = createView(durableLockingID); - initView(view, resourceSet); - return view; - } - - /** - * @since 2.0 - */ - protected InternalCDOView createView(CDOBranch branch, long timeStamp) - { - return new CDOViewImpl(branch, timeStamp); - } - - /** - * @since 4.0 - */ - protected InternalCDOView createView(String durableLockingID) - { - return new CDOViewImpl(durableLockingID); - } - - /** - * @since 2.0 - */ - public void viewDetached(InternalCDOView view) - { - // Detach viewset from the view - view.getViewSet().remove(view); - synchronized (views) - { - if (!views.remove(view)) - { - return; - } - } - - if (isActive()) - { - try - { - LifecycleUtil.deactivate(view); - } - catch (Exception ex) - { - throw WrappedException.wrap(ex); - } - } - - fireElementRemovedEvent(view); - } - - public CDOView getView(int viewID) - { - checkActive(); - for (InternalCDOView view : getViews()) - { - if (view.getViewID() == viewID) - { - return view; - } - } - - return null; - } - - /** - * @since 2.0 - */ - public InternalCDOView[] getViews() - { - checkActive(); - synchronized (views) - { - return views.toArray(new InternalCDOView[views.size()]); - } - } - - public CDOView[] getElements() + @Override + protected void initViewSynced(InternalCDOView view) { - return getViews(); + view.setSession(this); + view.setLastUpdateTime(getLastUpdateTime()); } @Override - public boolean isEmpty() + protected CDOBranch getMainBranch() { - checkActive(); - return views.isEmpty(); + return getBranchManager().getMainBranch(); } /** @@ -904,7 +697,7 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter public boolean waitForUpdate(long updateTime, long timeoutMillis) { long end = timeoutMillis == NO_TIMEOUT ? Long.MAX_VALUE : System.currentTimeMillis() + timeoutMillis; - for (CDOView view : views) + for (CDOView view : getViews()) { long viewTimeoutMillis = timeoutMillis == NO_TIMEOUT ? NO_TIMEOUT : end - System.currentTimeMillis(); boolean ok = view.waitForUpdate(updateTime, viewTimeoutMillis); @@ -1398,46 +1191,6 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter } } - protected ResourceSet createResourceSet() - { - return new ResourceSetImpl(); - } - - /** - * @since 2.0 - */ - protected void initView(InternalCDOView view, ResourceSet resourceSet) - { - InternalCDOViewSet viewSet = SessionUtil.prepareResourceSet(resourceSet); - synchronized (views) - { - view.setSession(this); - view.setViewID(++lastViewID); - view.setLastUpdateTime(getLastUpdateTime()); - views.add(view); - } - - // Link ViewSet with View - view.setViewSet(viewSet); - viewSet.add(view); - - try - { - view.activate(); - fireElementAddedEvent(view); - } - catch (RuntimeException ex) - { - synchronized (views) - { - views.remove(view); - } - - viewSet.remove(view); - throw ex; - } - } - @Override protected void doActivate() throws Exception { @@ -1455,18 +1208,8 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter @Override protected void doDeactivate() throws Exception { - for (InternalCDOView view : views.toArray(new InternalCDOView[views.size()])) - { - try - { - view.close(); - } - catch (RuntimeException ignore) - { - } - } + super.doDeactivate(); - views.clear(); outOfSequenceInvalidations.clear(); unhookSessionProtocol(); @@ -1478,8 +1221,6 @@ public abstract class CDOSessionImpl extends Container<CDOView> implements Inter CDOSessionProtocol sessionProtocol = getSessionProtocol(); LifecycleUtil.deactivate(sessionProtocol); setSessionProtocol(null); - - super.doDeactivate(); } /** diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOTransactionContainerImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOTransactionContainerImpl.java new file mode 100644 index 0000000000..848d6ca924 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOTransactionContainerImpl.java @@ -0,0 +1,134 @@ +/** + * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + * Simon McDuff - bug 226778 + * Simon McDuff - bug 230832 + * Simon McDuff - bug 233490 + * Simon McDuff - bug 213402 + * Victor Roldan Betancort - maintenance + */ +package org.eclipse.emf.internal.cdo.session; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.transaction.CDOTransactionContainer; +import org.eclipse.emf.cdo.view.CDOView; + +import org.eclipse.emf.internal.cdo.transaction.CDOTransactionImpl; + +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.spi.cdo.InternalCDOTransaction; +import org.eclipse.emf.spi.cdo.InternalCDOView; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Eike Stepper + */ +public abstract class CDOTransactionContainerImpl extends CDOViewContainerImpl implements CDOTransactionContainer +{ + public CDOTransactionContainerImpl() + { + } + + public InternalCDOTransaction getTransaction(int viewID) + { + CDOView view = getView(viewID); + if (view instanceof InternalCDOTransaction) + { + return (InternalCDOTransaction)view; + } + + return null; + } + + public InternalCDOTransaction[] getTransactions() + { + checkActive(); + List<InternalCDOTransaction> result = new ArrayList<InternalCDOTransaction>(); + + for (InternalCDOView view : getViews()) + { + if (view instanceof InternalCDOTransaction) + { + result.add((InternalCDOTransaction)view); + } + } + + return result.toArray(new InternalCDOTransaction[result.size()]); + } + + public CDOTransaction openTransaction(CDOBranchPoint target, ResourceSet resourceSet) + { + checkArg(target.getTimeStamp() == CDOBranchPoint.UNSPECIFIED_DATE, "Target is not head of a branch: " + target); + return null; + } + + public CDOTransaction openTransaction(CDOBranchPoint target) + { + return openTransaction(target, createResourceSet()); + } + + public InternalCDOTransaction openTransaction(CDOBranch branch, ResourceSet resourceSet) + { + checkActive(); + InternalCDOTransaction transaction = createTransaction(branch); + initView(transaction, resourceSet); + return transaction; + } + + public InternalCDOTransaction openTransaction(ResourceSet resourceSet) + { + return openTransaction(getMainBranch(), resourceSet); + } + + public InternalCDOTransaction openTransaction(CDOBranch branch) + { + return openTransaction(branch, createResourceSet()); + } + + /** + * @since 2.0 + */ + public InternalCDOTransaction openTransaction() + { + return openTransaction(getMainBranch()); + } + + public CDOTransaction openTransaction(String durableLockingID) + { + return openTransaction(durableLockingID, createResourceSet()); + } + + public CDOTransaction openTransaction(String durableLockingID, ResourceSet resourceSet) + { + checkActive(); + InternalCDOTransaction transaction = createTransaction(durableLockingID); + initView(transaction, resourceSet); + return transaction; + } + + /** + * @since 2.0 + */ + protected InternalCDOTransaction createTransaction(CDOBranch branch) + { + return new CDOTransactionImpl(branch); + } + + /** + * @since 4.0 + */ + protected InternalCDOTransaction createTransaction(String durableLockingID) + { + return new CDOTransactionImpl(durableLockingID); + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOViewContainerImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOViewContainerImpl.java new file mode 100644 index 0000000000..dd93c5eb29 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOViewContainerImpl.java @@ -0,0 +1,257 @@ +/** + * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + * Simon McDuff - bug 226778 + * Simon McDuff - bug 230832 + * Simon McDuff - bug 233490 + * Simon McDuff - bug 213402 + * Victor Roldan Betancort - maintenance + */ +package org.eclipse.emf.internal.cdo.session; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.view.CDOView; +import org.eclipse.emf.cdo.view.CDOViewContainer; + +import org.eclipse.emf.internal.cdo.view.CDOViewImpl; + +import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump; +import org.eclipse.net4j.util.WrappedException; +import org.eclipse.net4j.util.container.Container; +import org.eclipse.net4j.util.lifecycle.LifecycleUtil; + +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.spi.cdo.InternalCDOView; +import org.eclipse.emf.spi.cdo.InternalCDOViewSet; + +import java.util.HashSet; +import java.util.Set; + +/** + * @author Eike Stepper + */ +public abstract class CDOViewContainerImpl extends Container<CDOView> implements CDOViewContainer +{ + private Set<InternalCDOView> views = new HashSet<InternalCDOView>(); + + @ExcludeFromDump + private int lastViewID; + + public CDOViewContainerImpl() + { + } + + public CDOView getView(int viewID) + { + checkActive(); + for (InternalCDOView view : getViews()) + { + if (view.getViewID() == viewID) + { + return view; + } + } + + return null; + } + + /** + * @since 2.0 + */ + public InternalCDOView[] getViews() + { + checkActive(); + synchronized (views) + { + return views.toArray(new InternalCDOView[views.size()]); + } + } + + public CDOView[] getElements() + { + return getViews(); + } + + @Override + public boolean isEmpty() + { + checkActive(); + return views.isEmpty(); + } + + public CDOView openView(CDOBranchPoint target, ResourceSet resourceSet) + { + return openView(target.getBranch(), target.getTimeStamp(), resourceSet); + } + + public CDOView openView(CDOBranchPoint target) + { + return openView(target, createResourceSet()); + } + + public InternalCDOView openView(CDOBranch branch, long timeStamp, ResourceSet resourceSet) + { + checkActive(); + InternalCDOView view = createView(branch, timeStamp); + initView(view, resourceSet); + return view; + } + + public InternalCDOView openView(CDOBranch branch, long timeStamp) + { + return openView(branch, timeStamp, createResourceSet()); + } + + public InternalCDOView openView(CDOBranch branch) + { + return openView(branch, CDOBranchPoint.UNSPECIFIED_DATE); + } + + public InternalCDOView openView(long timeStamp) + { + return openView(getMainBranch(), timeStamp); + } + + public InternalCDOView openView(ResourceSet resourceSet) + { + return openView(getMainBranch(), CDOBranchPoint.UNSPECIFIED_DATE, resourceSet); + } + + /** + * @since 2.0 + */ + public InternalCDOView openView() + { + return openView(CDOBranchPoint.UNSPECIFIED_DATE); + } + + public CDOView openView(String durableLockingID) + { + return openView(durableLockingID, createResourceSet()); + } + + public CDOView openView(String durableLockingID, ResourceSet resourceSet) + { + checkActive(); + InternalCDOView view = createView(durableLockingID); + initView(view, resourceSet); + return view; + } + + /** + * @since 2.0 + */ + public void viewDetached(InternalCDOView view) + { + // Detach viewset from the view + view.getViewSet().remove(view); + synchronized (views) + { + if (!views.remove(view)) + { + return; + } + } + + if (isActive()) + { + try + { + LifecycleUtil.deactivate(view); + } + catch (Exception ex) + { + throw WrappedException.wrap(ex); + } + } + + fireElementRemovedEvent(view); + } + + /** + * @since 2.0 + */ + protected InternalCDOView createView(CDOBranch branch, long timeStamp) + { + return new CDOViewImpl(branch, timeStamp); + } + + /** + * @since 4.0 + */ + protected InternalCDOView createView(String durableLockingID) + { + return new CDOViewImpl(durableLockingID); + } + + protected ResourceSet createResourceSet() + { + return new ResourceSetImpl(); + } + + @Override + protected void doDeactivate() throws Exception + { + for (InternalCDOView view : views.toArray(new InternalCDOView[views.size()])) + { + try + { + view.close(); + } + catch (RuntimeException ignore) + { + } + } + + views.clear(); + super.doDeactivate(); + } + + /** + * @since 2.0 + */ + protected void initView(InternalCDOView view, ResourceSet resourceSet) + { + InternalCDOViewSet viewSet = SessionUtil.prepareResourceSet(resourceSet); + synchronized (views) + { + view.setViewID(++lastViewID); + initViewSynced(view); + views.add(view); + } + + // Link ViewSet with View + view.setViewSet(viewSet); + viewSet.add(view); + + try + { + view.activate(); + fireElementAddedEvent(view); + } + catch (RuntimeException ex) + { + synchronized (views) + { + views.remove(view); + } + + viewSet.remove(view); + throw ex; + } + } + + protected void initViewSynced(InternalCDOView view) + { + } + + protected abstract CDOBranch getMainBranch(); +} |