summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaspar De Groot2011-10-10 00:55:54 (EDT)
committerCaspar De Groot2011-10-10 00:55:54 (EDT)
commit6917f4258146f21f3394b876b861402bbccb0323 (patch)
tree7e64a1b735d7c48b2c1b5b91318ed51bf1e45c9c
parent5ed07c0998ec02364ffb549f7a693bd9648c5962 (diff)
downloadcdo-6917f4258146f21f3394b876b861402bbccb0323.zip
cdo-6917f4258146f21f3394b876b861402bbccb0323.tar.gz
cdo-6917f4258146f21f3394b876b861402bbccb0323.tar.bz2
[355045] Allow NEW objects to be locked on commit
https://bugs.eclipse.org/bugs/show_bug.cgi?id=355045
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockUtil.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockStateImpl.java17
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientProtocol.java38
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitDelegationRequest.java40
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitTransactionRequest.java41
-rw-r--r--plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionRequest.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitTransactionIndication.java14
-rw-r--r--plugins/org.eclipse.emf.cdo.server/.settings/.api_filters8
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java55
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionProtocol.java20
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/SynchronizableRepository.java110
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreAccessor.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalCommitContext.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2All.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DetachTest.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerTest.java64
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingNotificationsTest.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaTest.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/XATransactionTest.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266982_Test.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_267352_Test.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_321986_Test.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_330052_Test.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333950_Test.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334608_Test.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_340961_Test.java32
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_343332_Test.java6
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOCommitContext.java48
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java57
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java12
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapper.java41
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/DelegatingSessionProtocol.java44
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSingleTransactionStrategyImpl.java7
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java156
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXACommitContextImpl.java52
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java167
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java15
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java8
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java20
40 files changed, 877 insertions, 318 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockUtil.java
index 0f22468..2dbfde6 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockUtil.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockUtil.java
@@ -40,10 +40,20 @@ import java.util.Random;
*/
public final class CDOLockUtil
{
+ private static final int DURABLE_SESSION_ID = 0;
+
+ private static final int DURABLE_VIEW_ID = 0;
+
private CDOLockUtil()
{
}
+ public static CDOLockState copyLockState(CDOLockState lockState)
+ {
+ CheckUtil.checkArg(lockState instanceof CDOLockStateImpl, "lockState instanceof CDOLockStateImpl");
+ return ((CDOLockStateImpl)lockState).copy();
+ }
+
public static CDOLockState createLockState(Object target)
{
return new CDOLockStateImpl(target);
@@ -52,7 +62,6 @@ public final class CDOLockUtil
public static CDOLockState createLockState(LockState<Object, ? extends CDOCommonView> lockState)
{
CheckUtil.checkArg(lockState, "lockState");
-
InternalCDOLockState cdoLockState = new CDOLockStateImpl(lockState.getLockedObject());
for (CDOCommonView view : lockState.getReadLockOwners())
@@ -63,9 +72,8 @@ public final class CDOLockUtil
boolean isDurableView = session == null;
if (isDurableView)
{
- // TODO (CD) Use some symbolic constants here?
- sessionID = 0;
- viewID = 0;
+ sessionID = DURABLE_SESSION_ID;
+ viewID = DURABLE_VIEW_ID;
}
else
{
@@ -106,7 +114,7 @@ public final class CDOLockUtil
}
CheckUtil.checkNull(durableLockingID, "durableLockingID");
- return new CDOLockOwnerImpl(0, 0, durableLockingID, true); // TODO (CD) Symbolic constants?
+ return new CDOLockOwnerImpl(DURABLE_SESSION_ID, DURABLE_VIEW_ID, durableLockingID, true);
}
public static CDOLockChangeInfo createLockChangeInfo(long timestamp, CDOLockOwner lockOwner, CDOBranch branch,
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockStateImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockStateImpl.java
index bcad0f7..5f85e90 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockStateImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockStateImpl.java
@@ -10,7 +10,9 @@
*/
package org.eclipse.emf.cdo.internal.common.lock;
+import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.lock.CDOLockOwner;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
import org.eclipse.emf.cdo.spi.common.lock.InternalCDOLockState;
import org.eclipse.net4j.util.CheckUtil;
@@ -36,9 +38,24 @@ public class CDOLockStateImpl implements InternalCDOLockState
public CDOLockStateImpl(Object lockedObject)
{
CheckUtil.checkArg(lockedObject, "lockedObject");
+ CheckUtil.checkState(lockedObject instanceof CDOID || lockedObject instanceof CDOIDAndBranch,
+ "lockedObject is of wrong type");
this.lockedObject = lockedObject;
}
+ public CDOLockStateImpl copy()
+ {
+ CDOLockStateImpl newLockState = new CDOLockStateImpl(lockedObject);
+ for (CDOLockOwner owner : readLockOwners)
+ {
+ newLockState.readLockOwners.add(owner);
+ }
+
+ newLockState.writeLockOwner = writeLockOwner;
+ newLockState.writeOptionOwner = writeOptionOwner;
+ return newLockState;
+ }
+
public boolean isLocked(LockType lockType, CDOLockOwner lockOwner, boolean others)
{
switch (lockType)
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientProtocol.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientProtocol.java
index 0928603..2d63434 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientProtocol.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CDOClientProtocol.java
@@ -64,11 +64,11 @@ import org.eclipse.emf.spi.cdo.AbstractQueryIterator;
import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
import org.eclipse.emf.spi.cdo.InternalCDOObject;
import org.eclipse.emf.spi.cdo.InternalCDORemoteSessionManager;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction.InternalCDOCommitContext;
import org.eclipse.emf.spi.cdo.InternalCDOXATransaction.InternalCDOXACommitContext;
import java.io.IOException;
import java.util.Collection;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -226,13 +226,15 @@ public class CDOClientProtocol extends SignalProtocol<CDOSession> implements CDO
public LockObjectsResult lockObjects(List<InternalCDORevision> revisions, int viewID, CDOBranch viewedBranch,
LockType lockType, long timeout) throws InterruptedException
{
- List<CDORevisionKey> revisionKeys = new LinkedList<CDORevisionKey>();
- for (InternalCDORevision rev : revisions)
- {
- revisionKeys.add(rev);
- }
+ // List<CDORevisionKey> revisionKeys = new LinkedList<CDORevisionKey>();
+ // for (InternalCDORevision rev : revisions)
+ // {
+ // revisionKeys.add(rev);
+ // }
+ //
+ // return lockObjects2(revisionKeys, viewID, viewedBranch, lockType, false, timeout);
- return lockObjects2(revisionKeys, viewID, viewedBranch, lockType, false, timeout);
+ throw new UnsupportedOperationException();
}
public LockObjectsResult lockObjects2(List<CDORevisionKey> revisionKeys, int viewID, CDOBranch viewedBranch,
@@ -315,7 +317,9 @@ public class CDOClientProtocol extends SignalProtocol<CDOSession> implements CDO
@Deprecated
public void unlockObjects(CDOView view, Collection<CDOID> objectIDs, LockType lockType)
{
- send(new UnlockObjectsRequest(this, view.getViewID(), objectIDs, lockType, false));
+ // send(new UnlockObjectsRequest(this, view.getViewID(), objectIDs, lockType, false));
+
+ throw new UnsupportedOperationException();
}
public UnlockObjectsResult unlockObjects2(CDOView view, Collection<CDOID> objectIDs, LockType lockType,
@@ -371,18 +375,28 @@ public class CDOClientProtocol extends SignalProtocol<CDOSession> implements CDO
send(new HandleRevisionsRequest(this, eClass, branch, exactBranch, timeStamp, exactTime, handler));
}
+ @Deprecated
public CommitTransactionResult commitTransaction(int transactionID, String comment, boolean releaseLocks,
CDOIDProvider idProvider, CDOCommitData commitData, Collection<CDOLob<?>> lobs, OMMonitor monitor)
{
- return send(new CommitTransactionRequest(this, transactionID, comment, releaseLocks, idProvider, commitData, lobs),
- monitor);
+ throw new UnsupportedOperationException();
}
+ public CommitTransactionResult commitTransaction(InternalCDOCommitContext context, OMMonitor monitor)
+ {
+ return send(new CommitTransactionRequest(this, context), monitor);
+ }
+
+ @Deprecated
public CommitTransactionResult commitDelegation(CDOBranch branch, String userID, String comment,
CDOCommitData commitData, Map<CDOID, EClass> detachedObjectTypes, Collection<CDOLob<?>> lobs, OMMonitor monitor)
{
- return send(new CommitDelegationRequest(this, branch, userID, comment, commitData, detachedObjectTypes, lobs),
- monitor);
+ throw new UnsupportedOperationException();
+ }
+
+ public CommitTransactionResult commitDelegation(InternalCDOCommitContext context, OMMonitor monitor)
+ {
+ return send(new CommitDelegationRequest(this, context), monitor);
}
public CommitTransactionResult commitXATransactionPhase1(InternalCDOXACommitContext xaContext, OMMonitor monitor)
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitDelegationRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitDelegationRequest.java
index 641c43d..d048609 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitDelegationRequest.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitDelegationRequest.java
@@ -11,41 +11,33 @@
package org.eclipse.emf.cdo.internal.net4j.protocol;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.commit.CDOCommitData;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDProvider;
-import org.eclipse.emf.cdo.common.lob.CDOLob;
import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
import org.eclipse.emf.cdo.common.protocol.CDOProtocolConstants;
import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction.InternalCDOCommitContext;
import java.io.IOException;
-import java.util.Collection;
-import java.util.Map;
/**
* @author Eike Stepper
*/
public class CommitDelegationRequest extends CommitTransactionRequest
{
- private static final int UNKNOWN_TRANSACTION_ID = 0;
-
private CDOBranch branch;
private String userID;
- private Map<CDOID, EClass> detachedObjectTypes;
+ private static final DelegationIDProvider delegationIDProvider = new DelegationIDProvider();
- public CommitDelegationRequest(CDOClientProtocol protocol, CDOBranch branch, String userID, String comment,
- CDOCommitData commitData, Map<CDOID, EClass> detachedObjectTypes, Collection<CDOLob<?>> lobs)
+ public CommitDelegationRequest(CDOClientProtocol protocol, InternalCDOCommitContext context)
{
- super(protocol, CDOProtocolConstants.SIGNAL_COMMIT_DELEGATION, UNKNOWN_TRANSACTION_ID, comment, false,
- CDOIDProvider.NOOP, commitData, lobs);
+ super(protocol, CDOProtocolConstants.SIGNAL_COMMIT_DELEGATION, context);
- this.branch = branch;
- this.userID = userID;
- this.detachedObjectTypes = detachedObjectTypes;
+ branch = context.getBranch();
+ userID = context.getUserID();
}
@Override
@@ -58,6 +50,24 @@ public class CommitDelegationRequest extends CommitTransactionRequest
@Override
protected EClass getObjectType(CDOID id)
{
- return detachedObjectTypes.get(id);
+ // The types of detached objects are delivered through the wire and don't need to be queried locally.
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ protected CDOIDProvider getIDProvider()
+ {
+ return delegationIDProvider;
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static class DelegationIDProvider implements CDOIDProvider
+ {
+ public CDOID provideCDOID(Object idOrObject)
+ {
+ return (CDOID)idOrObject;
+ }
}
}
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitTransactionRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitTransactionRequest.java
index a49cd4e..e7ce43c 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitTransactionRequest.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitTransactionRequest.java
@@ -48,6 +48,7 @@ import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction.InternalCDOCommitContext;
import java.io.IOException;
import java.io.OutputStreamWriter;
@@ -74,26 +75,29 @@ public class CommitTransactionRequest extends CDOClientRequestWithMonitoring<Com
private Collection<CDOLob<?>> lobs;
+ private Collection<CDOLockState> locksOnNewObjects;
+
+ private int viewID;
+
private CDOTransaction transaction;
- public CommitTransactionRequest(CDOClientProtocol protocol, int transactionID, String comment, boolean releaseLocks,
- CDOIDProvider idProvider, CDOCommitData commitData, Collection<CDOLob<?>> lobs)
+ public CommitTransactionRequest(CDOClientProtocol protocol, InternalCDOCommitContext context)
{
- this(protocol, CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION, transactionID, comment, releaseLocks, idProvider,
- commitData, lobs);
+ this(protocol, CDOProtocolConstants.SIGNAL_COMMIT_TRANSACTION, context);
}
- public CommitTransactionRequest(CDOClientProtocol protocol, short signalID, int transactionID, String comment,
- boolean releaseLocks, CDOIDProvider idProvider, CDOCommitData commitData, Collection<CDOLob<?>> lobs)
+ public CommitTransactionRequest(CDOClientProtocol protocol, short signalID, InternalCDOCommitContext context)
{
super(protocol, signalID);
- transaction = (CDOTransaction)getSession().getView(transactionID);
- this.comment = comment;
- this.releaseLocks = releaseLocks;
- this.idProvider = idProvider;
- this.commitData = commitData;
- this.lobs = lobs;
+ transaction = context.getTransaction();
+ comment = context.getCommitComment();
+ releaseLocks = context.isAutoReleaseLocks();
+ idProvider = context.getTransaction();
+ commitData = context.getCommitData();
+ lobs = context.getLobs();
+ locksOnNewObjects = context.getLocksOnNewObjects();
+ viewID = context.getViewID();
}
@Override
@@ -118,7 +122,7 @@ public class CommitTransactionRequest extends CDOClientRequestWithMonitoring<Com
protected void requestingTransactionInfo(CDODataOutput out) throws IOException
{
- out.writeInt(transaction.getViewID());
+ out.writeInt(viewID);
}
protected void requestingCommit(CDODataOutput out) throws IOException
@@ -131,6 +135,7 @@ public class CommitTransactionRequest extends CDOClientRequestWithMonitoring<Com
out.writeBoolean(releaseLocks);
out.writeString(comment);
out.writeInt(newPackageUnits.size());
+ out.writeInt(locksOnNewObjects.size());
out.writeInt(newObjects.size());
out.writeInt(changedObjects.size());
out.writeInt(detachedObjects.size());
@@ -147,6 +152,16 @@ public class CommitTransactionRequest extends CDOClientRequestWithMonitoring<Com
if (TRACER.isEnabled())
{
+ TRACER.format("Writing {0} locks on new objects", locksOnNewObjects.size()); //$NON-NLS-1$
+ }
+
+ for (CDOLockState lockState : locksOnNewObjects)
+ {
+ out.writeCDOLockState(lockState);
+ }
+
+ if (TRACER.isEnabled())
+ {
TRACER.format("Writing {0} new objects", newObjects.size()); //$NON-NLS-1$
}
diff --git a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionRequest.java b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionRequest.java
index 3383cec..9671518 100644
--- a/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionRequest.java
+++ b/plugins/org.eclipse.emf.cdo.net4j/src/org/eclipse/emf/cdo/internal/net4j/protocol/CommitXATransactionRequest.java
@@ -21,9 +21,7 @@ public class CommitXATransactionRequest extends CommitTransactionRequest
public CommitXATransactionRequest(CDOClientProtocol protocol, short signalID, InternalCDOXACommitContext xaContext)
{
- super(protocol, signalID, xaContext.getTransaction().getViewID(), xaContext.getTransaction().getCommitComment(),
- xaContext.getTransaction().options().isAutoReleaseLocksEnabled(), xaContext.getTransaction(), xaContext
- .getCommitData(), xaContext.getLobs());
+ super(protocol, signalID, xaContext);
this.xaContext = xaContext;
}
diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitTransactionIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitTransactionIndication.java
index 36bd6c0..801811d 100644
--- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitTransactionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/CommitTransactionIndication.java
@@ -121,6 +121,7 @@ public class CommitTransactionIndication extends CDOServerIndicationWithMonitori
String commitComment = in.readString();
InternalCDOPackageUnit[] newPackageUnits = new InternalCDOPackageUnit[in.readInt()];
+ CDOLockState[] locksOnNewObjects = new CDOLockState[in.readInt()];
InternalCDORevision[] newObjects = new InternalCDORevision[in.readInt()];
InternalCDORevisionDelta[] dirtyObjectDeltas = new InternalCDORevisionDelta[in.readInt()];
CDOID[] detachedObjects = new CDOID[in.readInt()];
@@ -147,6 +148,18 @@ public class CommitTransactionIndication extends CDOServerIndicationWithMonitori
// Note: EcoreUtil.resolveAll(resourceSet) does *not* do the trick
EMFUtil.safeResolveAll(resourceSet);
+ // Locks on new objects
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Reading {0} locks on new objects", locksOnNewObjects.length); //$NON-NLS-1$
+ }
+
+ for (int i = 0; i < locksOnNewObjects.length; i++)
+ {
+ locksOnNewObjects[i] = in.readCDOLockState();
+ monitor.worked();
+ }
+
// New objects
if (TRACER.isEnabled())
{
@@ -206,6 +219,7 @@ public class CommitTransactionIndication extends CDOServerIndicationWithMonitori
}
commitContext.setNewPackageUnits(newPackageUnits);
+ commitContext.setLocksOnNewObjects(locksOnNewObjects);
commitContext.setNewObjects(newObjects);
commitContext.setDirtyObjectDeltas(dirtyObjectDeltas);
commitContext.setDetachedObjects(detachedObjects);
diff --git a/plugins/org.eclipse.emf.cdo.server/.settings/.api_filters b/plugins/org.eclipse.emf.cdo.server/.settings/.api_filters
index 7ea71f5..f680b1e 100644
--- a/plugins/org.eclipse.emf.cdo.server/.settings/.api_filters
+++ b/plugins/org.eclipse.emf.cdo.server/.settings/.api_filters
@@ -200,6 +200,14 @@
</message_arguments>
</filter>
</resource>
+ <resource path="src/org/eclipse/emf/cdo/internal/server/syncing/SynchronizableRepository.java" type="org.eclipse.emf.cdo.internal.server.syncing.SynchronizableRepository$WriteThroughCommitContext">
+ <filter id="574619656">
+ <message_arguments>
+ <message_argument value="InternalCDOCommitContext"/>
+ <message_argument value="WriteThroughCommitContext"/>
+ </message_arguments>
+ </filter>
+ </resource>
<resource path="src/org/eclipse/emf/cdo/server/IQueryContext.java" type="org.eclipse.emf.cdo.server.IQueryContext">
<filter id="571473929">
<message_arguments>
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java
index ce3a43a..71c6626 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/TransactionCommitContext.java
@@ -12,6 +12,7 @@
*/
package org.eclipse.emf.cdo.internal.server;
+import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.commit.CDOCommitData;
@@ -22,6 +23,7 @@ import org.eclipse.emf.cdo.common.id.CDOIDReference;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo.Operation;
+import org.eclipse.emf.cdo.common.lock.CDOLockOwner;
import org.eclipse.emf.cdo.common.lock.CDOLockState;
import org.eclipse.emf.cdo.common.lock.CDOLockUtil;
import org.eclipse.emf.cdo.common.model.CDOModelUtil;
@@ -127,6 +129,8 @@ public class TransactionCommitContext implements InternalCommitContext
private InternalCDOPackageUnit[] newPackageUnits = new InternalCDOPackageUnit[0];
+ private CDOLockState[] locksOnNewObjects = new CDOLockState[0];
+
private InternalCDORevision[] newObjects = new InternalCDORevision[0];
private InternalCDORevisionDelta[] dirtyObjectDeltas = new InternalCDORevisionDelta[0];
@@ -220,6 +224,11 @@ public class TransactionCommitContext implements InternalCommitContext
return newPackageUnits;
}
+ public CDOLockState[] getLocksOnNewObjects()
+ {
+ return locksOnNewObjects;
+ }
+
public InternalCDORevision[] getNewObjects()
{
return newObjects;
@@ -242,7 +251,7 @@ public class TransactionCommitContext implements InternalCommitContext
public InternalCDORevision[] getDetachedRevisions()
{
- // TODO This array can contain null values as they only come from the cache
+ // This array can contain null values as they only come from the cache!
for (InternalCDORevision cachedDetachedRevision : cachedDetachedRevisions)
{
if (cachedDetachedRevision == null)
@@ -372,6 +381,11 @@ public class TransactionCommitContext implements InternalCommitContext
this.newPackageUnits = newPackageUnits;
}
+ public void setLocksOnNewObjects(CDOLockState[] locksOnNewObjects)
+ {
+ this.locksOnNewObjects = locksOnNewObjects;
+ }
+
public void setNewObjects(InternalCDORevision[] newObjects)
{
this.newObjects = newObjects;
@@ -1048,7 +1062,7 @@ public class TransactionCommitContext implements InternalCommitContext
{
try
{
- monitor.begin(7);
+ monitor.begin(8);
addNewPackageUnits(monitor.fork());
addRevisions(newObjects, monitor.fork());
addRevisions(dirtyObjects, monitor.fork());
@@ -1057,11 +1071,16 @@ public class TransactionCommitContext implements InternalCommitContext
unlockObjects();
monitor.worked();
+ applyLocksOnNewObjects();
+ monitor.worked();
+
if (isAutoReleaseLocksEnabled())
{
postCommitLockStates = repository.getLockingManager().unlock2(true, transaction);
if (!postCommitLockStates.isEmpty())
{
+ // TODO (CD) Does doing this here make sense?
+ // The commit notifications get sent later, from postCommit.
sendLockNotifications(postCommitLockStates);
}
}
@@ -1069,12 +1088,44 @@ public class TransactionCommitContext implements InternalCommitContext
monitor.worked();
repository.notifyWriteAccessHandlers(transaction, this, false, monitor.fork());
}
+ catch (Throwable t)
+ {
+ handleException(t);
+ }
finally
{
monitor.done();
}
}
+ private void applyLocksOnNewObjects() throws InterruptedException
+ {
+ final CDOLockOwner owner = CDOLockUtil.createLockOwner(transaction);
+
+ for (CDOLockState lockState : locksOnNewObjects)
+ {
+ Object target = lockState.getLockedObject();
+
+ if (transaction.getRepository().getIDGenerationLocation() == IDGenerationLocation.STORE)
+ {
+ CDOIDAndBranch idAndBranch = target instanceof CDOIDAndBranch ? (CDOIDAndBranch)target : null;
+ CDOID id = idAndBranch != null ? ((CDOIDAndBranch)target).getID() : (CDOID)target;
+ CDOID newID = idMappings.get(id);
+ CheckUtil.checkNull(newID, "newID");
+
+ target = idAndBranch != null ? CDOIDUtil.createIDAndBranch(newID, idAndBranch.getBranch()) : newID;
+ }
+
+ for (LockType type : LockType.values())
+ {
+ if (lockState.isLocked(type, owner, false))
+ {
+ lockManager.lock2(type, transaction, Collections.singleton(target), 0);
+ }
+ }
+ }
+ }
+
private void sendLockNotifications(List<LockState<Object, IView>> newLockStates)
{
CDOLockState[] newStates = Repository.toCDOLockStates(newLockStates);
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionProtocol.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionProtocol.java
index f5861e1..6a5b082 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionProtocol.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/embedded/EmbeddedClientSessionProtocol.java
@@ -64,6 +64,8 @@ import org.eclipse.emf.spi.cdo.AbstractQueryIterator;
import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
import org.eclipse.emf.spi.cdo.InternalCDOObject;
import org.eclipse.emf.spi.cdo.InternalCDORemoteSessionManager;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction.InternalCDOCommitContext;
import org.eclipse.emf.spi.cdo.InternalCDOXATransaction.InternalCDOXACommitContext;
import java.util.ArrayList;
@@ -412,9 +414,15 @@ public class EmbeddedClientSessionProtocol extends Lifecycle implements CDOSessi
throw new UnsupportedOperationException();
}
+ @Deprecated
public CommitTransactionResult commitTransaction(int transactionID, String comment, boolean releaseLocks,
CDOIDProvider idProvider, CDOCommitData commitData, Collection<CDOLob<?>> lobs, OMMonitor monitor)
{
+ throw new UnsupportedOperationException();
+ }
+
+ public CommitTransactionResult commitTransaction(InternalCDOCommitContext context, OMMonitor monitor)
+ {
monitor.begin(2);
boolean success = false;
InternalCommitContext serverCommitContext = null;
@@ -422,11 +430,15 @@ public class EmbeddedClientSessionProtocol extends Lifecycle implements CDOSessi
try
{
+ InternalCDOTransaction transaction = context.getTransaction();
+ CDOCommitData commitData = context.getCommitData();
+
+ int transactionID = transaction.getViewID();
InternalTransaction serverTransaction = (InternalTransaction)serverSessionProtocol.getSession().getView(
transactionID);
serverCommitContext = serverTransaction.createCommitContext();
serverCommitContext.preWrite();
- serverCommitContext.setAutoReleaseLocksEnabled(releaseLocks);
+ serverCommitContext.setAutoReleaseLocksEnabled(transaction.options().isAutoReleaseLocksEnabled());
List<CDOPackageUnit> npu = commitData.getNewPackageUnits();
serverCommitContext.setNewPackageUnits(npu.toArray(new InternalCDOPackageUnit[npu.size()]));
@@ -479,12 +491,18 @@ public class EmbeddedClientSessionProtocol extends Lifecycle implements CDOSessi
return result;
}
+ @Deprecated
public CommitTransactionResult commitDelegation(CDOBranch branch, String userID, String comment,
CDOCommitData commitData, Map<CDOID, EClass> detachedObjectTypes, Collection<CDOLob<?>> lobs, OMMonitor monitor)
{
throw new UnsupportedOperationException();
}
+ public CommitTransactionResult commitDelegation(InternalCDOCommitContext context, OMMonitor monitor)
+ {
+ throw new UnsupportedOperationException();
+ }
+
public CommitTransactionResult commitXATransactionCancel(InternalCDOXACommitContext xaContext, OMMonitor monitor)
{
throw new UnsupportedOperationException();
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/SynchronizableRepository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/SynchronizableRepository.java
index c99f6fa..0d69c70 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/SynchronizableRepository.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/SynchronizableRepository.java
@@ -10,6 +10,7 @@
*/
package org.eclipse.emf.cdo.internal.server.syncing;
+import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.common.CDOCommonRepository;
import org.eclipse.emf.cdo.common.CDOCommonSession.Options.LockNotificationMode;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
@@ -34,6 +35,7 @@ import org.eclipse.emf.cdo.common.protocol.CDODataInput;
import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
import org.eclipse.emf.cdo.common.util.CDOException;
import org.eclipse.emf.cdo.internal.common.commit.CDOCommitDataImpl;
@@ -74,6 +76,8 @@ import org.eclipse.emf.spi.cdo.CDOSessionProtocol.CommitTransactionResult;
import org.eclipse.emf.spi.cdo.CDOSessionProtocol.LockObjectsResult;
import org.eclipse.emf.spi.cdo.CDOSessionProtocol.UnlockObjectsResult;
import org.eclipse.emf.spi.cdo.InternalCDOSession;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction.InternalCDOCommitContext;
import java.io.IOException;
import java.util.Arrays;
@@ -415,6 +419,7 @@ public abstract class SynchronizableRepository extends Repository.Default implem
List<CDOIDAndVersion> newObjects = changeSet.getNewObjects();
List<CDORevisionKey> changedObjects = changeSet.getChangedObjects();
List<CDOIDAndVersion> detachedObjects = changeSet.getDetachedObjects();
+
CDOCommitData data = new CDOCommitDataImpl(newPackages, newObjects, changedObjects, detachedObjects);
String comment = "<replicate raw commits>"; //$NON-NLS-1$
@@ -709,7 +714,7 @@ public abstract class SynchronizableRepository extends Repository.Default implem
/**
* @author Eike Stepper
*/
- private static final class CommitContextData implements CDOCommitData
+ protected static final class CommitContextData implements CDOCommitData
{
private InternalCommitContext commitContext;
@@ -832,6 +837,8 @@ public abstract class SynchronizableRepository extends Repository.Default implem
*/
protected final class WriteThroughCommitContext extends TransactionCommitContext
{
+ private static final int ARTIFICIAL_VIEW_ID = 0;
+
public WriteThroughCommitContext(InternalTransaction transaction)
{
super(transaction);
@@ -852,19 +859,102 @@ public abstract class SynchronizableRepository extends Repository.Default implem
@Override
public void commit(OMMonitor monitor)
{
- InternalTransaction transaction = getTransaction();
-
// Prepare commit to the master
- CDOBranch branch = transaction.getBranch();
- String userID = getUserID();
- String comment = getCommitComment();
- CDOCommitData commitData = new CommitContextData(this);
- Collection<CDOLob<?>> lobs = Collections.emptySet();
+ final CDOCommitData commitData = new CommitContextData(this);
+
+ InternalCDOCommitContext ctx = new InternalCDOCommitContext()
+ {
+ public boolean isPartialCommit()
+ {
+ return false;
+ }
+
+ public Map<CDOID, CDORevisionDelta> getRevisionDeltas()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public List<CDOPackageUnit> getNewPackageUnits()
+ {
+ return commitData.getNewPackageUnits();
+ }
+
+ public Map<CDOID, CDOObject> getNewObjects()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Collection<CDOLockState> getLocksOnNewObjects()
+ {
+ CDOLockState[] locksOnNewObjectsArr = WriteThroughCommitContext.this.getLocksOnNewObjects();
+ Collection<CDOLockState> locksOnNewObjects = Arrays.asList(locksOnNewObjectsArr);
+ return locksOnNewObjects;
+ }
+
+ public Collection<CDOLob<?>> getLobs()
+ {
+ return Collections.emptySet(); // TODO (CD) Did we forget to support this earlier?
+ }
+
+ public Map<CDOID, CDOObject> getDirtyObjects()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public Map<CDOID, CDOObject> getDetachedObjects()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void preCommit()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void postCommit(CommitTransactionResult result)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public InternalCDOTransaction getTransaction()
+ {
+ return null;
+ }
+
+ public CDOCommitData getCommitData()
+ {
+ return commitData;
+ }
+
+ public int getViewID()
+ {
+ return ARTIFICIAL_VIEW_ID;
+ }
+
+ public String getUserID()
+ {
+ return WriteThroughCommitContext.this.getUserID();
+ }
+
+ public boolean isAutoReleaseLocks()
+ {
+ return WriteThroughCommitContext.this.isAutoReleaseLocksEnabled();
+ }
+
+ public String getCommitComment()
+ {
+ return WriteThroughCommitContext.this.getCommitComment();
+ }
+
+ public CDOBranch getBranch()
+ {
+ return WriteThroughCommitContext.this.getTransaction().getBranch();
+ }
+ };
// Delegate commit to the master
CDOSessionProtocol sessionProtocol = getSynchronizer().getRemoteSession().getSessionProtocol();
- CommitTransactionResult result = sessionProtocol.commitDelegation(branch, userID, comment, commitData,
- getDetachedObjectTypes(), lobs, monitor);
+ CommitTransactionResult result = sessionProtocol.commitDelegation(ctx, monitor);
// Stop if commit to master failed
String rollbackMessage = result.getRollbackMessage();
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 376bd3a..ed6dd8f 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
@@ -20,6 +20,7 @@ import org.eclipse.emf.cdo.common.lob.CDOBlob;
import org.eclipse.emf.cdo.common.lob.CDOClob;
import org.eclipse.emf.cdo.common.lob.CDOLob;
import org.eclipse.emf.cdo.common.lob.CDOLobHandler;
+import org.eclipse.emf.cdo.common.lock.CDOLockState;
import org.eclipse.emf.cdo.common.lock.IDurableLockingManager;
import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
import org.eclipse.emf.cdo.common.protocol.CDODataInput;
@@ -270,6 +271,7 @@ public interface IStoreAccessor extends IQueryHandlerProvider, BranchLoader, Com
* @author Eike Stepper
* @since 2.0
* @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
* @apiviz.exclude
*/
public interface CommitContext extends CDORevisionProvider
@@ -323,6 +325,14 @@ public interface IStoreAccessor extends IQueryHandlerProvider, BranchLoader, Com
public InternalCDOPackageUnit[] getNewPackageUnits();
/**
+ * Returns an array of the locks on the new objects that are part of the commit operation represented by this
+ * <code>CommitContext</code>.
+ *
+ * @since 4.1
+ */
+ public CDOLockState[] getLocksOnNewObjects();
+
+ /**
* Returns an array of the new objects that are part of the commit operation represented by this
* <code>CommitContext</code>.
*/
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalCommitContext.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalCommitContext.java
index 44d8bcb..38965dc 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalCommitContext.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/spi/server/InternalCommitContext.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.cdo.spi.server;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.lock.CDOLockState;
import org.eclipse.emf.cdo.server.IStoreAccessor;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
@@ -77,6 +78,11 @@ public interface InternalCommitContext extends IStoreAccessor.CommitContext
public void setNewPackageUnits(InternalCDOPackageUnit[] newPackageUnits);
+ /**
+ * @since 4.1
+ */
+ public void setLocksOnNewObjects(CDOLockState[] locksOnNewObjects);
+
public void setNewObjects(InternalCDORevision[] newObjects);
public void setDirtyObjectDeltas(InternalCDORevisionDelta[] dirtyObjectDeltas);
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2All.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2All.java
index 591901a..efcbd32 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2All.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2All.java
@@ -30,7 +30,7 @@ public class AllTestsDBH2All extends DBConfigs
protected void initConfigSuites(TestSuite parent)
{
addScenarios(parent, IDGenerationLocation.STORE);
- // addScenarios(parent, IDGenerationLocation.CLIENT);
+ addScenarios(parent, IDGenerationLocation.CLIENT);
}
private void addScenarios(TestSuite parent, IDGenerationLocation idGenerationLocation)
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DetachTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DetachTest.java
index 335ffbb..0379a7b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DetachTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/DetachTest.java
@@ -34,8 +34,6 @@ import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.spi.cdo.FSMUtil;
import org.eclipse.emf.spi.cdo.InternalCDOObject;
-import junit.framework.Assert;
-
/**
* @author Simon McDuff
*/
@@ -234,8 +232,8 @@ public class DetachTest extends AbstractCDOTest
order.getOrderDetails().add(orderDetail);
orderDetail.setProduct(product1);
assertActive(resource);
- Assert.assertEquals(1, CDOUtil.getViewSet(rset).getViews().length);
- Assert.assertEquals(1, rset.getResources().size());// Bug 346636
+ assertEquals(1, CDOUtil.getViewSet(rset).getViews().length);
+ assertEquals(1, rset.getResources().size());// Bug 346636
if (commitBeforeDelete == true)
{
transaction.commit();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerTest.java
index 77e3f65..9c33cb8 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingManagerTest.java
@@ -25,6 +25,7 @@ import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.util.CommitException;
import org.eclipse.emf.cdo.util.LockTimeoutException;
import org.eclipse.emf.cdo.util.StaleRevisionLockException;
+import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
import org.eclipse.net4j.util.concurrent.RWOLockManager;
@@ -1084,4 +1085,67 @@ public class LockingManagerTest extends AbstractLockingTest
session.close();
}
+
+ public void testLockOnNewObject() throws Exception
+ {
+ CDOSession session1 = openSession();
+ CDOSession session2 = openSession();
+
+ CDOTransaction transaction = session1.openTransaction();
+ transaction.options().setAutoReleaseLocksEnabled(false);
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+ transaction.commit();
+
+ Category category1 = getModel1Factory().createCategory();
+ Category category2 = getModel1Factory().createCategory();
+ Category category3 = getModel1Factory().createCategory();
+ resource.getContents().add(category1);
+ resource.getContents().add(category2);
+ resource.getContents().add(category3);
+
+ readLock(category1);
+ writeLock(category2);
+ writeOption(category3);
+
+ assertReadLock(true, category1);
+ assertWriteLock(true, category2);
+ assertWriteOption(true, category3);
+
+ readUnlock(category1);
+ writeUnlock(category2);
+ writeUnoption(category3);
+
+ assertReadLock(false, category1);
+ assertWriteLock(false, category2);
+ assertWriteLock(false, category3);
+
+ readLock(category1);
+ writeLock(category2);
+ writeOption(category3);
+
+ transaction.commit();
+
+ CDOView controlView = session2.openView();
+ controlView.options().setLockNotificationEnabled(true);
+ CDOResource r = controlView.getResource(getResourcePath("/res1"));
+
+ CDOObject category1cv = CDOUtil.getCDOObject(r.getContents().get(0));
+ CDOObject category2cv = CDOUtil.getCDOObject(r.getContents().get(1));
+ CDOObject category3cv = CDOUtil.getCDOObject(r.getContents().get(2));
+
+ assertEquals(true, category1cv.cdoReadLock().isLockedByOthers());
+ assertEquals(true, category2cv.cdoWriteLock().isLockedByOthers());
+ assertEquals(true, category3cv.cdoWriteOption().isLockedByOthers());
+
+ readUnlock(category1);
+ writeUnlock(category2);
+ writeUnoption(category3);
+
+ assertEquals(false, category1cv.cdoReadLock().isLockedByOthers());
+ assertEquals(false, category2cv.cdoReadLock().isLockedByOthers());
+ assertEquals(false, category3cv.cdoReadLock().isLockedByOthers());
+
+ session1.close();
+ session2.close();
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingNotificationsTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingNotificationsTest.java
index 52ae2d1..240f243 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingNotificationsTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingNotificationsTest.java
@@ -424,12 +424,21 @@ public class LockingNotificationsTest extends AbstractLockingTest
CDOResource res1 = tx1.createResource(getResourcePath("r1"));
res1.getContents().add(company1);
assertNew(cdoObj, tx1);
+ assertNotNull(cdoObj.cdoLockState());
+
+ res1.getContents().remove(company1);
+ assertTransient(cdoObj);
assertNull(cdoObj.cdoLockState());
+ res1.getContents().add(company1);
tx1.commit();
assertClean(cdoObj, tx1);
assertNotNull(cdoObj.cdoLockState());
+ res1.getContents().remove(company1);
+ assertTransient(cdoObj);
+ assertNull(cdoObj.cdoLockState());
+
session1.close();
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java
index 414a686..b1759b3 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/ResourceTest.java
@@ -48,8 +48,6 @@ import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.List;
-import junit.framework.Assert;
-
/**
* @author Eike Stepper
*/
@@ -389,12 +387,12 @@ public class ResourceTest extends AbstractCDOTest
assertActive(resource);
transaction.commit();
- Assert.assertEquals(1, rset.getResources().size()); // Bug 346636
- Assert.assertEquals(1, CDOUtil.getViewSet(rset).getViews().length);
+ assertEquals(1, rset.getResources().size()); // Bug 346636
+ assertEquals(1, CDOUtil.getViewSet(rset).getViews().length);
transaction.close();
- Assert.assertEquals(0, CDOUtil.getViewSet(rset).getViews().length);
- Assert.assertEquals(0, rset.getResources().size());
+ assertEquals(0, CDOUtil.getViewSet(rset).getViews().length);
+ assertEquals(0, rset.getResources().size());
session.close();
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaTest.java
index 30b92c8..3659cee 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/RevisionDeltaTest.java
@@ -45,8 +45,6 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
-import junit.framework.Assert;
-
/**
* See bug 201266
*
@@ -142,7 +140,7 @@ public class RevisionDeltaTest extends AbstractCDOTest
EStructuralFeature customerFeature = getModel1Package().getSalesOrder_Customer();
Object value = salesRevision.data().get(customerFeature, 0);
- Assert.assertEquals(true, value instanceof CDOID);
+ assertEquals(true, value instanceof CDOID);
transaction2.close();
session.close();
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/XATransactionTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/XATransactionTest.java
index 79ee03a..27c7607 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/XATransactionTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/XATransactionTest.java
@@ -33,8 +33,6 @@ import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
import java.util.Date;
-import junit.framework.Assert;
-
/**
* @author Simon McDuff
*/
@@ -341,8 +339,8 @@ public class XATransactionTest extends AbstractCDOTest
{
}
- Assert.assertEquals(false, CDOUtil.getCDOObject(supplier).cdoWriteLock().isLocked());
- Assert.assertEquals(false, CDOUtil.getCDOObject(purchaseOrder).cdoWriteLock().isLocked());
+ assertEquals(false, CDOUtil.getCDOObject(supplier).cdoWriteLock().isLocked());
+ assertEquals(false, CDOUtil.getCDOObject(purchaseOrder).cdoWriteLock().isLocked());
xaTransaction.rollback();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266982_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266982_Test.java
index 09e8746..d6f72f7 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266982_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266982_Test.java
@@ -17,8 +17,6 @@ import org.eclipse.emf.cdo.tests.model1.Customer;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOUtil;
-import junit.framework.Assert;
-
/**
* IllegalStateException in CDOStore.getRevision
* <p>
@@ -80,7 +78,7 @@ public class Bugzilla_266982_Test extends AbstractCDOTest
if (exception[0] != null)
{
exception[0].printStackTrace();
- Assert.fail(exception[0].getMessage());
+ fail(exception[0].getMessage());
}
session.close();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_267352_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_267352_Test.java
index 7e0456f..b882dad 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_267352_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_267352_Test.java
@@ -18,8 +18,6 @@ import org.eclipse.emf.cdo.tests.model1.Customer;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOUtil;
-import junit.framework.Assert;
-
/**
* NullPointerException on reload
* <p>
@@ -81,7 +79,7 @@ public class Bugzilla_267352_Test extends AbstractCDOTest
if (exception[0] != null)
{
exception[0].printStackTrace();
- Assert.fail(exception[0].getMessage());
+ fail(exception[0].getMessage());
}
session.close();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_321986_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_321986_Test.java
index c11aab8..fc88631 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_321986_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_321986_Test.java
@@ -21,8 +21,6 @@ import org.eclipse.emf.cdo.util.CommitException;
import org.eclipse.emf.ecore.util.EcoreUtil;
-import junit.framework.Assert;
-
/**
* @author Eike Stepper
*/
@@ -51,7 +49,7 @@ public class Bugzilla_321986_Test extends AbstractCDOTest
{
// We must fail here, because object was locked
tx2.commit();
- Assert.fail("Commit should have failed");
+ fail("Commit should have failed");
}
catch (CommitException e)
{
@@ -69,7 +67,7 @@ public class Bugzilla_321986_Test extends AbstractCDOTest
catch (Exception ex)
{
ex.printStackTrace();
- Assert.fail("Exception on rollbak:" + ex.getMessage());
+ fail("Exception on rollbak:" + ex.getMessage());
}
session2.close();
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_330052_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_330052_Test.java
index 38afc7e..2e35da7 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_330052_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_330052_Test.java
@@ -22,8 +22,6 @@ import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.util.CommitException;
import org.eclipse.emf.cdo.view.CDOView;
-import org.junit.Assert;
-
/**
* Bug 330052 - Breakage related to sticky views
*
@@ -47,7 +45,7 @@ public class Bugzilla_330052_Test extends AbstractCDOTest
tx.commit();
CDOObject object = view.getObject(CDOUtil.getCDOObject(address).cdoID());
- Assert.assertNotNull(object);
+ assertNotNull(object);
session.close();
}
@@ -75,7 +73,7 @@ public class Bugzilla_330052_Test extends AbstractCDOTest
CDOView view = session.openView(commitTime);
Address historicalAddress = (Address)CDOUtil.getEObject(view.getObject(CDOUtil.getCDOObject(address).cdoID()));
- Assert.assertEquals(testName1, historicalAddress.getName());
+ assertEquals(testName1, historicalAddress.getName());
session.close();
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333950_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333950_Test.java
index 5a0ff2a..5e18cab 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333950_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_333950_Test.java
@@ -25,8 +25,6 @@ import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.emf.ecore.util.EcoreUtil;
-import junit.framework.Assert;
-
/**
* @author Egidijus Vaishnora, Caspar De Groot
*/
@@ -70,15 +68,15 @@ public class Bugzilla_333950_Test extends AbstractCDOTest
instanceA.eSet(eStructuralFeatureA, instanceB);
- Assert.assertEquals(instanceA, instanceB.eGet(eStructuralFeatureB));
+ assertEquals(instanceA, instanceB.eGet(eStructuralFeatureB));
createResource.getContents().add(instanceA);
createResource.getContents().add(instanceB);
openTransaction.commit();
- Assert.assertTrue(eStructuralFeatureB.isTransient());
- Assert.assertEquals(instanceA, instanceB.eGet(eStructuralFeatureB));
+ assertEquals(true, eStructuralFeatureB.isTransient());
+ assertEquals(instanceA, instanceB.eGet(eStructuralFeatureB));
System.out.println("---> instanceA: " + CDOUtil.getCDOObject(instanceA).cdoID());
System.out.println("---> instanceB: " + CDOUtil.getCDOObject(instanceB).cdoID());
@@ -94,12 +92,12 @@ public class Bugzilla_333950_Test extends AbstractCDOTest
EObject eObjectB = resource.getContents().get(1);
EStructuralFeature eStructuralFeatureA = eObjectA.eClass().getEStructuralFeature("AB");
- Assert.assertFalse(eStructuralFeatureA.isTransient());
- Assert.assertEquals(eObjectB, eObjectA.eGet(eStructuralFeatureA));
+ assertEquals(false, eStructuralFeatureA.isTransient());
+ assertEquals(eObjectB, eObjectA.eGet(eStructuralFeatureA));
EStructuralFeature eStructuralFeatureB = eObjectB.eClass().getEStructuralFeature("_AB");
- Assert.assertTrue(eStructuralFeatureB.isTransient());
- Assert.assertEquals(eObjectA, eObjectB.eGet(eStructuralFeatureB));
+ assertEquals(true, eStructuralFeatureB.isTransient());
+ assertEquals(eObjectA, eObjectB.eGet(eStructuralFeatureB));
}
private void createOpposites(EClass A, EClass B)
@@ -117,6 +115,6 @@ public class Bugzilla_333950_Test extends AbstractCDOTest
tmpRefA_B.setEOpposite(tmpRefB_A);
tmpRefB_A.setEOpposite(tmpRefA_B);
- Assert.assertSame(tmpRefA_B, tmpRefB_A.getEOpposite());
+ assertSame(tmpRefA_B, tmpRefB_A.getEOpposite());
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334608_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334608_Test.java
index 90b160d..8a6162b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334608_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_334608_Test.java
@@ -28,8 +28,6 @@ import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction.InternalCDOCommitContext;
-import junit.framework.Assert;
-
/**
* Bug 334608 - CommitIntegrityCheck erroneously checks non-persistent features
*
@@ -77,9 +75,9 @@ public class Bugzilla_334608_Test extends AbstractCDOTest
resource.getContents().add(instanceA);
resource.getContents().add(instanceB);
- Assert.assertTrue(eStructuralFeatureB.isTransient());
- Assert.assertTrue(eStructuralFeatureA.isTransient());
- Assert.assertEquals(instanceA, instanceB.eGet(eStructuralFeatureB));
+ assertEquals(true, eStructuralFeatureB.isTransient());
+ assertEquals(true, eStructuralFeatureA.isTransient());
+ assertEquals(instanceA, instanceB.eGet(eStructuralFeatureB));
transaction.commit();
resource.getContents().remove(instanceA);
@@ -111,6 +109,6 @@ public class Bugzilla_334608_Test extends AbstractCDOTest
tmpRefA_B.setEOpposite(tmpRefB_A);
tmpRefB_A.setEOpposite(tmpRefA_B);
- Assert.assertSame(tmpRefA_B, tmpRefB_A.getEOpposite());
+ assertSame(tmpRefA_B, tmpRefB_A.getEOpposite());
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_340961_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_340961_Test.java
index 1d3faea..f36ec5e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_340961_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_340961_Test.java
@@ -43,8 +43,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import junit.framework.Assert;
-
/**
* @author Egidijus Vaisnora
*/
@@ -115,8 +113,8 @@ public class Bugzilla_340961_Test extends AbstractCDOTest
closedCategory.getCategories().add(getModel1Factory().createCategory());
rootObject.getCategories().add(getModel1Factory().createCategory());
transaction.commit();
- Assert.assertEquals("ProtectedName", closedCategory.getName());
- Assert.assertEquals(1, closedCategory.getCategories().size());
+ assertEquals("ProtectedName", closedCategory.getName());
+ assertEquals(1, closedCategory.getCategories().size());
closedCdoID = CDOUtil.getCDOObject(closedCategory).cdoID();
rootObjectID = CDOUtil.getCDOObject(rootObject).cdoID();
handler.setProtectedIDs(Arrays.asList(new CDOID[] { closedCdoID }));
@@ -127,17 +125,17 @@ public class Bugzilla_340961_Test extends AbstractCDOTest
CDOSession session = openSession();
CDOTransaction transaction = session.openTransaction();
CDOResource openResource = transaction.getResource(getResourcePath("openResource"));
- Assert.assertEquals(1, openResource.getContents().size());
+ assertEquals(1, openResource.getContents().size());
// checking if protected object is empty - not readable for user
CDOObject object = transaction.getObject(closedCdoID);
CDOUtil.load(object, object.cdoView());
Category eObject = (Category)CDOUtil.getEObject(object);
- Assert.assertEquals(null, eObject.getName());
- Assert.assertEquals(0, eObject.getCategories().size());
+ assertEquals(null, eObject.getName());
+ assertEquals(0, eObject.getCategories().size());
Category rootCategory = (Category)CDOUtil.getEObject(transaction.getObject(rootObjectID));
- Assert.assertEquals(3, rootCategory.getCategories().size());
+ assertEquals(3, rootCategory.getCategories().size());
// simple editing not protected elements. It must not fail
EcoreUtil.delete(rootCategory.getCategories().get(0), false);
@@ -153,7 +151,7 @@ public class Bugzilla_340961_Test extends AbstractCDOTest
CDOSession session = openSession();
CDOTransaction transaction = session.openTransaction();
Category rootCategory = (Category)CDOUtil.getEObject(transaction.getObject(rootObjectID));
- Assert.assertEquals(2, rootCategory.getCategories().size());
+ assertEquals(2, rootCategory.getCategories().size());
session.close();
}
@@ -179,8 +177,8 @@ public class Bugzilla_340961_Test extends AbstractCDOTest
closedCategory.getCategories().add(getModel1Factory().createCategory());
transaction.commit();
- Assert.assertEquals("ProtectedName", closedCategory.getName());
- Assert.assertEquals(1, closedCategory.getCategories().size());
+ assertEquals("ProtectedName", closedCategory.getName());
+ assertEquals(1, closedCategory.getCategories().size());
closedCdoID = CDOUtil.getCDOObject(closedCategory).cdoID();
handler.setProtectedIDs(Arrays.asList(new CDOID[] { closedCdoID }));
session.close();
@@ -191,14 +189,14 @@ public class Bugzilla_340961_Test extends AbstractCDOTest
CDOSession session = openSession();
CDOTransaction transaction = session.openTransaction();
CDOResource openResource = transaction.getResource(getResourcePath("test"));
- Assert.assertEquals(1, openResource.getContents().size());
+ assertEquals(1, openResource.getContents().size());
// checking if protected object is empty - not readable for user
CDOObject object = transaction.getObject(closedCdoID);
CDOUtil.load(object, object.cdoView());
Category eObject = (Category)CDOUtil.getEObject(object);
- Assert.assertEquals(null, eObject.getName());
- Assert.assertEquals(0, eObject.getCategories().size());
+ assertEquals(null, eObject.getName());
+ assertEquals(0, eObject.getCategories().size());
session.close();
}
@@ -208,14 +206,14 @@ public class Bugzilla_340961_Test extends AbstractCDOTest
CDOSession session = openSession();
CDOTransaction transaction = session.openTransaction();
CDOResource openResource = transaction.getResource(getResourcePath("test"));
- Assert.assertEquals(1, openResource.getContents().size());
+ assertEquals(1, openResource.getContents().size());
// checking if protected object is empty - not readable for user
CDOObject object = transaction.getObject(closedCdoID);
CDOUtil.load(object, object.cdoView());
Category eObject = (Category)CDOUtil.getEObject(object);
- Assert.assertEquals("ProtectedName", eObject.getName());
- Assert.assertEquals(1, eObject.getCategories().size());
+ assertEquals("ProtectedName", eObject.getName());
+ assertEquals(1, eObject.getCategories().size());
session.close();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_343332_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_343332_Test.java
index fa39871..76483d6 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_343332_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_343332_Test.java
@@ -24,8 +24,6 @@ import org.eclipse.emf.cdo.util.CommitException;
import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.junit.Assert;
-
import java.text.MessageFormat;
/**
@@ -85,8 +83,8 @@ public class Bugzilla_343332_Test extends AbstractCDOTest
attachedObject[0] = null;
((Category)resource.getContents().get(1)).getCategories().add(nestedCategory);
- Assert.assertNotNull("CDOTransactionHandler1.attachingObject was not called", attachedObject[0]);
- Assert.assertEquals(MessageFormat.format("Re-attached object was not the expected object {0}", cdoCategory),
+ assertNotNull("CDOTransactionHandler1.attachingObject was not called", attachedObject[0]);
+ assertEquals(MessageFormat.format("Re-attached object was not the expected object {0}", cdoCategory),
cdoCategory, attachedObject[0]);
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOCommitContext.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOCommitContext.java
index 80de253..476f376 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOCommitContext.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/transaction/CDOCommitContext.java
@@ -12,8 +12,11 @@
package org.eclipse.emf.cdo.transaction;
import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.commit.CDOCommitData;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.lob.CDOLob;
+import org.eclipse.emf.cdo.common.lock.CDOLockState;
import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
@@ -32,16 +35,56 @@ import java.util.Map;
public interface CDOCommitContext
{
/**
+ * @since 4.1
+ */
+ public String getUserID();
+
+ /**
+ * @since 4.1
+ */
+ public int getViewID();
+
+ /**
+ * @since 4.1
+ */
+ public CDOBranch getBranch();
+
+ /**
* Returns the {@link CDOTransaction transaction} associated with this commit context.
*/
public CDOTransaction getTransaction();
/**
+ * @since 4.1
+ */
+ public boolean isAutoReleaseLocks();
+
+ /**
+ * @since 4.0
+ */
+ public boolean isPartialCommit();
+
+ /**
+ * @since 4.1
+ */
+ public CDOCommitData getCommitData();
+
+ /**
+ * @since 4.1
+ */
+ public String getCommitComment();
+
+ /**
* Returns a list of the new {@link CDOPackageUnit package units} that are to be committed with this commit context.
*/
public List<CDOPackageUnit> getNewPackageUnits();
/**
+ * @since 4.1
+ */
+ public Collection<CDOLockState> getLocksOnNewObjects();
+
+ /**
* Returns a map of the new {@link CDOObject objects} that are to be committed with this commit context.
*/
public Map<CDOID, CDOObject> getNewObjects();
@@ -65,9 +108,4 @@ public interface CDOCommitContext
* @since 4.0
*/
public Collection<CDOLob<?>> getLobs();
-
- /**
- * @since 4.0
- */
- public boolean isPartialCommit();
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
index fe4b21d..eb8ffd7 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
@@ -186,7 +186,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
*/
public CDOLock cdoReadLock()
{
- return createCDOLock(LockType.READ);
+ return createLock(this, LockType.READ);
}
/**
@@ -194,7 +194,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
*/
public CDOLock cdoWriteLock()
{
- return createCDOLock(LockType.WRITE);
+ return createLock(this, LockType.WRITE);
}
/**
@@ -202,22 +202,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
*/
public CDOLock cdoWriteOption()
{
- return createCDOLock(LockType.OPTION);
- }
-
- private CDOLock createCDOLock(LockType type)
- {
- if (FSMUtil.isTransient(this))
- {
- throw new IllegalStateException("Call CDOView.lockObjects() for transient object " + this);
- }
-
- if (FSMUtil.isNew(this))
- {
- return CDOLockImpl.NOOP;
- }
-
- return new CDOLockImpl(this, type);
+ return createLock(this, LockType.OPTION);
}
/**
@@ -225,12 +210,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
*/
public CDOLockState cdoLockState()
{
- if (!FSMUtil.isTransient(this) && !FSMUtil.isNew(this))
- {
- return view.getLockStates(Collections.singletonList(id))[0];
- }
-
- return null;
+ return getLockState(this);
}
public void cdoInternalSetID(CDOID id)
@@ -1187,6 +1167,35 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
}
/**
+ * @since 4.1
+ */
+ public static CDOLock createLock(InternalCDOObject object, LockType type)
+ {
+ if (FSMUtil.isTransient(object))
+ {
+ throw new IllegalStateException("Call CDOView.lockObjects() for transient object " + object);
+ }
+
+ return new CDOLockImpl(object, type);
+ }
+
+ /**
+ * @since 4.1
+ */
+ public static CDOLockState getLockState(InternalCDOObject object)
+ {
+ if (!FSMUtil.isTransient(object))
+ {
+ InternalCDOView view = object.cdoView();
+ CDOID id = object.cdoID();
+
+ return view.getLockStates(Collections.singletonList(id))[0];
+ }
+
+ return null;
+ }
+
+ /**
* For internal use only.
*
* @author Simon McDuff
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java
index 2aae1a4..1d16571 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOLegacyWrapper.java
@@ -14,7 +14,6 @@ package org.eclipse.emf.internal.cdo.object;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.lock.CDOLockState;
import org.eclipse.emf.cdo.common.model.CDOModelUtil;
import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
import org.eclipse.emf.cdo.common.model.CDOType;
@@ -58,7 +57,6 @@ import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -123,16 +121,6 @@ public abstract class CDOLegacyWrapper extends CDOObjectWrapper
return revision;
}
- public synchronized CDOLockState cdoLockState()
- {
- if (!FSMUtil.isTransient(this) && !FSMUtil.isNew(this))
- {
- return view.getLockStates(Collections.singletonList(id))[0];
- }
-
- return null;
- }
-
@Override
public CDOResourceImpl cdoResource()
{
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapper.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapper.java
index 4e37274..588e2c0 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapper.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/object/CDOObjectWrapper.java
@@ -12,9 +12,11 @@ package org.eclipse.emf.internal.cdo.object;
import org.eclipse.emf.cdo.CDOLock;
import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.lock.CDOLockState;
import org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl;
import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.internal.cdo.CDOObjectImpl;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
@@ -177,17 +179,7 @@ public abstract class CDOObjectWrapper implements InternalCDOObject
*/
public CDOLock cdoReadLock()
{
- if (FSMUtil.isTransient(this))
- {
- throw new IllegalStateException("Call CDOView.lockObjects() for transient object " + this);
- }
-
- if (FSMUtil.isNew(this))
- {
- return CDOLockImpl.NOOP;
- }
-
- return new CDOLockImpl(this, LockType.READ);
+ return CDOObjectImpl.createLock(this, LockType.READ);
}
/**
@@ -195,17 +187,7 @@ public abstract class CDOObjectWrapper implements InternalCDOObject
*/
public CDOLock cdoWriteLock()
{
- if (FSMUtil.isTransient(this))
- {
- throw new IllegalStateException("Call CDOView.lockObjects() for transient object " + this);
- }
-
- if (FSMUtil.isNew(this))
- {
- return CDOLockImpl.NOOP;
- }
-
- return new CDOLockImpl(this, LockType.WRITE);
+ return CDOObjectImpl.createLock(this, LockType.WRITE);
}
/**
@@ -213,17 +195,12 @@ public abstract class CDOObjectWrapper implements InternalCDOObject
*/
public CDOLock cdoWriteOption()
{
- if (FSMUtil.isTransient(this))
- {
- throw new IllegalStateException("Call CDOView.lockObjects() for transient object " + this);
- }
-
- if (FSMUtil.isNew(this))
- {
- return CDOLockImpl.NOOP;
- }
+ return CDOObjectImpl.createLock(this, LockType.OPTION);
+ }
- return new CDOLockImpl(this, LockType.OPTION);
+ public synchronized CDOLockState cdoLockState()
+ {
+ return CDOObjectImpl.getLockState(this);
}
public EList<Adapter> eAdapters()
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/DelegatingSessionProtocol.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/DelegatingSessionProtocol.java
index 0550881..d4f0f08 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/DelegatingSessionProtocol.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/DelegatingSessionProtocol.java
@@ -60,6 +60,7 @@ import org.eclipse.emf.spi.cdo.AbstractQueryIterator;
import org.eclipse.emf.spi.cdo.CDOSessionProtocol;
import org.eclipse.emf.spi.cdo.InternalCDOObject;
import org.eclipse.emf.spi.cdo.InternalCDORemoteSessionManager;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction.InternalCDOCommitContext;
import org.eclipse.emf.spi.cdo.InternalCDOXATransaction.InternalCDOXACommitContext;
import java.util.Collection;
@@ -274,15 +275,21 @@ public class DelegatingSessionProtocol extends Lifecycle implements CDOSessionPr
}
}
+ @Deprecated
public CommitTransactionResult commitTransaction(int transactionID, String comment, boolean releaseLocks,
CDOIDProvider idProvider, CDOCommitData commitData, Collection<CDOLob<?>> lobs, OMMonitor monitor)
{
+ throw new UnsupportedOperationException();
+ }
+
+ public CommitTransactionResult commitTransaction(InternalCDOCommitContext context, OMMonitor monitor)
+ {
int attempt = 0;
for (;;)
{
try
{
- return delegate.commitTransaction(transactionID, comment, releaseLocks, idProvider, commitData, lobs, monitor);
+ return delegate.commitTransaction(context, monitor);
}
catch (Exception ex)
{
@@ -291,15 +298,21 @@ public class DelegatingSessionProtocol extends Lifecycle implements CDOSessionPr
}
}
+ @Deprecated
public CommitTransactionResult commitDelegation(CDOBranch branch, String userID, String comment,
CDOCommitData commitData, Map<CDOID, EClass> detachedObjectTypes, Collection<CDOLob<?>> lobs, OMMonitor monitor)
{
+ throw new UnsupportedOperationException();
+ }
+
+ public CommitTransactionResult commitDelegation(InternalCDOCommitContext context, OMMonitor monitor)
+ {
int attempt = 0;
for (;;)
{
try
{
- return delegate.commitDelegation(branch, userID, comment, commitData, detachedObjectTypes, lobs, monitor);
+ return delegate.commitDelegation(context, monitor);
}
catch (Exception ex)
{
@@ -620,18 +633,7 @@ public class DelegatingSessionProtocol extends Lifecycle implements CDOSessionPr
public LockObjectsResult lockObjects(List<InternalCDORevision> viewedRevisions, int viewID, CDOBranch viewedBranch,
LockType lockType, long timeout) throws InterruptedException
{
- int attempt = 0;
- for (;;)
- {
- try
- {
- return delegate.lockObjects(viewedRevisions, viewID, viewedBranch, lockType, timeout);
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
+ throw new UnsupportedOperationException();
}
/**
@@ -778,19 +780,7 @@ public class DelegatingSessionProtocol extends Lifecycle implements CDOSessionPr
@Deprecated
public void unlockObjects(CDOView view, Collection<CDOID> objectIDs, LockType lockType)
{
- int attempt = 0;
- for (;;)
- {
- try
- {
- delegate.unlockObjects(view, objectIDs, lockType);
- return;
- }
- catch (Exception ex)
- {
- handleException(++attempt, ex);
- }
- }
+ throw new UnsupportedOperationException();
}
public UnlockObjectsResult unlockObjects2(CDOView view, Collection<CDOID> objectIDs, LockType lockType,
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSingleTransactionStrategyImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSingleTransactionStrategyImpl.java
index f0eb319..2db5700 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSingleTransactionStrategyImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOSingleTransactionStrategyImpl.java
@@ -14,7 +14,6 @@ import org.eclipse.emf.cdo.CDOObjectReference;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.commit.CDOCommitData;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.lob.CDOLob;
import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
import org.eclipse.emf.cdo.util.CommitException;
import org.eclipse.emf.cdo.util.ReferentialIntegrityException;
@@ -36,7 +35,6 @@ import org.eclipse.emf.spi.cdo.InternalCDOUserSavepoint;
import org.eclipse.core.runtime.IProgressMonitor;
-import java.util.Collection;
import java.util.List;
/**
@@ -66,18 +64,15 @@ public class CDOSingleTransactionStrategyImpl implements CDOTransactionStrategy
commitContext.preCommit();
CDOCommitData commitData = commitContext.getCommitData();
- Collection<CDOLob<?>> lobs = commitContext.getLobs();
InternalCDOSession session = transaction.getSession();
CommitTransactionResult result = null;
if (transaction.isDirty())
{
- int viewID = transaction.getViewID();
- boolean releaseLocks = transaction.options().isAutoReleaseLocksEnabled();
OMMonitor monitor = new EclipseMonitor(progressMonitor);
CDOSessionProtocol sessionProtocol = session.getSessionProtocol();
- result = sessionProtocol.commitTransaction(viewID, comment, releaseLocks, transaction, commitData, lobs, monitor);
+ result = sessionProtocol.commitTransaction(commitContext, monitor);
String rollbackMessage = result.getRollbackMessage();
if (rollbackMessage != null)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
index 582c64d..7b0be52 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOTransactionImpl.java
@@ -35,7 +35,9 @@ import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.lob.CDOLob;
import org.eclipse.emf.cdo.common.lob.CDOLobStore;
import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo.Operation;
+import org.eclipse.emf.cdo.common.lock.CDOLockOwner;
import org.eclipse.emf.cdo.common.lock.CDOLockState;
+import org.eclipse.emf.cdo.common.lock.CDOLockUtil;
import org.eclipse.emf.cdo.common.model.CDOModelUtil;
import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
@@ -67,6 +69,7 @@ import org.eclipse.emf.cdo.internal.common.revision.CDOListWithElementProxiesImp
import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
import org.eclipse.emf.cdo.spi.common.commit.CDORevisionAvailabilityInfo;
import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
+import org.eclipse.emf.cdo.spi.common.lock.InternalCDOLockState;
import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
import org.eclipse.emf.cdo.spi.common.revision.CDOIDMapper;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
@@ -92,6 +95,7 @@ import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.util.CommitException;
import org.eclipse.emf.cdo.util.LegacyModeNotEnabledException;
import org.eclipse.emf.cdo.util.ObjectNotFoundException;
+import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.messages.Messages;
@@ -105,11 +109,13 @@ import org.eclipse.emf.internal.cdo.util.IPackageClosure;
import org.eclipse.emf.internal.cdo.view.CDOStateMachine;
import org.eclipse.emf.internal.cdo.view.CDOViewImpl;
+import org.eclipse.net4j.util.CheckUtil;
import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.collection.ByteArrayWrapper;
import org.eclipse.net4j.util.collection.ConcurrentArray;
import org.eclipse.net4j.util.collection.Pair;
+import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.event.IListener;
import org.eclipse.net4j.util.io.ExtendedDataInputStream;
@@ -148,6 +154,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -2320,6 +2327,96 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
return super.getRevision(object);
}
+ @Override
+ protected InternalCDOLockState createUpdatedLockStateForNewObject(CDOObject object, LockType lockType, boolean on)
+ {
+ CheckUtil.checkState(FSMUtil.isNew(object), "Object is not in NEW state");
+ CheckUtil.checkArg(lockType, "lockType");
+
+ InternalCDOLockState lockState = (InternalCDOLockState)getLockState(object);
+ if (lockState == null)
+ {
+ CheckUtil.checkArg(on == true, "on != true");
+ Object lockTarget = getLockTarget(object);
+ lockState = (InternalCDOLockState)CDOLockUtil.createLockState(lockTarget);
+ }
+ else
+ {
+ lockState = (InternalCDOLockState)CDOLockUtil.copyLockState(lockState);
+ }
+
+ CDOLockOwner lockOwner = CDOLockUtil.createLockOwner(this);
+
+ if (on)
+ {
+ switch (lockType)
+ {
+ case READ:
+ lockState.addReadLockOwner(lockOwner);
+ break;
+ case WRITE:
+ lockState.setWriteLockOwner(lockOwner);
+ break;
+ case OPTION:
+ lockState.setWriteOptionOwner(lockOwner);
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown lock type " + lockType);
+ }
+ }
+ else
+ {
+ switch (lockType)
+ {
+ case READ:
+ lockState.removeReadLockOwner(lockOwner);
+ break;
+ case WRITE:
+ lockState.setWriteLockOwner(null);
+ break;
+ case OPTION:
+ lockState.setWriteOptionOwner(null);
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown lock type " + lockType);
+ }
+ }
+
+ return lockState;
+ }
+
+ @Override
+ protected List<CDOLockState> createUnlockedLockStatesForAllNewObjects()
+ {
+ List<CDOLockState> locksOnNewObjects = new LinkedList<CDOLockState>();
+ for (CDOObject object : getNewObjects().values())
+ {
+ Object lockTarget = getLockTarget(object);
+ CDOLockState lockState = CDOLockUtil.createLockState(lockTarget);
+ locksOnNewObjects.add(lockState);
+ }
+
+ return locksOnNewObjects;
+ }
+
+ private static Object getLockTarget(CDOObject object)
+ {
+ CDOView view = object.cdoView();
+ if (view == null)
+ {
+ return null;
+ }
+
+ CDOID id = object.cdoID();
+ boolean branching = view.getSession().getRepositoryInfo().isSupportingBranches();
+ if (branching)
+ {
+ return CDOIDUtil.createIDAndBranch(id, view.getBranch());
+ }
+
+ return id;
+ }
+
private final class ResolvingRevisionMap extends HashMap<InternalCDOObject, InternalCDORevision>
{
private static final long serialVersionUID = 1L;
@@ -2372,8 +2469,17 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
{
private InternalCDOTransaction transaction;
+ /**
+ * Tracks whether this commit is *actually* partial or not. (Having tx.committables != null does not in itself mean
+ * that the commit will be partial, because the committables could cover all dirty/new/detached objects. But this
+ * boolean gets set to reflect whether the commit will really commit less than all dirty/new/detached objects.)
+ */
+ private boolean isPartialCommit;
+
private CDOCommitData commitData;
+ private Collection<CDOLockState> locksOnNewObjects;
+
private Map<CDOID, CDOObject> newObjects;
private Map<CDOID, CDOObject> detachedObjects;
@@ -2382,13 +2488,6 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
private Map<CDOID, CDOObject> dirtyObjects;
- /**
- * Tracks whether this commit is *actually* partial or not. (Having tx.committables != null does not in itself mean
- * that the commit will be partial, because the committables could cover all dirty/new/detached objects. But this
- * boolean gets set to reflect whether the commit will really commit less than all dirty/new/detached objects.)
- */
- private boolean isPartialCommit;
-
private Map<ByteArrayWrapper, CDOLob<?>> lobs = new HashMap<ByteArrayWrapper, CDOLob<?>>();
public CDOCommitContextImpl(InternalCDOTransaction transaction)
@@ -2425,6 +2524,9 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
dirtyObjects = filterCommittables(transaction.getDirtyObjects());
+ CDOLockState[] locksOnNewObjectsArray = getLockStates(newObjects.keySet(), false);
+ locksOnNewObjects = Arrays.asList(locksOnNewObjectsArray);
+
commitData = new CDOCommitDataImpl(newPackageUnits, revisions, deltas, detached);
}
@@ -2454,11 +2556,41 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
return newMap;
}
+ public String getUserID()
+ {
+ return transaction.getSession().getUserID();
+ }
+
+ public int getViewID()
+ {
+ return transaction.getViewID();
+ }
+
+ public CDOBranch getBranch()
+ {
+ return transaction.getBranch();
+ }
+
public InternalCDOTransaction getTransaction()
{
return transaction;
}
+ public boolean isPartialCommit()
+ {
+ return isPartialCommit;
+ }
+
+ public boolean isAutoReleaseLocks()
+ {
+ return transaction.options().isAutoReleaseLocksEnabled();
+ }
+
+ public String getCommitComment()
+ {
+ return transaction.getCommitComment();
+ }
+
public CDOCommitData getCommitData()
{
return commitData;
@@ -2479,6 +2611,11 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
return commitData.getNewPackageUnits();
}
+ public Collection<CDOLockState> getLocksOnNewObjects()
+ {
+ return locksOnNewObjects;
+ }
+
public Map<CDOID, CDOObject> getDetachedObjects()
{
return detachedObjects;
@@ -2748,11 +2885,6 @@ public class CDOTransactionImpl extends CDOViewImpl implements InternalCDOTransa
}
}
}
-
- public boolean isPartialCommit()
- {
- return isPartialCommit;
- }
}
/**
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXACommitContextImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXACommitContextImpl.java
index 679c894..e99e395 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXACommitContextImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/transaction/CDOXACommitContextImpl.java
@@ -11,9 +11,11 @@
package org.eclipse.emf.internal.cdo.transaction;
import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.commit.CDOCommitData;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.lob.CDOLob;
+import org.eclipse.emf.cdo.common.lock.CDOLockState;
import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.internal.common.id.CDOIDTempObjectExternalImpl;
@@ -97,11 +99,46 @@ public class CDOXACommitContextImpl implements InternalCDOXACommitContext
this.result = result;
}
+ public int getViewID()
+ {
+ return delegateCommitContext.getViewID();
+ }
+
+ public String getUserID()
+ {
+ return delegateCommitContext.getUserID();
+ }
+
+ public CDOBranch getBranch()
+ {
+ return delegateCommitContext.getBranch();
+ }
+
public InternalCDOTransaction getTransaction()
{
return delegateCommitContext.getTransaction();
}
+ public boolean isAutoReleaseLocks()
+ {
+ return delegateCommitContext.isAutoReleaseLocks();
+ }
+
+ public boolean isPartialCommit()
+ {
+ return delegateCommitContext.isPartialCommit();
+ }
+
+ public CDOCommitData getCommitData()
+ {
+ return delegateCommitContext.getCommitData();
+ }
+
+ public String getCommitComment()
+ {
+ return delegateCommitContext.getCommitComment();
+ }
+
public Map<CDOIDTempObjectExternalImpl, InternalCDOTransaction> getRequestedIDs()
{
return requestedIDs;
@@ -122,6 +159,11 @@ public class CDOXACommitContextImpl implements InternalCDOXACommitContext
return delegateCommitContext.getNewPackageUnits();
}
+ public Collection<CDOLockState> getLocksOnNewObjects()
+ {
+ return delegateCommitContext.getLocksOnNewObjects();
+ }
+
public Map<CDOID, CDOObject> getDetachedObjects()
{
return delegateCommitContext.getDetachedObjects();
@@ -132,21 +174,11 @@ public class CDOXACommitContextImpl implements InternalCDOXACommitContext
return delegateCommitContext.getRevisionDeltas();
}
- public CDOCommitData getCommitData()
- {
- return delegateCommitContext.getCommitData();
- }
-
public Collection<CDOLob<?>> getLobs()
{
return delegateCommitContext.getLobs();
}
- public boolean isPartialCommit()
- {
- return delegateCommitContext.isPartialCommit();
- }
-
public Object call() throws Exception
{
state.handle(this, progressMonitor);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
index 009afef..50de3ae 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java
@@ -31,6 +31,7 @@ import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
import org.eclipse.emf.cdo.common.util.CDOException;
+import org.eclipse.emf.cdo.spi.common.lock.InternalCDOLockState;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
import org.eclipse.emf.cdo.transaction.CDOCommitContext;
@@ -130,7 +131,7 @@ public class CDOViewImpl extends AbstractCDOView
private QueueRunner invalidationRunner;
- private Map<InternalCDOObject, CDOLockState> lockStates = new WeakHashMap<InternalCDOObject, CDOLockState>();
+ private Map<CDOObject, CDOLockState> lockStates = new WeakHashMap<CDOObject, CDOLockState>();
@ExcludeFromDump
private InvalidationRunnerLock invalidationRunnerLock = new InvalidationRunnerLock();
@@ -276,59 +277,66 @@ public class CDOViewImpl extends AbstractCDOView
checkActive();
checkState(getTimeStamp() == CDOBranchPoint.UNSPECIFIED_DATE, "Locking not supported for historial views");
- long endMillis = System.currentTimeMillis() + timeout;
-
List<CDORevisionKey> revisionKeys = new LinkedList<CDORevisionKey>();
+ List<CDOLockState> locksOnNewObjects = new LinkedList<CDOLockState>();
for (CDOObject object : objects)
{
- InternalCDORevision revision = getRevision(object);
- if (revision != null)
+ if (FSMUtil.isNew(object))
+ {
+ CDOLockState lockState = createUpdatedLockStateForNewObject(object, lockType, true);
+ locksOnNewObjects.add(lockState);
+ }
+ else
{
- revisionKeys.add(revision);
+ InternalCDORevision revision = getRevision(object);
+ if (revision != null)
+ {
+ revisionKeys.add(revision);
+ }
}
}
- // Even if objects is not empty, revisionKeys may be empty, due to all of the
- // objects being NEW or TRANSIENT. In such a case there is nothing to do
- if (revisionKeys.isEmpty())
+ LockObjectsResult result = null;
+ if (!revisionKeys.isEmpty())
{
- return;
- }
-
- CDOSessionProtocol sessionProtocol = session.getSessionProtocol();
- LockObjectsResult result = sessionProtocol.lockObjects2(revisionKeys, viewID, getBranch(), lockType, recursive,
- timeout);
+ CDOSessionProtocol sessionProtocol = session.getSessionProtocol();
+ result = sessionProtocol.lockObjects2(revisionKeys, viewID, getBranch(), lockType, recursive, timeout);
- if (!result.isSuccessful())
- {
- if (result.isTimedOut())
+ if (!result.isSuccessful())
{
- throw new LockTimeoutException();
+ if (result.isTimedOut())
+ {
+ throw new LockTimeoutException();
+ }
+
+ CDORevisionKey[] staleRevisions = result.getStaleRevisions();
+ if (staleRevisions != null)
+ {
+ throw new StaleRevisionLockException(staleRevisions);
+ }
+
+ throw new AssertionError("Unexpected lock result state");
}
- CDORevisionKey[] staleRevisions = result.getStaleRevisions();
- if (staleRevisions != null)
+ if (result.isWaitForUpdate())
{
- throw new StaleRevisionLockException(staleRevisions);
- }
+ if (!getSession().options().isPassiveUpdateEnabled())
+ {
+ throw new AssertionError(
+ "Lock result requires client to wait, but client does not have passiveUpdates enabled.");
+ }
- throw new AssertionError("Unexpected lock result state");
+ long requiredTimestamp = result.getRequiredTimestamp();
+ waitForUpdate(requiredTimestamp);
+ }
}
- // Update the lock states in this view
- updateAndNotifyLockStates(Operation.LOCK, lockType, result.getTimestamp(), result.getNewLockStates());
+ CDOLockState[] locksOnNewObjectsArray = locksOnNewObjects.toArray(new CDOLockState[locksOnNewObjects.size()]);
+ updateLockStates(locksOnNewObjectsArray);
- if (result.isWaitForUpdate())
+ if (result != null)
{
- if (!getSession().options().isPassiveUpdateEnabled())
- {
- throw new AssertionError(
- "Lock result requires client to wait, but client does not have passiveUpdates enabled.");
- }
-
- long requiredTimestamp = result.getRequiredTimestamp();
- long waitMillis = endMillis - System.currentTimeMillis();
- waitForUpdate(requiredTimestamp, waitMillis);
+ updateAndNotifyLockStates(Operation.LOCK, lockType, result.getTimestamp(), result.getNewLockStates());
}
}
@@ -345,21 +353,31 @@ public class CDOViewImpl extends AbstractCDOView
{
for (CDOLockState lockState : newLockStates)
{
- Object o = lockState.getLockedObject();
+ Object lockedObject = lockState.getLockedObject();
CDOID id;
- if (o instanceof CDOID)
+
+ if (lockedObject instanceof CDOID)
+ {
+ id = (CDOID)lockedObject;
+ }
+ else if (lockedObject instanceof CDOIDAndBranch)
{
- id = (CDOID)o;
+ id = ((CDOIDAndBranch)lockedObject).getID();
+ }
+ else if (lockedObject instanceof EObject)
+ {
+ CDOObject newObj = CDOUtil.getCDOObject((EObject)lockedObject);
+ id = newObj.cdoID();
}
else
{
- id = ((CDOIDAndBranch)o).getID();
+ throw new IllegalStateException("Unexpected: " + lockedObject.getClass().getSimpleName());
}
- InternalCDOObject obj = getObject(id, false);
- if (obj != null)
+ InternalCDOObject object = getObject(id, false);
+ if (object != null)
{
- lockStates.put(obj, lockState);
+ lockStates.put(object, lockState);
}
}
}
@@ -467,20 +485,58 @@ public class CDOViewImpl extends AbstractCDOView
{
checkActive();
+ // Note: This may get called with objects == null, and lockType == null, which is a request
+ // to remove all locks on all objects in this view.
+
List<CDOID> objectIDs = null;
+ List<CDOLockState> locksOnNewObjects = new LinkedList<CDOLockState>();
+
if (objects != null)
{
- objectIDs = new LinkedList<CDOID>();
- for (CDOObject obj : objects)
+ objectIDs = new ArrayList<CDOID>();
+
+ for (CDOObject object : objects)
{
- objectIDs.add(obj.cdoID());
+ if (FSMUtil.isNew(object))
+ {
+ CDOLockState lockState = createUpdatedLockStateForNewObject(object, lockType, false);
+ locksOnNewObjects.add(lockState);
+ }
+ else
+ {
+ objectIDs.add(object.cdoID());
+ }
}
}
+ else
+ {
+ locksOnNewObjects.addAll(createUnlockedLockStatesForAllNewObjects());
+ }
- CDOSessionProtocol sessionProtocol = session.getSessionProtocol();
- UnlockObjectsResult result = sessionProtocol.unlockObjects2(this, objectIDs, lockType, recursive);
+ UnlockObjectsResult result = null;
+ if (objectIDs == null || !objectIDs.isEmpty())
+ {
+ CDOSessionProtocol sessionProtocol = session.getSessionProtocol();
+ result = sessionProtocol.unlockObjects2(this, objectIDs, lockType, recursive);
+ }
+
+ CDOLockState[] locksOnNewObjectsArray = locksOnNewObjects.toArray(new CDOLockState[locksOnNewObjects.size()]);
+ updateLockStates(locksOnNewObjectsArray);
- updateAndNotifyLockStates(Operation.UNLOCK, lockType, result.getTimestamp(), result.getNewLockStates());
+ if (result != null)
+ {
+ updateAndNotifyLockStates(Operation.UNLOCK, lockType, result.getTimestamp(), result.getNewLockStates());
+ }
+ }
+
+ protected InternalCDOLockState createUpdatedLockStateForNewObject(CDOObject object, LockType lockType, boolean on)
+ {
+ throw new ReadOnlyException();
+ }
+
+ protected Collection<CDOLockState> createUnlockedLockStatesForAllNewObjects()
+ {
+ return Collections.emptyList();
}
/**
@@ -599,6 +655,11 @@ public class CDOViewImpl extends AbstractCDOView
public synchronized CDOLockState[] getLockStates(Collection<CDOID> ids)
{
+ return getLockStates(ids, true);
+ }
+
+ protected synchronized CDOLockState[] getLockStates(Collection<CDOID> ids, boolean loadOnDemand)
+ {
List<CDOID> missing = new LinkedList<CDOID>();
List<CDOLockState> lockStates = new LinkedList<CDOLockState>();
for (CDOID id : ids)
@@ -609,6 +670,7 @@ public class CDOViewImpl extends AbstractCDOView
{
lockState = this.lockStates.get(obj);
}
+
if (lockState != null)
{
lockStates.add(lockState);
@@ -619,7 +681,7 @@ public class CDOViewImpl extends AbstractCDOView
}
}
- if (missing.size() > 0)
+ if (loadOnDemand && missing.size() > 0)
{
CDOSessionProtocol sessionProtocol = session.getSessionProtocol();
CDOLockState[] loadedLockStates = sessionProtocol.getLockStates(viewID, missing);
@@ -632,6 +694,11 @@ public class CDOViewImpl extends AbstractCDOView
return lockStates.toArray(new CDOLockState[lockStates.size()]);
}
+ protected CDOLockState getLockState(CDOObject object)
+ {
+ return lockStates.get(object);
+ }
+
private CDOBranchPoint getBranchPointForID(CDOID id)
{
// If this view's timestamp is something other than UNSPECIFIED_DATE,
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java
index cd92848..429ad18 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/CDOSessionProtocol.java
@@ -54,6 +54,7 @@ import org.eclipse.net4j.util.om.monitor.OMMonitor;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction.InternalCDOCommitContext;
import org.eclipse.emf.spi.cdo.InternalCDOXATransaction.InternalCDOXACommitContext;
import java.io.IOException;
@@ -199,17 +200,31 @@ public interface CDOSessionProtocol extends CDOProtocol, PackageLoader, BranchLo
/**
* @since 4.0
+ * @deprecated Not called anymore. Use {@link #commitTransaction(InternalCDOCommitContext, OMMonitor)} instead.
*/
+ @Deprecated
public CommitTransactionResult commitTransaction(int transactionID, String comment, boolean releaseLocks,
CDOIDProvider idProvider, CDOCommitData commitData, Collection<CDOLob<?>> lobs, OMMonitor monitor);
/**
+ * @since 4.1
+ */
+ public CommitTransactionResult commitTransaction(InternalCDOCommitContext context, OMMonitor monitor);
+
+ /**
* @since 4.0
+ * @deprecated Not called anymore. Use {@link #commitDelegation(InternalCDOCommitContext, OMMonitor)} instead.
*/
+ @Deprecated
public CommitTransactionResult commitDelegation(CDOBranch branch, String userID, String comment,
CDOCommitData commitData, Map<CDOID, EClass> detachedObjectTypes, Collection<CDOLob<?>> lobs, OMMonitor monitor);
/**
+ * @since 4.1
+ */
+ public CommitTransactionResult commitDelegation(InternalCDOCommitContext context, OMMonitor monitor);
+
+ /**
* @since 3.0
*/
public CommitTransactionResult commitXATransactionPhase1(InternalCDOXACommitContext xaContext, OMMonitor monitor);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java
index 2781aaf..63ee36b 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOTransaction.java
@@ -14,7 +14,6 @@ package org.eclipse.emf.spi.cdo;
import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.common.commit.CDOCommitData;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDTemp;
import org.eclipse.emf.cdo.common.revision.CDORevisionProvider;
@@ -135,16 +134,13 @@ public interface InternalCDOTransaction extends CDOTransaction, InternalCDOUserT
* Provides a context for a commit operation.
*
* @author Simon McDuff
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @noextend This interface is not intended to be extended by clients.
*/
public interface InternalCDOCommitContext extends CDOCommitContext
{
public InternalCDOTransaction getTransaction();
- /**
- * @since 3.0
- */
- public CDOCommitData getCommitData();
-
public void preCommit();
public void postCommit(CommitTransactionResult result);
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java
index b410756..c537839 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/AbstractOMTest.java
@@ -390,28 +390,40 @@ public abstract class AbstractOMTest extends TestCase
return file;
}
+ /**
+ * @deprecated Use assertEquals(message, true, ...)
+ */
@Deprecated
public static void assertTrue(String message, boolean condition)
{
- throw new UnsupportedOperationException("Use assertEquals()");
+ throw new UnsupportedOperationException("Use assertEquals(message, true, ...)");
}
+ /**
+ * @deprecated Use assertEquals(true, ...)
+ */
@Deprecated
public static void assertTrue(boolean condition)
{
- throw new UnsupportedOperationException("Use assertEquals()");
+ throw new UnsupportedOperationException("Use assertEquals(true, ...)");
}
+ /**
+ * @deprecated Use assertEquals(message, false, ...)
+ */
@Deprecated
public static void assertFalse(String message, boolean condition)
{
- throw new UnsupportedOperationException("Use assertEquals()");
+ throw new UnsupportedOperationException("Use assertEquals(message, false, ...)");
}
+ /**
+ * @deprecated Use assertEquals(false, ...)
+ */
@Deprecated
public static void assertFalse(boolean condition)
{
- throw new UnsupportedOperationException("Use assertEquals()");
+ throw new UnsupportedOperationException("Use assertEquals(false, ...)");
}
public static void assertEquals(Object[] expected, Object[] actual)