Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon McDuff2008-07-09 22:46:46 -0400
committerSimon McDuff2008-07-09 22:46:46 -0400
commit15bd26eebbbda254f9f63f95e95b584a2d257155 (patch)
treef20715c65d9d6fd36604e9548e1344dc3d5c397c
parent3e69feb582d89e87c7c017a8616deef200500879 (diff)
downloadcdo-15bd26eebbbda254f9f63f95e95b584a2d257155.tar.gz
cdo-15bd26eebbbda254f9f63f95e95b584a2d257155.tar.xz
cdo-15bd26eebbbda254f9f63f95e95b584a2d257155.zip
Reviewed by Eike
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOID.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDObjectFactory.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java39
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/CDOQueryParameter.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDNullImpl.java11
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/AbstractCDOID.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/AbstractCDOIDInteger.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/AbstractCDOIDLong.java11
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDOIDLongFactoryImpl.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AutoAttacherTest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SavepointTest.java (renamed from plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SavePointTest.java)42
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOAdapter.java (renamed from plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSavePoint.java)11
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOChangeSubscriptionPolicy.java8
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSavepoint.java25
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransaction.java18
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransactionHandler.java9
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java28
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOAutoAttacher.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSavepointImpl.java (renamed from plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSavePointImpl.java)57
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOTransactionImpl.java295
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java2
23 files changed, 362 insertions, 244 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOID.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOID.java
index b5d8ba84c9..570e4fc20a 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOID.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOID.java
@@ -32,11 +32,12 @@ public interface CDOID extends Serializable
public boolean isMeta();
public boolean isTemporary();
-
+
/**
* @since 2.0
*/
- public String getCDOIDString();
+ public String asString();
+
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDObjectFactory.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDObjectFactory.java
index b1f97811b5..138ab2ca2a 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDObjectFactory.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDObjectFactory.java
@@ -25,12 +25,13 @@ public interface CDOIDObjectFactory
* instance.
*/
public CDOIDObject createCDOIDObject(ExtendedDataInput in);
-
+
/**
* Returns a new instance of CDOIDObject. This implementation is different from createCDOIDObject(ExtendedDataInput
* in) since the implementor of this method needs to construct completely CDOIDObject from the String.
+ *
* @since 2.0
*/
- public CDOIDObject createCDOIDObject(String in);
+ public CDOIDObject createCDOIDObject(String fragmentPart);
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java
index 3e75323e36..dad54914c6 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java
@@ -222,14 +222,17 @@ public final class CDOIDUtil
}
/**
- * Format of the string
- * Not legacy : <ORDINAL>/<CUSTOM STRING FROM OBJECT FACTORY>
- * Legacy : <ORDINAL>/<PACKAGEURI>/<CLASSIFIERID>/<CUSTOM STRING FROM OBJECT FACTORY>
+ * Format of the uri fragment.
+ * <p>
+ * Not legacy : <IDTYPE>/<CUSTOM STRING FROM OBJECT FACTORY>
+ * <p>
+ * Legacy : <IDTYPE>/<PACKAGEURI>/<CLASSIFIERID>/<CUSTOM STRING FROM OBJECT FACTORY>
+ *
* @since 2.0
*/
- public static CDOID read(String in, CDOIDObjectFactory factory)
+ public static CDOID read(String uriFragment, CDOIDObjectFactory factory)
{
- byte ordinal = Byte.valueOf(in.substring(0, 1));
+ byte ordinal = Byte.valueOf(uriFragment.substring(0, 1));
if (TRACER.isEnabled())
{
@@ -247,7 +250,7 @@ public final class CDOIDUtil
}
Type type = Type.values()[ordinal];
- String fragment = in.substring(2);
+ String fragment = uriFragment.substring(2);
switch (type)
{
case NULL:
@@ -265,6 +268,7 @@ public final class CDOIDUtil
case OBJECT:
{
CDOIDObject id = factory.createCDOIDObject(fragment);
+ ((AbstractCDOID)id).read(fragment);
return id;
}
@@ -281,21 +285,26 @@ public final class CDOIDUtil
CDOIDObject id = factory.createCDOIDObject(fragment.substring(classifierIndex + 1));
+ ((AbstractCDOID)id).read(fragment);
+
return id.asLegacy(cdoClassRef);
}
default:
- throw new ImplementationError();
+ throw new IllegalArgumentException("Invalid ID type : " + uriFragment);
}
}
/**
- * Format of the string
- * Not legacy : <ORDINAL>/<CUSTOM STRING FROM OBJECT FACTORY>
- * Legacy : <ORDINAL>/<PACKAGEURI>/<CLASSIFIERID>/<CUSTOM STRING FROM OBJECT FACTORY>
+ * Format of the uri fragment.
+ * <p>
+ * Not legacy : <IDTYPE>/<CUSTOM STRING FROM OBJECT FACTORY>
+ * <p>
+ * Legacy : <IDTYPE>/<PACKAGEURI>/<CLASSIFIERID>/<CUSTOM STRING FROM OBJECT FACTORY>
+ *
* @since 2.0
*/
- public static void write(StringBuffer stringBuffer, CDOID id)
+ public static void write(StringBuilder builder, CDOID id)
{
if (id == null)
{
@@ -309,7 +318,7 @@ public final class CDOIDUtil
{
TRACER.format("Writing CDOID of type {0} ({1})", ordinal, type);
}
- stringBuffer.append(ordinal);
+ builder.append(ordinal);
switch (type)
{
@@ -322,14 +331,14 @@ public final class CDOIDUtil
case LEGACY_OBJECT:
CDOIDObject legacy = (CDOIDObject)id;
- stringBuffer.append("/" + legacy.getClassRef().getPackageURI());
- stringBuffer.append("/" + legacy.getClassRef().getClassifierID());
+ builder.append("/" + legacy.getClassRef().getPackageURI());
+ builder.append("/" + legacy.getClassRef().getClassifierID());
break;
default:
throw new ImplementationError();
}
- stringBuffer.append("/" + id.getCDOIDString());
+ builder.append("/" + id.asString());
}
public static CDOIDMeta createMeta(long value)
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/CDOQueryParameter.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/CDOQueryParameter.java
index 0fa04e003a..46926a75cf 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/CDOQueryParameter.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/query/CDOQueryParameter.java
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (c) 2004 - 2008 Simon McDuff, Canada.
+ * 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
@@ -23,6 +23,6 @@ public interface CDOQueryParameter
String getQueryString();
Map<String, Object> getParameters();
-
+
int getMaxResult();
}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDNullImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDNullImpl.java
index c1a29f1925..0778648d94 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDNullImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDNullImpl.java
@@ -60,12 +60,17 @@ public final class CDOIDNullImpl extends AbstractCDOID implements CDOIDMeta, CDO
{
return null;
}
-
- public String getCDOIDString()
+
+ public String asString()
{
return "NULL";
}
-
+
+ public void read(String fragmentPart)
+ {
+ // Do nothing
+ }
+
public void read(ExtendedDataInput in) throws IOException
{
// Do nothing
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/AbstractCDOID.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/AbstractCDOID.java
index be178cf37f..12ea5d3971 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/AbstractCDOID.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/AbstractCDOID.java
@@ -87,6 +87,13 @@ public abstract class AbstractCDOID implements CDOID
}
}
+ /**
+ * CDOID.asString and AbstractCDOID.read(String) need to match
+ *
+ * @since 2.0
+ */
+ public abstract void read(String fragmentPart);
+
public abstract void read(ExtendedDataInput in) throws IOException;
public abstract void write(ExtendedDataOutput out) throws IOException;
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/AbstractCDOIDInteger.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/AbstractCDOIDInteger.java
index 3d496ed5eb..72ec4244b2 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/AbstractCDOIDInteger.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/AbstractCDOIDInteger.java
@@ -43,15 +43,23 @@ public abstract class AbstractCDOIDInteger extends AbstractCDOID implements Comp
{
return value;
}
-
+
/**
* @since 2.0
*/
- public String getCDOIDString()
+ public String asString()
{
return String.valueOf(value);
}
-
+
+ /**
+ * @since 2.0
+ */
+ public void read(String fragmentPart)
+ {
+ value = Integer.valueOf(fragmentPart);
+ }
+
public void read(ExtendedDataInput in) throws IOException
{
value = in.readInt();
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/AbstractCDOIDLong.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/AbstractCDOIDLong.java
index e00f93daff..482fd5af28 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/AbstractCDOIDLong.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/AbstractCDOIDLong.java
@@ -44,15 +44,20 @@ public abstract class AbstractCDOIDLong extends AbstractCDOID implements Compara
{
return value;
}
-
+
/**
* @since 2.0
*/
- public String getCDOIDString()
+ public String asString()
{
return String.valueOf(value);
}
-
+
+ public void read(String fragmentPart)
+ {
+ value = Long.valueOf(fragmentPart);
+ }
+
public void read(ExtendedDataInput in) throws IOException
{
value = in.readLong();
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDOIDLongFactoryImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDOIDLongFactoryImpl.java
index 127045c2bf..06c97bc7af 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDOIDLongFactoryImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDOIDLongFactoryImpl.java
@@ -35,13 +35,13 @@ public class CDOIDLongFactoryImpl implements CDOIDObjectFactory
{
return new CDOIDLongImpl();
}
-
+
/**
* @since 2.0
*/
- public CDOIDObject createCDOIDObject(String in)
+ public CDOIDObject createCDOIDObject(String fragmentPart)
{
- return new CDOIDLongImpl(Long.valueOf(in));
+ return new CDOIDLongImpl();
}
public LibraryHandler getLibraryHandler()
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
index d93586d18c..3e357a6a10 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
@@ -41,7 +41,7 @@ public class AllTests
suite.addTestSuite(IndexReconstructionTest.class);
suite.addTestSuite(NoLegacyTest.class);
suite.addTestSuite(AutoAttacherTest.class);
- suite.addTestSuite(SavePointTest.class);
+ suite.addTestSuite(SavepointTest.class);
suite.addTestSuite(ChangeSubscriptionTest.class);
suite.addTestSuite(QueryTest.class);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AutoAttacherTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AutoAttacherTest.java
index a9c620e826..09d6503d23 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AutoAttacherTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AutoAttacherTest.java
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (c) 2004 - 2008 Simon McDuff, Canada.
+ * 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
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java
index c0fadef783..a5db82ade4 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/InitialTest.java
@@ -780,7 +780,6 @@ public class InitialTest extends AbstractCDOTest
transaction.close();
session.close();
}
-
public void testResourceAccessor() throws Exception
{
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SavePointTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SavepointTest.java
index b1e495e78c..95983ee391 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SavePointTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/SavepointTest.java
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (c) 2004 - 2008 Simon McDuff, Canada.
+ * 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
@@ -12,7 +12,7 @@
package org.eclipse.emf.cdo.tests;
import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.CDOSavePoint;
+import org.eclipse.emf.cdo.CDOSavepoint;
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.CDOTransaction;
import org.eclipse.emf.cdo.eresource.CDOResource;
@@ -24,12 +24,10 @@ import org.eclipse.emf.cdo.tests.model1.Model1Package;
import org.eclipse.emf.internal.cdo.CDOTransactionImpl;
import org.eclipse.emf.internal.cdo.util.FSMUtil;
-import junit.framework.Assert;
-
/**
* @author Simon McDuff
*/
-public class SavePointTest extends AbstractCDOTest
+public class SavepointTest extends AbstractCDOTest
{
public void testRollbackWithNewObject_Collection() throws Exception
{
@@ -47,17 +45,17 @@ public class SavePointTest extends AbstractCDOTest
Category category1 = Model1Factory.eINSTANCE.createCategory();
company1.getCategories().add(category1);
- transaction1.createSavePoint();
+ transaction1.setSavepoint();
Category category2 = Model1Factory.eINSTANCE.createCategory();
company1.getCategories().add(category2);
- CDOSavePoint savePoint2 = transaction1.createSavePoint();
+ CDOSavepoint savePoint2 = transaction1.setSavepoint();
Category category3 = Model1Factory.eINSTANCE.createCategory();
company1.getCategories().add(category3);
- transaction1.createSavePoint();
+ transaction1.setSavepoint();
transaction1.rollback(savePoint2, false);
@@ -101,13 +99,13 @@ public class SavePointTest extends AbstractCDOTest
Category category1 = Model1Factory.eINSTANCE.createCategory();
company1.getCategories().add(category1);
- CDOSavePoint savePoint1 = transaction1.createSavePoint();
- CDOSavePoint savePoint2 = transaction1.createSavePoint();
+ CDOSavepoint savePoint1 = transaction1.setSavepoint();
+ CDOSavepoint savePoint2 = transaction1.setSavepoint();
transaction1.rollback(savePoint1, false);
try
{
transaction1.rollback(savePoint2, false);
- Assert.assertEquals("Should have thrown an exception", false, true);
+ fail("Should have thrown an exception");
}
catch (IllegalArgumentException illegalArgumentException)
{
@@ -116,7 +114,7 @@ public class SavePointTest extends AbstractCDOTest
try
{
transaction1.rollback(null, false);
- Assert.assertEquals("Should have thrown an exception", false, true);
+ fail("Should have thrown an exception");
}
catch (IllegalArgumentException illegalArgumentException)
{
@@ -131,7 +129,7 @@ public class SavePointTest extends AbstractCDOTest
CDOTransactionImpl transaction1 = (CDOTransactionImpl)session.openTransaction();
- CDOSavePoint savePoint0 = transaction1.createSavePoint();
+ CDOSavepoint savePoint0 = transaction1.setSavepoint();
// Client1
CDOResource resource1 = transaction1.createResource("/test1");
Company company1 = Model1Factory.eINSTANCE.createCompany();
@@ -139,12 +137,12 @@ public class SavePointTest extends AbstractCDOTest
Category category1 = Model1Factory.eINSTANCE.createCategory();
company1.getCategories().add(category1);
- CDOSavePoint savePoint1 = transaction1.createSavePoint();
+ CDOSavepoint savePoint1 = transaction1.setSavepoint();
Category category2 = Model1Factory.eINSTANCE.createCategory();
company1.getCategories().add(category2);
- CDOSavePoint savePoint2 = transaction1.createSavePoint();
- CDOSavePoint savePoint3 = transaction1.createSavePoint();
+ CDOSavepoint savePoint2 = transaction1.setSavepoint();
+ CDOSavepoint savePoint3 = transaction1.setSavepoint();
assertEquals(true, transaction1.isDirty());
@@ -180,7 +178,7 @@ public class SavePointTest extends AbstractCDOTest
Category category1 = Model1Factory.eINSTANCE.createCategory();
company1.getCategories().add(category1);
- CDOSavePoint savePoint1 = transaction1.createSavePoint();
+ CDOSavepoint savePoint1 = transaction1.setSavepoint();
// Modification for savePoint1
Company company2 = Model1Factory.eINSTANCE.createCompany();
@@ -202,14 +200,14 @@ public class SavePointTest extends AbstractCDOTest
company1.getCategories().add(category2);
}
- CDOSavePoint savePoint2 = transaction1.createSavePoint();
+ CDOSavepoint savePoint2 = transaction1.setSavepoint();
{
company1.setCity("CITY2");
category3 = Model1Factory.eINSTANCE.createCategory();
company1.getCategories().add(category3);
}
- transaction1.createSavePoint();
+ transaction1.setSavepoint();
{
company1.setCity("CITY3");
assertEquals(3, company1.getCategories().size());
@@ -251,14 +249,14 @@ public class SavePointTest extends AbstractCDOTest
assertEquals(2, company1.getCategories().size());
- assertEquals(null, transaction1.getLastSavePoint().getPreviousSavePoint());
+ assertEquals(null, transaction1.getLastSavepoint().getPreviousSavepoint());
}
else
{
transaction1.rollback(false);
assertEquals(false, transaction1.isDirty());
- assertEquals(null, transaction1.getLastSavePoint().getNextSavePoint());
- assertEquals(null, transaction1.getLastSavePoint().getPreviousSavePoint());
+ assertEquals(null, transaction1.getLastSavepoint().getNextSavepoint());
+ assertEquals(null, transaction1.getLastSavepoint().getPreviousSavepoint());
assertEquals(commitBegin, !FSMUtil.isTransient(company1));
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSavePoint.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOAdapter.java
index b26ca06b38..73ae0f7175 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSavePoint.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOAdapter.java
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (c) 2004 - 2008 Simon McDuff, Canada.
+ * 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
@@ -10,16 +10,13 @@
**************************************************************************/
package org.eclipse.emf.cdo;
+import org.eclipse.emf.common.notify.Adapter;
+
/**
* @author Simon McDuff
* @since 2.0
*/
-public interface CDOSavePoint
+public interface CDOAdapter extends Adapter
{
- CDOTransaction getTransaction();
-
- CDOSavePoint getNextSavePoint();
-
- CDOSavePoint getPreviousSavePoint();
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOChangeSubscriptionPolicy.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOChangeSubscriptionPolicy.java
index 846199800d..cc6b4b1ddc 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOChangeSubscriptionPolicy.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOChangeSubscriptionPolicy.java
@@ -27,6 +27,14 @@ public interface CDOChangeSubscriptionPolicy
}
};
+ public static CDOChangeSubscriptionPolicy ONLY_CDOADAPTER = new CDOChangeSubscriptionPolicy()
+ {
+ public boolean valid(EObject eObject, Adapter adapter)
+ {
+ return (adapter instanceof CDOAdapter);
+ }
+ };
+
public static CDOChangeSubscriptionPolicy ALL = new CDOChangeSubscriptionPolicy()
{
public boolean valid(EObject eObject, Adapter adapter)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSavepoint.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSavepoint.java
new file mode 100644
index 0000000000..1234746078
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSavepoint.java
@@ -0,0 +1,25 @@
+/***************************************************************************
+ * 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
+ **************************************************************************/
+package org.eclipse.emf.cdo;
+
+/**
+ * @author Simon McDuff
+ * @since 2.0
+ */
+public interface CDOSavepoint
+{
+ public CDOTransaction getTransaction();
+
+ public CDOSavepoint getNextSavepoint();
+
+ public CDOSavepoint getPreviousSavepoint();
+
+ public boolean isValid();
+
+ public void rollback(boolean remote);
+}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransaction.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransaction.java
index ef298782b0..5cd22dde49 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransaction.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransaction.java
@@ -53,21 +53,31 @@ public interface CDOTransaction extends CDOView
public void commit() throws TransactionException;
public void rollback(boolean remote);
-
+
+ /**
+ * @since 2.0
+ */
+ public void rollback();
+
+ /**
+ * @since 2.0
+ */
+ public void rollback(CDOSavepoint savepoint, boolean remote);
+
/**
* @since 2.0
*/
- public void rollback(CDOSavePoint savePoint, boolean remote);
+ public void rollback(CDOSavepoint savepoint);
/**
* @since 2.0
*/
- public CDOSavePoint createSavePoint();
+ public CDOSavepoint setSavepoint();
/**
* @since 2.0
*/
- public CDOSavePoint getLastSavePoint();
+ public CDOSavepoint getLastSavepoint();
public void addHandler(CDOTransactionHandler handler);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransactionHandler.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransactionHandler.java
index ca7384d420..541042c0b9 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransactionHandler.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOTransactionHandler.java
@@ -39,12 +39,13 @@ public interface CDOTransactionHandler
* transaction.
*/
public void committingTransaction(CDOTransaction transaction);
-
+
/**
- * Called by a <code>CDOTransaction</code> <b>after</b> it is being rolled back. If the implementor of this method
- * throw an exception other listener would not be notify and the exception will be propagated.
+ * Called by a <code>CDOTransaction</code> <b>after</b> it is rolled back. If the implementor of this method throws an
+ * exception other handlers will be notified and the exception will be logged as an error.
+ *
* @since 2.0
*/
- public void rollingbackTransaction(CDOTransaction transaction);
+ public void rolledBackTransaction(CDOTransaction transaction);
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
index 1f385a50b3..e40dabd983 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/eresource/impl/CDOResourceImpl.java
@@ -333,16 +333,28 @@ public class CDOResourceImpl extends CDOObjectImpl implements CDOResource
*/
public EObject getEObject(String uriFragment)
{
- if (uriFragment == null) return null;
+ // Should we return CDOResource (this ?) ?
+ if (uriFragment == null)
+ {
+ return null;
+ }
CDOID cdoID = CDOIDUtil.read(uriFragment, cdoView().getSession().getPackageManager().getCDOIDObjectFactory());
- if (cdoID.isNull()) return null;
+ if (cdoID.isNull())
+ {
+ return null;
+ }
if (cdoID.isTemporary() && !cdoView().isObjectRegistered(cdoID))
+ {
throw new IllegalStateException("Temporary object : " + uriFragment + " is not available anymore.");
+ }
- if (cdoID.isObject()) return cdoView().getObject(cdoID, true);
+ if (cdoID.isObject())
+ {
+ return cdoView().getObject(cdoID, true);
+ }
// If it doesn`t match to anything we return null like ResourceImpl.getEObject
return null;
@@ -353,13 +365,15 @@ public class CDOResourceImpl extends CDOObjectImpl implements CDOResource
*/
public String getURIFragment(EObject object)
{
- InternalCDOObject internalCDOObject = FSMUtil.adapt(object, this.cdoView());
+ // if object == this ??? what we do. Is it wanted ? How we handle them ?
+
+ InternalCDOObject internalCDOObject = FSMUtil.adapt(object, cdoView());
- StringBuffer idBuffer = new StringBuffer();
+ StringBuilder builder = new StringBuilder();
- CDOIDUtil.write(idBuffer, internalCDOObject.cdoID());
+ CDOIDUtil.write(builder, internalCDOObject.cdoID());
- return idBuffer.toString();
+ return builder.toString();
}
/**
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOAutoAttacher.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOAutoAttacher.java
index 2b5801bdef..502b1cab27 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOAutoAttacher.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/util/CDOAutoAttacher.java
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (c) 2004 - 2008 Simon McDuff, Canada.
+ * 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
@@ -189,7 +189,7 @@ public class CDOAutoAttacher implements CDOTransactionHandler
}
- public void rollingbackTransaction(CDOTransaction transaction)
+ public void rolledBackTransaction(CDOTransaction transaction)
{
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSavePointImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSavepointImpl.java
index 3e79932840..fae06df1a1 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSavePointImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSavepointImpl.java
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (c) 2004 - 2008 Simon McDuff, Canada.
+ * 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
@@ -12,12 +12,12 @@
package org.eclipse.emf.internal.cdo;
import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.CDOSavePoint;
+import org.eclipse.emf.cdo.CDOSavepoint;
import org.eclipse.emf.cdo.CDOTransaction;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.eresource.CDOResource;
-import org.eclipse.emf.cdo.internal.common.revision.CDORevisionImpl;
import java.util.HashMap;
import java.util.Map;
@@ -28,7 +28,7 @@ import java.util.concurrent.ConcurrentMap;
* @author Simon McDuff
* @since 2.0
*/
-public class CDOSavePointImpl implements CDOSavePoint
+public class CDOSavepointImpl implements CDOSavepoint
{
private CDOTransactionImpl transaction = null;
@@ -36,24 +36,24 @@ public class CDOSavePointImpl implements CDOSavePoint
private Map<CDOID, CDOObject> newObjects = new HashMap<CDOID, CDOObject>();
- private Map<CDOID, CDORevisionImpl> baseNewObjects = new HashMap<CDOID, CDORevisionImpl>();
+ private Map<CDOID, CDORevision> baseNewObjects = new HashMap<CDOID, CDORevision>();
private Map<CDOID, CDOObject> dirtyObjects = new HashMap<CDOID, CDOObject>();
private ConcurrentMap<CDOID, CDORevisionDelta> revisionDeltas = new ConcurrentHashMap<CDOID, CDORevisionDelta>();
- private CDOSavePointImpl previousSavePoint = null;
+ private CDOSavepointImpl previousSavepoint = null;
- private CDOSavePointImpl nextSavePoint = null;
+ private CDOSavepointImpl nextSavepoint = null;
private boolean isDirty = false;
- public CDOSavePointImpl(CDOTransactionImpl transaction, CDOSavePointImpl lastSavePoint)
+ public CDOSavepointImpl(CDOTransactionImpl transaction, CDOSavepointImpl lastSavepoint)
{
this.transaction = transaction;
this.isDirty = transaction.isDirty();
- this.previousSavePoint = lastSavePoint;
- if (this.previousSavePoint != null) this.previousSavePoint.setNextSavePoint(this);
+ this.previousSavepoint = lastSavepoint;
+ if (this.previousSavepoint != null) this.previousSavepoint.setNextSavepoint(this);
}
public void clear()
@@ -90,29 +90,29 @@ public class CDOSavePointImpl implements CDOSavePoint
return revisionDeltas;
}
- public Map<CDOID, CDORevisionImpl> getBaseNewObjects()
+ public Map<CDOID, CDORevision> getBaseNewObjects()
{
return baseNewObjects;
}
- public CDOSavePointImpl getPreviousSavePoint()
+ public CDOSavepointImpl getPreviousSavepoint()
{
- return previousSavePoint;
+ return previousSavepoint;
}
- public CDOSavePointImpl getNextSavePoint()
+ public CDOSavepointImpl getNextSavepoint()
{
- return nextSavePoint;
+ return nextSavepoint;
}
- public void setPreviousSavePoint(CDOSavePointImpl previousSavePoint)
+ public void setPreviousSavepoint(CDOSavepointImpl previousSavepoint)
{
- this.previousSavePoint = previousSavePoint;
+ this.previousSavepoint = previousSavepoint;
}
- public void setNextSavePoint(CDOSavePointImpl nextSavePoint)
+ public void setNextSavepoint(CDOSavepointImpl nextSavepoint)
{
- this.nextSavePoint = nextSavePoint;
+ this.nextSavepoint = nextSavepoint;
}
public CDOTransaction getTransaction()
@@ -120,4 +120,23 @@ public class CDOSavePointImpl implements CDOSavePoint
return transaction;
}
+ public void rollback(boolean remote)
+ {
+ getTransaction().rollback(this, remote);
+ }
+
+ public boolean isValid()
+ {
+ CDOSavepoint lastSavepoint = getTransaction().getLastSavepoint();
+
+ for (CDOSavepoint savepoint = lastSavepoint; savepoint != null; savepoint = savepoint.getPreviousSavepoint())
+ {
+ if (savepoint == this)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
}
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 16003067fc..448d939cc8 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
@@ -15,7 +15,7 @@
package org.eclipse.emf.internal.cdo;
import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.CDOSavePoint;
+import org.eclipse.emf.cdo.CDOSavepoint;
import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.CDOTransaction;
import org.eclipse.emf.cdo.CDOTransactionConflictEvent;
@@ -28,13 +28,13 @@ 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.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDeltaUtil;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
-import org.eclipse.emf.cdo.internal.common.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.internal.common.revision.delta.CDORevisionDeltaImpl;
import org.eclipse.emf.cdo.spi.common.InternalCDOPackage;
import org.eclipse.emf.cdo.spi.common.InternalCDORevisionDelta;
@@ -82,9 +82,9 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
private List<CDOPackage> newPackages;
- private CDOSavePointImpl lastSavePoint = new CDOSavePointImpl(this, null);
+ private CDOSavepointImpl lastSavepoint = new CDOSavepointImpl(this, null);
- private CDOSavePointImpl firstSavePoint = lastSavePoint;
+ private CDOSavepointImpl firstSavepoint = lastSavepoint;
private boolean dirty;
@@ -191,9 +191,9 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
/**
* @since 2.0
*/
- public CDOSavePointImpl getLastSavePoint()
+ public CDOSavepointImpl getLastSavepoint()
{
- return this.lastSavePoint;
+ return this.lastSavepoint;
}
public void commit() throws TransactionException
@@ -216,11 +216,11 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
Collection<CDORevisionDelta> deltas = getRevisionDeltas().values();
- for (CDOSavePointImpl itrSavePoint = lastSavePoint; itrSavePoint != null; itrSavePoint = itrSavePoint
- .getPreviousSavePoint())
+ for (CDOSavepointImpl itrSavepoint = lastSavepoint; itrSavepoint != null; itrSavepoint = itrSavepoint
+ .getPreviousSavepoint())
{
- preCommit(itrSavePoint.getNewObjects());
- preCommit(itrSavePoint.getDirtyObjects());
+ preCommit(itrSavepoint.getNewObjects());
+ preCommit(itrSavepoint.getDirtyObjects());
}
CDOSessionImpl session = getSession();
IChannel channel = session.getChannel();
@@ -234,27 +234,22 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
throw new TransactionException(rollbackMessage);
}
- for (CDOSavePointImpl irtSavePoint = lastSavePoint; irtSavePoint != null; irtSavePoint = irtSavePoint
- .getPreviousSavePoint())
+ for (CDOSavepointImpl irtSavepoint = lastSavepoint; irtSavepoint != null; irtSavepoint = irtSavepoint
+ .getPreviousSavepoint())
{
- postCommit(irtSavePoint.getNewResources(), result);
- postCommit(irtSavePoint.getNewObjects(), result);
- postCommit(irtSavePoint.getDirtyObjects(), result);
+ postCommit(irtSavepoint.getNewResources(), result);
+ postCommit(irtSavepoint.getNewObjects(), result);
+ postCommit(irtSavepoint.getDirtyObjects(), result);
}
for (CDOPackage newPackage : newPackages)
{
((InternalCDOPackage)newPackage).setPersistent(true);
}
-
+
changeSubscriptionManager.notifyDirtyObjects();
-
- Map<CDOID, CDOObject> dirtyObjects = this.getDirtyObjects();
- if (!dirtyObjects.isEmpty())
- {
-
- }
+ Map<CDOID, CDOObject> dirtyObjects = this.getDirtyObjects();
if (!dirtyObjects.isEmpty())
{
@@ -283,69 +278,84 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
}
}
}
+
public void rollback(boolean remote)
{
- rollback(firstSavePoint, remote);
+ rollback(firstSavepoint, remote);
cleanUp();
}
- private Set<CDOID> rollbackTo(CDOSavePoint savePoint, boolean remote)
+
+ /**
+ * @since 2.0
+ */
+ public void rollback()
{
- Set<CDOID> newObjectsDelta = new HashSet<CDOID>();
+ rollback(true);
+ }
- boolean isActiveSavePoint = false;
+ /**
+ * @since 2.0
+ */
+ public void rollback(CDOSavepoint savepoint)
+ {
+ rollback(savepoint, true);
+ }
- // Start from the last savepoint and come back up to the active
+ private void removeObjects(Collection<? extends CDOObject> objects)
+ {
- for (CDOSavePointImpl itrSavePoint = lastSavePoint; itrSavePoint != null; itrSavePoint = itrSavePoint
- .getPreviousSavePoint())
+ if (!objects.isEmpty())
{
-
- if (isActiveSavePoint == false)
+ for (CDOObject object : objects)
{
- // Rollback new objects created after the save point
- Map<CDOID, CDOResource> newResources = itrSavePoint.getNewResources();
- Map<CDOID, CDOObject> newObjects = itrSavePoint.getNewObjects();
+ ((InternalCDOObject)object).cdoInternalSetState(CDOState.TRANSIENT);
- if (!newResources.isEmpty())
- {
- for (CDOObject newResource : newResources.values())
- {
- // TODO Should call detach transition : not there yet
- ((InternalCDOObject)newResource).cdoInternalSetState(CDOState.TRANSIENT);
+ removeObject(object.cdoID());
- removeObject(newResource.cdoID());
- getResourceSet().getResources().remove(newResource);
- }
- }
+ if (object instanceof CDOResource) getResourceSet().getResources().remove(object);
- if (!newObjects.isEmpty())
- {
- for (CDOObject newObject : newObjects.values())
- {
- ((InternalCDOObject)newObject).cdoInternalSetState(CDOState.TRANSIENT);
+ // TODO Should call detach transition : not there yet
+ // TODO How to remove it from Resource?
+ // CDOStateMachine.INSTANCE.detach(newObject);
- removeObject(newObject.cdoID());
+ }
+ }
- // TODO Should call detach transition : not there yet
- // TODO How to remove it from Resource?
- // CDOStateMachine.INSTANCE.detach(newObject);
- }
- }
+ }
+
+ private Set<CDOID> rollbackCompletely(CDOSavepoint savepoint, boolean remote)
+ {
+ Set<CDOID> idsOfNewObjectWithDeltas = new HashSet<CDOID>();
- Map<CDOID, CDORevisionDelta> revisionDeltas = itrSavePoint.getRevisionDeltas();
+ // TODO Add comments - what is it used for.
+ boolean isSavepointActive = false;
+
+ // Start from the last savepoint and come back up to the active
+
+ for (CDOSavepointImpl itrSavepoint = lastSavepoint; itrSavepoint != null; itrSavepoint = itrSavepoint
+ .getPreviousSavepoint())
+ {
+
+ if (isSavepointActive == false)
+ {
+ // Rollback new objects created after the save point
+ removeObjects(itrSavepoint.getNewResources().values());
+ removeObjects(itrSavepoint.getNewObjects().values());
+
+ Map<CDOID, CDORevisionDelta> revisionDeltas = itrSavepoint.getRevisionDeltas();
if (!revisionDeltas.isEmpty())
{
for (CDORevisionDelta dirtyObject : revisionDeltas.values())
{
- if (dirtyObject.getID().isTemporary()) newObjectsDelta.add(dirtyObject.getID());
+ if (dirtyObject.getID().isTemporary()) idsOfNewObjectWithDeltas.add(dirtyObject.getID());
}
}
}
// Rollback every persisted objects
- Map<CDOID, CDOObject> dirtyObjects = itrSavePoint.getDirtyObjects();
+ Map<CDOID, CDOObject> dirtyObjects = itrSavepoint.getDirtyObjects();
if (!dirtyObjects.isEmpty())
{
for (CDOObject dirtyObject : dirtyObjects.values())
@@ -353,43 +363,44 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
CDOStateMachine.INSTANCE.rollback((InternalCDOObject)dirtyObject, remote);
}
}
- if (savePoint == itrSavePoint) isActiveSavePoint = true;
+
+ if (savepoint == itrSavepoint) isSavepointActive = true;
}
- return newObjectsDelta;
+ return idsOfNewObjectWithDeltas;
}
- private void loadSavePoint(CDOSavePoint savePoint, Set<CDOID> newObjectsDelta)
+ private void loadSavepoint(CDOSavepoint savepoint, Set<CDOID> idsOfNewObjectWithDeltas)
{
Map<CDOID, CDOObject> dirtyObjects = getDirtyObjects();
Map<CDOID, CDOObject> newObjMaps = getNewObjects();
Map<CDOID, CDOResource> newResources = getNewResources();
- Map<CDOID, CDORevisionImpl> newBaseRevision = getBaseNewObjects();
+ Map<CDOID, CDORevision> newBaseRevision = getBaseNewObjects();
// Reload the objects (NEW) with their base.
- for (CDOID newObject : newObjectsDelta)
+ for (CDOID id : idsOfNewObjectWithDeltas)
{
- InternalCDOObject object = (InternalCDOObject)newObjMaps.get(newObject);
- if (object == null) object = (InternalCDOObject)newResources.get(newObject);
+ InternalCDOObject object = (InternalCDOObject)newObjMaps.get(id);
+ if (object == null) object = (InternalCDOObject)newResources.get(id);
- CDORevisionImpl revisionImpl = newBaseRevision.get(newObject);
+ CDORevision revision = newBaseRevision.get(id);
- if (revisionImpl != null)
+ if (revision != null)
{
- object.cdoInternalSetRevision(new CDORevisionImpl(revisionImpl));
+ object.cdoInternalSetRevision(CDORevisionUtil.copy(revision));
// Load the object from revision to EObject
object.cdoInternalPostLoad();
}
}
- for (CDOSavePointImpl itrSavePoint = firstSavePoint; itrSavePoint != savePoint; itrSavePoint = itrSavePoint
- .getNextSavePoint())
+ for (CDOSavepointImpl itrSavepoint = firstSavepoint; itrSavepoint != savepoint; itrSavepoint = itrSavepoint
+ .getNextSavepoint())
{
CDOObjectMerger merger = new CDOObjectMerger();
- for (CDORevisionDelta delta : itrSavePoint.getRevisionDeltas().values())
+ for (CDORevisionDelta delta : itrSavepoint.getRevisionDeltas().values())
{
Map<CDOID, CDOObject> map = delta.getID().isTemporary() ? newObjMaps : dirtyObjects;
@@ -403,16 +414,18 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
object.cdoInternalPostLoad();
}
}
- dirty = ((CDOSavePointImpl)savePoint).isDirty();
+ dirty = ((CDOSavepointImpl)savepoint).isDirty();
}
/**
* @since 2.0
*/
- public void rollback(CDOSavePoint savePoint, boolean remote)
+ public void rollback(CDOSavepoint savepoint, boolean remote)
{
- if (savePoint == null || savePoint.getTransaction() != this)
- throw new IllegalArgumentException("Save point to rollback doesn't belong to this transaction: " + savePoint);
+ if (savepoint == null) throw new IllegalArgumentException("Save point is null");
+
+ if (savepoint.getTransaction() != this)
+ throw new IllegalArgumentException("Save point to rollback doesn't belong to this transaction: " + savepoint);
if (TRACER.isEnabled())
{
@@ -422,31 +435,19 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
try
{
- boolean isPresent = false;
-
- for (CDOSavePointImpl indexsavePoint = lastSavePoint; indexsavePoint != null; indexsavePoint = indexsavePoint
- .getPreviousSavePoint())
- {
- if (indexsavePoint == savePoint)
- {
- isPresent = true;
- break;
- }
- }
- if (isPresent == false)
- throw new IllegalArgumentException("Save point to rollback isn't valid for this transaction: " + savePoint);
+ if (!savepoint.isValid()) throw new IllegalArgumentException("Savepoint isn't valid : " + savepoint);
// Rollback objects
- Set<CDOID> newObjectsDelta = rollbackTo(savePoint, remote);
+ Set<CDOID> idsOfNewObjectWithDeltas = rollbackCompletely(savepoint, remote);
- this.lastSavePoint = (CDOSavePointImpl)savePoint;
+ lastSavepoint = (CDOSavepointImpl)savepoint;
- // Make savePoint active. Erase savepoint that could have be after
- this.lastSavePoint.setNextSavePoint(null);
- this.lastSavePoint.clear();
+ // Make savepoint active. Erase savepoint that could have be after
+ lastSavepoint.setNextSavepoint(null);
+ lastSavepoint.clear();
// Load from first savepoint up to current savepoint
- loadSavePoint(lastSavePoint, newObjectsDelta);
+ loadSavepoint(lastSavepoint, idsOfNewObjectWithDeltas);
Map<CDOIDTemp, CDOID> idMappings = Collections.emptyMap();
@@ -454,7 +455,14 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
for (CDOTransactionHandler handler : getHandlers())
{
- handler.rollingbackTransaction(this);
+ try
+ {
+ handler.rolledBackTransaction(this);
+ }
+ catch (RuntimeException ex)
+ {
+ OM.LOG.error(ex);
+ }
}
}
catch (RuntimeException ex)
@@ -470,26 +478,26 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
/**
* @since 2.0
*/
- public CDOSavePoint createSavePoint()
+ public CDOSavepoint setSavepoint()
{
// Take a copy of all new objects for the current save point
- for (CDOObject object : lastSavePoint.getNewObjects().values())
- {
- // Load instance to revision
- ((InternalCDOObject)object).cdoInternalPreCommit();
- lastSavePoint.getBaseNewObjects().put(object.cdoID(), new CDORevisionImpl((CDORevisionImpl)object.cdoRevision()));
- }
- // Take a copy of all new resources for the current save point
- for (CDOObject object : lastSavePoint.getNewResources().values())
+ addToBase(lastSavepoint.getNewObjects());
+ addToBase(lastSavepoint.getNewResources());
+
+ lastSavepoint = new CDOSavepointImpl(this, lastSavepoint);
+
+ return lastSavepoint;
+ }
+
+ private void addToBase(Map<CDOID, ? extends CDOObject> objects)
+ {
+ for (CDOObject object : objects.values())
{
// Load instance to revision
((InternalCDOObject)object).cdoInternalPreCommit();
- lastSavePoint.getBaseNewObjects().put(object.cdoID(), new CDORevisionImpl((CDORevisionImpl)object.cdoRevision()));
- }
-
- lastSavePoint = new CDOSavePointImpl(this, lastSavePoint);
- return lastSavePoint;
+ lastSavepoint.getBaseNewObjects().put(object.cdoID(), CDORevisionUtil.copy(object.cdoRevision()));
+ }
}
@Override
@@ -512,13 +520,14 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
if (object instanceof CDOResourceImpl)
{
- register(this.lastSavePoint.getNewResources(), object);
+ register(this.lastSavepoint.getNewResources(), object);
}
else
{
- register(this.lastSavePoint.getNewObjects(), object);
+ register(this.lastSavepoint.getNewObjects(), object);
}
}
+
/**
* Receives notification for new and dirty objects
*/
@@ -529,14 +538,14 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
if (object.cdoState() == CDOState.NEW)
{
// Register Delta for new objects only if objectA doesn't belong to this savepoint
- if (this.getLastSavePoint().getPreviousSavePoint() == null || featureDelta == null)
+ if (this.getLastSavepoint().getPreviousSavepoint() == null || featureDelta == null)
{
needToSaveFeatureDelta = false;
}
else
{
- Map<CDOID, ? extends CDOObject> map = object instanceof CDOResource ? this.getLastSavePoint().getNewResources()
- : this.getLastSavePoint().getNewObjects();
+ Map<CDOID, ? extends CDOObject> map = object instanceof CDOResource ? this.getLastSavepoint().getNewResources()
+ : this.getLastSavepoint().getNewObjects();
needToSaveFeatureDelta = !map.containsKey(object.cdoID());
}
@@ -544,12 +553,12 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
if (needToSaveFeatureDelta)
{
- CDORevisionDelta revisionDelta = (CDORevisionDelta)lastSavePoint.getRevisionDeltas().get(object.cdoID());
+ CDORevisionDelta revisionDelta = (CDORevisionDelta)lastSavepoint.getRevisionDeltas().get(object.cdoID());
if (revisionDelta == null)
{
revisionDelta = (CDORevisionDelta)CDORevisionDeltaUtil.create(object.cdoRevision());
- lastSavePoint.getRevisionDeltas().put(object.cdoID(), revisionDelta);
+ lastSavepoint.getRevisionDeltas().put(object.cdoID(), revisionDelta);
}
((InternalCDORevisionDelta)revisionDelta).addFeatureDelta(featureDelta);
@@ -563,7 +572,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
public void registerRevisionDelta(CDORevisionDelta revisionDelta)
{
- lastSavePoint.getRevisionDeltas().putIfAbsent(revisionDelta.getID(), revisionDelta);
+ lastSavepoint.getRevisionDeltas().putIfAbsent(revisionDelta.getID(), revisionDelta);
}
public void registerDirty(InternalCDOObject object, CDOFeatureDelta featureDelta)
@@ -574,7 +583,7 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
}
registerFeatureDelta(object, featureDelta);
- register(lastSavePoint.getDirtyObjects(), object);
+ register(lastSavepoint.getDirtyObjects(), object);
}
@SuppressWarnings("unchecked")
@@ -674,48 +683,49 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
private void cleanUp()
{
newPackages = null;
- lastSavePoint = firstSavePoint;
- firstSavePoint.clear();
- firstSavePoint.setNextSavePoint(null);
+ lastSavepoint = firstSavepoint;
+ firstSavepoint.clear();
+ firstSavepoint.setNextSavepoint(null);
dirty = false;
conflict = false;
lastTemporaryID = 0;
}
+
public Map<CDOID, CDOObject> getDirtyObjects()
{
- if (this.lastSavePoint.getPreviousSavePoint() == null) return lastSavePoint.getDirtyObjects();
+ if (this.lastSavepoint.getPreviousSavepoint() == null) return lastSavepoint.getDirtyObjects();
MultiMap.ListBased<CDOID, CDOObject> dirtyObjects = new MultiMap.ListBased<CDOID, CDOObject>();
- for (CDOSavePointImpl savePoint = lastSavePoint; savePoint != null; savePoint = savePoint.getPreviousSavePoint())
+ for (CDOSavepointImpl savepoint = lastSavepoint; savepoint != null; savepoint = savepoint.getPreviousSavepoint())
{
- dirtyObjects.getDelegates().add(savePoint.getDirtyObjects());
+ dirtyObjects.getDelegates().add(savepoint.getDirtyObjects());
}
return dirtyObjects;
}
public Map<CDOID, CDOObject> getNewObjects()
{
- if (this.lastSavePoint.getPreviousSavePoint() == null)
- return Collections.unmodifiableMap(lastSavePoint.getNewObjects());
+ if (this.lastSavepoint.getPreviousSavepoint() == null)
+ return Collections.unmodifiableMap(lastSavepoint.getNewObjects());
MultiMap.ListBased<CDOID, CDOObject> newObjects = new MultiMap.ListBased<CDOID, CDOObject>();
- for (CDOSavePointImpl savePoint = lastSavePoint; savePoint != null; savePoint = savePoint.getPreviousSavePoint())
+ for (CDOSavepointImpl savepoint = lastSavepoint; savepoint != null; savepoint = savepoint.getPreviousSavepoint())
{
- newObjects.getDelegates().add(savePoint.getNewObjects());
+ newObjects.getDelegates().add(savepoint.getNewObjects());
}
return newObjects;
}
public Map<CDOID, CDOResource> getNewResources()
{
- if (this.lastSavePoint.getPreviousSavePoint() == null)
- return Collections.unmodifiableMap(lastSavePoint.getNewResources());
+ if (this.lastSavepoint.getPreviousSavepoint() == null)
+ return Collections.unmodifiableMap(lastSavepoint.getNewResources());
MultiMap.ListBased<CDOID, CDOResource> newResources = new MultiMap.ListBased<CDOID, CDOResource>();
- for (CDOSavePointImpl savePoint = lastSavePoint; savePoint != null; savePoint = savePoint.getPreviousSavePoint())
+ for (CDOSavepointImpl savepoint = lastSavepoint; savepoint != null; savepoint = savepoint.getPreviousSavepoint())
{
- newResources.getDelegates().add(savePoint.getNewResources());
+ newResources.getDelegates().add(savepoint.getNewResources());
}
return newResources;
}
@@ -723,29 +733,29 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
/**
* @since 2.0
*/
- public Map<CDOID, CDORevisionImpl> getBaseNewObjects()
+ public Map<CDOID, CDORevision> getBaseNewObjects()
{
- if (this.lastSavePoint.getPreviousSavePoint() == null)
- return Collections.unmodifiableMap(lastSavePoint.getBaseNewObjects());
+ if (this.lastSavepoint.getPreviousSavepoint() == null)
+ return Collections.unmodifiableMap(lastSavepoint.getBaseNewObjects());
- MultiMap.ListBased<CDOID, CDORevisionImpl> newObjects = new MultiMap.ListBased<CDOID, CDORevisionImpl>();
- for (CDOSavePointImpl savePoint = lastSavePoint; savePoint != null; savePoint = savePoint.getPreviousSavePoint())
+ MultiMap.ListBased<CDOID, CDORevision> newObjects = new MultiMap.ListBased<CDOID, CDORevision>();
+ for (CDOSavepointImpl savepoint = lastSavepoint; savepoint != null; savepoint = savepoint.getPreviousSavepoint())
{
- newObjects.getDelegates().add(savePoint.getBaseNewObjects());
+ newObjects.getDelegates().add(savepoint.getBaseNewObjects());
}
return newObjects;
}
public Map<CDOID, CDORevisionDelta> getRevisionDeltas()
{
- if (this.lastSavePoint.getPreviousSavePoint() == null) return lastSavePoint.getRevisionDeltas();
+ if (this.lastSavepoint.getPreviousSavepoint() == null) return lastSavepoint.getRevisionDeltas();
- // We need to combined the result for all delta in different SavePoint
+ // We need to combined the result for all delta in different Savepoint
Map<CDOID, CDORevisionDelta> revisionDeltas = new ConcurrentHashMap<CDOID, CDORevisionDelta>();
- for (CDOSavePointImpl savePoint = firstSavePoint; savePoint != null; savePoint = savePoint.getNextSavePoint())
+ for (CDOSavepointImpl savepoint = firstSavepoint; savepoint != null; savepoint = savepoint.getNextSavepoint())
{
- for (Entry<CDOID, CDORevisionDelta> entry : savePoint.getRevisionDeltas().entrySet())
+ for (Entry<CDOID, CDORevisionDelta> entry : savepoint.getRevisionDeltas().entrySet())
{
// Skipping temporary
if (entry.getKey().isTemporary()) continue;
@@ -858,4 +868,5 @@ public class CDOTransactionImpl extends CDOViewImpl implements CDOTransaction
getSource(), getConflictingObject(), isFirstConflict());
}
}
+
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java
index 026fc663e7..09b9a5c909 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java
@@ -312,7 +312,7 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements CDOP
{
}
- public void rollingbackTransaction(CDOTransaction transaction)
+ public void rolledBackTransaction(CDOTransaction transaction)
{
}
}

Back to the top