Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-10-30 12:12:02 -0400
committerEike Stepper2008-10-30 12:12:02 -0400
commit77a34c32138695906f466f9758b4a2cfe1211f7d (patch)
tree20fc292257ce482d63c7237be3856d24fd46232a
parent3b3d6365b80dcc1ad6aad352ddad82be48dd5397 (diff)
downloadcdo-77a34c32138695906f466f9758b4a2cfe1211f7d.tar.gz
cdo-77a34c32138695906f466f9758b4a2cfe1211f7d.tar.xz
cdo-77a34c32138695906f466f9758b4a2cfe1211f7d.zip
[252161] StackOverflow in CDOEditor.populateNewRoot() when sessino.packageRegistry contains a package not registered in the client machine
https://bugs.eclipse.org/bugs/show_bug.cgi?id=252161
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassImpl.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOFeatureImpl.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOModelElementImpl.java21
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageImpl.java72
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageManagerImpl.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/InternalCDOModelElement.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/InternalCDOPackage.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/InternalCDOPackageManager.java33
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java23
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContextImpl.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadPackageIndication.java30
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246442_Test.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConstants.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java35
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RollbackTransactionAction.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java3
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java2
22 files changed, 197 insertions, 119 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassImpl.java
index 1c4e871524..ec858f1b0f 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassImpl.java
@@ -361,15 +361,6 @@ public class CDOClassImpl extends CDOModelElementImpl implements InternalCDOClas
return MessageFormat.format("CDOClass(ID={0}, name={1})", classifierID, getName());
}
- @Override
- protected void onInitialize()
- {
- for (CDOFeature cdoFeature : features)
- {
- ((InternalCDOFeature)cdoFeature).initialize();
- }
- }
-
private void setIndex(int featureID, int index)
{
while (indices.size() <= featureID)
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOFeatureImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOFeatureImpl.java
index 97f65bd835..1f2b22abf2 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOFeatureImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOFeatureImpl.java
@@ -276,9 +276,4 @@ public class CDOFeatureImpl extends CDOModelElementImpl implements InternalCDOFe
return MessageFormat.format("CDOFeature(ID={0}, name={1}, type={2})", featureID, getName(), type);
}
}
-
- @Override
- protected void onInitialize()
- {
- }
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOModelElementImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOModelElementImpl.java
index 1507c35ece..0424733340 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOModelElementImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOModelElementImpl.java
@@ -15,7 +15,6 @@ import org.eclipse.emf.cdo.common.CDODataOutput;
import org.eclipse.emf.cdo.internal.common.bundle.OM;
import org.eclipse.emf.cdo.spi.common.InternalCDOModelElement;
-import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import java.io.IOException;
@@ -33,8 +32,6 @@ public abstract class CDOModelElementImpl implements InternalCDOModelElement
private Object serverInfo;
- private boolean initialized;
-
protected CDOModelElementImpl(String name)
{
this.name = name;
@@ -93,22 +90,4 @@ public abstract class CDOModelElementImpl implements InternalCDOModelElement
this.serverInfo = serverInfo;
}
-
- public boolean isInitialized()
- {
- return initialized;
- }
-
- public final void initialize()
- {
- if (initialized)
- {
- throw new ImplementationError("Duplicate initialization");
- }
-
- initialized = true;
- onInitialize();
- }
-
- protected abstract void onInitialize();
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageImpl.java
index dfbb4fed4a..4f89272b79 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageImpl.java
@@ -20,6 +20,7 @@ import org.eclipse.emf.cdo.common.model.CDOPackageManager;
import org.eclipse.emf.cdo.internal.common.bundle.OM;
import org.eclipse.emf.cdo.spi.common.InternalCDOClass;
import org.eclipse.emf.cdo.spi.common.InternalCDOPackage;
+import org.eclipse.emf.cdo.spi.common.InternalCDOPackageManager;
import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.om.trace.ContextTracer;
@@ -48,6 +49,8 @@ public class CDOPackageImpl extends CDOModelElementImpl implements InternalCDOPa
private String ecore;
+ private boolean ecoreLoaded;
+
private boolean dynamic;
private CDOIDMetaRange metaIDRange;
@@ -66,7 +69,6 @@ public class CDOPackageImpl extends CDOModelElementImpl implements InternalCDOPa
super(name);
this.packageManager = packageManager;
this.packageURI = packageURI;
- this.ecore = ecore;
this.dynamic = dynamic;
this.metaIDRange = metaIDRange;
this.parentURI = parentURI;
@@ -75,6 +77,7 @@ public class CDOPackageImpl extends CDOModelElementImpl implements InternalCDOPa
MODEL_TRACER.format("Created {0}", this);
}
+ setEcore(ecore);
createLists();
}
@@ -109,7 +112,6 @@ public class CDOPackageImpl extends CDOModelElementImpl implements InternalCDOPa
super.read(in);
packageURI = in.readCDOPackageURI();
dynamic = in.readBoolean();
- ecore = in.readString();
metaIDRange = in.readCDOIDMetaRange();
parentURI = in.readString();
if (PROTOCOL_TRACER.isEnabled())
@@ -134,7 +136,7 @@ public class CDOPackageImpl extends CDOModelElementImpl implements InternalCDOPa
@Override
public void write(CDODataOutput out) throws IOException
{
- resolve();
+ load();
if (PROTOCOL_TRACER.isEnabled())
{
PROTOCOL_TRACER.format("Writing package: URI={0}, name={1}, dynamic={2}, metaIDRange={3}, parentURI={4}",
@@ -144,7 +146,6 @@ public class CDOPackageImpl extends CDOModelElementImpl implements InternalCDOPa
super.write(out);
out.writeCDOPackageURI(packageURI);
out.writeBoolean(dynamic);
- out.writeString(ecore);
out.writeCDOIDMetaRange(metaIDRange);
out.writeString(parentURI);
@@ -189,6 +190,11 @@ public class CDOPackageImpl extends CDOModelElementImpl implements InternalCDOPa
public CDOPackage getParentPackage()
{
+ if (parentURI == null)
+ {
+ return null;
+ }
+
return packageManager.lookupPackage(parentURI);
}
@@ -239,13 +245,13 @@ public class CDOPackageImpl extends CDOModelElementImpl implements InternalCDOPa
public int getClassCount()
{
- resolve();
+ load();
return classes.size();
}
public CDOClass[] getClasses()
{
- resolve();
+ load();
return classes.toArray(new CDOClass[classes.size()]);
}
@@ -264,7 +270,7 @@ public class CDOPackageImpl extends CDOModelElementImpl implements InternalCDOPa
*/
public CDOClass[] getConcreteClasses()
{
- resolve();
+ load();
List<CDOClass> result = new ArrayList<CDOClass>(0);
for (CDOClass cdoClass : classes)
{
@@ -279,33 +285,32 @@ public class CDOPackageImpl extends CDOModelElementImpl implements InternalCDOPa
public CDOClass lookupClass(int classifierID)
{
- resolve();
+ load();
return index.get(classifierID);
}
- public String getEcore()
+ public synchronized String basicGetEcore()
+ {
+ return ecore;
+ }
+
+ public synchronized String getEcore()
{
- if (ecore == null && packageManager instanceof CDOPackageManagerImpl && parentURI == null)
+ if (!ecoreLoaded)
{
- if (isPersistent() && isDynamic())
- {
- resolve();
- }
- else
+ if (parentURI == null && !isSystem())
{
- ecore = ((CDOPackageManagerImpl)packageManager).provideEcore(this);
+ ((InternalCDOPackageManager)packageManager).loadPackageEcore(this);
}
}
return ecore;
}
- /**
- * TODO Add IStore API to demand read dynamic ecore string
- */
- public void setEcore(String ecore)
+ public synchronized void setEcore(String ecore)
{
this.ecore = ecore;
+ ecoreLoaded = true;
}
public CDOIDMetaRange getMetaIDRange()
@@ -372,15 +377,6 @@ public class CDOPackageImpl extends CDOModelElementImpl implements InternalCDOPa
packageURI, getName(), dynamic, metaIDRange, parentURI);
}
- @Override
- protected void onInitialize()
- {
- for (CDOClass cdoClass : classes)
- {
- ((InternalCDOClass)cdoClass).initialize();
- }
- }
-
private void setIndex(int classifierID, CDOClass cdoClass)
{
while (classifierID >= index.size())
@@ -391,18 +387,18 @@ public class CDOPackageImpl extends CDOModelElementImpl implements InternalCDOPa
index.set(classifierID, cdoClass);
}
- private void resolve()
- {
- if (classes == null && packageManager instanceof CDOPackageManagerImpl)
- {
- createLists();
- ((CDOPackageManagerImpl)packageManager).resolve(this);
- }
- }
-
private void createLists()
{
classes = new ArrayList<CDOClass>(0);
index = new ArrayList<CDOClass>(0);
}
+
+ private synchronized void load()
+ {
+ if (classes == null)
+ {
+ createLists();
+ ((InternalCDOPackageManager)packageManager).loadPackage(this);
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageManagerImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageManagerImpl.java
index b8c9c21f93..9ca85e6f25 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageManagerImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageManagerImpl.java
@@ -11,12 +11,12 @@
package org.eclipse.emf.cdo.internal.common.model;
import org.eclipse.emf.cdo.common.model.CDOPackage;
-import org.eclipse.emf.cdo.common.model.CDOPackageManager;
import org.eclipse.emf.cdo.common.model.core.CDOCorePackage;
import org.eclipse.emf.cdo.common.model.resource.CDOResourcePackage;
import org.eclipse.emf.cdo.internal.common.bundle.OM;
import org.eclipse.emf.cdo.internal.common.model.core.CDOCorePackageImpl;
import org.eclipse.emf.cdo.internal.common.model.resource.CDOResourcePackageImpl;
+import org.eclipse.emf.cdo.spi.common.InternalCDOPackageManager;
import org.eclipse.net4j.util.container.Container;
import org.eclipse.net4j.util.om.trace.ContextTracer;
@@ -29,7 +29,7 @@ import java.util.concurrent.ConcurrentMap;
/**
* @author Eike Stepper
*/
-public abstract class CDOPackageManagerImpl extends Container<CDOPackage> implements CDOPackageManager
+public abstract class CDOPackageManagerImpl extends Container<CDOPackage> implements InternalCDOPackageManager
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_MODEL, CDOPackageManagerImpl.class);
@@ -129,16 +129,4 @@ public abstract class CDOPackageManagerImpl extends Container<CDOPackage> implem
packages.remove(cdoPackage.getPackageURI());
fireElementRemovedEvent(cdoPackage);
}
-
- /**
- * @param cdoPackage
- * is a proxy CDO package. The implementer of this method must only use the package URI of the cdoPackage
- * passed in.
- */
- protected abstract void resolve(CDOPackage cdoPackage);
-
- /**
- * Only called on clients for generated models
- */
- protected abstract String provideEcore(CDOPackage cdoPackage);
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/InternalCDOModelElement.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/InternalCDOModelElement.java
index 2017f65d9b..deab4bf6e9 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/InternalCDOModelElement.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/InternalCDOModelElement.java
@@ -28,8 +28,6 @@ public interface InternalCDOModelElement extends CDOModelElement
public void setServerInfo(Object serverInfo);
- public void initialize();
-
/**
* @since 2.0
*/
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/InternalCDOPackage.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/InternalCDOPackage.java
index 72b3cb461d..bf29bbf001 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/InternalCDOPackage.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/InternalCDOPackage.java
@@ -31,6 +31,11 @@ public interface InternalCDOPackage extends CDOPackage, InternalCDOModelElement
public void setEcore(String ecore);
+ /**
+ * @since 2.0
+ */
+ public String basicGetEcore();
+
public void addClass(CDOClass cdoClass);
public void setClasses(List<CDOClass> classes);
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/InternalCDOPackageManager.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/InternalCDOPackageManager.java
new file mode 100644
index 0000000000..1b6091e697
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/InternalCDOPackageManager.java
@@ -0,0 +1,33 @@
+/***************************************************************************
+ * 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.cdo.spi.common;
+
+import org.eclipse.emf.cdo.common.model.CDOPackage;
+import org.eclipse.emf.cdo.common.model.CDOPackageManager;
+
+/**
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public interface InternalCDOPackageManager extends CDOPackageManager
+{
+ /**
+ * @param cdoPackage
+ * A proxy CDO package.
+ */
+ public void loadPackage(CDOPackage cdoPackage);
+
+ /**
+ * @param cdoPackage
+ * A CDO package with <code>ecore == null</code>.
+ */
+ public void loadPackageEcore(CDOPackage cdoPackage);
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java
index d80e219eb1..4e949eba07 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernatePackageHandler.java
@@ -23,6 +23,7 @@ import org.eclipse.emf.cdo.spi.common.InternalCDOClass;
import org.eclipse.emf.cdo.spi.common.InternalCDOFeature;
import org.eclipse.emf.cdo.spi.common.InternalCDOPackage;
+import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.io.IOUtil;
import org.eclipse.net4j.util.lifecycle.Lifecycle;
@@ -168,9 +169,11 @@ public class HibernatePackageHandler extends Lifecycle
CDOPackage[] cdoPackages = hibernateStore.getRepository().getPackageManager().getPackages();
for (CDOPackage cdoPackage : cdoPackages)
{
- if (cdoPackage.getClassCount() > 0 && cdoPackage.getPackageURI().compareTo(newCDOPackage.getPackageURI()) == 0)
+ if (cdoPackage.getClassCount() > 0 && cdoPackage.getPackageURI().equals(newCDOPackage.getPackageURI()))
{
- return cdoPackage.getEcore().compareTo(newCDOPackage.getEcore()) == 0;
+ String ecore = cdoPackage.getEcore();
+ String newEcore = newCDOPackage.getEcore();
+ return ObjectUtil.equals(ecore, newEcore);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
index 573094e026..a69f5f30a0 100644
--- a/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.hibernate/src/org/eclipse/emf/cdo/server/internal/hibernate/HibernateStoreAccessor.java
@@ -211,6 +211,11 @@ public class HibernateStoreAccessor extends StoreAccessor implements IHibernateS
getStore().getPackageHandler().readPackage(cdoPackage);
}
+ public void readPackageEcore(CDOPackage cdoPackage)
+ {
+ throw new UnsupportedOperationException();
+ }
+
public Collection<CDOPackageInfo> readPackageInfos()
{
return getStore().getPackageHandler().getCDOPackageInfos();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java
index beafe2249a..0a03b7b4fd 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java
@@ -57,21 +57,22 @@ public class PackageManager extends CDOPackageManagerImpl implements IPackageMan
return repository.getStore().getCDOIDObjectFactory();
}
- @Override
- protected void resolve(CDOPackage cdoPackage)
+ /**
+ * @since 2.0
+ */
+ public void loadPackage(CDOPackage cdoPackage)
{
- if (!cdoPackage.isSystem())
- {
- IStoreAccessor accessor = StoreThreadLocal.getAccessor();
- accessor.readPackage(cdoPackage);
- }
+ IStoreAccessor accessor = StoreThreadLocal.getAccessor();
+ accessor.readPackage(cdoPackage);
}
- @Override
- protected String provideEcore(CDOPackage cdoPackage)
+ /**
+ * @since 2.0
+ */
+ public void loadPackageEcore(CDOPackage cdoPackage)
{
- // No generated model on server side
- return null;
+ IStoreAccessor accessor = StoreThreadLocal.getAccessor();
+ accessor.readPackageEcore(cdoPackage);
}
@Override
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContextImpl.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContextImpl.java
index ee5cfa7126..3181762b78 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContextImpl.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContextImpl.java
@@ -16,7 +16,6 @@ import org.eclipse.emf.cdo.common.id.CDOIDObjectFactory;
import org.eclipse.emf.cdo.common.id.CDOIDTemp;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.model.CDOPackage;
-import org.eclipse.emf.cdo.common.model.CDOPackageManager;
import org.eclipse.emf.cdo.common.model.core.CDOCorePackage;
import org.eclipse.emf.cdo.common.model.resource.CDOResourcePackage;
import org.eclipse.emf.cdo.common.revision.CDORevision;
@@ -28,6 +27,7 @@ import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.emf.cdo.server.IStoreAccessor;
import org.eclipse.emf.cdo.server.StoreThreadLocal;
import org.eclipse.emf.cdo.spi.common.InternalCDOPackage;
+import org.eclipse.emf.cdo.spi.common.InternalCDOPackageManager;
import org.eclipse.emf.cdo.spi.common.InternalCDORevision;
import org.eclipse.emf.cdo.spi.common.InternalCDORevisionDelta;
@@ -459,7 +459,7 @@ public class TransactionCommitContextImpl implements IStoreAccessor.CommitContex
/**
* @author Eike Stepper
*/
- public final class TransactionPackageManager implements CDOPackageManager
+ public final class TransactionPackageManager implements InternalCDOPackageManager
{
private List<CDOPackage> newPackages = new ArrayList<CDOPackage>();
@@ -507,6 +507,16 @@ public class TransactionCommitContextImpl implements IStoreAccessor.CommitContex
return repositoryPackageManager.getCDOResourcePackage();
}
+ public void loadPackage(CDOPackage cdoPackage)
+ {
+ repositoryPackageManager.loadPackage(cdoPackage);
+ }
+
+ public void loadPackageEcore(CDOPackage cdoPackage)
+ {
+ repositoryPackageManager.loadPackageEcore(cdoPackage);
+ }
+
public int getPackageCount()
{
throw new UnsupportedOperationException();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java
index afbe5c75b4..3a46b9f43c 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java
@@ -26,6 +26,7 @@ import org.eclipse.emf.cdo.internal.server.Transaction.InternalCommitContext;
import org.eclipse.emf.cdo.internal.server.TransactionCommitContextImpl.TransactionPackageManager;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.emf.cdo.server.IView;
+import org.eclipse.emf.cdo.spi.common.InternalCDOPackage;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.om.trace.ContextTracer;
@@ -127,8 +128,10 @@ public class CommitTransactionIndication extends CDOServerIndication
for (int i = 0; i < newPackages.length; i++)
{
- newPackages[i] = in.readCDOPackage();
- packageManager.addPackage(newPackages[i]);
+ InternalCDOPackage newPackage = (InternalCDOPackage)in.readCDOPackage();
+ newPackage.setEcore(in.readString());
+ newPackages[i] = newPackage;
+ packageManager.addPackage(newPackage);
}
// New objects
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadPackageIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadPackageIndication.java
index bafeb7a654..96bf63227b 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadPackageIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/LoadPackageIndication.java
@@ -16,7 +16,6 @@ import org.eclipse.emf.cdo.common.CDOProtocolConstants;
import org.eclipse.emf.cdo.common.model.CDOPackage;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
-import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import java.io.IOException;
@@ -30,6 +29,8 @@ public class LoadPackageIndication extends CDOReadIndication
private CDOPackage cdoPackage;
+ private boolean onlyEcore;
+
public LoadPackageIndication()
{
}
@@ -49,21 +50,40 @@ public class LoadPackageIndication extends CDOReadIndication
PROTOCOL_TRACER.format("Read packageURI: {0}", packageURI);
}
+ onlyEcore = in.readBoolean();
+ if (PROTOCOL_TRACER.isEnabled())
+ {
+ PROTOCOL_TRACER.format("Read onlyEcore: {0}", onlyEcore);
+ }
+
cdoPackage = getPackageManager().lookupPackage(packageURI);
if (cdoPackage == null)
{
- throw new ImplementationError("CDO package not found: " + packageURI);
+ throw new IllegalStateException("CDO package not found: " + packageURI);
}
}
@Override
protected void responding(CDODataOutput out) throws IOException
{
- if (PROTOCOL_TRACER.isEnabled())
+ if (onlyEcore)
{
- PROTOCOL_TRACER.format("Writing package: {0}", cdoPackage);
+ String ecore = cdoPackage.getEcore();
+ if (PROTOCOL_TRACER.isEnabled())
+ {
+ PROTOCOL_TRACER.format("Writing ecore:\n{0}", ecore);
+ }
+
+ out.writeString(ecore);
}
+ else
+ {
+ if (PROTOCOL_TRACER.isEnabled())
+ {
+ PROTOCOL_TRACER.format("Writing package: {0}", cdoPackage);
+ }
- out.writeCDOPackage(cdoPackage);
+ out.writeCDOPackage(cdoPackage);
+ }
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java
index 6ce01c6541..cbb796f2d4 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java
@@ -21,6 +21,7 @@ import org.eclipse.emf.cdo.common.model.CDOPackageManager;
import org.eclipse.emf.cdo.common.query.CDOQueryInfo;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.spi.common.InternalCDOPackage;
import org.eclipse.net4j.util.collection.CloseableIterator;
@@ -66,12 +67,27 @@ public interface IStoreAccessor extends IQueryHandler
/**
* Demand loads a given package proxy that has been created on startup of the repository.
+ * <p>
+ * It's left to the implementor's choice whether to load the {@link CDOPackage#getEcore() ecore xml} at this time
+ * already. In case it is <b>not</b> loaded at this time {@link #readPackageEcore(CDOPackage) readPackageEcore()} is
+ * called later on demand.
+ * <p>
+ * This method must only load the given package, <b>not</b> possible contained packages.
*
+ * @see InternalCDOPackage
* @since 2.0
*/
public void readPackage(CDOPackage cdoPackage);
/**
+ * Loads the {@link CDOPackage#getEcore() ecore xml} of the given package.
+ *
+ * @see InternalCDOPackage#setEcore(String)
+ * @since 2.0
+ */
+ public void readPackageEcore(CDOPackage cdoPackage);
+
+ /**
* Returns an iterator that iterates over all objects in the store and makes their CDOIDs available for processing.
* This method is supposed to be called very infrequently, for example during the recovery from a crash.
*
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java
index 0308ed8b7f..5f8cf51867 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/PackageRegistryTest.java
@@ -356,6 +356,8 @@ public class PackageRegistryTest extends AbstractCDOTest
public void testDynamicPackageFactory() throws Exception
{
+ // -Dorg.eclipse.emf.ecore.EPackage.Registry.INSTANCE=org.eclipse.emf.ecore.impl.EPackageRegistryImpl
+
{
EPackage model1 = loadModel("model1.ecore");
EClass companyClass = (EClass)model1.getEClassifier("Company");
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246442_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246442_Test.java
index 40f008cfb2..f64794cdd6 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246442_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_246442_Test.java
@@ -109,6 +109,7 @@ public class Bugzilla_246442_Test extends AbstractCDOTest
subPackage1.setName("subPackage1");
subPackage1.setNsPrefix("subPackage1");
subPackage1.setNsURI("http:///www.elver.org/subPackage1");
+
{
EClass schoolBookEClass = efactory.createEClass();
schoolBookEClass.setName("class1");
@@ -119,17 +120,20 @@ public class Bugzilla_246442_Test extends AbstractCDOTest
schoolBookEClass.getEStructuralFeatures().add(level);
subPackage1.getEClassifiers().add(schoolBookEClass);
}
+
{
EEnum schoolBookEClass = efactory.createEEnum();
schoolBookEClass.setName("enum");
subPackage1.getEClassifiers().add(schoolBookEClass);
}
+
{
EClass schoolBookEClass = efactory.createEClass();
schoolBookEClass.setName("class2");
// create a new attribute for this EClass
subPackage1.getEClassifiers().add(schoolBookEClass);
}
+
{
EClass schoolBookEClass = efactory.createEClass();
schoolBookEClass.setName("class3");
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConstants.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConstants.java
index 142b2e01c9..4550e08e26 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConstants.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/IConstants.java
@@ -16,7 +16,6 @@ import org.eclipse.emf.cdo.tests.config.impl.ModelConfig;
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
import org.eclipse.emf.cdo.tests.config.impl.SessionConfig;
-
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java
index 392ff96f70..c9679ffd05 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java
@@ -17,6 +17,8 @@ import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
import org.eclipse.emf.cdo.tests.config.ISessionConfig;
import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.internal.cdo.util.CDOPackageTypeRegistryImpl;
+
import org.eclipse.net4j.acceptor.IAcceptor;
import org.eclipse.net4j.connector.IConnector;
import org.eclipse.net4j.jvm.JVMUtil;
@@ -24,6 +26,7 @@ import org.eclipse.net4j.tcp.TCPUtil;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.impl.EPackageImpl;
import java.util.Set;
@@ -121,10 +124,25 @@ public abstract class SessionConfig extends Config implements ISessionConfig
}
@Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ CDOPackageTypeRegistryImpl.INSTANCE.activate();
+ }
+
+ @Override
public void tearDown() throws Exception
{
- stopTransport();
- super.tearDown();
+ try
+ {
+ stopTransport();
+ super.tearDown();
+ }
+ finally
+ {
+ CDOPackageTypeRegistryImpl.INSTANCE.deactivate();
+ removeDynamicPackagesFromGlobalRegistry();
+ }
}
private CDOSessionConfiguration createSessionConfiguration(String repositoryName)
@@ -135,6 +153,19 @@ public abstract class SessionConfig extends Config implements ISessionConfig
return configuration;
}
+ private void removeDynamicPackagesFromGlobalRegistry()
+ {
+ EPackage.Registry registry = EPackage.Registry.INSTANCE;
+ for (String uri : registry.keySet().toArray(new String[registry.size()]))
+ {
+ Object object = registry.get(uri);
+ if (object != null && object.getClass() == EPackageImpl.class)
+ {
+ registry.remove(uri);
+ }
+ }
+ }
+
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RollbackTransactionAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RollbackTransactionAction.java
index 55d64409c8..96538c45f9 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RollbackTransactionAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RollbackTransactionAction.java
@@ -25,8 +25,6 @@ public final class RollbackTransactionAction extends ViewAction
private static final String TOOL_TIP = "Rollback this transaction";
- private static final String MESSAGE = "Choose how to rollback this transaction.";
-
public RollbackTransactionAction(IWorkbenchPage page, CDOView view)
{
super(page, TITLE + INTERACTIVE, TOOL_TIP, null, view);
@@ -37,7 +35,7 @@ public final class RollbackTransactionAction extends ViewAction
protected void preRun() throws Exception
{
CDOTransaction transaction = (CDOTransaction)getView();
- RollbackTransactionDialog dialog = new RollbackTransactionDialog(getPage(), TITLE, MESSAGE, transaction);
+ RollbackTransactionDialog dialog = new RollbackTransactionDialog(getPage(), TITLE, TOOL_TIP, transaction);
if (dialog.open() != RollbackTransactionDialog.OK)
{
cancel();
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
index 785af9e345..60ff7aac99 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
@@ -1581,6 +1581,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
catch (final TransactionException exception)
{
+ OM.LOG.error(exception);
final Shell shell = getSite().getShell();
shell.getDisplay().syncExec(new Runnable()
{
@@ -1588,7 +1589,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
{
CDOTransaction transaction = (CDOTransaction)view;
String title = "Transaction Error";
- String message = exception.getMessage();
+ String message = "An error occured while committing the tranasaction (see Error Log for details)";
RollbackTransactionDialog dialog = new RollbackTransactionDialog(getEditorSite().getPage(), title,
message, transaction);
if (dialog.open() == RollbackTransactionDialog.OK)
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 32976ed8f8..82e5376250 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
@@ -344,7 +344,7 @@ public final class ModelUtil
return registry.getEPackage(packageURI);
}
- public static EPackageImpl createDynamicEPackage(CDOPackage cdoPackage)
+ private static EPackageImpl createDynamicEPackage(CDOPackage cdoPackage)
{
CDOPackage topLevelPackage = cdoPackage.getTopLevelPackage();
String ecore = topLevelPackage.getEcore();

Back to the top