summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-17 05:28:28 (EDT)
committerEike Stepper2007-07-17 05:28:28 (EDT)
commit47dabed44c556e67a420f20034f2db0bafc82dfa (patch)
treee34c5c122ed25bb1040ef8d41273789340d90645
parent8cafaf357477ef020616cacfad7a307cb6409f5b (diff)
downloadcdo-47dabed44c556e67a420f20034f2db0bafc82dfa.zip
cdo-47dabed44c556e67a420f20034f2db0bafc82dfa.tar.gz
cdo-47dabed44c556e67a420f20034f2db0bafc82dfa.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenReadOnlyViewAction.java (renamed from plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenTransactionAction.java)10
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewAction.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOPackageRegistry.java1
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOUtil.java14
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOFactoryImpl.java8
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java13
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOPackageRegistryImpl.java64
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java11
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManager.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java12
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java39
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/DynamicCDOObjectImpl.java45
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/EMFUtil.java14
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/OverridablePackageRegistry.java103
16 files changed, 291 insertions, 59 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenTransactionAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenReadOnlyViewAction.java
index 6ef4079..b765c4b 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenTransactionAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenReadOnlyViewAction.java
@@ -2,7 +2,6 @@ package org.eclipse.emf.cdo.internal.ui.actions;
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.internal.ui.SharedIcons;
-import org.eclipse.emf.cdo.internal.ui.views.CDOItemProvider;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
@@ -12,16 +11,17 @@ import org.eclipse.ui.IWorkbenchPage;
/**
* @author Eike Stepper
*/
-public final class OpenTransactionAction extends SessionAction
+public final class OpenReadOnlyViewAction extends SessionAction
{
- public OpenTransactionAction(IWorkbenchPage page, CDOSession session)
+ public OpenReadOnlyViewAction(IWorkbenchPage page, CDOSession session)
{
- super(page, "Open Transaction", "Open a CDO transaction", SharedIcons.getDescriptor(SharedIcons.ETOOL_OPEN_EDITOR), session);
+ super(page, "Open Read-Only View", "Open a read-only CDO view", SharedIcons
+ .getDescriptor(SharedIcons.ETOOL_OPEN_EDITOR), session);
}
@Override
protected void doRun(IWorkbenchPage page, IProgressMonitor monitor) throws Exception
{
- getSession().openView(new ResourceSetImpl());
+ getSession().openView(new ResourceSetImpl(), true);
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewAction.java
index 807708a..dbde404 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/OpenViewAction.java
@@ -2,7 +2,6 @@ package org.eclipse.emf.cdo.internal.ui.actions;
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.internal.ui.SharedIcons;
-import org.eclipse.emf.cdo.internal.ui.views.CDOItemProvider;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
@@ -16,12 +15,13 @@ public final class OpenViewAction extends SessionAction
{
public OpenViewAction(IWorkbenchPage page, CDOSession session)
{
- super(page, "Open View", "Open a CDO view", SharedIcons.getDescriptor(SharedIcons.ETOOL_OPEN_EDITOR), session);
+ super(page, "Open View", "Open a read-write CDO view", SharedIcons.getDescriptor(SharedIcons.ETOOL_OPEN_EDITOR),
+ session);
}
@Override
protected void doRun(IWorkbenchPage page, IProgressMonitor monitor) throws Exception
{
- getSession().openView(new ResourceSetImpl(), true);
+ getSession().openView(new ResourceSetImpl());
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
index e9c4dec..c4e0edb 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
@@ -21,8 +21,8 @@ import org.eclipse.emf.cdo.internal.ui.actions.CloseViewAction;
import org.eclipse.emf.cdo.internal.ui.actions.CreateResourceAction;
import org.eclipse.emf.cdo.internal.ui.actions.LoadResourceAction;
import org.eclipse.emf.cdo.internal.ui.actions.OpenHistoricalViewAction;
-import org.eclipse.emf.cdo.internal.ui.actions.OpenTransactionAction;
import org.eclipse.emf.cdo.internal.ui.actions.OpenViewAction;
+import org.eclipse.emf.cdo.internal.ui.actions.OpenReadOnlyViewAction;
import org.eclipse.emf.cdo.internal.ui.actions.ShowViewAction;
import org.eclipse.emf.cdo.internal.ui.views.CDOViewHistory.Entry;
@@ -248,8 +248,8 @@ public class CDOItemProvider extends ContainerItemProvider
protected void fillSession(IMenuManager manager, CDOSession session)
{
- manager.add(new OpenTransactionAction(page, session));
manager.add(new OpenViewAction(page, session));
+ manager.add(new OpenReadOnlyViewAction(page, session));
manager.add(new OpenHistoricalViewAction(page, session));
manager.add(new Separator());
manager.add(new CloseSessionAction(page, session));
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
index 83245d4..b284916 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
@@ -17,6 +17,7 @@ import org.eclipse.emf.cdo.protocol.revision.CDORevision;
import org.eclipse.net4j.util.event.INotifier;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.resource.ResourceSet;
/**
@@ -50,6 +51,8 @@ public interface CDOView extends INotifier
*/
public CDOResource getResource(String path);
+ public CDOObject newInstance(EClass eClass);
+
public CDORevision resolve(CDOID id);
public boolean isDirty();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOPackageRegistry.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOPackageRegistry.java
index c051a43..b7b8bf7 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOPackageRegistry.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOPackageRegistry.java
@@ -17,4 +17,5 @@ import org.eclipse.emf.ecore.EPackage;
*/
public interface CDOPackageRegistry extends EPackage.Registry
{
+ public EPackage putEPackage(EPackage ePackage);
}
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 c0129c2..dd358d6 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
@@ -10,14 +10,12 @@
**************************************************************************/
package org.eclipse.emf.cdo.util;
-import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.eresource.CDOResourceFactory;
import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
-import org.eclipse.emf.cdo.protocol.model.CDOClass;
import org.eclipse.net4j.ConnectorException;
import org.eclipse.net4j.IConnector;
@@ -36,10 +34,8 @@ import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.emf.ecore.impl.EFactoryImpl;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.Resource.Factory.Registry;
-import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.internal.cdo.CDOFactoryImpl;
import org.eclipse.emf.internal.cdo.CDOSessionImpl;
-import org.eclipse.emf.internal.cdo.util.EMFUtil;
import java.util.Map;
@@ -53,10 +49,10 @@ public final class CDOUtil
}
@Deprecated
- public static CDOSession openSession(IConnector connector, String repositoryName, EPackage.Registry ePackageRegistry)
+ public static CDOSession openSession(IConnector connector, String repositoryName, EPackage.Registry delegate)
throws ConnectorException
{
- CDOSessionImpl session = new CDOSessionImpl(ePackageRegistry);
+ CDOSessionImpl session = new CDOSessionImpl(delegate);
session.setConnector(connector);
session.setRepositoryName(repositoryName);
LifecycleUtil.activate(session);
@@ -154,12 +150,6 @@ public final class CDOUtil
return URI.createURI(CDOProtocolConstants.PROTOCOL_NAME + ":" + path);
}
- public static CDOObject createObject(CDOClass cdoClass)
- {
- EClass eClass = EMFUtil.getEClass(cdoClass);
- return (CDOObject)EcoreUtil.create(eClass);
- }
-
public static void prepareEPackage(EPackage ePackage)
{
EFactory factory = ePackage.getEFactoryInstance();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOFactoryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOFactoryImpl.java
index 8b5be87..3bc7e24 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOFactoryImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOFactoryImpl.java
@@ -12,6 +12,8 @@ package org.eclipse.emf.internal.cdo;
import org.eclipse.emf.cdo.util.CDOFactory;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.impl.EFactoryImpl;
@@ -24,4 +26,10 @@ public class CDOFactoryImpl extends EFactoryImpl implements CDOFactory
{
this.ePackage = ePackage;
}
+
+ @Override
+ protected EObject basicCreate(EClass eClass)
+ {
+ return new DynamicCDOObjectImpl(eClass);
+ }
}
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 de4291d..eff2d2d 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
@@ -52,15 +52,18 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements CDOObject
super(CDOStore.INSTANCE);
state = CDOState.TRANSIENT;
eContainer = null;
- if (TRACER.isEnabled())
- {
- TRACER.format("Creating object: {0}", cdoClass());
- }
}
public CDOClassImpl cdoClass()
{
- return EMFUtil.getCDOClass(eClass(), cdoView().getSession().getPackageManager());
+ CDOViewImpl view = cdoView();
+ if (view == null)
+ {
+ System.out.println(eClass());
+ }
+
+ CDOSessionPackageManager packageManager = view.getSession().getPackageManager();
+ return EMFUtil.getCDOClass(eClass(), packageManager);
}
public CDOID cdoID()
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOPackageRegistryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOPackageRegistryImpl.java
index fef6dfc..7b30e77 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOPackageRegistryImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOPackageRegistryImpl.java
@@ -12,8 +12,17 @@ package org.eclipse.emf.internal.cdo;
import org.eclipse.emf.cdo.util.CDOPackageRegistry;
+import org.eclipse.net4j.util.ReflectUtil;
+
+import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EPackage.Registry;
+import org.eclipse.emf.ecore.impl.EPackageImpl;
import org.eclipse.emf.ecore.impl.EPackageRegistryImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.internal.cdo.bundle.OM;
+
+import java.lang.reflect.Method;
+import java.util.Map;
/**
* @author Eike Stepper
@@ -30,4 +39,59 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements CDOP
{
super(delegateRegistry);
}
+
+ public EPackage putEPackage(EPackage ePackage)
+ {
+ return (EPackage)put(ePackage.getNsURI(), ePackage);
+ }
+
+ @Override
+ public Object put(String key, Object value)
+ {
+ EPackage ePackage = (EPackage)value;
+ if (isDynamicPackage(ePackage))
+ {
+ EPackageImpl copy = (EPackageImpl)EcoreUtil.copy(ePackage);
+ copy.setEFactoryInstance(createCDOFactory(copy));
+ fixEClassifiers(copy);
+ ePackage = copy;
+ }
+
+ super.put(key, ePackage);
+ return ePackage;
+ }
+
+ @Override
+ public void putAll(Map<? extends String, ? extends Object> m)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ protected CDOFactoryImpl createCDOFactory(EPackage ePackage)
+ {
+ return new CDOFactoryImpl(ePackage);
+ }
+
+ private boolean isDynamicPackage(EPackage ePackage)
+ {
+ return ePackage.getClass() == EPackageImpl.class;
+ }
+
+ private void fixEClassifiers(EPackageImpl ePackage)
+ {
+ try
+ {
+ Method method = EPackageImpl.class.getDeclaredMethod("fixEClassifiers", ReflectUtil.NO_PARAMETERS);
+ if (!method.isAccessible())
+ {
+ method.setAccessible(true);
+ }
+
+ method.invoke(ePackage, ReflectUtil.NO_ARGUMENTS);
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ }
+ }
}
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 0c79fa4..a1ea58c 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
@@ -15,7 +15,6 @@ import org.eclipse.emf.cdo.CDOSessionInvalidationEvent;
import org.eclipse.emf.cdo.CDOSessionViewsEvent;
import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.protocol.CDOID;
-import org.eclipse.emf.cdo.util.CDOPackageRegistry;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.net4j.ConnectorException;
@@ -85,14 +84,14 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession
}
};
- public CDOSessionImpl(EPackage.Registry ePackageRegistry)
+ public CDOSessionImpl(EPackage.Registry delegate)
{
- if (ePackageRegistry == null)
+ if (delegate == null)
{
- ePackageRegistry = EPackage.Registry.INSTANCE;
+ delegate = EPackage.Registry.INSTANCE;
}
- this.packageRegistry = new CDOPackageRegistryImpl(ePackageRegistry);
+ this.packageRegistry = new CDOPackageRegistryImpl(delegate);
packageManager = new CDOSessionPackageManager(this);
revisionManager = new CDORevisionManagerImpl(this);
}
@@ -160,7 +159,7 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession
deactivate();
}
- public CDOPackageRegistry getPackageRegistry()
+ public CDOPackageRegistryImpl getPackageRegistry()
{
return packageRegistry;
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManager.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManager.java
index ee4aa11..2682e1e 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManager.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManager.java
@@ -13,6 +13,8 @@ package org.eclipse.emf.internal.cdo;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageManagerImpl;
+import org.eclipse.emf.internal.cdo.util.EMFUtil;
+
/**
* @author Eike Stepper
*/
@@ -23,6 +25,7 @@ public class CDOSessionPackageManager extends CDOPackageManagerImpl
public CDOSessionPackageManager(CDOSessionImpl session)
{
this.session = session;
+ EMFUtil.addModelInfos(this);
}
public CDOSessionImpl getSession()
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 f6fe3cb..f42c245 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
@@ -307,20 +307,18 @@ public final class CDOStateMachine
CDOViewImpl view = (CDOViewImpl)data2;
CDOTransactionImpl transaction = getTransaction(view);
- // Create new revision
- CDOID id = CDOIDImpl.create(transaction.getNextTemporaryID());
- CDORevisionImpl revision = new CDORevisionImpl(object.cdoClass(), id);
- revision.setVersion(1);
-
// Prepare object
+ CDOID id = CDOIDImpl.create(transaction.getNextTemporaryID());
object.setID(id);
- object.setRevision(revision);
object.setResource(resource);
object.setAdapter(view);
object.setState(CDOState.PREPARED_ATTACH);
- // Adjust revision
+ // Create new revision
+ CDORevisionImpl revision = new CDORevisionImpl(object.cdoClass(), id);
+ revision.setVersion(1);
revision.setResourceID(resource.cdoID());
+ object.setRevision(revision);
// Register object
view.registerObject(object);
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 df69a95..6eec484 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
@@ -35,11 +35,15 @@ import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.protocol.CommitTransactionResult;
import org.eclipse.emf.internal.cdo.protocol.ResourcePathRequest;
+import org.eclipse.emf.internal.cdo.util.EMFUtil;
import java.text.MessageFormat;
import java.util.Date;
@@ -128,17 +132,6 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
return transaction == null;
}
- public CDORevisionImpl resolve(CDOID id)
- {
- CDORevisionResolver revisionManager = session.getRevisionManager();
- if (isReadWrite())
- {
- return (CDORevisionImpl)revisionManager.getRevision(id);
- }
-
- return (CDORevisionImpl)revisionManager.getRevision(id, timeStamp);
- }
-
public CDOResource createResource(String path)
{
URI createURI = CDOUtil.createURI(path);
@@ -195,6 +188,28 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
}
}
+ public CDOObjectImpl newInstance(EClass eClass)
+ {
+ return (CDOObjectImpl)EcoreUtil.create(eClass);
+ }
+
+ public CDOObjectImpl newInstance(CDOClass cdoClass)
+ {
+ EClass eClass = EMFUtil.getEClass(cdoClass);
+ return newInstance(eClass);
+ }
+
+ public CDORevisionImpl resolve(CDOID id)
+ {
+ CDORevisionResolver revisionManager = session.getRevisionManager();
+ if (isReadWrite())
+ {
+ return (CDORevisionImpl)revisionManager.getRevision(id);
+ }
+
+ return (CDORevisionImpl)revisionManager.getRevision(id, timeStamp);
+ }
+
public CDOObject lookupObject(CDOID id)
{
if (id.equals(lastLookupID))
@@ -489,7 +504,7 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
CDOClass cdoClass = revision.getCDOClass();
CDOID resourceID = revision.getResourceID();
- CDOObjectImpl object = (CDOObjectImpl)CDOUtil.createObject(cdoClass);
+ CDOObjectImpl object = newInstance(cdoClass);
if (object instanceof CDOResourceImpl)
{
object.setResource((CDOResourceImpl)object);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/DynamicCDOObjectImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/DynamicCDOObjectImpl.java
new file mode 100644
index 0000000..69bf116
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/DynamicCDOObjectImpl.java
@@ -0,0 +1,45 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 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.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * @author Eike Stepper
+ */
+public class DynamicCDOObjectImpl extends CDOObjectImpl implements EStructuralFeature.Internal.DynamicValueHolder
+{
+ private EClass eClass;
+
+ public DynamicCDOObjectImpl(EClass eClass)
+ {
+ this.eClass = eClass;
+ }
+
+ @Override
+ public EClass eClass()
+ {
+ return eClass;
+ }
+
+ @Override
+ public void eSetClass(EClass eClass)
+ {
+ this.eClass = eClass;
+ }
+
+ @Override
+ protected EClass eDynamicClass()
+ {
+ return eClass;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/EMFUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/EMFUtil.java
index c8314db..ef33a5e 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/EMFUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/EMFUtil.java
@@ -234,11 +234,11 @@ public final class EMFUtil
CDOClassImpl cdoClass = new CDOClassImpl(eClass.getClassifierID(), eClass.getName(), eClass.isAbstract());
cdoClass.setClientInfo(eClass);
- for (EClass superEClass : eClass.getESuperTypes())
- {
- CDOClassRefImpl classRef = createClassRef(superEClass);
- cdoClass.addSuperType(classRef);
- }
+ // XXX for (EClass superEClass : eClass.getESuperTypes())
+ // {
+ // CDOClassRefImpl classRef = createClassRef(superEClass);
+ // cdoClass.addSuperType(classRef);
+ // }
for (EStructuralFeature eFeature : getPersistentFeatures(eClass.getEStructuralFeatures()))
{
@@ -246,8 +246,8 @@ public final class EMFUtil
cdoClass.addFeature(cdoFeature);
}
- initAllSuperTypes(cdoClass, packageManager);
- initAllFeatures(cdoClass, packageManager);
+ // XXX initAllSuperTypes(cdoClass, packageManager);
+ // XXX initAllFeatures(cdoClass, packageManager);
return cdoClass;
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/OverridablePackageRegistry.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/OverridablePackageRegistry.java
new file mode 100644
index 0000000..c5a15ad
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/OverridablePackageRegistry.java
@@ -0,0 +1,103 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 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.ecore.EPackage;
+import org.eclipse.emf.ecore.EPackage.Registry;
+import org.eclipse.emf.ecore.impl.EPackageRegistryImpl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author Eike Stepper
+ */
+public class OverridablePackageRegistry extends EPackageRegistryImpl
+{
+ private static final long serialVersionUID = 1L;
+
+ public OverridablePackageRegistry()
+ {
+ }
+
+ public OverridablePackageRegistry(Registry delegateRegistry)
+ {
+ super(delegateRegistry);
+ }
+
+ @Override
+ public final void clear()
+ {
+ if (!isEmpty())
+ {
+ List<EPackage> ePackages = new ArrayList(values());
+ super.clear();
+ removed(ePackages);
+ }
+ }
+
+ @Override
+ public final Set<java.util.Map.Entry<String, Object>> entrySet()
+ {
+ return super.entrySet();
+ }
+
+ @Override
+ public final Object get(Object key)
+ {
+ return filterGet(super.get(key));
+ }
+
+ @Override
+ public final Set<String> keySet()
+ {
+ Set<String> keySet = super.keySet();
+ Iterator<String> iterator = keySet().iterator();
+ return keySet;
+ }
+
+ @Override
+ public final Object put(String key, Object value)
+ {
+ return super.put(key, value);
+ }
+
+ @Override
+ public final void putAll(Map<? extends String, ? extends Object> m)
+ {
+ super.putAll(m);
+ }
+
+ @Override
+ public final Object remove(Object key)
+ {
+ return super.remove(key);
+ }
+
+ @Override
+ public final Collection<Object> values()
+ {
+ return super.values();
+ }
+
+ protected Object filterGet(Object object)
+ {
+ return object;
+ }
+
+ protected void removed(List<EPackage> ePackages)
+ {
+ }
+}