summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-03 12:57:32 (EDT)
committerEike Stepper2007-08-03 12:57:32 (EDT)
commit23435c3bed8555fb94f45b13a97d867eb736550c (patch)
tree6f46b8c6ffe955765510e8e9b368fc67c1f17ed6
parent9e5549bd614b531c1a5e6f9664361c7b287030c5 (diff)
downloadcdo-23435c3bed8555fb94f45b13a97d867eb736550c.zip
cdo-23435c3bed8555fb94f45b13a97d867eb736550c.tar.gz
cdo-23435c3bed8555fb94f45b13a97d867eb736550c.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAuditImpl.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java5
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyImpl.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java5
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java67
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ProxyResolverResource.java2
8 files changed, 73 insertions, 18 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
index 5d6467b..2ca373f 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
@@ -45,9 +45,9 @@ public interface CDOView extends INotifier
*/
public CDOResource getResource(String path);
- public CDOObject lookupObject(CDOID id);
+ public CDOObject getObject(CDOID id);
- public CDORevision lookupRevision(CDOID id);
+ public CDORevision getRevision(CDOID id);
public void close();
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAuditImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAuditImpl.java
index 372325a..181abd8 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAuditImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAuditImpl.java
@@ -42,7 +42,7 @@ public class CDOAuditImpl extends CDOViewImpl implements CDOAudit
}
@Override
- public CDORevisionImpl lookupRevision(CDOID id)
+ public CDORevisionImpl getRevision(CDOID id)
{
CDORevisionResolver revisionManager = getSession().getRevisionManager();
return (CDORevisionImpl)revisionManager.getRevision(id, timeStamp);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java
index a7b228e..c6f9447 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java
@@ -10,6 +10,8 @@
**************************************************************************/
package org.eclipse.emf.internal.cdo;
+import org.eclipse.emf.cdo.protocol.CDOID;
+
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.CDOCallback;
import org.eclipse.emf.ecore.impl.EObjectImpl;
@@ -37,7 +39,6 @@ public class CDOCallbackImpl extends CDOLegacyImpl implements CDOCallback
@Override
protected Object convertPotentialID(CDOViewImpl view, Object potentialID)
{
- // XXX
- return view.convertIDToObject(potentialID);
+ return view.getObject((CDOID)potentialID, false);
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyImpl.java
index adc3452..172fa74 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyImpl.java
@@ -278,14 +278,14 @@ public abstract class CDOLegacyImpl extends CDOWrapperImpl
if (containerID.isNull())
{
CDOID resourceID = revision.getResourceID();
- Resource.Internal resource = (Resource.Internal)view.lookupObject(resourceID);
+ Resource.Internal resource = (Resource.Internal)view.getObject(resourceID);
transferResourceToInstance((BasicEObjectImpl)instance, resource);
}
else
{
int containingFeatureID = revision.getContainingFeatureID();
// TODO Maybe convertPotentialID() better here?
- InternalCDOObject container = view.lookupObject(containerID);
+ InternalCDOObject container = view.getObject(containerID);
((BasicEObjectImpl)instance).eBasicSetContainer(container, containingFeatureID, null);
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
index 87f2d61..bf7a6f5 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java
@@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.CDOSessionViewsEvent;
import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl;
import org.eclipse.emf.cdo.internal.protocol.CDOIDRangeImpl;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.CDOIDRange;
@@ -57,6 +58,8 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
/**
* @author Eike Stepper
@@ -87,6 +90,8 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession
private Map<InternalEObject, CDOID> metaInstanceToIDMap = new HashMap();
+ private ConcurrentMap<CDOID, CDOClassImpl> types = new ConcurrentHashMap();
+
private Map<ResourceSet, CDOViewImpl> views = new HashMap();
private transient int lastViewID = 0;
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
index 3e03352..339954f 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java
@@ -322,7 +322,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
{
CDOID id = object.cdoID();
CDOViewImpl view = (CDOViewImpl)object.cdoView();
- CDORevisionImpl revision = view.lookupRevision(id);
+ CDORevisionImpl revision = view.getRevision(id);
object.cdoInternalSetRevision(revision);
object.cdoInternalSetState(CDOState.CLEAN);
object.cdoInternalPostLoad();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
index 6b0491a..4399f44 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
@@ -21,7 +21,9 @@ import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
import org.eclipse.emf.cdo.internal.protocol.revision.CDOIDProvider;
import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
+import org.eclipse.emf.cdo.protocol.CDOIDTyped;
import org.eclipse.emf.cdo.protocol.model.CDOClass;
+import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
import org.eclipse.emf.cdo.protocol.revision.CDORevisionResolver;
import org.eclipse.emf.cdo.protocol.util.TransportException;
import org.eclipse.emf.cdo.util.CDOUtil;
@@ -206,13 +208,19 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
return newInstance(eClass);
}
- public CDORevisionImpl lookupRevision(CDOID id)
+ public CDORevisionImpl getRevision(CDOID id)
{
CDORevisionResolver revisionManager = session.getRevisionManager();
return (CDORevisionImpl)revisionManager.getRevision(id);
}
- public InternalCDOObject lookupObject(CDOID id)
+ public InternalCDOObject getObject(CDOID id)
+ {
+ // TODO Really load on demand here?
+ return getObject(id, true);
+ }
+
+ public InternalCDOObject getObject(CDOID id, boolean loadOnDemand)
{
if (id.equals(lastLookupID))
{
@@ -225,11 +233,18 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
{
if (id.isMeta())
{
- lastLookupObject = createObjectForMeta(id);
+ lastLookupObject = createMetaObject(id);
}
else
{
- lastLookupObject = createObjectForRevision(id);
+ if (loadOnDemand)
+ {
+ lastLookupObject = createObject(id);
+ }
+ else
+ {
+ lastLookupObject = createProxy(id);
+ }
}
registerObject(lastLookupObject);
@@ -241,7 +256,7 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
/**
* @return Never <code>null</code>
*/
- private InternalCDOObject createObjectForMeta(CDOID id)
+ private InternalCDOObject createMetaObject(CDOID id)
{
InternalEObject metaInstance = session.lookupMetaInstance(id);
if (metaInstance == null)
@@ -255,15 +270,16 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
/**
* @return Never <code>null</code>
*/
- private InternalCDOObject createObjectForRevision(CDOID id)
+ private InternalCDOObject createObject(CDOID id)
{
- CDORevisionImpl revision = lookupRevision(id);
+ CDORevisionImpl revision = getRevision(id);
if (TRACER.isEnabled())
{
TRACER.trace("Creating object for revision: " + revision);
}
- InternalCDOObject object = newInstance(revision.getCDOClass());
+ CDOClassImpl cdoClass = revision.getCDOClass();
+ InternalCDOObject object = newInstance(cdoClass);
if (object instanceof CDOResourceImpl)
{
object.cdoInternalSetResource((CDOResourceImpl)object);
@@ -281,10 +297,43 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
object.cdoInternalSetView(this);
object.cdoInternalSetRevision(revision);
object.cdoInternalSetID(revision.getID());
+ object.cdoInternalSetState(CDOState.PROXY); // FIXME
+ return object;
+ }
+
+ private InternalCDOObject createProxy(CDOID id)
+ {
+ CDOClassImpl cdoClass = getObjectType(id);
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Creating proxy for {0}: {1}" + id, cdoClass);
+ }
+
+ InternalCDOObject object = newInstance(cdoClass);
+ if (object instanceof CDOResourceImpl)
+ {
+ object.cdoInternalSetResource((CDOResourceImpl)object);
+ }
+
+ object.cdoInternalSetView(this);
+ object.cdoInternalSetID(id);
object.cdoInternalSetState(CDOState.PROXY);
+
return object;
}
+ private CDOClassImpl getObjectType(CDOID id)
+ {
+ if (id instanceof CDOIDTyped)
+ {
+ CDOIDTyped typed = (CDOIDTyped)id;
+ CDOClassRef type = typed.getType();
+ return session.getPackageManager().resolveClass(type);
+ }
+
+ return null;
+ }
+
public CDOID provideCDOID(Object idOrObject)
{
Object shouldBeCDOID = convertObjectToID(idOrObject);
@@ -346,7 +395,7 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
}
CDOID id = (CDOID)potentialID;
- InternalCDOObject result = lookupObject(id);
+ InternalCDOObject result = getObject(id);
if (result == null)
{
throw new ImplementationError("ID not registered: " + id);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ProxyResolverResource.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ProxyResolverResource.java
index c93b6c7..a0921d2 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ProxyResolverResource.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ProxyResolverResource.java
@@ -48,7 +48,7 @@ final class ProxyResolverResource implements Resource
public EObject getEObject(String uriFragment)
{
CDOID id = CDOIDImpl.create(Long.parseLong(uriFragment));
- InternalCDOObject object = view.lookupObject(id);
+ InternalCDOObject object = view.getObject(id);
if (object instanceof CDOCallbackImpl)
{
CDOCallbackImpl callback = (CDOCallbackImpl)object;