Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java')
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java53
1 files changed, 33 insertions, 20 deletions
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 e2e2aa0924..ffe5f921ce 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
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.CDOLock;
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.EMFUtil;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.eresource.CDOResource;
@@ -63,6 +64,7 @@ import org.eclipse.emf.spi.cdo.InternalCDOObject;
import org.eclipse.emf.spi.cdo.InternalCDOView;
import java.util.Collection;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
@@ -84,6 +86,8 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
private InternalCDORevision revision;
+ private CDOLockState lockState;
+
/**
* CDO uses this list instead of eSettings for transient objects. EMF uses eSettings as cache. CDO deactivates the
* cache but EMF still used eSettings to store list wrappers. CDO needs another place to store the real list with the
@@ -184,17 +188,7 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
*/
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 createCDOLock(LockType.READ);
}
/**
@@ -202,6 +196,19 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
*/
public CDOLock cdoWriteLock()
{
+ return createCDOLock(LockType.WRITE);
+ }
+
+ /**
+ * @since 4.1
+ */
+ 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);
@@ -212,25 +219,31 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
return CDOLockImpl.NOOP;
}
- return new CDOLockImpl(this, LockType.WRITE);
+ return new CDOLockImpl(this, type);
}
/**
* @since 4.1
*/
- public CDOLock cdoWriteOption()
+ public synchronized CDOLockState cdoLockState()
{
- if (FSMUtil.isTransient(this))
+ if (lockState == null)
{
- throw new IllegalStateException("Call CDOView.lockObjects() for transient object " + this);
+ if (!FSMUtil.isTransient(this) && !FSMUtil.isNew(this))
+ {
+ lockState = view.getLockStates(Collections.singletonList(id))[0];
+ }
}
- if (FSMUtil.isNew(this))
- {
- return CDOLockImpl.NOOP;
- }
+ return lockState;
+ }
- return new CDOLockImpl(this, LockType.OPTION);
+ /**
+ * @since 4.1
+ */
+ public synchronized void cdoInternalSetLockState(CDOLockState lockState)
+ {
+ this.lockState = lockState;
}
public void cdoInternalSetID(CDOID id)

Back to the top