Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2009-01-10 02:56:55 -0500
committerEike Stepper2009-01-10 02:56:55 -0500
commit364c7897a153a12b904932f9118f01d51d8ffefa (patch)
tree99077dd93e0c8dc7f58a7dd36ffde1ca9bca9d29 /plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util
parent9e9b95c59cb1e3f4be543c7551079a3153176ad1 (diff)
downloadcdo-364c7897a153a12b904932f9118f01d51d8ffefa.tar.gz
cdo-364c7897a153a12b904932f9118f01d51d8ffefa.tar.xz
cdo-364c7897a153a12b904932f9118f01d51d8ffefa.zip
[260613] Cleanup cdo.common plugin
https://bugs.eclipse.org/bugs/show_bug.cgi?id=260613
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.java446
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageTypeRegistryImpl.java266
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOViewProviderRegistryImpl.java279
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOViewSetPackageRegistryImpl.java79
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ChannelInjector.java74
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java26
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/PluginContainerViewProvider.java79
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/RevisionAdjuster.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/SessionUtil.java110
10 files changed, 17 insertions, 1350 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
deleted file mode 100644
index 6047687e4e..0000000000
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java
+++ /dev/null
@@ -1,446 +0,0 @@
-/***************************************************************************
- * 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
- * Eike Stepper - maintenance
- **************************************************************************/
-package org.eclipse.emf.internal.cdo.util;
-
-import org.eclipse.emf.cdo.CDOCommitContext;
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.CDOSession;
-import org.eclipse.emf.cdo.CDOTransaction;
-import org.eclipse.emf.cdo.CDOTransactionHandler;
-import org.eclipse.emf.cdo.CDOView;
-import org.eclipse.emf.cdo.common.id.CDOIDMetaRange;
-import org.eclipse.emf.cdo.common.model.CDOPackage;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackage;
-import org.eclipse.emf.cdo.util.CDOPackageRegistry;
-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.CDOSessionPackageManagerImpl;
-import org.eclipse.emf.internal.cdo.InternalCDOSession;
-import org.eclipse.emf.internal.cdo.bundle.OM;
-
-import org.eclipse.net4j.util.container.ContainerEventAdapter;
-import org.eclipse.net4j.util.container.IContainer;
-import org.eclipse.net4j.util.event.IListener;
-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.EClass;
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.impl.EPackageRegistryImpl;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements CDOPackageRegistry
-{
- private static final long serialVersionUID = 1L;
-
- private final ContextTracer tracer = new ContextTracer(OM.DEBUG_MODEL, CDOPackageRegistryImpl.class);
-
- private InternalCDOSession session;
-
- public CDOPackageRegistryImpl()
- {
- }
-
- public InternalCDOSession getSession()
- {
- return session;
- }
-
- public void setSession(CDOSession session)
- {
- this.session = (InternalCDOSession)session;
- }
-
- public void putPackageDescriptor(CDOPackage cdoPackage)
- {
- checkSession();
- EPackage.Descriptor descriptor = new RemotePackageDescriptor(cdoPackage);
- String uri = cdoPackage.getPackageURI();
- if (tracer.isEnabled())
- {
- tracer.format("Registering package descriptor for {0}", uri);
- }
-
- put(uri, descriptor);
- }
-
- /**
- * Insert the topPackage and its sub-packages by their URI
- */
- public EPackage putEPackage(EPackage ePackage) throws IllegalArgumentException
- {
- checkSession();
- String uri = ePackage.getNsURI();
- if (ePackage.getESuperPackage() != null)
- {
- throw new IllegalArgumentException("Not a top level package: " + uri);
- }
-
- putEPackage(uri, ePackage);
- return getEPackage(uri);
- }
-
- private void putEPackage(String uri, EPackage ePackage)
- {
- if (uri != null)
- {
- put(uri, ePackage);
- }
-
- for (EPackage subPackage : ePackage.getESubpackages())
- {
- putEPackage(subPackage.getNsURI(), subPackage);
- }
- }
-
- @Override
- public Object put(String key, Object value)
- {
- checkSession();
- if (value instanceof EPackage)
- {
- if (tracer.isEnabled())
- {
- tracer.format("Registering package for {0}", key);
- }
-
- EPackage ePackage = (EPackage)value;
- EMFUtil.prepareDynamicEPackage(ePackage);
-
- CDOSessionPackageManagerImpl packageManager = (CDOSessionPackageManagerImpl)session.getPackageManager();
- CDOPackage cdoPackage = ModelUtil.getCDOPackage(ePackage, packageManager);
- CDOIDMetaRange metaIDRange = cdoPackage.getTopLevelPackage().getMetaIDRange();
- ((InternalCDOPackage)cdoPackage).setPersistent(metaIDRange != null && !metaIDRange.isTemporary());
- }
-
- return super.put(key, value);
- }
-
- @Override
- public void putAll(Map<? extends String, ? extends Object> m)
- {
- throw new UnsupportedOperationException();
- }
-
- private void checkSession()
- {
- if (session == null)
- {
- throw new IllegalStateException("session == null");
- }
- }
-
- /**
- * @author Eike Stepper
- */
- private final class RemotePackageDescriptor implements EPackage.Descriptor
- {
- private CDOPackage cdoPackage;
-
- private RemotePackageDescriptor(CDOPackage cdoPackage)
- {
- this.cdoPackage = cdoPackage;
- }
-
- public CDOPackage getCDOPackage()
- {
- return cdoPackage;
- }
-
- public EFactory getEFactory()
- {
- // TODO Implement method RemotePackageDescriptor.getEFactory()
- throw new UnsupportedOperationException("Not yet implemented");
- }
-
- public EPackage getEPackage()
- {
- EPackage ePackage = ModelUtil.createEPackage(cdoPackage);
- CDOIDMetaRange idRange = cdoPackage.getMetaIDRange();
- if (idRange != null)
- {
- session.registerEPackage(ePackage, idRange);
- }
-
- return ePackage;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("RemotePackageDescriptor[{0}]", cdoPackage.getPackageURI());
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static abstract class SessionBound extends CDOPackageRegistryImpl
- {
- private static final long serialVersionUID = 1L;
-
- private IListener sessionLifecycleListener = new LifecycleEventAdapter()
- {
- @Override
- protected void onActivated(ILifecycle lifecycle)
- {
- sessionActivated();
- }
-
- @Override
- protected void onAboutToDeactivate(ILifecycle lifecycle)
- {
- getSession().removeListener(this);
- sessionAboutToDeactivate();
- }
- };
-
- public SessionBound()
- {
- }
-
- @Override
- public void setSession(CDOSession session)
- {
- super.setSession(session);
- session.addListener(sessionLifecycleListener);
- }
-
- protected abstract void sessionActivated();
-
- protected abstract void sessionAboutToDeactivate();
- }
-
- /**
- * @author Eike Stepper
- */
- public static class Eager extends SessionBound
- {
- private static final long serialVersionUID = 1L;
-
- private IListener typeListener = new ContainerEventAdapter<Map.Entry<String, CDOPackageType>>()
- {
- @Override
- protected void onAdded(IContainer<java.util.Map.Entry<String, CDOPackageType>> container,
- java.util.Map.Entry<String, CDOPackageType> entry)
- {
- addEntry(entry);
- }
- };
-
- public Eager()
- {
- }
-
- @Override
- protected void sessionActivated()
- {
- for (Map.Entry<String, CDOPackageType> entry : CDOPackageTypeRegistry.INSTANCE.entrySet())
- {
- addEntry(entry);
- }
-
- CDOPackageTypeRegistry.INSTANCE.addListener(typeListener);
- }
-
- @Override
- protected void sessionAboutToDeactivate()
- {
- CDOPackageTypeRegistry.INSTANCE.removeListener(typeListener);
- }
-
- protected void addEntry(Map.Entry<String, CDOPackageType> entry)
- {
- CDOPackageType packageType = entry.getValue();
- // TODO LEGACY
- if (packageType != CDOPackageType.LEGACY)
- {
- String uri = entry.getKey();
- if (!containsKey(uri))
- {
- try
- {
- EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(uri);
- if (ePackage.getESuperPackage() == null)
- {
- putEPackage(ePackage);
- }
- }
- catch (RuntimeException ex)
- {
- OM.LOG.error(ex);
- }
- }
- }
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static class TransactionBound extends SessionBound implements CDOTransactionHandler
- {
- private static final long serialVersionUID = 1L;
-
- private List<CDOTransaction> transactions = new ArrayList<CDOTransaction>();
-
- private IListener sessionContainerListener = new ContainerEventAdapter<CDOView>()
- {
- @Override
- protected void onAdded(IContainer<CDOView> session, CDOView view)
- {
- if (view instanceof CDOTransaction)
- {
- CDOTransaction transaction = (CDOTransaction)view;
- transaction.addHandler(TransactionBound.this);
- synchronized (transactions)
- {
- transactions.add(transaction);
- }
- }
- }
-
- @Override
- protected void onRemoved(IContainer<CDOView> session, CDOView view)
- {
- if (view instanceof CDOTransaction)
- {
- CDOTransaction transaction = (CDOTransaction)view;
- transaction.removeHandler(TransactionBound.this);
- synchronized (transactions)
- {
- transactions.remove(transaction);
- }
- }
- }
- };
-
- public TransactionBound()
- {
- }
-
- @Override
- protected void sessionActivated()
- {
- getSession().addListener(sessionContainerListener);
- }
-
- @Override
- protected void sessionAboutToDeactivate()
- {
- getSession().removeListener(sessionContainerListener);
- synchronized (transactions)
- {
- for (CDOTransaction transaction : transactions)
- {
- transaction.removeHandler(this);
- }
-
- transactions.clear();
- }
- }
-
- public void attachingObject(CDOTransaction transaction, CDOObject object)
- {
- }
-
- public void modifyingObject(CDOTransaction transaction, CDOObject object, CDOFeatureDelta featureDelta)
- {
- }
-
- public void committingTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
- {
- }
-
- public void rolledBackTransaction(CDOTransaction transaction)
- {
- }
-
- public void detachingObject(CDOTransaction transaction, CDOObject object)
- {
- }
-
- public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
- {
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static class Lazy extends TransactionBound
- {
- private static final long serialVersionUID = 1L;
-
- private Set<EClass> usedClasses = new HashSet<EClass>();
-
- public Lazy()
- {
- }
-
- @Override
- public void attachingObject(CDOTransaction transaction, CDOObject object)
- {
- EClass usedClass = object.eClass();
- addAllEPackages(usedClass);
- }
-
- private void addAllEPackages(EClass eClass)
- {
- if (usedClasses.add(eClass))
- {
- addPackage(eClass.getEPackage());
- for (EClass superType : eClass.getEAllSuperTypes())
- {
- addAllEPackages(superType);
- }
-
- for (EReference eReference : eClass.getEAllReferences())
- {
- addAllEPackages(eReference.getEReferenceType());
- }
- }
- }
-
- @Override
- protected void sessionAboutToDeactivate()
- {
- usedClasses.clear();
- super.sessionAboutToDeactivate();
- }
-
- private void addPackage(EPackage ePackage)
- {
- if (!containsKey(ePackage.getNsURI()))
- {
- EPackage topLevelPackage = ModelUtil.getTopLevelPackage(ePackage);
- // PutEPackage
- putEPackage(topLevelPackage);
- }
- }
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageTypeRegistryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageTypeRegistryImpl.java
deleted file mode 100644
index dd2629cad2..0000000000
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageTypeRegistryImpl.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/***************************************************************************
- * 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.CDOObject;
-import org.eclipse.emf.cdo.eresource.EresourcePackage;
-import org.eclipse.emf.cdo.util.CDOFactory;
-import org.eclipse.emf.cdo.util.CDOPackageType;
-import org.eclipse.emf.cdo.util.CDOPackageTypeRegistry;
-
-import org.eclipse.emf.internal.cdo.bundle.OM;
-
-import org.eclipse.net4j.util.StringUtil;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.registry.HashMapRegistry;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.impl.EPackageImpl;
-import org.eclipse.emf.ecore.plugin.EcorePlugin;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.dynamichelpers.ExtensionTracker;
-import org.eclipse.core.runtime.dynamichelpers.IExtensionChangeHandler;
-import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker;
-import org.eclipse.core.runtime.dynamichelpers.IFilter;
-
-import org.osgi.framework.Bundle;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public final class CDOPackageTypeRegistryImpl extends HashMapRegistry<String, CDOPackageType> implements
- CDOPackageTypeRegistry
-{
- public static final CDOPackageTypeRegistryImpl INSTANCE = new CDOPackageTypeRegistryImpl();
-
- private static final String ECORE_ID = "org.eclipse.emf.ecore";
-
- private Object extensionTracker;
-
- private CDOPackageTypeRegistryImpl()
- {
- activate();
- }
-
- public void register(EPackage ePackage)
- {
- put(ePackage.getNsURI(), getPackageType(ePackage));
- }
-
- public void registerLegacy(String packageURI)
- {
- put(packageURI, CDOPackageType.LEGACY);
- }
-
- public void registerNative(String packageURI)
- {
- put(packageURI, CDOPackageType.NATIVE);
- }
-
- public void reset()
- {
- deactivate();
- activate();
- }
-
- @Override
- protected void doActivate() throws Exception
- {
- super.doActivate();
- initPackageTypes();
- if (OMPlatform.INSTANCE.isOSGiRunning())
- {
- try
- {
- connectExtensionTracker();
- }
- catch (Throwable t)
- {
- OM.LOG.error(t);
- }
- }
- }
-
- @Override
- protected void doDeactivate() throws Exception
- {
- if (OMPlatform.INSTANCE.isOSGiRunning())
- {
- try
- {
- disconnectExtensionTracker();
- }
- catch (Throwable t)
- {
- OM.LOG.error(t);
- }
- }
-
- clear();
- super.doDeactivate();
- }
-
- private void initPackageTypes()
- {
- for (Object object : EPackage.Registry.INSTANCE.values())
- {
- if (object instanceof EPackage)
- {
- EPackage ePackage = (EPackage)object;
- register(ePackage);
- }
- }
-
- if (OMPlatform.INSTANCE.isOSGiRunning())
- {
- IConfigurationElement[] elements = Platform.getExtensionRegistry().getConfigurationElementsFor(ECORE_ID,
- EcorePlugin.GENERATED_PACKAGE_PPID);
- addPackageTypes(elements);
- }
- }
-
- private void addPackageTypes(IConfigurationElement[] elements)
- {
- Map<String, CDOPackageType> bundles = new HashMap<String, CDOPackageType>();
- for (IConfigurationElement element : elements)
- {
- String uri = element.getAttribute("uri");
- if (!StringUtil.isEmpty(uri) && !uri.equals(EresourcePackage.eINSTANCE.getNsURI()) && !containsKey(uri))
- {
- String bundleName = element.getContributor().getName();
- CDOPackageType packageType = bundles.get(bundleName);
- if (packageType == null)
- {
- Bundle bundle = Platform.getBundle(bundleName);
- packageType = getBundleType(bundle);
- bundles.put(bundleName, packageType);
- }
-
- put(uri, packageType);
- }
- }
- }
-
- private CDOPackageType getBundleType(Bundle bundle)
- {
- if (bundle.getEntry("META-INF/CDO.MF") != null)
- {
- return CDOPackageType.NATIVE;
- }
-
- return CDOPackageType.LEGACY;
- }
-
- private void connectExtensionTracker()
- {
- ExtensionTracker extensionTracker = new ExtensionTracker();
- extensionTracker.registerHandler(new IExtensionChangeHandler()
- {
- public void addExtension(IExtensionTracker tracker, IExtension extension)
- {
- IConfigurationElement[] elements = extension.getConfigurationElements();
- addPackageTypes(elements);
- }
-
- public void removeExtension(IExtension extension, Object[] objects)
- {
- }
- }, createExtensionPointFilter());
-
- this.extensionTracker = extensionTracker;
- }
-
- private void disconnectExtensionTracker()
- {
- ExtensionTracker extensionTracker = (ExtensionTracker)this.extensionTracker;
- extensionTracker.close();
- }
-
- private IFilter createExtensionPointFilter()
- {
- final IExtensionPoint xpt = Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.emf.ecore",
- EcorePlugin.GENERATED_PACKAGE_PPID);
- return new IFilter()
- {
- public boolean matches(IExtensionPoint target)
- {
- return xpt.equals(target);
- }
- };
- }
-
- public static CDOPackageType getPackageType(EPackage ePackage)
- {
- if (ePackage.getClass() == EPackageImpl.class)
- {
- EFactory factory = ePackage.getEFactoryInstance();
- if (factory instanceof CDOFactory)
- {
- return CDOPackageType.NATIVE;
- }
-
- return CDOPackageType.LEGACY;
- }
-
- EPackage topLevelPackage = ModelUtil.getTopLevelPackage(ePackage);
- EClass eClass = getAnyConcreteEClass(topLevelPackage);
- if (eClass == null)
- {
- return CDOPackageType.LEGACY;
- }
-
- EObject testObject = EcoreUtil.create(eClass);
- if (testObject instanceof CDOObject)
- {
- return CDOPackageType.NATIVE;
- }
-
- return CDOPackageType.LEGACY;
- }
-
- private static EClass getAnyConcreteEClass(EPackage ePackage)
- {
- for (EClassifier classifier : ePackage.getEClassifiers())
- {
- if (classifier instanceof EClass)
- {
- EClass eClass = (EClass)classifier;
- if (!(eClass.isAbstract() || eClass.isInterface()))
- {
- return eClass;
- }
- }
- }
-
- for (EPackage subpackage : ePackage.getESubpackages())
- {
- EClass eClass = getAnyConcreteEClass(subpackage);
- if (eClass != null)
- {
- return eClass;
- }
- }
-
- return null;
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOViewProviderRegistryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOViewProviderRegistryImpl.java
deleted file mode 100644
index 33c3d1355e..0000000000
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOViewProviderRegistryImpl.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/***************************************************************************
- * 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:
- * Victor Roldan Betancort - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.internal.cdo.util;
-
-import org.eclipse.emf.cdo.CDOView;
-import org.eclipse.emf.cdo.CDOViewSet;
-import org.eclipse.emf.cdo.util.AbstractCDOViewProvider;
-import org.eclipse.emf.cdo.util.CDOURIUtil;
-import org.eclipse.emf.cdo.util.CDOViewProvider;
-import org.eclipse.emf.cdo.util.CDOViewProviderRegistry;
-
-import org.eclipse.emf.internal.cdo.bundle.OM;
-
-import org.eclipse.net4j.util.StringUtil;
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.container.Container;
-import org.eclipse.net4j.util.om.OMPlatform;
-
-import org.eclipse.emf.common.util.URI;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-/**
- * When instanced in Eclipse, it's populated with contributions from the viewProvider Extension Point. A default
- * CDOViewProvider implementation is registered, regardless of the execution environment.
- *
- * @author Victor Roldan Betancort
- * @since 2.0
- * @see CDOViewProvider
- */
-public class CDOViewProviderRegistryImpl extends Container<CDOViewProvider> implements CDOViewProviderRegistry
-{
- public static final CDOViewProviderRegistryImpl INSTANCE = new CDOViewProviderRegistryImpl();
-
- private static final String EXT_POINT = "viewProviders";
-
- private List<CDOViewProvider> viewProviders = new ArrayList<CDOViewProvider>();
-
- public CDOViewProviderRegistryImpl()
- {
- if (OMPlatform.INSTANCE.isOSGiRunning())
- {
- addViewProvider(new PluginContainerViewProvider());
- }
- }
-
- public CDOView provideView(URI uri, CDOViewSet viewSet)
- {
- if (uri == null)
- {
- return null;
- }
-
- if (viewSet != null)
- {
- try
- {
- String uuid = CDOURIUtil.extractRepositoryUUID(uri);
- CDOView view = viewSet.resolveView(uuid);
- if (view != null)
- {
- return view;
- }
- }
- catch (Exception ignore)
- {
- // Do nothing
- }
- }
-
- for (CDOViewProvider viewProvider : getViewProviders(uri))
- {
- CDOView view = viewProvider.getView(uri, viewSet);
- if (view != null)
- {
- return view;
- }
- }
-
- return null;
- }
-
- public CDOViewProvider[] getViewProviders(URI uri)
- {
- List<CDOViewProvider> result = new ArrayList<CDOViewProvider>();
- for (CDOViewProvider viewProvider : viewProviders)
- {
- if (viewProvider.matchesRegex(uri))
- {
- result.add(viewProvider);
- }
- }
-
- // Sort highest priority first
- Collections.sort(result, new Comparator<CDOViewProvider>()
- {
- public int compare(CDOViewProvider o1, CDOViewProvider o2)
- {
- return -new Integer(o1.getPriority()).compareTo(o2.getPriority());
- }
- });
-
- return result.toArray(new CDOViewProvider[result.size()]);
- }
-
- // public CDOViewProvider[] getViewProviders(URI uri, CDOViewSet viewSet)
- // {
- // List<CDOViewProvider> orderedProviders = new ArrayList<CDOViewProvider>();
- // for (CDOViewProvider viewProvider : viewProviders)
- // {
- // if (viewProvider.matchesRegex(uri))
- // {
- // for (int i = orderedProviders.size() - 1; i >= 0; i--)
- // {
- // if (viewProvider.getPriority() <= orderedProviders.get(i).getPriority())
- // {
- // orderedProviders.add(i + 1, viewProvider);
- // break;
- // }
- // }
- //
- // // if not inserted, it has highest priority
- // if (!orderedProviders.contains(viewProvider))
- // {
- // orderedProviders.add(0, viewProvider);
- // }
- // }
- // }
- //
- // return orderedProviders.toArray(new CDOViewProvider[orderedProviders.size()]);
- // }
-
- public void addViewProvider(CDOViewProvider viewProvider)
- {
- boolean added;
- synchronized (viewProviders)
- {
- added = !viewProviders.contains(viewProvider);
- if (added)
- {
- viewProviders.add(viewProvider);
- }
- }
-
- if (added)
- {
- fireElementAddedEvent(viewProvider);
- }
- }
-
- public void removeViewProvider(CDOViewProvider viewProvider)
- {
- boolean removed;
- synchronized (viewProviders)
- {
- removed = viewProviders.remove(viewProvider);
- }
-
- if (removed)
- {
- fireElementRemovedEvent(viewProvider);
- }
- }
-
- public CDOViewProvider[] getElements()
- {
- synchronized (viewProviders)
- {
- return viewProviders.toArray(new CDOViewProvider[viewProviders.size()]);
- }
- }
-
- @Override
- public boolean isEmpty()
- {
- synchronized (viewProviders)
- {
- return viewProviders.isEmpty();
- }
- }
-
- @Override
- protected void doActivate() throws Exception
- {
- super.doActivate();
- if (OMPlatform.INSTANCE.isOSGiRunning())
- {
- try
- {
- readExtensions();
- }
- catch (Throwable t)
- {
- OM.LOG.error(t);
- }
- }
- }
-
- @Override
- protected void doDeactivate() throws Exception
- {
- super.doDeactivate();
- }
-
- public void readExtensions()
- {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] configurationElements = registry.getConfigurationElementsFor(OM.BUNDLE_ID, EXT_POINT);
- for (IConfigurationElement element : configurationElements)
- {
- try
- {
- CDOViewProviderDescriptor descriptor = new CDOViewProviderDescriptor(element);
- addViewProvider(descriptor);
- }
- catch (Exception ex)
- {
- OM.LOG.error(ex);
- }
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public static final class CDOViewProviderDescriptor extends AbstractCDOViewProvider
- {
- private IConfigurationElement element;
-
- public CDOViewProviderDescriptor(IConfigurationElement element)
- {
- super(element.getAttribute("regex"), Integer.parseInt(element.getAttribute("priority")));
- this.element = element;
-
- if (StringUtil.isEmpty(element.getAttribute("class")))
- {
- throw new IllegalArgumentException("class not defined for extension " + element);
- }
-
- if (StringUtil.isEmpty(element.getAttribute("regex")))
- {
- throw new IllegalArgumentException("regex not defined for extension " + element);
- }
- }
-
- public CDOView getView(URI uri, CDOViewSet viewSet)
- {
- return getViewProvider().getView(uri, viewSet);
- }
-
- private CDOViewProvider getViewProvider()
- {
- try
- {
- return (CDOViewProvider)element.createExecutableExtension("class");
- }
- catch (CoreException ex)
- {
- throw WrappedException.wrap(ex);
- }
- }
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOViewSetPackageRegistryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOViewSetPackageRegistryImpl.java
deleted file mode 100644
index b000f25016..0000000000
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOViewSetPackageRegistryImpl.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/***************************************************************************
- * 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:
- * Simon McDuff - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.internal.cdo.util;
-
-import org.eclipse.emf.cdo.CDOView;
-import org.eclipse.emf.cdo.CDOViewSet;
-
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.impl.EPackageRegistryImpl;
-
-/**
- * @author Simon McDuff
- */
-public class CDOViewSetPackageRegistryImpl extends EPackageRegistryImpl
-{
- private static final long serialVersionUID = 1L;
-
- private CDOViewSet viewSet;
-
- public CDOViewSetPackageRegistryImpl(CDOViewSet viewSet, EPackage.Registry delegateRegistry)
- {
- super(delegateRegistry);
- this.viewSet = viewSet;
- }
-
- @Override
- protected EPackage delegatedGetEPackage(String nsURI)
- {
- for (CDOView view : viewSet.getViews())
- {
- EPackage ePackage = view.getSession().getPackageRegistry().getEPackage(nsURI);
- if (ePackage != null)
- {
- return ePackage;
- }
- }
-
- return super.delegatedGetEPackage(nsURI);
- }
-
- @Override
- public Object put(String key, Object value)
- {
- super.put(key, value);
- for (CDOView view : viewSet.getViews())
- {
- view.getSession().getPackageRegistry().put(key, value);
- }
-
- return null;
- }
-
- @Override
- public synchronized Object get(Object key)
- {
- Object ePackage = super.get(key);
- if (ePackage == null)
- {
- for (CDOView view : viewSet.getViews())
- {
- ePackage = view.getSession().getPackageRegistry().get(key);
- if (ePackage != null)
- {
- return ePackage;
- }
- }
- }
-
- return ePackage;
- }
-}
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
deleted file mode 100644
index 947e8e2b5f..0000000000
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ChannelInjector.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/***************************************************************************
- * 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.CDOSession;
-
-import org.eclipse.net4j.connector.IConnector;
-import org.eclipse.net4j.signal.failover.NOOPFailOverStrategy;
-import org.eclipse.net4j.util.StringUtil;
-import org.eclipse.net4j.util.container.IElementProcessor;
-import org.eclipse.net4j.util.container.IManagedContainer;
-
-import org.eclipse.spi.net4j.ConnectorFactory;
-
-/**
- * @author Eike Stepper
- */
-public class ChannelInjector implements IElementProcessor
-{
- private static final String SCHEME_SEPARATOR = "://";
-
- public ChannelInjector()
- {
- }
-
- public Object process(IManagedContainer container, String productGroup, String factoryType, String description,
- Object element)
- {
- if (element instanceof CDOSession)
- {
- CDOSession session = (CDOSession)element;
- session.getProtocol().setFailOverStrategy(new NOOPFailOverStrategy(getConnector(container, description)));
- }
-
- return element;
- }
-
- protected IConnector getConnector(IManagedContainer container, String description)
- {
- int pos = description.indexOf(SCHEME_SEPARATOR);
- if (pos == -1)
- {
- throw new IllegalArgumentException("Invalid URI: " + description);
- }
-
- String factoryType = description.substring(0, pos);
- if (StringUtil.isEmpty(factoryType))
- {
- throw new IllegalArgumentException("Invalid URI: " + description);
- }
-
- String connectorDescription = description.substring(pos + SCHEME_SEPARATOR.length());
- if (StringUtil.isEmpty(connectorDescription))
- {
- throw new IllegalArgumentException("Invalid URI: " + description);
- }
-
- pos = connectorDescription.indexOf('?');
- if (pos != -1)
- {
- connectorDescription = connectorDescription.substring(0, pos);
- }
-
- return (IConnector)container.getElement(ConnectorFactory.PRODUCT_GROUP, factoryType, connectorDescription);
- }
-}
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 1e30fb82e4..69dc63ce6a 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
@@ -13,17 +13,15 @@ package org.eclipse.emf.internal.cdo.util;
import org.eclipse.emf.cdo.CDOObject;
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.util.InvalidObjectException;
import org.eclipse.emf.cdo.util.ObjectNotFoundException;
+import org.eclipse.emf.cdo.view.CDOView;
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.InternalCDOObject;
-import org.eclipse.emf.internal.cdo.InternalCDOView;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EGenericType;
@@ -32,6 +30,8 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.spi.cdo.InternalCDOObject;
+import org.eclipse.emf.spi.cdo.InternalCDOView;
import java.util.Collection;
import java.util.Iterator;
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 a6032d53e4..81b3d3df17 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
@@ -27,15 +27,14 @@ import org.eclipse.emf.cdo.common.model.resource.CDOResourceNodeClass;
import org.eclipse.emf.cdo.common.model.resource.CDOResourcePackage;
import org.eclipse.emf.cdo.common.util.CDOException;
import org.eclipse.emf.cdo.eresource.EresourcePackage;
+import org.eclipse.emf.cdo.session.CDOPackageRegistry;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOClass;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOFeature;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackage;
-import org.eclipse.emf.cdo.util.CDOPackageRegistry;
import org.eclipse.emf.cdo.util.EMFUtil;
-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.session.CDOSessionPackageManagerImpl;
import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.net4j.util.ObjectUtil;
@@ -51,6 +50,7 @@ import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.impl.EPackageImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.spi.cdo.InternalCDOSession;
/**
* @author Eike Stepper
@@ -172,7 +172,7 @@ public final class ModelUtil
return cdoClass.lookupFeature(eFeature.getFeatureID());
}
- static CDOPackage addCDOPackage(EPackage ePackage, CDOSessionPackageManagerImpl packageManager)
+ public static CDOPackage addCDOPackage(EPackage ePackage, CDOSessionPackageManagerImpl packageManager)
{
CDOPackage cdoPackage = createCDOPackage(ePackage, packageManager);
packageManager.addPackage(cdoPackage);
@@ -189,7 +189,7 @@ public final class ModelUtil
* @see EMFUtil#getPersistentFeatures(org.eclipse.emf.common.util.EList)
* @see http://www.eclipse.org/newsportal/article.php?id=26780&group=eclipse.tools.emf#26780
*/
- static CDOPackage createCDOPackage(EPackage ePackage, CDOSessionPackageManagerImpl packageManager)
+ public static CDOPackage createCDOPackage(EPackage ePackage, CDOSessionPackageManagerImpl packageManager)
{
InternalCDOSession session = packageManager.getSession();
String uri = ePackage.getNsURI();
@@ -214,7 +214,7 @@ public final class ModelUtil
return cdoPackage;
}
- static CDOClass createCDOClass(EClass eClass, CDOPackage containingPackage)
+ public static CDOClass createCDOClass(EClass eClass, CDOPackage containingPackage)
{
InternalCDOClass cdoClass = (InternalCDOClass)CDOModelUtil.createClass(containingPackage, eClass.getClassifierID(),
eClass.getName(), eClass.isAbstract());
@@ -238,7 +238,7 @@ public final class ModelUtil
return cdoClass;
}
- static CDOFeature createCDOFeature(EStructuralFeature eFeature, CDOClass containingClass)
+ public static CDOFeature createCDOFeature(EStructuralFeature eFeature, CDOClass containingClass)
{
InternalCDOFeature cdoFeature = (InternalCDOFeature)(EMFUtil.isReference(eFeature) ? createCDOReference(
(EReference)eFeature, containingClass) : createCDOAttribute((EAttribute)eFeature, containingClass));
@@ -246,7 +246,7 @@ public final class ModelUtil
return cdoFeature;
}
- static CDOFeature createCDOReference(EReference eFeature, CDOClass containingClass)
+ public static CDOFeature createCDOReference(EReference eFeature, CDOClass containingClass)
{
CDOPackageManager packageManager = containingClass.getPackageManager();
int featureID = eFeature.getFeatureID();
@@ -267,7 +267,7 @@ public final class ModelUtil
return cdoFeature;
}
- static CDOFeature createCDOAttribute(EAttribute eFeature, CDOClass containingClass)
+ public static CDOFeature createCDOAttribute(EAttribute eFeature, CDOClass containingClass)
{
int featureID = eFeature.getFeatureID();
String name = eFeature.getName();
@@ -327,7 +327,7 @@ public final class ModelUtil
return eFeature;
}
- static EPackage createEPackage(CDOPackage cdoPackage)
+ public static EPackage createEPackage(CDOPackage cdoPackage)
{
if (cdoPackage.isDynamic())
{
@@ -343,7 +343,7 @@ public final class ModelUtil
return ePackage;
}
- static EPackage getGeneratedEPackage(CDOPackage cdoPackage)
+ public static EPackage getGeneratedEPackage(CDOPackage cdoPackage)
{
String packageURI = cdoPackage.getPackageURI();
if (packageURI.equals(EcorePackage.eINSTANCE.getNsURI()))
@@ -355,7 +355,7 @@ public final class ModelUtil
return registry.getEPackage(packageURI);
}
- static EPackage createDynamicEPackage(CDOPackage cdoPackage)
+ public static EPackage createDynamicEPackage(CDOPackage cdoPackage)
{
CDOPackage topLevelPackage = cdoPackage.getTopLevelPackage();
String ecore = topLevelPackage.getEcore();
@@ -364,7 +364,7 @@ public final class ModelUtil
return ePackage;
}
- static EPackageImpl prepareDynamicEPackage(EPackageImpl ePackage, String nsURI)
+ public static EPackageImpl prepareDynamicEPackage(EPackageImpl ePackage, String nsURI)
{
EMFUtil.prepareDynamicEPackage(ePackage);
EPackageImpl result = ObjectUtil.equals(ePackage.getNsURI(), nsURI) ? ePackage : null;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/PluginContainerViewProvider.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/PluginContainerViewProvider.java
deleted file mode 100644
index 19762a77bc..0000000000
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/PluginContainerViewProvider.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/***************************************************************************
- * 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:
- * Victor Roldan Betancort - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.internal.cdo.util;
-
-import org.eclipse.emf.cdo.CDOSession;
-import org.eclipse.emf.cdo.CDOView;
-import org.eclipse.emf.cdo.CDOViewSet;
-import org.eclipse.emf.cdo.util.CDOURIUtil;
-import org.eclipse.emf.cdo.util.CDOViewProvider;
-import org.eclipse.emf.cdo.util.ManagedContainerViewProvider;
-
-import org.eclipse.emf.internal.cdo.CDOSessionFactory;
-
-import org.eclipse.net4j.util.container.IManagedContainer;
-import org.eclipse.net4j.util.container.IPluginContainer;
-
-import org.eclipse.emf.common.util.URI;
-
-/**
- * Provides <code>CDOView</code> from <code>CDOSession</code> registered in IPluginContainer
- *
- * @author Victor Roldan Betancort
- */
-public class PluginContainerViewProvider extends ManagedContainerViewProvider implements CDOViewProvider
-{
- private final static String REGEX = "cdo:.*";
-
- private final static int PRIORITY = 400;
-
- public PluginContainerViewProvider()
- {
- super(IPluginContainer.INSTANCE, REGEX, PRIORITY);
- }
-
- public CDOView getView(URI uri, CDOViewSet viewSet)
- {
- IManagedContainer container = getContainer();
- if (container == null)
- {
- return null;
- }
-
- String repoUUID = CDOURIUtil.extractRepositoryUUID(uri);
- for (Object element : container.getElements(CDOSessionFactory.PRODUCT_GROUP, CDOSessionFactory.TYPE))
- {
- CDOSession session = (CDOSession)element;
- String uuid = session.repository().getUUID();
- if (repoUUID.equals(uuid))
- {
- CDOView view = openView(session, uri);
- if (view != null)
- {
- return view;
- }
- }
- }
-
- return null;
- }
-
- @Override
- protected IManagedContainer getContainer()
- {
- return IPluginContainer.INSTANCE;
- }
-
- protected CDOView openView(CDOSession session, URI uri)
- {
- return session.openTransaction();
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/RevisionAdjuster.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/RevisionAdjuster.java
index 224e4123cb..8b687eae0b 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/RevisionAdjuster.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/RevisionAdjuster.java
@@ -25,7 +25,7 @@ import org.eclipse.emf.cdo.internal.common.revision.delta.CDOListFeatureDeltaImp
import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.internal.cdo.revision.CDOElementProxy;
+import org.eclipse.emf.spi.cdo.CDOElementProxy;
/**
* @author Simon McDuff
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
deleted file mode 100644
index a29ebd08ac..0000000000
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/SessionUtil.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/***************************************************************************
- * 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