diff options
author | Eike Stepper | 2008-11-14 20:16:09 +0000 |
---|---|---|
committer | Eike Stepper | 2008-11-14 20:16:09 +0000 |
commit | 59b6e52cd6d890b1a3a83d89c4ed4eb93ac485eb (patch) | |
tree | a3b56a3b2e924e3ee273e37818340b02ad2242d4 /plugins/org.eclipse.emf.cdo/src/org/eclipse | |
parent | b90b1de0facff285594feef6563cad94209da11e (diff) | |
download | cdo-59b6e52cd6d890b1a3a83d89c4ed4eb93ac485eb.tar.gz cdo-59b6e52cd6d890b1a3a83d89c4ed4eb93ac485eb.tar.xz cdo-59b6e52cd6d890b1a3a83d89c4ed4eb93ac485eb.zip |
[255395] [POLISH] Introduce InternalCDOSession, InternalCDOView, ...
https://bugs.eclipse.org/bugs/show_bug.cgi?id=255395
Diffstat (limited to 'plugins/org.eclipse.emf.cdo/src/org/eclipse')
44 files changed, 706 insertions, 391 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionPackageManager.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionPackageManager.java index 16f9435350..8223614238 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionPackageManager.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionPackageManager.java @@ -15,8 +15,6 @@ import org.eclipse.emf.cdo.common.model.CDOFeature; import org.eclipse.emf.cdo.common.model.CDOPackage; import org.eclipse.emf.cdo.common.model.CDOPackageManager; -import org.eclipse.emf.internal.cdo.CDOSessionImpl; - import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EStructuralFeature; @@ -30,7 +28,7 @@ public interface CDOSessionPackageManager extends CDOPackageManager /** * @since 2.0 */ - public CDOSessionImpl getSession(); + public CDOSession getSession(); public CDOPackage convert(EPackage ePackage); diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFactoryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFactoryImpl.java index da87dba0a4..d5e8a83248 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFactoryImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceFactoryImpl.java @@ -16,8 +16,8 @@ import org.eclipse.emf.cdo.CDOViewSet; import org.eclipse.emf.cdo.eresource.CDOResourceFactory; import org.eclipse.emf.cdo.util.CDOURIUtil; -import org.eclipse.emf.internal.cdo.CDOViewImpl; import org.eclipse.emf.internal.cdo.CDOViewSetImpl; +import org.eclipse.emf.internal.cdo.InternalCDOView; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.resource.Resource; @@ -49,7 +49,7 @@ public class CDOResourceFactoryImpl implements Resource.Factory, CDOResourceFact String repositoryUUID = CDOURIUtil.extractRepositoryUUID(uri); // repoUUID can be null but can be null - CDOViewImpl view = viewSet.resolveView(repositoryUUID); + InternalCDOView view = viewSet.resolveView(repositoryUUID); String path = CDOURIUtil.extractResourcePath(uri); // Build a new URI with the view and the path diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java index e39b44c9f6..bad59b18ab 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java @@ -22,9 +22,9 @@ import org.eclipse.emf.cdo.util.CDOURIUtil; import org.eclipse.emf.cdo.util.ObjectNotFoundException; import org.eclipse.emf.internal.cdo.CDOStateMachine; -import org.eclipse.emf.internal.cdo.CDOTransactionImpl; -import org.eclipse.emf.internal.cdo.CDOViewImpl; import org.eclipse.emf.internal.cdo.InternalCDOObject; +import org.eclipse.emf.internal.cdo.InternalCDOTransaction; +import org.eclipse.emf.internal.cdo.InternalCDOView; import org.eclipse.emf.internal.cdo.util.FSMUtil; import org.eclipse.emf.common.notify.Notification; @@ -564,7 +564,7 @@ public class CDOResourceImpl extends CDOResourceNodeImpl implements CDOResource, { if (!isLoaded()) { - CDOViewImpl view = cdoView(); + InternalCDOView view = cdoView(); if (!FSMUtil.isTransient(this)) { CDOID id = cdoID(); @@ -720,7 +720,7 @@ public class CDOResourceImpl extends CDOResourceNodeImpl implements CDOResource, if (getFolder() == null) { - CDOViewImpl view = cdoView(); + InternalCDOView view = cdoView(); view.getRootResource().getContents().remove(this); } else @@ -764,7 +764,7 @@ public class CDOResourceImpl extends CDOResourceNodeImpl implements CDOResource, /** * @ADDED */ - private void attached(InternalCDOObject cdoObject, CDOTransactionImpl transaction) + private void attached(InternalCDOObject cdoObject, InternalCDOTransaction transaction) { CDOStateMachine.INSTANCE.attach(cdoObject, transaction); } @@ -903,7 +903,7 @@ public class CDOResourceImpl extends CDOResourceNodeImpl implements CDOResource, } else { - CDOTransactionImpl transaction = cdoView().toTransaction(); + InternalCDOTransaction transaction = cdoView().toTransaction(); InternalCDOObject cdoObject = FSMUtil.adapt(object, transaction); notifications = cdoObject.eSetResource(CDOResourceImpl.this, notifications); diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceNodeImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceNodeImpl.java index 4dee625f88..b485be8b94 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceNodeImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceNodeImpl.java @@ -2,7 +2,7 @@ * <copyright> * </copyright> * - * $Id: CDOResourceNodeImpl.java,v 1.3 2008-10-20 22:47:22 smcduff Exp $ + * $Id: CDOResourceNodeImpl.java,v 1.4 2008-11-14 20:16:06 estepper Exp $ */ package org.eclipse.emf.cdo.eresource.impl; @@ -13,7 +13,7 @@ import org.eclipse.emf.cdo.eresource.EresourcePackage; import org.eclipse.emf.cdo.util.CDOURIUtil; import org.eclipse.emf.internal.cdo.CDOObjectImpl; -import org.eclipse.emf.internal.cdo.CDOTransactionImpl; +import org.eclipse.emf.internal.cdo.InternalCDOTransaction; import org.eclipse.net4j.util.ObjectUtil; @@ -198,7 +198,7 @@ public abstract class CDOResourceNodeImpl extends CDOObjectImpl implements CDORe */ public void setPath(String newPath) { - CDOTransactionImpl transaction = cdoView().toTransaction(); + InternalCDOTransaction transaction = cdoView().toTransaction(); if (newPath == null) { throw new CDOException("Null path is not allowed"); diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java index e7291133c9..c1a232e938 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java @@ -25,9 +25,9 @@ import org.eclipse.emf.internal.cdo.CDOCollectionLoadingPolicyImpl; import org.eclipse.emf.internal.cdo.CDORevisionPrefetchingPolicyImpl; import org.eclipse.emf.internal.cdo.CDOSessionConfigurationImpl; import org.eclipse.emf.internal.cdo.CDOStateMachine; -import org.eclipse.emf.internal.cdo.CDOViewImpl; import org.eclipse.emf.internal.cdo.CDOXATransactionImpl; import org.eclipse.emf.internal.cdo.InternalCDOObject; +import org.eclipse.emf.internal.cdo.InternalCDOView; import org.eclipse.emf.internal.cdo.protocol.CDOClientProtocolFactory; import org.eclipse.emf.internal.cdo.util.CDOPackageRegistryImpl; import org.eclipse.emf.internal.cdo.util.FSMUtil; @@ -218,7 +218,7 @@ public final class CDOUtil InternalCDOObject cdoObject = FSMUtil.adapt(eObject, view); CDOStateMachine.INSTANCE.read(cdoObject); - for (Iterator<InternalCDOObject> it = FSMUtil.iterator(cdoObject.eContents(), (CDOViewImpl)view); it.hasNext();) + for (Iterator<InternalCDOObject> it = FSMUtil.iterator(cdoObject.eContents(), (InternalCDOView)view); it.hasNext();) { InternalCDOObject content = it.next(); load(content, view); diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAuditImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAuditImpl.java index c4e3a32109..9537bf1721 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAuditImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAuditImpl.java @@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.revision.CDORevisionResolver; import org.eclipse.emf.cdo.spi.common.InternalCDORevision; +import org.eclipse.emf.internal.cdo.protocol.CDOClientProtocol; import org.eclipse.emf.internal.cdo.protocol.SetAuditRequest; import org.eclipse.net4j.util.WrappedException; @@ -30,7 +31,10 @@ public class CDOAuditImpl extends CDOViewImpl implements CDOAudit { private long timeStamp; - public CDOAuditImpl(int id, CDOSessionImpl session, long timeStamp) + /** + * @since 2.0 + */ + public CDOAuditImpl(InternalCDOSession session, int id, long timeStamp) { super(session, id); this.timeStamp = timeStamp; @@ -81,8 +85,8 @@ public class CDOAuditImpl extends CDOViewImpl implements CDOAudit { try { - CDOSessionImpl session = getSession(); - return new SetAuditRequest(session.getProtocol(), getViewID(), timeStamp, invalidObjects).send(); + CDOClientProtocol protocol = (CDOClientProtocol)getSession().getProtocol(); + return new SetAuditRequest(protocol, getViewID(), timeStamp, invalidObjects).send(); } catch (Exception ex) { @@ -94,7 +98,7 @@ public class CDOAuditImpl extends CDOViewImpl implements CDOAudit public InternalCDORevision getRevision(CDOID id, boolean loadOnDemand) { checkOpen(); - CDOSessionImpl session = getSession(); + InternalCDOSession session = getSession(); int initialChunkSize = session.getCollectionLoadingPolicy().getInitialChunkSize(); CDORevisionResolver revisionManager = session.getRevisionManager(); diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyWrapper.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyWrapper.java index 483ea8f60e..7fb3b5fc22 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyWrapper.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyWrapper.java @@ -159,7 +159,7 @@ public final class CDOLegacyWrapper extends CDOObjectWrapper instanceToRevision(); if (cdoState() == CDOState.DIRTY) // NEW is handled in PrepareTransition { - CDORevisionManagerImpl revisionManager = cdoView().getSession().getRevisionManager(); + CDORevisionManagerImpl revisionManager = (CDORevisionManagerImpl)cdoView().getSession().getRevisionManager(); InternalCDORevision originRevision = revisionManager.getRevisionByVersion(revision.getID(), CDORevision.UNCHUNKED, revision.getVersion() - 1, false); CDORevisionDelta delta = revision.compare(originRevision); @@ -516,7 +516,7 @@ public final class CDOLegacyWrapper extends CDOObjectWrapper * that will be used later to resolve the proxy. <code>null</code> indicates that proxy creation will be * avoided! */ - private InternalEObject getEObjectFromPotentialID(CDOViewImpl view, CDOFeature feature, Object potentialID) + private InternalEObject getEObjectFromPotentialID(InternalCDOView view, CDOFeature feature, Object potentialID) { if (potentialID instanceof CDOID) { @@ -557,7 +557,7 @@ public final class CDOLegacyWrapper extends CDOObjectWrapper * <p> * TODO {@link InternalEObject#eResolveProxy(InternalEObject) */ - private InternalEObject createProxy(CDOViewImpl view, CDOFeature feature, CDOID id) + private InternalEObject createProxy(InternalCDOView view, CDOFeature feature, CDOID id) { CDOPackageRegistry packageRegistry = view.getSession().getPackageRegistry(); EStructuralFeature eFeature = ModelUtil.getEFeature(feature, packageRegistry); @@ -611,7 +611,7 @@ public final class CDOLegacyWrapper extends CDOObjectWrapper if (element instanceof LegacyProxy) { CDOID id = ((LegacyProxy)element).getID(); - InternalCDOObject resolved = view.getObject(id); + InternalCDOObject resolved = (InternalCDOObject)view.getObject(id); InternalEObject instance = resolved.cdoInternalInstance(); // TODO LEGACY @@ -637,7 +637,7 @@ public final class CDOLegacyWrapper extends CDOObjectWrapper if (value instanceof LegacyProxy) { CDOID id = ((LegacyProxy)value).getID(); - InternalCDOObject resolved = view.getObject(id); + InternalCDOObject resolved = (InternalCDOObject)view.getObject(id); InternalEObject instance = resolved.cdoInternalInstance(); setInstanceValue(instance, feature, instance); } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOMetaWrapper.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOMetaWrapper.java index 9020dbf1e2..75c9a198dc 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOMetaWrapper.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOMetaWrapper.java @@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.model.CDOClass; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl; +import org.eclipse.emf.cdo.spi.common.InternalCDORevision; import org.eclipse.emf.ecore.InternalEObject; @@ -24,7 +25,7 @@ import org.eclipse.emf.ecore.InternalEObject; */ public class CDOMetaWrapper extends CDOObjectWrapper { - public CDOMetaWrapper(CDOViewImpl view, InternalEObject instance, CDOID id) + public CDOMetaWrapper(InternalCDOView view, InternalEObject instance, CDOID id) { this.view = view; this.instance = instance; @@ -36,7 +37,7 @@ public class CDOMetaWrapper extends CDOObjectWrapper return CDOState.CLEAN; } - public CDORevision cdoRevision() + public InternalCDORevision cdoRevision() { throw new UnsupportedOperationException(); } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java index 0aaf941388..6b2f44b2c8 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java @@ -76,7 +76,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec private CDOState state; - private CDOViewImpl view; + private InternalCDOView view; private InternalCDORevision revision; @@ -137,7 +137,10 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec return getCDOClass(this); } - public CDOViewImpl cdoView() + /** + * @since 2.0 + */ + public InternalCDOView cdoView() { return view; } @@ -217,7 +220,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec public void cdoInternalSetView(CDOView view) { - this.view = (CDOViewImpl)view; + this.view = (InternalCDOView)view; if (this.view != null) { eSetStore(this.view.getStore()); @@ -276,7 +279,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec TRACER.format("Populating revision for {0}", this); } - CDOViewImpl view = cdoView(); + InternalCDOView view = cdoView(); revision.setContainerID(eContainer == null ? CDOID.NULL : cdoView().convertObjectToID(eContainer, true)); revision.setContainingFeatureID(eContainerFeatureID); @@ -329,10 +332,10 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec } @SuppressWarnings("unchecked") - private void populateRevisionFeature(CDOViewImpl view, InternalCDORevision revision, EStructuralFeature eFeature, + private void populateRevisionFeature(InternalCDOView view, InternalCDORevision revision, EStructuralFeature eFeature, Object[] eSettings, int i) { - CDOSessionPackageManagerImpl packageManager = view.getSession().getPackageManager(); + CDOSessionPackageManagerImpl packageManager = (CDOSessionPackageManagerImpl)view.getSession().getPackageManager(); CDOFeature cdoFeature = packageManager.getCDOFeature(eFeature); if (TRACER.isEnabled()) { @@ -377,7 +380,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec TRACER.format("Depopulating revision for {0}", this); } - CDOViewImpl view = cdoView(); + InternalCDOView view = cdoView(); super.eSetDirectResource((Resource.Internal)cdoStore().getResource(this)); CDOStore store = cdoStore(); @@ -408,8 +411,8 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec cdoSettings(); } - private void depopulateRevisionFeature(CDOViewImpl view, InternalCDORevision revision, EStructuralFeature eFeature, - Object[] eSettings, int i) + private void depopulateRevisionFeature(InternalCDOView view, InternalCDORevision revision, + EStructuralFeature eFeature, Object[] eSettings, int i) { if (TRACER.isEnabled()) { @@ -978,8 +981,8 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec static CDOClass getCDOClass(InternalCDOObject cdoObject) { - CDOViewImpl view = (CDOViewImpl)cdoObject.cdoView(); - CDOSessionPackageManagerImpl packageManager = view.getSession().getPackageManager(); + InternalCDOView view = cdoObject.cdoView(); + CDOSessionPackageManagerImpl packageManager = (CDOSessionPackageManagerImpl)view.getSession().getPackageManager(); return ModelUtil.getCDOClass(cdoObject.eClass(), packageManager); } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectWrapper.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectWrapper.java index 54b83f104a..c98660881c 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectWrapper.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectWrapper.java @@ -43,7 +43,7 @@ public abstract class CDOObjectWrapper implements InternalCDOObject protected CDOID id; - protected CDOViewImpl view; + protected InternalCDOView view; protected InternalEObject instance; @@ -57,7 +57,7 @@ public abstract class CDOObjectWrapper implements InternalCDOObject return id; } - public CDOViewImpl cdoView() + public InternalCDOView cdoView() { return view; } @@ -109,7 +109,7 @@ public abstract class CDOObjectWrapper implements InternalCDOObject TRACER.format("Setting view: {0} for {1}", view, instance); } - this.view = (CDOViewImpl)view; + this.view = (InternalCDOView)view; } public InternalEObject cdoInternalInstance() diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java index b6d3d63445..9c5eb44b46 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDORevisionManagerImpl.java @@ -42,16 +42,22 @@ public class CDORevisionManagerImpl extends CDORevisionResolverImpl implements C { private static final PerfTracer LOADING = new PerfTracer(OM.PERF_REVISION_LOADING, CDORevisionManagerImpl.class); - private CDOSessionImpl session; + private InternalCDOSession session; private CDOFetchRuleManager ruleManager = CDOFetchRuleManager.NOOP; - public CDORevisionManagerImpl(CDOSessionImpl session) + /** + * @since 2.0 + */ + public CDORevisionManagerImpl(InternalCDOSession session) { this.session = session; } - public CDOSessionImpl getSession() + /** + * @since 2.0 + */ + public InternalCDOSession getSession() { return session; } @@ -77,7 +83,7 @@ public class CDORevisionManagerImpl extends CDORevisionResolverImpl implements C { try { - CDOClientProtocol protocol = session.getProtocol(); + CDOClientProtocol protocol = (CDOClientProtocol)session.getProtocol(); return new LoadChunkRequest(protocol, (InternalCDORevision)revision, feature, accessIndex, fetchIndex, fromIndex, toIndex).send(); } @@ -94,35 +100,35 @@ public class CDORevisionManagerImpl extends CDORevisionResolverImpl implements C @Override protected InternalCDORevision loadRevision(CDOID id, int referenceChunk) { - CDOClientProtocol protocol = session.getProtocol(); + CDOClientProtocol protocol = (CDOClientProtocol)session.getProtocol(); return send(new LoadRevisionRequest(protocol, Collections.singleton(id), referenceChunk)).get(0); } @Override protected InternalCDORevision loadRevisionByTime(CDOID id, int referenceChunk, long timeStamp) { - CDOClientProtocol protocol = session.getProtocol(); + CDOClientProtocol protocol = (CDOClientProtocol)session.getProtocol(); return send(new LoadRevisionByTimeRequest(protocol, Collections.singleton(id), referenceChunk, timeStamp)).get(0); } @Override protected InternalCDORevision loadRevisionByVersion(CDOID id, int referenceChunk, int version) { - CDOClientProtocol protocol = session.getProtocol(); + CDOClientProtocol protocol = (CDOClientProtocol)session.getProtocol(); return send(new LoadRevisionByVersionRequest(protocol, id, referenceChunk, version)).get(0); } @Override protected List<InternalCDORevision> loadRevisions(Collection<CDOID> ids, int referenceChunk) { - CDOClientProtocol protocol = session.getProtocol(); + CDOClientProtocol protocol = (CDOClientProtocol)session.getProtocol(); return send(new LoadRevisionRequest(protocol, ids, referenceChunk)); } @Override protected List<InternalCDORevision> loadRevisionsByTime(Collection<CDOID> ids, int referenceChunk, long timeStamp) { - CDOClientProtocol protocol = session.getProtocol(); + CDOClientProtocol protocol = (CDOClientProtocol)session.getProtocol(); return send(new LoadRevisionByTimeRequest(protocol, ids, referenceChunk, timeStamp)); } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSavepointImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSavepointImpl.java index 6ecaf0ce26..b7143ce57c 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSavepointImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSavepointImpl.java @@ -74,7 +74,7 @@ public class CDOSavepointImpl extends CDOAbstractSavepoint private boolean isDirty; - public CDOSavepointImpl(CDOTransactionImpl transaction, CDOSavepointImpl lastSavepoint) + public CDOSavepointImpl(InternalCDOTransaction transaction, CDOSavepointImpl lastSavepoint) { super(transaction, lastSavepoint); isDirty = transaction.isDirty(); diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionConfigurationImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionConfigurationImpl.java index 0368989405..573cfee603 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionConfigurationImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionConfigurationImpl.java @@ -10,12 +10,13 @@ **************************************************************************/ package org.eclipse.emf.internal.cdo; -import org.eclipse.emf.cdo.CDOSession; import org.eclipse.emf.cdo.CDOSessionConfiguration; import org.eclipse.emf.cdo.common.revision.cache.CDORevisionCache; import org.eclipse.emf.cdo.util.CDOPackageRegistry; import org.eclipse.emf.cdo.util.CDOUtil; +import org.eclipse.emf.internal.cdo.util.SessionUtil; + import org.eclipse.net4j.connector.IConnector; import org.eclipse.net4j.signal.failover.IFailOverStrategy; import org.eclipse.net4j.signal.failover.NOOPFailOverStrategy; @@ -26,7 +27,7 @@ import org.eclipse.net4j.util.CheckUtil; */ public class CDOSessionConfigurationImpl implements CDOSessionConfiguration { - private CDOSessionImpl session; + private InternalCDOSession session; private IConnector connector; @@ -138,14 +139,17 @@ public class CDOSessionConfigurationImpl implements CDOSessionConfiguration this.activateOnOpen = activateOnOpen; } - public CDOSession openSession() + /** + * @since 2.0 + */ + public InternalCDOSession openSession() { CheckUtil.checkState(connector != null ^ failOverStrategy != null, "Specify exactly one of connector or failOverStrategy"); if (!isSessionOpen()) { - session = new CDOSessionImpl(); + session = SessionUtil.createSession(); if (connector != null) { session.getProtocol().setFailOverStrategy(new NOOPFailOverStrategy(connector)); diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java index 55b801c7f0..726d35f45f 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionFactory.java @@ -13,6 +13,7 @@ package org.eclipse.emf.internal.cdo; import org.eclipse.emf.cdo.CDOSession; import org.eclipse.emf.internal.cdo.util.CDOPackageRegistryImpl; +import org.eclipse.emf.internal.cdo.util.SessionUtil; import org.eclipse.net4j.signal.failover.IFailOverStrategy; import org.eclipse.net4j.util.StringUtil; @@ -92,10 +93,10 @@ public class CDOSessionFactory extends Factory /** * @since 2.0 */ - public static CDOSessionImpl createSession(String repositoryName, boolean automaticPackageRegistry, + public static InternalCDOSession createSession(String repositoryName, boolean automaticPackageRegistry, IFailOverStrategy failOverStrategy) { - CDOSessionImpl session = new CDOSessionImpl(); + InternalCDOSession session = SessionUtil.createSession(); if (automaticPackageRegistry) { CDOPackageRegistryImpl.Eager packageRegistry = new CDOPackageRegistryImpl.Eager(); diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java index 5524c10d72..1b274b4383 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java @@ -20,7 +20,6 @@ import org.eclipse.emf.cdo.CDOSession; import org.eclipse.emf.cdo.CDOSessionInvalidationEvent; import org.eclipse.emf.cdo.CDOTimeStampContext; import org.eclipse.emf.cdo.CDOView; -import org.eclipse.emf.cdo.CDOViewSet; import org.eclipse.emf.cdo.common.CDOProtocolConstants; import org.eclipse.emf.cdo.common.CDOProtocolView; import org.eclipse.emf.cdo.common.id.CDOID; @@ -33,7 +32,6 @@ import org.eclipse.emf.cdo.common.id.CDOIDTemp; import org.eclipse.emf.cdo.common.id.CDOIDTempMeta; import org.eclipse.emf.cdo.common.id.CDOIDUtil; import org.eclipse.emf.cdo.common.model.CDOPackage; -import org.eclipse.emf.cdo.common.model.CDOPackageURICompressor; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; import org.eclipse.emf.cdo.spi.common.InternalCDORevision; @@ -52,6 +50,7 @@ import org.eclipse.emf.internal.cdo.protocol.SyncRevisionRequest; import org.eclipse.emf.internal.cdo.protocol.ViewsChangedRequest; import org.eclipse.emf.internal.cdo.util.CDOPackageRegistryImpl; import org.eclipse.emf.internal.cdo.util.ModelUtil; +import org.eclipse.emf.internal.cdo.util.SessionUtil; import org.eclipse.net4j.channel.IChannel; import org.eclipse.net4j.util.ImplementationError; @@ -70,7 +69,6 @@ import org.eclipse.net4j.util.lifecycle.ILifecycle; import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter; import org.eclipse.net4j.util.om.trace.ContextTracer; -import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.resource.ResourceSet; @@ -91,8 +89,7 @@ import java.util.Set; /** * @author Eike Stepper */ -public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CDOIDObjectFactory, - CDOPackageURICompressor +public class CDOSessionImpl extends Container<CDOView> implements InternalCDOSession { private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SESSION, CDOSessionImpl.class); @@ -128,7 +125,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD private CDORevisionManagerImpl revisionManager; - private Set<CDOViewImpl> views = new HashSet<CDOViewImpl>(); + private Set<InternalCDOView> views = new HashSet<InternalCDOView>(); private QueueRunner invalidationRunner; @@ -213,9 +210,6 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD collectionLoadingPolicy = policy; } - /** - * @noreference This method is not intended to be referenced by clients. - */ public CDOClientProtocol getProtocol() { return protocol; @@ -321,38 +315,56 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD return revisionManager; } - public CDOTransactionImpl openTransaction(ResourceSet resourceSet) + /** + * @since 2.0 + */ + public InternalCDOTransaction openTransaction(ResourceSet resourceSet) { checkActive(); - CDOTransactionImpl transaction = createTransaction(++lastViewID); + InternalCDOTransaction transaction = createTransaction(++lastViewID); attach(resourceSet, transaction); return transaction; } - public CDOTransactionImpl openTransaction() + /** + * @since 2.0 + */ + public InternalCDOTransaction openTransaction() { return openTransaction(createResourceSet()); } - protected CDOTransactionImpl createTransaction(int id) + /** + * @since 2.0 + */ + protected InternalCDOTransaction createTransaction(int id) { - return new CDOTransactionImpl(id, this); + return new CDOTransactionImpl(this, id); } - public CDOViewImpl openView(ResourceSet resourceSet) + /** + * @since 2.0 + */ + public InternalCDOView openView(ResourceSet resourceSet) { checkActive(); - CDOViewImpl view = createView(++lastViewID); + InternalCDOView view = createView(++lastViewID); attach(resourceSet, view); return view; } - public CDOViewImpl openView() + /** + * @since 2.0 + */ + public InternalCDOView openView() { return openView(createResourceSet()); } - protected CDOViewImpl createView(int id) + /** + * @since 2.0 + */ + protected InternalCDOView createView(int id) { return new CDOViewImpl(this, id); } @@ -372,13 +384,16 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD protected CDOAuditImpl createAudit(int id, long timeStamp) { - return new CDOAuditImpl(id, this, timeStamp); + return new CDOAuditImpl(this, id, timeStamp); } - public void viewDetached(CDOViewImpl view) + /** + * @since 2.0 + */ + public void viewDetached(InternalCDOView view) { // Detach viewset from the view - ((CDOViewSetImpl)view.getViewSet()).remove(view); + view.getViewSet().remove(view); synchronized (views) { if (!views.remove(view)) @@ -403,7 +418,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD fireElementRemovedEvent(view); } - private void sendViewsChangedRequest(CDOViewImpl view) + private void sendViewsChangedRequest(InternalCDOView view) { try { @@ -423,7 +438,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD } } - private byte getKind(CDOViewImpl view) + private byte getKind(InternalCDOView view) { CDOView.Type type = view.getViewType(); switch (type) @@ -445,7 +460,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD public CDOView getView(int viewID) { checkActive(); - for (CDOViewImpl view : getViews()) + for (InternalCDOView view : getViews()) { if (view.getViewID() == viewID) { @@ -456,12 +471,15 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD return null; } - public CDOViewImpl[] getViews() + /** + * @since 2.0 + */ + public InternalCDOView[] getViews() { checkActive(); synchronized (views) { - return views.toArray(new CDOViewImpl[views.size()]); + return views.toArray(new InternalCDOView[views.size()]); } } @@ -519,7 +537,8 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD } CDOIDMetaRange range = CDOIDUtil.createMetaRange(metaIDRange.getLowerBound(), 0); - range = registerMetaInstance((InternalEObject)ePackage, range, idToMetaInstanceMap, metaInstanceToIDMap); + range = SessionUtil + .registerMetaInstance((InternalEObject)ePackage, range, idToMetaInstanceMap, metaInstanceToIDMap); if (range.size() != metaIDRange.size()) { throw new IllegalStateException("range.size() != metaIDRange.size()"); @@ -528,54 +547,12 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD public CDOIDMetaRange registerEPackage(EPackage ePackage) { - CDOIDMetaRange range = registerEPackage(ePackage, lastTempMetaID + 1, idToMetaInstanceMap, metaInstanceToIDMap); + CDOIDMetaRange range = SessionUtil.registerEPackage(ePackage, lastTempMetaID + 1, idToMetaInstanceMap, + metaInstanceToIDMap); lastTempMetaID = ((CDOIDTempMeta)range.getUpperBound()).getIntValue(); return range; } - public static CDOIDMetaRange registerEPackage(EPackage ePackage, int firstMetaID, - Map<CDOID, InternalEObject> idToMetaInstances, Map<InternalEObject, CDOID> metaInstanceToIDs) - { - CDOIDTemp lowerBound = CDOIDUtil.createTempMeta(firstMetaID); - CDOIDMetaRange range = CDOIDUtil.createMetaRange(lowerBound, 0); - range = registerMetaInstance((InternalEObject)ePackage, range, idToMetaInstances, metaInstanceToIDs); - return range; - } - - public static CDOIDMetaRange registerMetaInstance(InternalEObject metaInstance, CDOIDMetaRange range, - Map<CDOID, InternalEObject> idToMetaInstances, Map<InternalEObject, CDOID> metaInstanceToIDs) - { - range = range.increase(); - CDOID id = range.getUpperBound(); - if (TRACER.isEnabled()) - { - TRACER.format("Registering meta instance: {0} <-> {1}", id, metaInstance); - } - - if (idToMetaInstances != null) - { - if (idToMetaInstances.put(id, metaInstance) != null) - { - throw new IllegalStateException("Duplicate meta ID: " + id + " --> " + metaInstance); - } - } - - if (metaInstanceToIDs != null) - { - if (metaInstanceToIDs.put(metaInstance, id) != null) - { - throw new IllegalStateException("Duplicate metaInstance: " + metaInstance + " --> " + id); - } - } - - for (EObject content : metaInstance.eContents()) - { - range = registerMetaInstance((InternalEObject)content, range, idToMetaInstances, metaInstanceToIDs); - } - - return range; - } - public void remapMetaInstance(CDOID oldID, CDOID newID) { InternalEObject metaInstance = idToMetaInstanceMap.remove(oldID); @@ -597,7 +574,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD * @since 2.0 */ public void handleCommitNotification(long timeStamp, Set<CDOIDAndVersion> dirtyOIDs, - Collection<CDOID> detachedObjects, Collection<CDORevisionDelta> deltas, CDOViewImpl excludedView) + Collection<CDOID> detachedObjects, Collection<CDORevisionDelta> deltas, InternalCDOView excludedView) { if (isPassiveUpdateEnabled()) { @@ -617,7 +594,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD } private void notifyInvalidation(final long timeStamp, Set<CDOIDAndVersion> dirtyOIDs, - Collection<CDOID> detachedObjects, CDOViewImpl excludedView, boolean async) + Collection<CDOID> detachedObjects, InternalCDOView excludedView, boolean async) { // revised is done automatically when postCommit is CDOTransaction.postCommit is happening @@ -656,7 +633,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD final Set<CDOIDAndVersion> finalDirtyOIDs = Collections.unmodifiableSet(dirtyOIDs); final Collection<CDOID> finalDetachedObjects = Collections.unmodifiableCollection(detachedObjects); - for (final CDOViewImpl view : getViews()) + for (final InternalCDOView view : getViews()) { if (view != excludedView) { @@ -703,13 +680,13 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD } private void handleChangeSubcription(Collection<CDORevisionDelta> deltas, Collection<CDOID> detachedObjects, - CDOViewImpl excludedView) + InternalCDOView excludedView) { if ((deltas == null || deltas.size() <= 0) && (detachedObjects == null || detachedObjects.size() <= 0)) { return; } - for (CDOViewImpl view : getViews()) + for (InternalCDOView view : getViews()) { if (view != excludedView) { @@ -729,7 +706,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD * @since 2.0 */ public void fireInvalidationEvent(long timeStamp, Set<CDOIDAndVersion> dirtyOIDs, Collection<CDOID> detachedObjects, - CDOViewImpl excludedView) + InternalCDOView excludedView) { fireEvent(new InvalidationEvent(excludedView, timeStamp, dirtyOIDs, detachedObjects)); } @@ -780,9 +757,12 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD return new ResourceSetImpl(); } - protected void attach(ResourceSet resourceSet, CDOViewImpl view) + /** + * @since 2.0 + */ + protected void attach(ResourceSet resourceSet, InternalCDOView view) { - CDOViewSet viewSet = CDOSessionImpl.prepareResourceSet(resourceSet); + InternalCDOViewSet viewSet = SessionUtil.prepareResourceSet(resourceSet); synchronized (views) { views.add(view); @@ -790,7 +770,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD // Link ViewSet with View view.setViewSet(viewSet); - ((CDOViewSetImpl)viewSet).add(view); + viewSet.add(view); sendViewsChangedRequest(view); fireElementAddedEvent(view); @@ -831,7 +811,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD @Override protected void doDeactivate() throws Exception { - for (CDOViewImpl view : views.toArray(new CDOViewImpl[views.size()])) + for (InternalCDOView view : views.toArray(new InternalCDOView[views.size()])) { try { @@ -938,7 +918,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD private Map<CDOID, CDORevision> getAllRevisions() { Map<CDOID, CDORevision> uniqueObjects = new HashMap<CDOID, CDORevision>(); - for (CDOViewImpl view : getViews()) + for (InternalCDOView view : getViews()) { for (InternalCDOObject internalCDOObject : view.getObjectsArray()) { @@ -1020,32 +1000,13 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD } /** - * @since 2.0 - */ - public static CDOViewSet prepareResourceSet(ResourceSet resourceSet) - { - CDOViewSetImpl viewSet = null; - synchronized (resourceSet) - { - viewSet = (CDOViewSetImpl)CDOUtil.getViewSet(resourceSet); - if (viewSet == null) - { - viewSet = new CDOViewSetImpl(); - resourceSet.eAdapters().add(viewSet); - } - } - - return viewSet; - } - - /** * @author Eike Stepper */ private final class InvalidationEvent extends Event implements CDOSessionInvalidationEvent { private static final long serialVersionUID = 1L; - private CDOViewImpl view; + private InternalCDOView view; private long timeStamp; @@ -1053,7 +1014,7 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD private Collection<CDOID> detachedObjects; - public InvalidationEvent(CDOViewImpl view, long timeStamp, Set<CDOIDAndVersion> dirtyOIDs, + public InvalidationEvent(InternalCDOView view, long timeStamp, Set<CDOIDAndVersion> dirtyOIDs, Collection<CDOID> detachedObjects) { super(CDOSessionImpl.this); @@ -1065,10 +1026,10 @@ public class CDOSessionImpl extends Container<CDOView> implements CDOSession, CD public CDOSession getSession() { - return CDOSessionImpl.this; + return (CDOSession)getSource(); } - public CDOViewImpl getView() + public InternalCDOView getView() { return view; } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManagerImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManagerImpl.java index c394715380..481ef2afcd 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManagerImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManagerImpl.java @@ -24,6 +24,7 @@ import org.eclipse.emf.cdo.internal.common.model.CDOPackageManagerImpl; import org.eclipse.emf.cdo.spi.common.InternalCDOPackage; import org.eclipse.emf.internal.cdo.bundle.OM; +import org.eclipse.emf.internal.cdo.protocol.CDOClientProtocol; import org.eclipse.emf.internal.cdo.protocol.LoadPackageRequest; import org.eclipse.emf.internal.cdo.util.ModelUtil; @@ -40,7 +41,7 @@ import java.util.concurrent.ConcurrentHashMap; */ public class CDOSessionPackageManagerImpl extends CDOPackageManagerImpl implements CDOSessionPackageManager { - private CDOSessionImpl session; + private InternalCDOSession session; /** * For optimization only. Instead of doing 3 lookups we are doing only one. @@ -54,13 +55,19 @@ public class CDOSessionPackageManagerImpl extends CDOPackageManagerImpl implemen */ private Map<EStructuralFeature, CDOFeature> featureCache = new ConcurrentHashMap<EStructuralFeature, CDOFeature>(); - public CDOSessionPackageManagerImpl(CDOSessionImpl session) + /** + * @since 2.0 + */ + public CDOSessionPackageManagerImpl(InternalCDOSession session) { this.session = session; ModelUtil.addModelInfos(this); } - public CDOSessionImpl getSession() + /** + * @since 2.0 + */ + public InternalCDOSession getSession() { return session; } @@ -152,7 +159,8 @@ public class CDOSessionPackageManagerImpl extends CDOPackageManagerImpl implemen try { - new LoadPackageRequest(session.getProtocol(), cdoPackage, false).send(); + CDOClientProtocol protocol = (CDOClientProtocol)session.getProtocol(); + new LoadPackageRequest(protocol, cdoPackage, false).send(); if (!cdoPackage.isDynamic()) { OM.LOG.info("Dynamic package created for " + cdoPackage.getPackageURI()); @@ -175,7 +183,8 @@ public class CDOSessionPackageManagerImpl extends CDOPackageManagerImpl implemen { try { - String ecore = new LoadPackageRequest(session.getProtocol(), cdoPackage, true).send(); + CDOClientProtocol protocol = (CDOClientProtocol)session.getProtocol(); + String ecore = new LoadPackageRequest(protocol, cdoPackage, true).send(); ((InternalCDOPackage)cdoPackage).setEcore(ecore); } catch (RuntimeException ex) diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSingleTransactionStrategy.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSingleTransactionStrategy.java index 42c067b746..054fccc741 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSingleTransactionStrategy.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSingleTransactionStrategy.java @@ -13,6 +13,7 @@ package org.eclipse.emf.internal.cdo; import org.eclipse.emf.cdo.CDOSavepoint; import org.eclipse.emf.internal.cdo.bundle.OM; +import org.eclipse.emf.internal.cdo.protocol.CDOClientProtocol; import org.eclipse.emf.internal.cdo.protocol.CommitTransactionRequest; import org.eclipse.emf.internal.cdo.protocol.CommitTransactionResult; @@ -46,8 +47,8 @@ public class CDOSingleTransactionStrategy implements CDOTransactionStrategy commitContext.preCommit(); - CDOSessionImpl session = (CDOSessionImpl)transaction.getSession(); - CommitTransactionRequest request = new CommitTransactionRequest(session.getProtocol(), commitContext); + CDOClientProtocol protocol = (CDOClientProtocol)transaction.getSession().getProtocol(); + CommitTransactionRequest request = new CommitTransactionRequest(protocol, commitContext); if (TRACER.isEnabled()) { TRACER.format("Sending commit request"); diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java index 54ced2b903..a87b272717 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java @@ -26,6 +26,7 @@ import org.eclipse.emf.cdo.spi.common.InternalCDORevision; import org.eclipse.emf.cdo.util.InvalidObjectException; import org.eclipse.emf.internal.cdo.bundle.OM; +import org.eclipse.emf.internal.cdo.protocol.CDOClientProtocol; import org.eclipse.emf.internal.cdo.protocol.CommitTransactionResult; import org.eclipse.emf.internal.cdo.protocol.VerifyRevisionRequest; import org.eclipse.emf.internal.cdo.util.FSMUtil; @@ -174,10 +175,10 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent * * @since 2.0 */ - public void attach(InternalCDOObject object, CDOTransactionImpl transaction) + public void attach(InternalCDOObject object, InternalCDOTransaction transaction) { List<InternalCDOObject> contents = new ArrayList<InternalCDOObject>(); - attach1(object, new Pair<CDOTransactionImpl, List<InternalCDOObject>>(transaction, contents)); + attach1(object, new Pair<InternalCDOTransaction, List<InternalCDOObject>>(transaction, contents)); attach2(object); for (InternalCDOObject content : contents) @@ -190,7 +191,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent * Phase 1: TRANSIENT --> PREPARED */ private void attach1(InternalCDOObject object, - Pair<CDOTransactionImpl, List<InternalCDOObject>> transactionAndMapOfContents) + Pair<InternalCDOTransaction, List<InternalCDOObject>> transactionAndMapOfContents) { if (TRACER.isEnabled()) { @@ -221,7 +222,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent } List<InternalCDOObject> objectsToDetach = new ArrayList<InternalCDOObject>(); - CDOTransactionImpl transaction = (CDOTransactionImpl)object.cdoView(); + InternalCDOTransaction transaction = (InternalCDOTransaction)object.cdoView(); // Accumulate objects that needs to be detached // If we have an error, we will keep the graph exactly like it was before. @@ -289,7 +290,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent view = object.cdoView(); } - InternalCDORevision revision = (InternalCDORevision)object.cdoRevision(); + InternalCDORevision revision = object.cdoRevision(); if (revision.isCurrent()) { revisions.add(revision); @@ -307,8 +308,8 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent { try { - CDOSessionImpl session = (CDOSessionImpl)view.getSession(); - revisions = new VerifyRevisionRequest(session.getProtocol(), revisions).send(); + CDOClientProtocol protocol = (CDOClientProtocol)view.getSession().getProtocol(); + revisions = new VerifyRevisionRequest(protocol, revisions).send(); } catch (Exception ex) { @@ -433,12 +434,12 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent * @author Eike Stepper */ private final class PrepareTransition implements - ITransition<CDOState, CDOEvent, InternalCDOObject, Pair<CDOTransactionImpl, List<InternalCDOObject>>> + ITransition<CDOState, CDOEvent, InternalCDOObject, Pair<InternalCDOTransaction, List<InternalCDOObject>>> { public void execute(InternalCDOObject object, CDOState state, CDOEvent event, - Pair<CDOTransactionImpl, List<InternalCDOObject>> transactionAndMapOfContents) + Pair<InternalCDOTransaction, List<InternalCDOObject>> transactionAndMapOfContents) { - CDOTransactionImpl transaction = transactionAndMapOfContents.getElement1(); + InternalCDOTransaction transaction = transactionAndMapOfContents.getElement1(); List<InternalCDOObject> contents = transactionAndMapOfContents.getElement2(); // Prepare object @@ -504,7 +505,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent public void execute(InternalCDOObject object, CDOState state, CDOEvent event, List<InternalCDOObject> objectsToDetach) { - CDOTransactionImpl transaction = (CDOTransactionImpl)object.cdoView(); + InternalCDOTransaction transaction = (InternalCDOTransaction)object.cdoView(); objectsToDetach.add(object); boolean isResource = object instanceof Resource; @@ -540,11 +541,8 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent public void execute(InternalCDOObject object, CDOState state, CDOEvent event, CommitTransactionResult data) { - - CDOViewImpl view = (CDOViewImpl)object.cdoView(); - - InternalCDORevision revision = (InternalCDORevision)object.cdoRevision(); - + InternalCDOView view = object.cdoView(); + InternalCDORevision revision = object.cdoRevision(); Map<CDOIDTemp, CDOID> idMappings = data.getIDMappings(); // Adjust object @@ -576,12 +574,10 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent revision.adjustReferences(data.getReferenceAdjuster()); } - CDORevisionManagerImpl revisionManager = view.getSession().getRevisionManager(); + CDORevisionManagerImpl revisionManager = (CDORevisionManagerImpl)view.getSession().getRevisionManager(); revisionManager.addCachedRevision(revision); - changeState(object, CDOState.CLEAN); } - } /** @@ -607,8 +603,8 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent revision.setTransactional(); object.cdoInternalSetRevision(revision); - CDOViewImpl view = (CDOViewImpl)object.cdoView(); - CDOTransactionImpl transaction = view.toTransaction(); + InternalCDOView view = object.cdoView(); + InternalCDOTransaction transaction = view.toTransaction(); transaction.registerDirty(object, (CDOFeatureDelta)featureDelta); changeState(object, CDOState.DIRTY); } @@ -621,8 +617,8 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent { public void execute(InternalCDOObject object, CDOState state, CDOEvent event, Object featureDelta) { - CDOViewImpl view = (CDOViewImpl)object.cdoView(); - CDOTransactionImpl transaction = view.toTransaction(); + InternalCDOView view = object.cdoView(); + InternalCDOTransaction transaction = view.toTransaction(); transaction.registerFeatureDelta(object, (CDOFeatureDelta)featureDelta); } } @@ -634,8 +630,8 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent { public void execute(InternalCDOObject object, CDOState state, CDOEvent event, Object featureDelta) { - CDOViewImpl view = (CDOViewImpl)object.cdoView(); - CDOTransactionImpl transaction = view.toTransaction(); + InternalCDOView view = object.cdoView(); + InternalCDOTransaction transaction = view.toTransaction(); transaction.registerFeatureDelta(object, (CDOFeatureDelta)featureDelta); } } @@ -660,7 +656,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent public void execute(InternalCDOObject object, CDOState state, CDOEvent event, Object NULL) { - CDOViewImpl view = (CDOViewImpl)object.cdoView(); + InternalCDOView view = object.cdoView(); view.deregisterObject(object); object.cdoInternalSetState(CDOState.INVALID); @@ -675,7 +671,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent { public void execute(InternalCDOObject object, CDOState state, CDOEvent event, Integer version) { - InternalCDORevision revision = (InternalCDORevision)object.cdoRevision(); + InternalCDORevision revision = object.cdoRevision(); if (version == CDORevision.UNSPECIFIED_VERSION || revision.getVersion() <= version) { changeState(object, CDOState.PROXY); @@ -693,11 +689,11 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent @Override public void execute(InternalCDOObject object, CDOState state, CDOEvent event, Integer version) { - InternalCDORevision revision = (InternalCDORevision)object.cdoRevision(); + InternalCDORevision revision = object.cdoRevision(); if (version == 0 || revision.getVersion() <= version + 1) { - CDOViewImpl view = (CDOViewImpl)object.cdoView(); - CDOTransactionImpl transaction = view.toTransaction(); + InternalCDOView view = object.cdoView(); + InternalCDOTransaction transaction = view.toTransaction(); transaction.setConflict(object); changeState(object, CDOState.CONFLICT); } @@ -712,8 +708,8 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent @Override public void execute(InternalCDOObject object, CDOState state, CDOEvent event, Integer version) { - CDOViewImpl view = (CDOViewImpl)object.cdoView(); - CDOTransactionImpl transaction = view.toTransaction(); + InternalCDOView view = object.cdoView(); + InternalCDOTransaction transaction = view.toTransaction(); transaction.setConflict(object); changeState(object, CDOState.INVALID_CONFLICT); } @@ -734,7 +730,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent public void execute(InternalCDOObject object, CDOState state, CDOEvent event, Object delta) { CDOID id = object.cdoID(); - CDOViewImpl view = (CDOViewImpl)object.cdoView(); + InternalCDOView view = object.cdoView(); InternalCDORevision revision = view.getRevision(id, true); FSMUtil.validate(object, revision); object.cdoInternalSetRevision(revision); diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java index 157616af35..3b6202dbb3 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java @@ -15,7 +15,6 @@ package org.eclipse.emf.internal.cdo; import org.eclipse.emf.cdo.CDORevisionPrefetchingPolicy; -import org.eclipse.emf.cdo.CDOView; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.model.CDOFeature; import org.eclipse.emf.cdo.common.model.CDOType; @@ -59,7 +58,8 @@ import java.util.Collection; * - Keep CDOID only when the object (!isNew && !isTransient) // Only when CDOID will not changed.<br> * - Keep EObject for external reference, new, transient and that until commit time.<br> * It is important since these objects could changed and we need to keep a reference to {@link EObject} until the end. - * It is the reason why {@link CDOStore} always call {@link CDOViewImpl#convertObjectToID(Object, boolean)} with true. + * It is the reason why {@link CDOStore} always call {@link InternalCDOView#convertObjectToID(Object, boolean)} with + * true. * * @author Eike Stepper */ @@ -67,7 +67,7 @@ public final class CDOStore implements EStore { private final ContextTracer TRACER = new ContextTracer(OM.DEBUG_STORE, CDOStore.class); - private CDOViewImpl view; + private InternalCDOView view; // Used for optimization. Multiple call to CDStore will be sent like size and than add. private EStructuralFeature lastLookupEFeature; @@ -76,12 +76,18 @@ public final class CDOStore implements EStore private Object lock = new Object(); - public CDOStore(CDOViewImpl view) + /** + * @since 2.0 + */ + public CDOStore(InternalCDOView view) { this.view = view; } - public CDOViewImpl getView() + /** + * @since 2.0 + */ + public InternalCDOView getView() { return view; } @@ -97,8 +103,9 @@ public final class CDOStore implements EStore { TRACER.format("setContainer({0}, {1}, {2}, {3})", cdoObject, newResource, newEContainer, newContainerFeatureID); } - Object newContainerID = newEContainer == null ? CDOID.NULL : ((CDOViewImpl)cdoObject.cdoView()).convertObjectToID( - newEContainer, true); + + Object newContainerID = newEContainer == null ? CDOID.NULL : cdoObject.cdoView().convertObjectToID(newEContainer, + true); CDOID newResourceID = newResource == null ? CDOID.NULL : newResource.cdoID(); CDOFeatureDelta delta = new CDOContainerFeatureDeltaImpl(newResourceID, newContainerID, newContainerFeatureID); @@ -117,8 +124,7 @@ public final class CDOStore implements EStore } InternalCDORevision revision = getRevisionForReading(cdoObject); - - return (InternalEObject)((CDOViewImpl)cdoObject.cdoView()).convertIDToObject(revision.getContainerID()); + return (InternalEObject)cdoObject.cdoView().convertIDToObject(revision.getContainerID()); } public int getContainingFeatureID(InternalEObject eObject) @@ -145,7 +151,7 @@ public final class CDOStore implements EStore } InternalCDORevision revision = getRevisionForReading(cdoObject); - return (InternalEObject)((CDOViewImpl)cdoObject.cdoView()).convertIDToObject(revision.getResourceID()); + return (InternalEObject)cdoObject.cdoView().convertIDToObject(revision.getResourceID()); } @Deprecated @@ -222,7 +228,7 @@ public final class CDOStore implements EStore if (cdoFeature.isReference()) { - value = ((CDOViewImpl)cdoObject.cdoView()).convertObjectToID(value, true); + value = cdoObject.cdoView().convertObjectToID(value, true); } InternalCDORevision revision = getRevisionForReading(cdoObject); @@ -240,7 +246,7 @@ public final class CDOStore implements EStore if (cdoFeature.isReference()) { - value = ((CDOViewImpl)cdoObject.cdoView()).convertObjectToID(value, true); + value = cdoObject.cdoView().convertObjectToID(value, true); } InternalCDORevision revision = getRevisionForReading(cdoObject); @@ -258,7 +264,7 @@ public final class CDOStore implements EStore if (cdoFeature.isReference()) { - value = ((CDOViewImpl)cdoObject.cdoView()).convertObjectToID(value, true); + value = cdoObject.cdoView().convertObjectToID(value, true); } InternalCDORevision revision = getRevisionForReading(cdoObject); @@ -294,7 +300,7 @@ public final class CDOStore implements EStore for (int i = 0; i < result.length; i++) { result[i] = resolveProxy(revision, cdoFeature, i, result[i]); - result[i] = ((CDOViewImpl)cdoObject.cdoView()).convertIDToObject(result[i]); + result[i] = cdoObject.cdoView().convertIDToObject(result[i]); } } @@ -338,7 +344,7 @@ public final class CDOStore implements EStore { Object oldValue = revision.get(cdoFeature, index); oldValue = resolveProxy(revision, cdoFeature, index, oldValue); - value = ((CDOViewImpl)cdoObject.cdoView()).convertObjectToID(value, true); + value = cdoObject.cdoView().convertObjectToID(value, true); } Object oldValue = revision.set(cdoFeature, index, value); @@ -350,8 +356,8 @@ public final class CDOStore implements EStore /** * @since 2.0 */ - public Object convertToEMF(CDOView view, EObject eObject, InternalCDORevision revision, EStructuralFeature eFeature, - CDOFeature cdoFeature, int index, Object value) + public Object convertToEMF(InternalCDOView view, EObject eObject, InternalCDORevision revision, + EStructuralFeature eFeature, CDOFeature cdoFeature, int index, Object value) { if (cdoFeature.isMany() && EStore.NO_INDEX != index) { @@ -360,7 +366,7 @@ public final class CDOStore implements EStore { CDOID id = (CDOID)value; CDOList list = revision.getList(cdoFeature); - CDORevisionManagerImpl revisionManager = ((CDOViewImpl)view).getSession().getRevisionManager(); + CDORevisionManagerImpl revisionManager = (CDORevisionManagerImpl)view.getSession().getRevisionManager(); CDORevisionPrefetchingPolicy policy = view.getRevisionPrefetchingPolicy(); Collection<CDOID> listOfIDs = policy.loadAhead(revisionManager, eObject, eFeature, list, index, id); if (!listOfIDs.isEmpty()) @@ -372,7 +378,7 @@ public final class CDOStore implements EStore if (cdoFeature.isReference()) { - value = ((CDOViewImpl)view).convertIDToObject(value); + value = view.convertIDToObject(value); } else if (cdoFeature.getType() == CDOType.CUSTOM) { @@ -383,7 +389,7 @@ public final class CDOStore implements EStore CDOFeatureMapEntryDataTypeImpl entry = (CDOFeatureMapEntryDataTypeImpl)value; EStructuralFeature feature = (EStructuralFeature)view.getResourceSet().getEObject(URI.createURI(entry.getURI()), true); - Object object = ((CDOViewImpl)view).convertIDToObject(entry.getObject()); + Object object = view.convertIDToObject(entry.getObject()); value = FeatureMapUtil.createEntry(feature, object); } @@ -393,11 +399,11 @@ public final class CDOStore implements EStore /** * @since 2.0 */ - public Object convertToCDO(CDOView view, EStructuralFeature eFeature, CDOFeature cdoFeature, Object value) + public Object convertToCDO(InternalCDOView view, EStructuralFeature eFeature, CDOFeature cdoFeature, Object value) { if (cdoFeature.isReference()) { - value = ((CDOViewImpl)view).convertObjectToID(value, true); + value = view.convertObjectToID(value, true); } else if (cdoFeature.getType() == CDOType.FEATURE_MAP_ENTRY) { @@ -538,13 +544,13 @@ public final class CDOStore implements EStore } } - CDOViewImpl view = (CDOViewImpl)cdoObject.cdoView(); + InternalCDOView view = cdoObject.cdoView(); if (view == null) { throw new IllegalStateException("view == null"); } - CDOSessionPackageManagerImpl packageManager = view.getSession().getPackageManager(); + CDOSessionPackageManagerImpl packageManager = (CDOSessionPackageManagerImpl)view.getSession().getPackageManager(); CDOFeature cdoFeature = packageManager.getCDOFeature(eFeature); synchronized (lock) @@ -570,7 +576,7 @@ public final class CDOStore implements EStore private static InternalCDORevision getRevision(InternalCDOObject cdoObject) { - InternalCDORevision revision = (InternalCDORevision)cdoObject.cdoRevision(); + InternalCDORevision revision = cdoObject.cdoRevision(); if (revision == null) { throw new IllegalStateException("revision == null"); diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java index f51fc936c9..37b6886c8a 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java @@ -37,7 +37,6 @@ import org.eclipse.emf.cdo.eresource.EresourceFactory; import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl; import org.eclipse.emf.cdo.eresource.impl.CDOResourceNodeImpl; import org.eclipse.emf.cdo.spi.common.InternalCDOPackage; -import org.eclipse.emf.cdo.spi.common.InternalCDORevision; import org.eclipse.emf.cdo.spi.common.InternalCDORevisionDelta; import org.eclipse.emf.cdo.util.CDOURIUtil; @@ -100,7 +99,10 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa private boolean autoReleaseLocksEnabled = true; - public CDOTransactionImpl(int id, CDOSessionImpl session) + /** + * @since 2.0 + */ + public CDOTransactionImpl(InternalCDOSession session, int id) { super(session, id); commitTimeout = OM.PREF_DEFAULT_COMMIT_TIMEOUT.getValue(); @@ -625,7 +627,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa InternalCDOObject object = (InternalCDOObject)entryNewObject.getValue(); // Go back to the previous state - cleanObject(object, (InternalCDORevision)object.cdoRevision()); + cleanObject(object, object.cdoRevision()); object.cdoInternalSetState(CDOState.NEW); } @@ -929,7 +931,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa @SuppressWarnings("unchecked") private List<CDOPackage> analyzeNewPackages() { - CDOSessionPackageManagerImpl packageManager = getSession().getPackageManager(); + CDOSessionPackageManagerImpl packageManager = (CDOSessionPackageManagerImpl)getSession().getPackageManager(); Set<EPackage> usedPackages = new HashSet<EPackage>(); Set<EPackage> usedNewPackages = new HashSet<EPackage>(); for (CDOObject object : getNewObjects().values()) @@ -1072,6 +1074,11 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa newPackages = transaction.analyzeNewPackages(); } + public CDOTransactionImpl getTransaction() + { + return CDOTransactionImpl.this; + } + public Map<CDOID, CDOObject> getDirtyObjects() { return dirtyObjects; @@ -1102,21 +1109,16 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa return revisionDeltas; } - public CDOTransactionImpl getTransaction() - { - return CDOTransactionImpl.this; - } - public void preCommit() { - if (getTransaction().isDirty()) + if (isDirty()) { if (TRACER.isEnabled()) { TRACER.trace("commit()"); } - for (CDOTransactionHandler handler : getTransaction().getHandlers()) + for (CDOTransactionHandler handler : getHandlers()) { handler.committingTransaction(getTransaction()); } @@ -1140,7 +1142,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa public void postCommit(CommitTransactionResult result) { - if (getTransaction().isDirty()) + if (isDirty()) { try { @@ -1154,13 +1156,13 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa removeObject(entry.getKey()); } - CDOSessionImpl session = getTransaction().getSession(); + InternalCDOSession session = getSession(); for (CDOPackage newPackage : newPackages) { ((InternalCDOPackage)newPackage).setPersistent(true); } - ChangeSubscriptionManager changeSubscriptionManager = getTransaction().getChangeSubscriptionManager(); + ChangeSubscriptionManager changeSubscriptionManager = getChangeSubscriptionManager(); changeSubscriptionManager.handleNewObjects(getNewObjects().values()); changeSubscriptionManager.handleNewObjects(getNewResources().values()); changeSubscriptionManager.handleDetachedObjects(getDetachedObjects().keySet()); @@ -1190,10 +1192,10 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa session.handleCommitNotification(timeStamp, dirtyIDs, detachedIDs, deltasCopy, getTransaction()); } - getTransaction().cleanUp(); + cleanUp(); lastCommitTime = timeStamp; Map<CDOIDTemp, CDOID> idMappings = result.getIDMappings(); - getTransaction().fireEvent(new FinishedEvent(CDOTransactionFinishedEvent.Type.COMMITTED, idMappings)); + fireEvent(new FinishedEvent(CDOTransactionFinishedEvent.Type.COMMITTED, idMappings)); } catch (RuntimeException ex) { diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOURIHandler.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOURIHandler.java index 8e8310a0e1..725fd163bc 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOURIHandler.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOURIHandler.java @@ -26,14 +26,14 @@ import java.util.Map; */ public class CDOURIHandler implements URIHandler { - private CDOViewImpl view; + private InternalCDOView view; - public CDOURIHandler(CDOViewImpl view) + public CDOURIHandler(InternalCDOView view) { this.view = view; } - public CDOViewImpl getView() + public InternalCDOView getView() { return view; } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java index c9ae5eec98..679bb14691 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java @@ -22,12 +22,10 @@ import org.eclipse.emf.cdo.CDOState; import org.eclipse.emf.cdo.CDOView; import org.eclipse.emf.cdo.CDOViewEvent; import org.eclipse.emf.cdo.CDOViewInvalidationEvent; -import org.eclipse.emf.cdo.CDOViewSet; import org.eclipse.emf.cdo.common.CDOProtocolConstants; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.id.CDOIDAndVersion; import org.eclipse.emf.cdo.common.id.CDOIDMeta; -import org.eclipse.emf.cdo.common.id.CDOIDProvider; import org.eclipse.emf.cdo.common.id.CDOIDUtil; import org.eclipse.emf.cdo.common.model.CDOClass; import org.eclipse.emf.cdo.common.model.CDOFeature; @@ -50,6 +48,7 @@ import org.eclipse.emf.cdo.util.InvalidURIException; import org.eclipse.emf.cdo.util.ReadOnlyException; import org.eclipse.emf.internal.cdo.bundle.OM; +import org.eclipse.emf.internal.cdo.protocol.CDOClientProtocol; import org.eclipse.emf.internal.cdo.protocol.ChangeSubscriptionRequest; import org.eclipse.emf.internal.cdo.protocol.LockObjectsRequest; import org.eclipse.emf.internal.cdo.protocol.ObjectLockedRequest; @@ -96,15 +95,15 @@ import java.util.concurrent.locks.ReentrantLock; /** * @author Eike Stepper */ -public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implements CDOView, CDOIDProvider +public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implements InternalCDOView { private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_VIEW, CDOViewImpl.class); private int viewID; - private CDOSessionImpl session; + private InternalCDOSession session; - private CDOViewSet viewSet; + private InternalCDOViewSet viewSet; private CDOURIHandler uriHandler = new CDOURIHandler(this); @@ -141,7 +140,7 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement /** * @since 2.0 */ - public CDOViewImpl(CDOSessionImpl session, int viewID) + public CDOViewImpl(InternalCDOSession session, int viewID) { this.session = session; this.viewID = viewID; @@ -168,12 +167,15 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement /** * @since 2.0 */ - public CDOViewSet getViewSet() + public InternalCDOViewSet getViewSet() { return viewSet; } - public CDOSessionImpl getSession() + /** + * @since 2.0 + */ + public InternalCDOSession getSession() { return session; } @@ -234,7 +236,8 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement try { - new LockObjectsRequest(getSession().getProtocol(), this, objects, timeout, lockType).send(); + CDOClientProtocol protocol = (CDOClientProtocol)getSession().getProtocol(); + new LockObjectsRequest(protocol, this, objects, timeout, lockType).send(); } catch (RemoteException ex) { @@ -270,7 +273,8 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement { try { - new UnlockObjectsRequest(getSession().getProtocol(), this, objects, lockType).send(); + CDOClientProtocol protocol = (CDOClientProtocol)getSession().getProtocol(); + new UnlockObjectsRequest(protocol, this, objects, lockType).send(); } catch (Exception ex) { @@ -294,7 +298,8 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement { try { - return new ObjectLockedRequest(getSession().getProtocol(), this, object, lockType).send(); + CDOClientProtocol protocol = (CDOClientProtocol)getSession().getProtocol(); + return new ObjectLockedRequest(protocol, this, object, lockType).send(); } catch (Exception ex) { @@ -390,12 +395,15 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement this.featureAnalyzer = featureAnalyzer == null ? CDOFeatureAnalyzer.NOOP : featureAnalyzer; } - public CDOTransactionImpl toTransaction() + /** + * @since 2.0 + */ + public InternalCDOTransaction toTransaction() { checkOpen(); - if (this instanceof CDOTransactionImpl) + if (this instanceof InternalCDOTransaction) { - return (CDOTransactionImpl)this; + return (InternalCDOTransaction)this; } throw new ReadOnlyException("CDO view is read only: " + this); @@ -567,7 +575,7 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement InternalCDOObject object = getObject(id, false); if (object != null && object.cdoState() != CDOState.PROXY) { - revision = (InternalCDORevision)object.cdoRevision(); + revision = object.cdoRevision(); } if (revision == null) @@ -1376,7 +1384,7 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement /** * @since 2.0 */ - public void setViewSet(CDOViewSet viewSet) + public void setViewSet(InternalCDOViewSet viewSet) { this.viewSet = viewSet; if (viewSet != null) @@ -1510,7 +1518,8 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement { try { - new ChangeSubscriptionRequest(getSession().getProtocol(), getViewID(), cdoIDs, subscribeMode, clear).send(); + CDOClientProtocol protocol = (CDOClientProtocol)getSession().getProtocol(); + new ChangeSubscriptionRequest(protocol, getViewID(), cdoIDs, subscribeMode, clear).send(); } catch (Exception ex) { @@ -1549,6 +1558,7 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement { throw new CDOException("Object " + internalCDOObject + " doesn`t belong to this view."); } + subscribe(internalCDOObject.cdoID(), internalCDOObject, adjust); } } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewSetImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewSetImpl.java index 64491de399..27634277d4 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewSetImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewSetImpl.java @@ -12,7 +12,6 @@ package org.eclipse.emf.internal.cdo; import org.eclipse.emf.cdo.CDOView; -import org.eclipse.emf.cdo.CDOViewSet; import org.eclipse.emf.cdo.common.CDOProtocolConstants; import org.eclipse.emf.cdo.eresource.CDOResource; import org.eclipse.emf.cdo.eresource.impl.CDOResourceFactoryImpl; @@ -22,7 +21,6 @@ import org.eclipse.emf.cdo.util.CDOURIUtil; import org.eclipse.emf.internal.cdo.bundle.OM; import org.eclipse.emf.internal.cdo.util.CDOViewSetPackageRegistryImpl; -import org.eclipse.emf.common.notify.Adapter; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.Notifier; import org.eclipse.emf.common.notify.impl.NotificationImpl; @@ -44,11 +42,11 @@ import java.util.Set; * @author Simon McDuff * @since 2.0 */ -public class CDOViewSetImpl extends NotifierImpl implements CDOViewSet, Adapter +public class CDOViewSetImpl extends NotifierImpl implements InternalCDOViewSet { - private Set<CDOViewImpl> views = new HashSet<CDOViewImpl>(); + private Set<InternalCDOView> views = new HashSet<InternalCDOView>(); - private Map<String, CDOViewImpl> mapOfViews = new HashMap<String, CDOViewImpl>(); + private Map<String, InternalCDOView> mapOfViews = new HashMap<String, InternalCDOView>(); private CDOResourceFactoryImpl resourceFactory = new CDOResourceFactoryImpl(this); @@ -87,9 +85,9 @@ public class CDOViewSetImpl extends NotifierImpl implements CDOViewSet, Adapter * @throws IllegalArgumentException * if repositoryUUID doesn't match any CDOView. */ - public CDOViewImpl resolveView(String repositoryUUID) + public InternalCDOView resolveView(String repositoryUUID) { - CDOViewImpl view = null; + InternalCDOView view = null; synchronized (views) { view = mapOfViews.get(repositoryUUID); @@ -117,7 +115,7 @@ public class CDOViewSetImpl extends NotifierImpl implements CDOViewSet, Adapter return view; } - public CDOViewImpl getView(String repositoryUUID) + public InternalCDOView getView(String repositoryUUID) { synchronized (views) { @@ -125,7 +123,7 @@ public class CDOViewSetImpl extends NotifierImpl implements CDOViewSet, Adapter } } - public void add(CDOViewImpl view) + public void add(InternalCDOView view) { synchronized (views) { @@ -151,25 +149,7 @@ public class CDOViewSetImpl extends NotifierImpl implements CDOViewSet, Adapter } } - private void initializeResources(CDOView cdoView) - { - // Intialize the resourceset correctly when it get connected to the first time to a view. - for (Resource resource : resourceSet.getResources()) - { - if (resource instanceof CDOResourceImpl) - { - CDOResourceImpl cdoResource = (CDOResourceImpl)resource; - if (cdoResource.cdoView() == null) - { - URI newURI = CDOURIUtil.createResourceURI(cdoView, cdoResource.getPath()); - cdoResource.setURI(newURI); - notifyAdd(cdoResource); - } - } - } - } - - public void remove(CDOViewImpl view) + public void remove(InternalCDOView view) { List<Resource> resToRemove = new ArrayList<Resource>(); synchronized (views) @@ -279,10 +259,28 @@ public class CDOViewSetImpl extends NotifierImpl implements CDOViewSet, Adapter private void notifyAdd(CDOResourceImpl resource) { String respositoryUUID = CDOURIUtil.extractRepositoryUUID(resource.getURI()); - CDOViewImpl view = resolveView(respositoryUUID); + InternalCDOView view = resolveView(respositoryUUID); if (view != null) { view.attachResource(resource); } } + + private void initializeResources(CDOView cdoView) + { + // Intialize the resourceset correctly when it get connected to the first time to a view. + for (Resource resource : resourceSet.getResources()) + { + if (resource instanceof CDOResourceImpl) + { + CDOResourceImpl cdoResource = (CDOResourceImpl)resource; + if (cdoResource.cdoView() == null) + { + URI newURI = CDOURIUtil.createResourceURI(cdoView, cdoResource.getPath()); + cdoResource.setURI(newURI); + notifyAdd(cdoResource); + } + } + } + } } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOXATransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOXATransactionImpl.java index cdfe6cf6a6..5ed76bd4e2 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOXATransactionImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOXATransactionImpl.java @@ -18,6 +18,7 @@ import org.eclipse.emf.cdo.CDOXATransaction; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.util.CDOUtil; +import org.eclipse.emf.internal.cdo.protocol.CDOClientProtocol; import org.eclipse.emf.internal.cdo.protocol.CommitTransactionCancelRequest; import org.eclipse.emf.internal.cdo.protocol.CommitTransactionPhase1Request; import org.eclipse.emf.internal.cdo.protocol.CommitTransactionPhase2Request; @@ -464,17 +465,15 @@ public class CDOXATransactionImpl implements CDOXATransaction protected void handle(CDOXATransactionCommitContext xaContext, IProgressMonitor progressMonitor) throws Exception { xaContext.preCommit(); - CDOSessionImpl session = (CDOSessionImpl)xaContext.getTransaction().getSession(); // Phase 1 - { - CommitTransactionResult result = new CommitTransactionPhase1Request(session.getProtocol(), xaContext) - .send(new EclipseMonitor(progressMonitor)); - check_result(result); + CDOClientProtocol protocol = (CDOClientProtocol)xaContext.getTransaction().getSession().getProtocol(); + CommitTransactionPhase1Request request = new CommitTransactionPhase1Request(protocol, xaContext); + CommitTransactionResult result = request.send(new EclipseMonitor(progressMonitor)); + check_result(result); - xaContext.setResult(result); - xaContext.setState(CDOXAPhase2State.INSTANCE); - } + xaContext.setResult(result); + xaContext.setState(CDOXAPhase2State.INSTANCE); } }; @@ -492,15 +491,13 @@ public class CDOXATransactionImpl implements CDOXATransaction @Override protected void handle(CDOXATransactionCommitContext xaContext, IProgressMonitor progressMonitor) throws Exception { - CDOSessionImpl session = (CDOSessionImpl)xaContext.getTransaction().getSession(); - // Phase 2 - { - CommitTransactionResult result = new CommitTransactionPhase2Request(session.getProtocol(), xaContext) - .send(new EclipseMonitor(progressMonitor)); - check_result(result); - xaContext.setState(CDOXAPhase3State.INSTANCE); - } + CDOClientProtocol protocol = (CDOClientProtocol)xaContext.getTransaction().getSession().getProtocol(); + CommitTransactionPhase2Request request = new CommitTransactionPhase2Request(protocol, xaContext); + CommitTransactionResult result = request.send(new EclipseMonitor(progressMonitor)); + check_result(result); + + xaContext.setState(CDOXAPhase3State.INSTANCE); } }; @@ -518,16 +515,13 @@ public class CDOXATransactionImpl implements CDOXATransaction @Override protected void handle(CDOXATransactionCommitContext xaContext, IProgressMonitor progressMonitor) throws Exception { - CDOSessionImpl session = (CDOSessionImpl)xaContext.getTransaction().getSession(); - // Phase 2 - { - CommitTransactionResult result = new CommitTransactionPhase3Request(session.getProtocol(), xaContext) - .send(new EclipseMonitor(progressMonitor)); - check_result(result); - xaContext.postCommit(xaContext.getResult()); - xaContext.setState(null); - } + CDOClientProtocol protocol = (CDOClientProtocol)xaContext.getTransaction().getSession().getProtocol(); + CommitTransactionPhase3Request request = new CommitTransactionPhase3Request(protocol, xaContext); + CommitTransactionResult result = request.send(new EclipseMonitor(progressMonitor)); + check_result(result); + xaContext.postCommit(xaContext.getResult()); + xaContext.setState(null); } }; @@ -545,14 +539,11 @@ public class CDOXATransactionImpl implements CDOXATransaction @Override protected void handle(CDOXATransactionCommitContext xaContext, IProgressMonitor progressMonitor) throws Exception { - CDOSessionImpl session = (CDOSessionImpl)xaContext.getTransaction().getSession(); - // Phase 2 - { - CommitTransactionResult result = new CommitTransactionCancelRequest(session.getProtocol(), xaContext) - .send(new EclipseMonitor(progressMonitor)); - check_result(result); - } + CDOClientProtocol protocol = (CDOClientProtocol)xaContext.getTransaction().getSession().getProtocol(); + CommitTransactionCancelRequest request = new CommitTransactionCancelRequest(protocol, xaContext); + CommitTransactionResult result = request.send(new EclipseMonitor(progressMonitor)); + check_result(result); } }; diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/InternalCDOObject.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/InternalCDOObject.java index dec266eb1d..3a873be884 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/InternalCDOObject.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/InternalCDOObject.java @@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.CDOState; import org.eclipse.emf.cdo.CDOView; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.spi.common.InternalCDORevision; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.InternalEObject; @@ -27,6 +28,16 @@ public interface InternalCDOObject extends CDOObject, InternalEObject, InternalC /** * @since 2.0 */ + public InternalCDOView cdoView(); + + /** + * @since 2.0 + */ + public InternalCDORevision cdoRevision(); + + /** + * @since 2.0 + */ public void cdoInternalCleanup(); public void cdoInternalPostAttach(); diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/InternalCDOSession.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/InternalCDOSession.java new file mode 100644 index 0000000000..ffc07b6050 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/InternalCDOSession.java @@ -0,0 +1,60 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2008 Eike Stepper, Germany. + * 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 + **************************************************************************/ +package org.eclipse.emf.internal.cdo; + +import org.eclipse.emf.cdo.CDOSession; +import org.eclipse.emf.cdo.CDOSessionProtocol; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.id.CDOIDAndVersion; +import org.eclipse.emf.cdo.common.id.CDOIDMetaRange; +import org.eclipse.emf.cdo.common.id.CDOIDObjectFactory; +import org.eclipse.emf.cdo.common.model.CDOPackageURICompressor; +import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; +import org.eclipse.emf.cdo.util.CDOPackageRegistry; + +import org.eclipse.net4j.util.lifecycle.ILifecycle; + +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.InternalEObject; + +import java.util.Collection; +import java.util.Set; + +/** + * @author Eike Stepper + * @since 2.0 + */ +public interface InternalCDOSession extends CDOSession, CDOIDObjectFactory, CDOPackageURICompressor, + ILifecycle.Introspection +{ + public CDOSessionProtocol getProtocol(); + + public void setRepositoryName(String repositoryName); + + public void setPackageRegistry(CDOPackageRegistry packageRegistry); + + public void registerEPackage(EPackage ePackage, CDOIDMetaRange metaIDRange); + + public CDOIDMetaRange registerEPackage(EPackage ePackage); + + public InternalEObject lookupMetaInstance(CDOID id); + + public CDOID lookupMetaInstanceID(InternalEObject metaInstance); + + public void remapMetaInstance(CDOID oldID, CDOID newID); + + public void viewDetached(InternalCDOView view); + + public void handleCommitNotification(long timeStamp, Set<CDOIDAndVersion> dirtyOIDs, + Collection<CDOID> detachedObjects, Collection<CDORevisionDelta> deltas, InternalCDOView excludedView); + + public void handleSyncResponse(long timestamp, Set<CDOIDAndVersion> dirtyOIDs, Collection<CDOID> detachedObjects); +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/InternalCDOTransaction.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/InternalCDOTransaction.java index c128f6d692..76e82bb391 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/InternalCDOTransaction.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/InternalCDOTransaction.java @@ -12,13 +12,18 @@ package org.eclipse.emf.internal.cdo; import org.eclipse.emf.cdo.CDOSavepoint; import org.eclipse.emf.cdo.CDOTransaction; -import org.eclipse.emf.cdo.common.id.CDOIDProvider; +import org.eclipse.emf.cdo.common.id.CDOIDTemp; +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; +import org.eclipse.emf.cdo.eresource.CDOResourceFolder; + +import java.util.List; /** * @author Simon McDuff * @since 2.0 */ -public interface InternalCDOTransaction extends CDOTransaction, CDOIDProvider +public interface InternalCDOTransaction extends CDOTransaction, InternalCDOView { public CDOCommitContext createCommitContext(); @@ -29,4 +34,23 @@ public interface InternalCDOTransaction extends CDOTransaction, CDOIDProvider public CDOTransactionStrategy getTransactionStrategy(); public void setTransactionStrategy(CDOTransactionStrategy transactionStrategy); + + /** + * @return never <code>null</code>; + */ + public CDOResourceFolder getOrCreateResourceFolder(List<String> names); + + public void detachObject(InternalCDOObject object); + + public CDOIDTemp getNextTemporaryID(); + + public void registerNew(InternalCDOObject object); + + public void registerDirty(InternalCDOObject object, CDOFeatureDelta featureDelta); + + public void registerFeatureDelta(InternalCDOObject object, CDOFeatureDelta featureDelta); + + public void registerRevisionDelta(CDORevisionDelta revisionDelta); + + public void setConflict(InternalCDOObject object); } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/InternalCDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/InternalCDOView.java new file mode 100644 index 0000000000..ff470b5349 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/InternalCDOView.java @@ -0,0 +1,86 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2008 Eike Stepper, Germany. + * 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 + **************************************************************************/ +package org.eclipse.emf.internal.cdo; + +import org.eclipse.emf.cdo.CDOFeatureAnalyzer; +import org.eclipse.emf.cdo.CDOObject; +import org.eclipse.emf.cdo.CDOView; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.id.CDOIDAndVersion; +import org.eclipse.emf.cdo.common.id.CDOIDProvider; +import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; +import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl; +import org.eclipse.emf.cdo.spi.common.InternalCDORevision; + +import org.eclipse.net4j.util.concurrent.RWLockManager; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.ecore.EObject; + +import java.util.Collection; +import java.util.Set; + +/** + * @author Eike Stepper + * @since 2.0 + */ +public interface InternalCDOView extends CDOView, CDOIDProvider +{ + public InternalCDOSession getSession(); + + public InternalCDOViewSet getViewSet(); + + public void setViewSet(InternalCDOViewSet viewSet); + + public CDOFeatureAnalyzer getFeatureAnalyzer(); + + public void setFeatureAnalyzer(CDOFeatureAnalyzer featureAnalyzer); + + public CDOStore getStore(); + + public InternalCDOTransaction toTransaction(); + + public void attachResource(CDOResourceImpl resource); + + public void handleInvalidation(long timeStamp, Set<CDOIDAndVersion> dirtyOIDs, Collection<CDOID> detachedOIDs); + + public void handleChangeSubscription(Collection<CDORevisionDelta> deltas, Collection<CDOID> detachedObjects); + + public InternalCDOObject[] getObjectsArray(); + + public void remapObject(CDOID oldID); + + public CDOID getResourceID(String path); + + public void registerProxyResource(CDOResourceImpl resource); + + public void registerObject(InternalCDOObject object); + + public void deregisterObject(InternalCDOObject object); + + public InternalCDOObject removeObject(CDOID id); + + public InternalCDORevision getRevision(CDOID id, boolean loadOnDemand); + + public Object convertObjectToID(Object potentialObject); + + public Object convertObjectToID(Object potentialObject, boolean onlyPersistedID); + + public Object convertIDToObject(Object potentialID); + + public boolean isLocked(CDOObject object, RWLockManager.LockType lockType); + + public void subscribe(EObject eObject, Adapter adapter); + + public void unsubscribe(EObject eObject, Adapter adapter); + + public boolean hasSubscription(CDOID id); +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/InternalCDOViewSet.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/InternalCDOViewSet.java new file mode 100644 index 0000000000..9c945cb8c6 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/InternalCDOViewSet.java @@ -0,0 +1,28 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2008 Eike Stepper, Germany. + * 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 + **************************************************************************/ +package org.eclipse.emf.internal.cdo; + +import org.eclipse.emf.cdo.CDOViewSet; + +import org.eclipse.emf.common.notify.Adapter; + +/** + * @author Eike Stepper + * @since 2.0 + */ +public interface InternalCDOViewSet extends CDOViewSet, Adapter +{ + public void add(InternalCDOView view); + + public void remove(InternalCDOView view); + + public InternalCDOView resolveView(String repositoryUUID); +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientIndication.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientIndication.java index 5e7ee80521..ce5d83aa03 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientIndication.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientIndication.java @@ -11,6 +11,8 @@ **************************************************************************/ package org.eclipse.emf.internal.cdo.protocol; +import org.eclipse.emf.cdo.CDORevisionManager; +import org.eclipse.emf.cdo.CDOSessionPackageManager; import org.eclipse.emf.cdo.common.CDODataInput; import org.eclipse.emf.cdo.common.id.CDOIDObjectFactory; import org.eclipse.emf.cdo.common.model.CDOPackageManager; @@ -19,9 +21,7 @@ import org.eclipse.emf.cdo.common.revision.CDOListFactory; import org.eclipse.emf.cdo.common.revision.CDORevisionResolver; import org.eclipse.emf.cdo.internal.common.CDODataInputImpl; -import org.eclipse.emf.internal.cdo.CDORevisionManagerImpl; -import org.eclipse.emf.internal.cdo.CDOSessionImpl; -import org.eclipse.emf.internal.cdo.CDOSessionPackageManagerImpl; +import org.eclipse.emf.internal.cdo.InternalCDOSession; import org.eclipse.emf.internal.cdo.revision.CDOListWithElementProxiesImpl; import org.eclipse.net4j.signal.Indication; @@ -45,17 +45,17 @@ public abstract class CDOClientIndication extends Indication return (CDOClientProtocol)super.getProtocol(); } - protected CDOSessionImpl getSession() + protected InternalCDOSession getSession() { - return (CDOSessionImpl)getProtocol().getInfraStructure(); + return (InternalCDOSession)getProtocol().getInfraStructure(); } - protected CDORevisionManagerImpl getRevisionManager() + protected CDORevisionManager getRevisionManager() { return getSession().getRevisionManager(); } - protected CDOSessionPackageManagerImpl getPackageManager() + protected CDOSessionPackageManager getPackageManager() { return getSession().getPackageManager(); } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientRequest.java index 24a34c3bc3..b82c638a34 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientRequest.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CDOClientRequest.java @@ -11,6 +11,8 @@ **************************************************************************/ package org.eclipse.emf.internal.cdo.protocol; +import org.eclipse.emf.cdo.CDORevisionManager; +import org.eclipse.emf.cdo.CDOSessionPackageManager; import org.eclipse.emf.cdo.common.CDODataInput; import org.eclipse.emf.cdo.common.CDODataOutput; import org.eclipse.emf.cdo.common.id.CDOIDObjectFactory; @@ -22,9 +24,7 @@ import org.eclipse.emf.cdo.common.revision.CDORevisionResolver; import org.eclipse.emf.cdo.internal.common.CDODataInputImpl; import org.eclipse.emf.cdo.internal.common.CDODataOutputImpl; -import org.eclipse.emf.internal.cdo.CDORevisionManagerImpl; -import org.eclipse.emf.internal.cdo.CDOSessionImpl; -import org.eclipse.emf.internal.cdo.CDOSessionPackageManagerImpl; +import org.eclipse.emf.internal.cdo.InternalCDOSession; import org.eclipse.emf.internal.cdo.revision.CDOListWithElementProxiesImpl; import org.eclipse.net4j.signal.RequestWithConfirmation; @@ -49,17 +49,17 @@ public abstract class CDOClientRequest<RESULT> extends RequestWithConfirmation<R return (CDOClientProtocol)super.getProtocol(); } - protected CDOSessionImpl getSession() + protected InternalCDOSession getSession() { - return (CDOSessionImpl)getProtocol().getInfraStructure(); + return (InternalCDOSession)getProtocol().getInfraStructure(); } - protected CDORevisionManagerImpl getRevisionManager() + protected CDORevisionManager getRevisionManager() { return getSession().getRevisionManager(); } - protected CDOSessionPackageManagerImpl getPackageManager() + protected CDOSessionPackageManager getPackageManager() { return getSession().getPackageManager(); } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitNotificationIndication.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitNotificationIndication.java index 5aac1afedb..4fb147af58 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitNotificationIndication.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitNotificationIndication.java @@ -17,7 +17,7 @@ import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.id.CDOIDAndVersion; import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; -import org.eclipse.emf.internal.cdo.CDOSessionImpl; +import org.eclipse.emf.internal.cdo.InternalCDOSession; import org.eclipse.emf.internal.cdo.bundle.OM; import org.eclipse.net4j.util.om.trace.ContextTracer; @@ -56,7 +56,7 @@ public class CommitNotificationIndication extends CDOClientIndication PROTOCOL_TRACER.format("Reading {0} dirty IDs", size); } - CDOSessionImpl session = getSession(); + InternalCDOSession session = getSession(); Set<CDOIDAndVersion> dirtyOIDs = new HashSet<CDOIDAndVersion>(); for (int i = 0; i < size; i++) { diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java index f6aa949d91..758e593f18 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java @@ -14,6 +14,8 @@ package org.eclipse.emf.internal.cdo.protocol; import org.eclipse.emf.cdo.CDOObject; +import org.eclipse.emf.cdo.CDORevisionManager; +import org.eclipse.emf.cdo.CDOSessionPackageManager; import org.eclipse.emf.cdo.common.CDODataInput; import org.eclipse.emf.cdo.common.CDODataOutput; import org.eclipse.emf.cdo.common.CDOProtocolConstants; @@ -36,9 +38,7 @@ import org.eclipse.emf.cdo.internal.common.CDODataOutputImpl; import org.eclipse.emf.cdo.spi.common.InternalCDOPackage; import org.eclipse.emf.internal.cdo.CDOCommitContext; -import org.eclipse.emf.internal.cdo.CDORevisionManagerImpl; -import org.eclipse.emf.internal.cdo.CDOSessionImpl; -import org.eclipse.emf.internal.cdo.CDOSessionPackageManagerImpl; +import org.eclipse.emf.internal.cdo.InternalCDOSession; import org.eclipse.emf.internal.cdo.bundle.OM; import org.eclipse.emf.internal.cdo.revision.CDOListWithElementProxiesImpl; @@ -85,17 +85,17 @@ public class CommitTransactionRequest extends RequestWithMonitoring<CommitTransa return (CDOClientProtocol)super.getProtocol(); } - protected CDOSessionImpl getSession() + protected InternalCDOSession getSession() { - return (CDOSessionImpl)getProtocol().getInfraStructure(); + return (InternalCDOSession)getProtocol().getInfraStructure(); } - protected CDORevisionManagerImpl getRevisionManager() + protected CDORevisionManager getRevisionManager() { return getSession().getRevisionManager(); } - protected CDOSessionPackageManagerImpl getPackageManager() + protected CDOSessionPackageManager getPackageManager() { return getSession().getPackageManager(); } @@ -272,7 +272,7 @@ public class CommitTransactionRequest extends RequestWithMonitoring<CommitTransa protected void confirmingNewPackage(CDODataInput in, CommitTransactionResult result) throws IOException { - CDOSessionImpl session = (CDOSessionImpl)commitContext.getTransaction().getSession(); + InternalCDOSession session = commitContext.getTransaction().getSession(); List<CDOPackage> newPackages = commitContext.getNewPackages(); for (CDOPackage newPackage : newPackages) { diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java index 0ac67166c1..722b882a69 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java @@ -77,7 +77,8 @@ public class LoadRevisionRequest extends CDOClientRequest<List<InternalCDORevisi out.writeCDOID(id); } - CDOFetchRuleManager ruleManager = getRevisionManager().getRuleManager(); + CDORevisionManagerImpl revisionManager = (CDORevisionManagerImpl)getRevisionManager(); + CDOFetchRuleManager ruleManager = revisionManager.getRuleManager(); List<CDOFetchRule> fetchRules = ruleManager.getFetchRules(ids); if (fetchRules == null || fetchRules.size() <= 0) { @@ -124,7 +125,7 @@ public class LoadRevisionRequest extends CDOClientRequest<List<InternalCDORevisi PROTOCOL_TRACER.format("Reading {0} additional revisions", additionalSize); } - CDORevisionManagerImpl revisionManager = getRevisionManager(); + CDORevisionManagerImpl revisionManager = (CDORevisionManagerImpl)getRevisionManager(); for (int i = 0; i < additionalSize; i++) { InternalCDORevision revision = (InternalCDORevision)in.readCDORevision(); diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java index 8064311121..5c6691e4fd 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/OpenSessionRequest.java @@ -22,8 +22,8 @@ import org.eclipse.emf.cdo.common.model.CDOPackageURICompressor; import org.eclipse.emf.cdo.util.ServerException; import org.eclipse.emf.internal.cdo.CDORevisionManagerImpl; -import org.eclipse.emf.internal.cdo.CDOSessionImpl; import org.eclipse.emf.internal.cdo.CDOSessionPackageManagerImpl; +import org.eclipse.emf.internal.cdo.InternalCDOSession; import org.eclipse.emf.internal.cdo.bundle.OM; import org.eclipse.net4j.util.om.trace.ContextTracer; @@ -52,7 +52,7 @@ public class OpenSessionRequest extends CDOTimeRequest<OpenSessionResult> } @Override - protected CDOSessionImpl getSession() + protected InternalCDOSession getSession() { throw new UnsupportedOperationException(); } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/SetPassiveUpdateRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/SetPassiveUpdateRequest.java index 9478fa9b35..086ab3db70 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/SetPassiveUpdateRequest.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/SetPassiveUpdateRequest.java @@ -16,7 +16,7 @@ import org.eclipse.emf.cdo.common.CDOProtocolConstants; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.revision.CDORevision; -import org.eclipse.emf.internal.cdo.CDOSessionImpl; +import org.eclipse.emf.internal.cdo.InternalCDOSession; import org.eclipse.emf.internal.cdo.bundle.OM; import org.eclipse.net4j.util.om.trace.ContextTracer; @@ -35,8 +35,8 @@ public class SetPassiveUpdateRequest extends SyncRevisionRequest private boolean passiveUpdateEnabled; - public SetPassiveUpdateRequest(CDOClientProtocol protocol, CDOSessionImpl session, Map<CDOID, CDORevision> revisions, - int referenceChunk, boolean passiveUpdateEnabled) + public SetPassiveUpdateRequest(CDOClientProtocol protocol, InternalCDOSession session, + Map<CDOID, CDORevision> revisions, int referenceChunk, boolean passiveUpdateEnabled) { super(protocol, CDOProtocolConstants.SIGNAL_PASSIVE_UPDATE, session, revisions, referenceChunk); this.passiveUpdateEnabled = passiveUpdateEnabled; diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/SyncRevisionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/SyncRevisionRequest.java index 0b9cf12a83..2426d53b4d 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/SyncRevisionRequest.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/SyncRevisionRequest.java @@ -22,8 +22,8 @@ import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.spi.common.InternalCDORevision; import org.eclipse.emf.internal.cdo.CDORevisionManagerImpl; -import org.eclipse.emf.internal.cdo.CDOSessionImpl; import org.eclipse.emf.internal.cdo.CDOTimeStampContextImpl; +import org.eclipse.emf.internal.cdo.InternalCDOSession; import org.eclipse.emf.internal.cdo.bundle.OM; import org.eclipse.net4j.util.om.trace.ContextTracer; @@ -45,17 +45,17 @@ public class SyncRevisionRequest extends CDOClientRequest<Collection<CDOTimeStam private Map<CDOID, CDORevision> revisions; - private CDOSessionImpl session; + private InternalCDOSession session; private int referenceChunk; - public SyncRevisionRequest(CDOClientProtocol protocol, CDOSessionImpl session, Map<CDOID, CDORevision> revisions, + public SyncRevisionRequest(CDOClientProtocol protocol, InternalCDOSession session, Map<CDOID, CDORevision> revisions, int referenceChunk) { this(protocol, CDOProtocolConstants.SIGNAL_SYNC, session, revisions, referenceChunk); } - public SyncRevisionRequest(CDOClientProtocol protocol, short signalID, CDOSessionImpl session, + public SyncRevisionRequest(CDOClientProtocol protocol, short signalID, InternalCDOSession session, Map<CDOID, CDORevision> revisions, int referenceChunk) { super(protocol, signalID); @@ -84,7 +84,7 @@ public class SyncRevisionRequest extends CDOClientRequest<Collection<CDOTimeStam @Override protected Collection<CDOTimeStampContext> confirming(CDODataInput in) throws IOException { - CDORevisionManagerImpl revisionManager = getRevisionManager(); + CDORevisionManagerImpl revisionManager = (CDORevisionManagerImpl)getRevisionManager(); TreeMap<Long, CDOTimeStampContext> mapofContext = new TreeMap<Long, CDOTimeStampContext>(); int size = in.readInt(); diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOAbstractQueryIteratorImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOAbstractQueryIteratorImpl.java index ebbf106aca..9d79c87f5c 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOAbstractQueryIteratorImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOAbstractQueryIteratorImpl.java @@ -14,7 +14,8 @@ import org.eclipse.emf.cdo.CDOView; import org.eclipse.emf.cdo.common.query.CDOQueryInfo; import org.eclipse.emf.cdo.internal.common.query.AbstractQueryResult; -import org.eclipse.emf.internal.cdo.CDOSessionImpl; +import org.eclipse.emf.internal.cdo.InternalCDOSession; +import org.eclipse.emf.internal.cdo.protocol.CDOClientProtocol; import org.eclipse.emf.internal.cdo.protocol.QueryCancelRequest; import org.eclipse.net4j.util.concurrent.ConcurrentValue; @@ -76,8 +77,8 @@ public abstract class CDOAbstractQueryIteratorImpl<T> extends AbstractQueryResul try { - CDOSessionImpl session = (CDOSessionImpl)getView().getSession(); - new QueryCancelRequest(session.getProtocol(), getQueryID()).send(); + CDOClientProtocol protocol = (CDOClientProtocol)((InternalCDOSession)getView().getSession()).getProtocol(); + new QueryCancelRequest(protocol, getQueryID()).send(); } catch (Exception ignore) { diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java index c0f2d78b5f..225349c1c1 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/query/CDOQueryImpl.java @@ -12,14 +12,14 @@ package org.eclipse.emf.internal.cdo.query; import org.eclipse.emf.cdo.CDOQuery; -import org.eclipse.emf.cdo.CDOView; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.util.BlockingCloseableIterator; import org.eclipse.emf.cdo.internal.common.query.CDOQueryInfoImpl; -import org.eclipse.emf.internal.cdo.CDOSessionImpl; -import org.eclipse.emf.internal.cdo.CDOViewImpl; +import org.eclipse.emf.internal.cdo.CDOSessionPackageManagerImpl; import org.eclipse.emf.internal.cdo.InternalCDOObject; +import org.eclipse.emf.internal.cdo.InternalCDOView; +import org.eclipse.emf.internal.cdo.protocol.CDOClientProtocol; import org.eclipse.emf.internal.cdo.protocol.QueryRequest; import org.eclipse.emf.internal.cdo.util.FSMUtil; import org.eclipse.emf.internal.cdo.util.ModelUtil; @@ -36,15 +36,15 @@ import java.util.Map.Entry; */ public class CDOQueryImpl extends CDOQueryInfoImpl implements CDOQuery { - private CDOViewImpl view; + private InternalCDOView view; - public CDOQueryImpl(CDOViewImpl view, String queryLanguage, String queryString) + public CDOQueryImpl(InternalCDOView view, String queryLanguage, String queryString) { super(queryLanguage, queryString); this.view = view; } - public CDOView getView() + public InternalCDOView getView() { return view; } @@ -80,8 +80,8 @@ public class CDOQueryImpl extends CDOQueryInfoImpl implements CDOQuery try { - CDOSessionImpl session = view.getSession(); - new QueryRequest(session.getProtocol(), view.getViewID(), queryResult).send(); + CDOClientProtocol protocol = (CDOClientProtocol)view.getSession().getProtocol(); + new QueryRequest(protocol, view.getViewID(), queryResult).send(); } catch (Exception exception) { @@ -101,8 +101,8 @@ public class CDOQueryImpl extends CDOQueryInfoImpl implements CDOQuery { try { - CDOSessionImpl session = view.getSession(); - new QueryRequest(session.getProtocol(), view.getViewID(), queryResult).send(); + CDOClientProtocol protocol = (CDOClientProtocol)view.getSession().getProtocol(); + new QueryRequest(protocol, view.getViewID(), queryResult).send(); } catch (Exception ex) { @@ -151,7 +151,7 @@ public class CDOQueryImpl extends CDOQueryInfoImpl implements CDOQuery if (object instanceof EClass) { EClass eClass = (EClass)object; - return ModelUtil.getCDOClass(eClass, view.getSession().getPackageManager()); + return ModelUtil.getCDOClass(eClass, (CDOSessionPackageManagerImpl)view.getSession().getPackageManager()); } else if (object instanceof InternalCDOObject) { diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java index d2ee08ab74..fcdfad65fe 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java @@ -25,7 +25,8 @@ import org.eclipse.emf.cdo.util.CDOPackageType; import org.eclipse.emf.cdo.util.CDOPackageTypeRegistry; import org.eclipse.emf.cdo.util.EMFUtil; -import org.eclipse.emf.internal.cdo.CDOSessionImpl; +import org.eclipse.emf.internal.cdo.CDOSessionPackageManagerImpl; +import org.eclipse.emf.internal.cdo.InternalCDOSession; import org.eclipse.emf.internal.cdo.bundle.OM; import org.eclipse.net4j.util.container.ContainerEventAdapter; @@ -57,20 +58,20 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements CDOP private final ContextTracer tracer = new ContextTracer(OM.DEBUG_MODEL, CDOPackageRegistryImpl.class); - private CDOSessionImpl session; + private InternalCDOSession session; public CDOPackageRegistryImpl() { } - public CDOSessionImpl getSession() + public InternalCDOSession getSession() { return session; } public void setSession(CDOSession session) { - this.session = (CDOSessionImpl)session; + this.session = (InternalCDOSession)session; } public void putPackageDescriptor(CDOPackage cdoPackage) @@ -125,7 +126,9 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements CDOP EPackage ePackage = (EPackage)value; EMFUtil.prepareDynamicEPackage(ePackage); - CDOPackage cdoPackage = ModelUtil.getCDOPackage(ePackage, session.getPackageManager()); + + CDOSessionPackageManagerImpl packageManager = (CDOSessionPackageManagerImpl)session.getPackageManager(); + CDOPackage cdoPackage = ModelUtil.getCDOPackage(ePackage, packageManager); CDOIDMetaRange metaIDRange = cdoPackage.getTopLevelPackage().getMetaIDRange(); ((InternalCDOPackage)cdoPackage).setPersistent(metaIDRange != null && !metaIDRange.isTemporary()); } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ChannelInjector.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ChannelInjector.java index fbc04a9020..947e8e2b5f 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ChannelInjector.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ChannelInjector.java @@ -10,7 +10,7 @@ **************************************************************************/ package org.eclipse.emf.internal.cdo.util; -import org.eclipse.emf.internal.cdo.CDOSessionImpl; +import org.eclipse.emf.cdo.CDOSession; import org.eclipse.net4j.connector.IConnector; import org.eclipse.net4j.signal.failover.NOOPFailOverStrategy; @@ -34,9 +34,9 @@ public class ChannelInjector implements IElementProcessor public Object process(IManagedContainer container, String productGroup, String factoryType, String description, Object element) { - if (element instanceof CDOSessionImpl) + if (element instanceof CDOSession) { - CDOSessionImpl session = (CDOSessionImpl)element; + CDOSession session = (CDOSession)element; session.getProtocol().setFailOverStrategy(new NOOPFailOverStrategy(getConnector(container, description))); } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java index a7b8be4dc2..c51d3df97e 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java @@ -22,8 +22,8 @@ import org.eclipse.emf.cdo.util.ObjectNotFoundException; import org.eclipse.emf.internal.cdo.CDOLegacyWrapper; import org.eclipse.emf.internal.cdo.CDOMetaWrapper; import org.eclipse.emf.internal.cdo.CDOStateMachine; -import org.eclipse.emf.internal.cdo.CDOViewImpl; import org.eclipse.emf.internal.cdo.InternalCDOObject; +import org.eclipse.emf.internal.cdo.InternalCDOView; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EGenericType; @@ -115,10 +115,10 @@ public final class FSMUtil object = (InternalEObject)EcoreUtil.resolve(object, view.getResourceSet()); } - CDOID id = ((CDOViewImpl)view).getSession().lookupMetaInstanceID(object); + CDOID id = ((InternalCDOView)view).getSession().lookupMetaInstanceID(object); if (id != null) { - return new CDOMetaWrapper((CDOViewImpl)view, object, id); + return new CDOMetaWrapper((InternalCDOView)view, object, id); } return null; @@ -229,7 +229,7 @@ public final class FSMUtil }; } - public static Iterator<InternalCDOObject> iterator(final Iterator<?> delegate, final CDOViewImpl view) + public static Iterator<InternalCDOObject> iterator(final Iterator<?> delegate, final InternalCDOView view) { return new Iterator<InternalCDOObject>() { @@ -261,7 +261,7 @@ public final class FSMUtil }; } - public static Iterator<InternalCDOObject> iterator(Collection<?> instances, final CDOViewImpl view) + public static Iterator<InternalCDOObject> iterator(Collection<?> instances, final InternalCDOView view) { return iterator(instances.iterator(), view); } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java index 9eb4715f2c..8f8a6647a2 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java @@ -33,8 +33,8 @@ import org.eclipse.emf.cdo.spi.common.InternalCDOPackage; import org.eclipse.emf.cdo.util.CDOPackageRegistry; import org.eclipse.emf.cdo.util.EMFUtil; -import org.eclipse.emf.internal.cdo.CDOSessionImpl; import org.eclipse.emf.internal.cdo.CDOSessionPackageManagerImpl; +import org.eclipse.emf.internal.cdo.InternalCDOSession; import org.eclipse.emf.internal.cdo.bundle.OM; import org.eclipse.net4j.util.ImplementationError; @@ -190,7 +190,7 @@ public final class ModelUtil */ static CDOPackage createCDOPackage(EPackage ePackage, CDOSessionPackageManagerImpl packageManager) { - CDOSessionImpl session = packageManager.getSession(); + InternalCDOSession session = packageManager.getSession(); String uri = ePackage.getNsURI(); String parentURI = getParentURI(ePackage); String name = ePackage.getName(); diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/SessionUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/SessionUtil.java new file mode 100644 index 0000000000..a29ebd08ac --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/SessionUtil.java @@ -0,0 +1,110 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2008 Eike Stepper, Germany. + * 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 + **************************************************************************/ +package org.eclipse.emf.internal.cdo.util; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.id.CDOIDMetaRange; +import org.eclipse.emf.cdo.common.id.CDOIDTemp; +import org.eclipse.emf.cdo.common.id.CDOIDUtil; +import org.eclipse.emf.cdo.util.CDOUtil; + +import org.eclipse.emf.internal.cdo.CDOSessionImpl; +import org.eclipse.emf.internal.cdo.CDOViewSetImpl; +import org.eclipse.emf.internal.cdo.InternalCDOViewSet; +import org.eclipse.emf.internal.cdo.bundle.OM; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.resource.ResourceSet; + +import java.util.Map; + +/** + * @author Eike Stepper + */ +public final class SessionUtil +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_SESSION, SessionUtil.class); + + private SessionUtil() + { + } + + public static CDOIDMetaRange registerEPackage(EPackage ePackage, int firstMetaID, + Map<CDOID, InternalEObject> idToMetaInstances, Map<InternalEObject, CDOID> metaInstanceToIDs) + { + CDOIDTemp lowerBound = CDOIDUtil.createTempMeta(firstMetaID); + CDOIDMetaRange range = CDOIDUtil.createMetaRange(lowerBound, 0); + range = registerMetaInstance((InternalEObject)ePackage, range, idToMetaInstances, metaInstanceToIDs); + return range; + } + + public static CDOIDMetaRange registerMetaInstance(InternalEObject metaInstance, CDOIDMetaRange range, + Map<CDOID, InternalEObject> idToMetaInstances, Map<InternalEObject, CDOID> metaInstanceToIDs) + { + range = range.increase(); + CDOID id = range.getUpperBound(); + if (TRACER.isEnabled()) + { + TRACER.format("Registering meta instance: {0} <-> {1}", id, metaInstance); + } + + if (idToMetaInstances != null) + { + if (idToMetaInstances.put(id, metaInstance) != null) + { + throw new IllegalStateException("Duplicate meta ID: " + id + " --> " + metaInstance); + } + } + + if (metaInstanceToIDs != null) + { + if (metaInstanceToIDs.put(metaInstance, id) != null) + { + throw new IllegalStateException("Duplicate metaInstance: " + metaInstance + " --> " + id); + } + } + + for (EObject content : metaInstance.eContents()) + { + range = registerMetaInstance((InternalEObject)content, range, idToMetaInstances, metaInstanceToIDs); + } + + return range; + } + + /** + * @since 2.0 + */ + public static InternalCDOViewSet prepareResourceSet(ResourceSet resourceSet) + { + InternalCDOViewSet viewSet = null; + synchronized (resourceSet) + { + viewSet = (InternalCDOViewSet)CDOUtil.getViewSet(resourceSet); + if (viewSet == null) + { + viewSet = new CDOViewSetImpl(); + resourceSet.eAdapters().add(viewSet); + } + } + + return viewSet; + } + + public static CDOSessionImpl createSession() + { + return new CDOSessionImpl(); + } +} |