summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-01 13:24:41 (EDT)
committerEike Stepper2007-08-01 13:24:41 (EDT)
commitaee76e3052729d2db15634d71c09501ce12c7760 (patch)
tree7a3a5c2e34dc8812ada98007f28180cda7adeac7
parent0f08e24e9a677d84229694198be6c5ac7ce4b47f (diff)
downloadcdo-aee76e3052729d2db15634d71c09501ce12c7760.zip
cdo-aee76e3052729d2db15634d71c09501ce12c7760.tar.gz
cdo-aee76e3052729d2db15634d71c09501ce12c7760.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java35
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java7
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java9
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java (renamed from plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/weaver/IPersistenceCallback.java)19
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionImpl.java21
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java23
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java8
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java28
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ProxyResolverResource.java8
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/weaver/IPersistenceAware.java21
11 files changed, 115 insertions, 66 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java
index 0918e9d..69abb60 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CommitTransactionIndication.java
@@ -19,6 +19,7 @@ import org.eclipse.emf.cdo.internal.server.RepositoryPackageManager;
import org.eclipse.emf.cdo.internal.server.RevisionManager;
import org.eclipse.emf.cdo.internal.server.bundle.OM;
import org.eclipse.emf.cdo.protocol.CDOID;
+import org.eclipse.emf.cdo.protocol.CDOIDRange;
import org.eclipse.emf.cdo.protocol.CDOProtocolConstants;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
@@ -60,15 +61,6 @@ public class CommitTransactionIndication extends CDOServerIndication
@Override
protected void indicating(ExtendedDataInputStream in) throws IOException
{
- // try
- // {
- // Thread.sleep(100000000000L);
- // }
- // catch (InterruptedException ex)
- // {
- // throw new IOException(ex.getMessage());
- // }
-
addNewPackages(in);
newResources = readNewResources(in);
newObjects = readNewObjects(in);
@@ -90,7 +82,20 @@ public class CommitTransactionIndication extends CDOServerIndication
for (int i = 0; i < size; i++)
{
newPackages[i] = new CDOPackageImpl(packageManager, in);
+ CDOIDRange oldRange = newPackages[i].getMetaIDRange();
+
packageManager.addPackage(newPackages[i]);
+ CDOIDRange newRange = newPackages[i].getMetaIDRange();
+
+ long count = oldRange.getCount();
+ for (long l = 0; l < count; l++)
+ {
+ CDOID oldID = oldRange.get(l);
+ CDOID newID = newRange.get(l);
+
+ TRACER.format("Mapping ID: {0} --> {1}", oldID, newID);
+ idMappings.put(oldID, newID);
+ }
}
}
}
@@ -201,11 +206,17 @@ public class CommitTransactionIndication extends CDOServerIndication
private void writeIDMappings(ExtendedDataOutputStream out) throws IOException
{
- out.writeInt(idMappings.size());
for (Entry<CDOID, CDOID> entry : idMappings.entrySet())
{
- CDOIDImpl.write(out, entry.getKey());
- CDOIDImpl.write(out, entry.getValue());
+ CDOID oldID = entry.getKey();
+ if (!oldID.isMeta())
+ {
+ CDOID newID = entry.getValue();
+ CDOIDImpl.write(out, oldID);
+ CDOIDImpl.write(out, newID);
+ }
}
+
+ CDOIDImpl.write(out, CDOID.NULL);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java
index 93c27e2..a294502 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/OpenSessionIndication.java
@@ -128,7 +128,7 @@ public class OpenSessionIndication extends IndicationWithResponse
if (PROTOCOL.isEnabled())
{
PROTOCOL.format("Writing package info: uri={0}, dynamic={1}, metaIDRange={2}", p.getPackageURI(), p
- .getMetaIDRange());
+ .isDynamic(), p.getMetaIDRange());
}
out.writeString(p.getPackageURI());
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
index 399de4d..2c54a6b 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
@@ -57,6 +57,7 @@ import org.eclipse.emf.edit.ui.util.EditUIMarkerHelper;
import org.eclipse.emf.edit.ui.util.EditUIUtil;
import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage;
import org.eclipse.emf.internal.cdo.CDOAdapterImpl;
+import org.eclipse.emf.internal.cdo.CDOCallbackImpl;
import org.eclipse.emf.internal.cdo.CDOStateMachine;
import org.eclipse.emf.internal.cdo.InternalCDOObject;
@@ -1223,7 +1224,11 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
@Override
protected void objectInvalidated(CDOObject cdoObject)
{
- if (cdoObject instanceof CDOAdapterImpl)
+ if (cdoObject instanceof CDOCallbackImpl)
+ {
+ // Do nothing
+ }
+ else if (cdoObject instanceof CDOAdapterImpl)
{
CDOStateMachine.INSTANCE.read((InternalCDOObject)cdoObject);
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java
index de25d7e..cf48952 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOAdapterImpl.java
@@ -49,7 +49,6 @@ import org.eclipse.emf.ecore.impl.EReferenceImpl;
import org.eclipse.emf.ecore.impl.EStructuralFeatureImpl;
import org.eclipse.emf.ecore.impl.ETypedElementImpl;
import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.util.GenUtil;
@@ -86,7 +85,7 @@ public class CDOAdapterImpl extends AdapterImpl implements InternalCDOObject
@Override
public boolean isAdapterForType(Object type)
{
- return type == CDOAdapterImpl.class;
+ return type == CDOAdapterImpl.class || type == CDOCallbackImpl.class;
}
@Override
@@ -811,10 +810,4 @@ public class CDOAdapterImpl extends AdapterImpl implements InternalCDOObject
{
return getTarget().eURIFragmentSegment(feature, object);
}
-
- public static CDOAdapterImpl get(InternalEObject eObject)
- {
- EList<Adapter> adapters = eObject.eAdapters();
- return (CDOAdapterImpl)EcoreUtil.getAdapter(adapters, CDOAdapterImpl.class);
- }
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/weaver/IPersistenceCallback.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java
index 1def303..0737270 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/weaver/IPersistenceCallback.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java
@@ -8,16 +8,27 @@
* Contributors:
* Eike Stepper - initial API and implementation
**************************************************************************/
-package org.eclipse.emf.internal.cdo.weaver;
+package org.eclipse.emf.internal.cdo;
+import org.eclipse.emf.ecore.impl.CDOCallback;
import org.eclipse.emf.ecore.impl.EObjectImpl;
/**
* @author Eike Stepper
*/
-public interface IPersistenceCallback
+public class CDOCallbackImpl extends CDOAdapterImpl implements CDOCallback
{
- public void beforeRead(EObjectImpl eObject);
+ public CDOCallbackImpl()
+ {
+ }
- public void beforeWrite(EObjectImpl eObject);
+ public void beforeRead(EObjectImpl instance)
+ {
+ CDOStateMachine.INSTANCE.read(this);
+ }
+
+ public void beforeWrite(EObjectImpl instance)
+ {
+ CDOStateMachine.INSTANCE.write(this);
+ }
}
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 394ed87..a595f14 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.CDOPackageImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.CDOIDRange;
import org.eclipse.emf.cdo.util.CDOUtil;
@@ -47,6 +48,7 @@ import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.protocol.CDOClientProtocol;
import org.eclipse.emf.internal.cdo.protocol.OpenSessionRequest;
import org.eclipse.emf.internal.cdo.protocol.OpenSessionResult;
+import org.eclipse.emf.internal.cdo.util.ModelUtil;
import org.eclipse.emf.internal.cdo.util.ProxyResolverURIResourceMap;
import java.text.MessageFormat;
@@ -254,7 +256,24 @@ public class CDOSessionImpl extends Lifecycle implements CDOSession
public InternalEObject lookupMetaInstance(CDOID id)
{
- return idToMetaInstanceMap.get(id);
+ InternalEObject metaInstance = idToMetaInstanceMap.get(id);
+ if (metaInstance == null)
+ {
+ CDOPackageImpl[] cdoPackages = packageManager.getPackages();
+ for (CDOPackageImpl cdoPackage : cdoPackages)
+ {
+ CDOIDRange metaIDRange = cdoPackage.getMetaIDRange();
+ if (metaIDRange != null && metaIDRange.contains(id))
+ {
+ EPackage ePackage = ModelUtil.getEPackage(cdoPackage, packageRegistry);
+ registerEPackage(ePackage);
+ metaInstance = idToMetaInstanceMap.get(id);
+ break;
+ }
+ }
+ }
+
+ return metaInstance;
}
public CDOID lookupMetaInstanceID(InternalEObject metaInstance)
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 405a528..3e03352 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
@@ -47,7 +47,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
transit(CDOState.PREPARED_ATTACH, CDOEvent.ATTACH, FAIL);
transit(CDOState.PREPARED_ATTACH, CDOEvent.DETACH, FAIL);
- transit(CDOState.PREPARED_ATTACH, CDOEvent.READ, FAIL);
+ transit(CDOState.PREPARED_ATTACH, CDOEvent.READ, IGNORE);
transit(CDOState.PREPARED_ATTACH, CDOEvent.WRITE, FAIL);
transit(CDOState.PREPARED_ATTACH, CDOEvent.COMMIT, FAIL);
transit(CDOState.PREPARED_ATTACH, CDOEvent.ROLLBACK, FAIL);
@@ -107,13 +107,11 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
data.view = view;
// TRANSIENT --> PREPARED_ATTACH
- if (TRACER.isEnabled())
- TRACER.format("ATTACH: {0} --> {1}", object, view);
+ if (TRACER.isEnabled()) TRACER.format("ATTACH: {0} --> {1}", object, view);
process(object, CDOEvent.ATTACH, data);
// PREPARED_ATTACH --> NEW
- if (TRACER.isEnabled())
- TRACER.format("FINALIZE_ATTACH: {0} --> {1}", object, view);
+ if (TRACER.isEnabled()) TRACER.format("FINALIZE_ATTACH: {0} --> {1}", object, view);
process(object, CDOEvent.FINALIZE_ATTACH, data);
}
@@ -125,36 +123,31 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent
public void read(InternalCDOObject object)
{
- if (TRACER.isEnabled())
- TRACER.format("READ: {0}", object);
+ if (TRACER.isEnabled()) TRACER.format("READ: {0}", object);
process(object, CDOEvent.READ, null);
}
public void write(InternalCDOObject object)
{
- if (TRACER.isEnabled())
- TRACER.format("WRITE: {0}", object);
+ if (TRACER.isEnabled()) TRACER.format("WRITE: {0}", object);
process(object, CDOEvent.WRITE, null);
}
public void invalidate(InternalCDOObject object, long timeStamp)
{
- if (TRACER.isEnabled())
- TRACER.format("INVALIDATE: {0}", object);
+ if (TRACER.isEnabled()) TRACER.format("INVALIDATE: {0}", object);
process(object, CDOEvent.INVALIDATE, timeStamp);
}
public void commit(InternalCDOObject object, CommitTransactionResult result)
{
- if (TRACER.isEnabled())
- TRACER.format("COMMIT: {0}", object);
+ if (TRACER.isEnabled()) TRACER.format("COMMIT: {0}", object);
process(object, CDOEvent.COMMIT, result);
}
public void rollback(InternalCDOObject object)
{
- if (TRACER.isEnabled())
- TRACER.format("ROLLBACK: {0}", object);
+ if (TRACER.isEnabled()) TRACER.format("ROLLBACK: {0}", object);
process(object, CDOEvent.ROLLBACK, null);
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
index ac19e8b..8f7fea9 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
@@ -137,10 +137,14 @@ public class CommitTransactionRequest extends CDOClientRequest<CommitTransaction
}
}
- int size = in.readInt();
- for (int i = 0; i < size; i++)
+ for (;;)
{
CDOID oldID = CDOIDImpl.read(in);
+ if (oldID.isNull())
+ {
+ break;
+ }
+
CDOID newID = CDOIDImpl.read(in);
result.addIDMapping(oldID, newID);
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
index a709772..8a6b31d 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
@@ -22,11 +22,15 @@ import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EGenericType;
import org.eclipse.emf.ecore.EModelElement;
import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.impl.CDOAware;
+import org.eclipse.emf.ecore.impl.CDOCallback;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.internal.cdo.CDOAdapterImpl;
+import org.eclipse.emf.internal.cdo.CDOCallbackImpl;
import org.eclipse.emf.internal.cdo.CDOMetaImpl;
import org.eclipse.emf.internal.cdo.CDOViewImpl;
import org.eclipse.emf.internal.cdo.InternalCDOObject;
+import org.eclipse.emf.internal.cdo.bundle.OM;
import java.util.Collection;
import java.util.Iterator;
@@ -78,6 +82,30 @@ public final class FSMUtil
}
}
+ try
+ {
+ if (object instanceof CDOAware)
+ {
+ CDOAware aware = (CDOAware)object;
+ CDOCallback callback = aware.getCDOCallback();
+ if (callback != null)
+ {
+ return (InternalCDOObject)callback;
+ }
+
+ CDOCallbackImpl callbackAdapter = new CDOCallbackImpl();
+ aware.setCDOCallback(callbackAdapter);
+
+ EList<Adapter> adapters = ((InternalEObject)object).eAdapters();
+ adapters.add(callbackAdapter);
+ return callbackAdapter;
+ }
+ }
+ catch (Throwable t)
+ {
+ OM.LOG.info(t);
+ }
+
if (object instanceof InternalEObject)
{
EList<Adapter> adapters = ((InternalEObject)object).eAdapters();
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 b6890a0..6675ed9 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
@@ -13,6 +13,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.internal.cdo.CDOAdapterImpl;
+import org.eclipse.emf.internal.cdo.CDOCallbackImpl;
import org.eclipse.emf.internal.cdo.CDOViewImpl;
import org.eclipse.emf.internal.cdo.InternalCDOObject;
@@ -48,7 +49,12 @@ final class ProxyResolverResource implements Resource
{
CDOID id = CDOIDImpl.create(Long.parseLong(uriFragment));
InternalCDOObject object = view.lookupInstance(id);
- if (object instanceof CDOAdapterImpl)
+ if (object instanceof CDOCallbackImpl)
+ {
+ CDOCallbackImpl callbackAdapter = (CDOCallbackImpl)object;
+ return callbackAdapter.getTarget();
+ }
+ else if (object instanceof CDOAdapterImpl)
{
CDOAdapterImpl adapter = (CDOAdapterImpl)object;
if (adapter.cdoState() == CDOState.PROXY)
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/weaver/IPersistenceAware.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/weaver/IPersistenceAware.java
deleted file mode 100644
index 53b8f68..0000000
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/weaver/IPersistenceAware.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- **************************************************************************/
-package org.eclipse.emf.internal.cdo.weaver;
-
-/**
- * @author Eike Stepper
- */
-public interface IPersistenceAware
-{
- public IPersistenceCallback getPersistenceCallback();
-
- public void setPersistenceCallback(IPersistenceCallback persistenceCallback);
-}