Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-11-14 15:16:09 -0500
committerEike Stepper2008-11-14 15:16:09 -0500
commit59b6e52cd6d890b1a3a83d89c4ed4eb93ac485eb (patch)
treea3b56a3b2e924e3ee273e37818340b02ad2242d4 /plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util
parentb90b1de0facff285594feef6563cad94209da11e (diff)
downloadcdo-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/emf/internal/cdo/util')
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java13
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ChannelInjector.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java10
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/SessionUtil.java110
5 files changed, 128 insertions, 15 deletions
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();
+ }
+}

Back to the top