summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-18 11:00:18 (EDT)
committerEike Stepper2007-07-18 11:00:18 (EDT)
commitdbaca03953e8a38c08f7840e72c8207f501da90a (patch)
treefeb365f03d1052afb6cf909c7d25b700900be2c3
parent15df1b9201591c52faed5d8caf1d2dcb13364702 (diff)
downloadcdo-dbaca03953e8a38c08f7840e72c8207f501da90a.zip
cdo-dbaca03953e8a38c08f7840e72c8207f501da90a.tar.gz
cdo-dbaca03953e8a38c08f7840e72c8207f501da90a.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOPackageRegistryImpl.java59
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManager.java1
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java20
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java31
5 files changed, 92 insertions, 23 deletions
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 6959dee..0250c22 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
@@ -14,12 +14,14 @@ import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.util.CDOPackageRegistry;
import org.eclipse.emf.cdo.util.EMFUtil;
+import org.eclipse.emf.ecore.EFactory;
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.internal.cdo.util.ModelUtil;
+import java.text.MessageFormat;
import java.util.Map;
/**
@@ -47,6 +49,13 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements CDOP
return session;
}
+ public void putPackageDescriptor(CDOPackageImpl cdoPackage)
+ {
+ EPackage.Descriptor descriptor = new CDOPackageDescriptor(cdoPackage);
+ String uri = cdoPackage.getPackageURI();
+ put(uri, descriptor);
+ }
+
public EPackage putEPackage(EPackage ePackage)
{
String uri = ePackage.getNsURI();
@@ -57,20 +66,24 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements CDOP
@Override
public Object put(String key, Object value)
{
- if (EMFUtil.isDynamicEPackage(value))
+ Object oldValue = super.get(key);
+ if (oldValue instanceof EPackageImpl)
+ {
+ throw new IllegalArgumentException("Duplicate key: " + key);
+ }
+
+ if (value instanceof EPackageImpl)
{
EPackageImpl ePackage = (EPackageImpl)value;
- ModelUtil.prepareEPackage(ePackage);
+ if (EMFUtil.isDynamicEPackage(ePackage))
+ {
+ ModelUtil.prepareEPackage(ePackage);
+ }
+
CDOPackageImpl cdoPackage = ModelUtil.getCDOPackage(ePackage, session.getPackageManager());
cdoPackage.setPersistent(false);
- value = ePackage;
}
- return internalPut(key, value);
- }
-
- public Object internalPut(String key, Object value)
- {
return super.put(key, value);
}
@@ -79,4 +92,34 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements CDOP
{
throw new UnsupportedOperationException();
}
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class CDOPackageDescriptor implements EPackage.Descriptor
+ {
+ private CDOPackageImpl cdoPackage;
+
+ private CDOPackageDescriptor(CDOPackageImpl cdoPackage)
+ {
+ this.cdoPackage = cdoPackage;
+ }
+
+ public EFactory getEFactory()
+ {
+ // TODO Implement method CDOPackageDescriptor.getEFactory()
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public EPackage getEPackage()
+ {
+ return ModelUtil.createEPackage(cdoPackage);
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("CDOPackageDescriptor[{0}]", cdoPackage.getPackageURI());
+ }
+ }
}
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 1f7e97b..d42a40c 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
@@ -45,6 +45,7 @@ public class CDOSessionPackageManager extends CDOPackageManagerImpl
{
CDOPackageImpl proxy = new CDOPackageImpl(this, packageURI);
addPackage(proxy);
+ session.getPackageRegistry().putPackageDescriptor(proxy);
}
}
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 6e761fb..642bc60 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
@@ -96,10 +96,6 @@ public class CDOTransactionImpl
nextTemporaryID = INITIAL_TEMPORARY_ID;
}
- /**
- * @return
- * @return A set of the ids that have changed due to object creation
- */
public CommitTransactionResult commit()
{
if (dirty)
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 5bff6e2..c1aac85 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
@@ -10,6 +10,7 @@
**************************************************************************/
package org.eclipse.emf.internal.cdo.protocol;
+import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.CDOReferenceConverter;
@@ -82,12 +83,12 @@ public class CommitTransactionRequest extends CDOClientRequest<CommitTransaction
private void writeNewPackages(ExtendedDataOutputStream out) throws IOException
{
+ List<CDOPackageImpl> newPackages = transaction.getNewPackages();
if (PROTOCOL.isEnabled())
{
- PROTOCOL.format("Writing {0} new packages", transaction.getNewResources().size());
+ PROTOCOL.format("Writing {0} new packages", newPackages.size());
}
- List<CDOPackageImpl> newPackages = transaction.getNewPackages();
out.writeInt(newPackages.size());
for (CDOPackageImpl newPackage : newPackages)
{
@@ -97,32 +98,35 @@ public class CommitTransactionRequest extends CDOClientRequest<CommitTransaction
private void writeNewResources(ExtendedDataOutputStream out) throws IOException
{
+ Collection<CDOResourceImpl> newResources = transaction.getNewResources().values();
if (PROTOCOL.isEnabled())
{
- PROTOCOL.format("Writing {0} new resources", transaction.getNewResources().size());
+ PROTOCOL.format("Writing {0} new resources", newResources.size());
}
- writeRevisions(out, transaction.getNewResources().values());
+ writeRevisions(out, newResources);
}
private void writeNewObjects(ExtendedDataOutputStream out) throws IOException
{
+ Collection<CDOObjectImpl> newObjects = transaction.getNewObjects().values();
if (PROTOCOL.isEnabled())
{
- PROTOCOL.format("Writing {0} new objects", transaction.getNewObjects().size());
+ PROTOCOL.format("Writing {0} new objects", newObjects.size());
}
- writeRevisions(out, transaction.getNewObjects().values());
+ writeRevisions(out, newObjects);
}
private void writeDirtyObjects(ExtendedDataOutputStream out) throws IOException
{
+ Collection<CDOObjectImpl> dirtyObjects = transaction.getDirtyObjects().values();
if (PROTOCOL.isEnabled())
{
- PROTOCOL.format("Writing {0} dirty objects", transaction.getDirtyObjects().size());
+ PROTOCOL.format("Writing {0} dirty objects", dirtyObjects.size());
}
- writeRevisions(out, transaction.getDirtyObjects().values());
+ writeRevisions(out, dirtyObjects);
}
private void writeRevisions(ExtendedDataOutputStream out, Collection objects) throws IOException
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 0bdf399..5144c94 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
@@ -177,8 +177,14 @@ public final class ModelUtil
EPackage ePackage = (EPackage)cdoPackage.getClientInfo();
if (ePackage == null)
{
- ePackage = createEPackage(cdoPackage);
- packageRegistry.internalPut(ePackage.getNsURI(), ePackage);
+ String uri = cdoPackage.getPackageURI();
+ ePackage = packageRegistry.getEPackage(uri);
+ if (ePackage == null)
+ {
+ ePackage = createEPackage(cdoPackage);
+ packageRegistry.put(uri, ePackage);
+ }
+
cdoPackage.setClientInfo(ePackage);
}
@@ -211,7 +217,26 @@ public final class ModelUtil
return eFeature;
}
- private static EPackage createEPackage(CDOPackageImpl cdoPackage)
+ public static EPackage createEPackage(CDOPackageImpl cdoPackage)
+ {
+ if (!cdoPackage.isDynamic())
+ {
+ EPackage ePackage = createGeneratedEPackage(cdoPackage.getPackageURI());
+ if (ePackage != null)
+ {
+ return ePackage;
+ }
+ }
+
+ return createDynamicEPackage(cdoPackage);
+ }
+
+ public static EPackage createGeneratedEPackage(String packageURI)
+ {
+ return EPackage.Registry.INSTANCE.getEPackage(packageURI);
+ }
+
+ public static EPackageImpl createDynamicEPackage(CDOPackageImpl cdoPackage)
{
String ecore = cdoPackage.getEcore();
EPackageImpl ePackage = (EPackageImpl)EMFUtil.ePackageFromString(ecore);