Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOCallbackImpl.java29
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java67
2 files changed, 62 insertions, 34 deletions
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 0a4d805854..8c1620d11f 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,11 +10,15 @@
**************************************************************************/
package org.eclipse.emf.internal.cdo;
+import org.eclipse.emf.cdo.CDOView;
+
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EReference;
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.impl.EObjectImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.util.FSMUtil;
@@ -141,4 +145,29 @@ public class CDOCallbackImpl extends CDOLegacyImpl implements CDOCallback
}
}
}
+
+ public static InternalCDOObject adapt(Object object, CDOView view) throws Throwable
+ {
+ if (object instanceof CDOAware)
+ {
+ CDOAware aware = (CDOAware)object;
+ CDOCallbackImpl callback = (CDOCallbackImpl)aware.getCDOCallback();
+ if (callback == null)
+ {
+ InternalEObject instance = (InternalEObject)aware;
+ if (instance.eIsProxy())
+ {
+ instance = (InternalEObject)EcoreUtil.resolve(instance, view.getResourceSet());
+ }
+
+ callback = new CDOCallbackImpl(instance);
+ aware.setCDOCallback(callback);
+ instance.eAdapters().add(callback);
+ }
+
+ return callback;
+ }
+
+ return null;
+ }
}
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 baddc47acb..40b93473f4 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
@@ -27,6 +27,7 @@ import org.eclipse.emf.internal.cdo.CDOViewImpl;
import org.eclipse.emf.internal.cdo.InternalCDOObject;
import org.eclipse.emf.internal.cdo.bundle.OM;
+import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Iterator;
@@ -35,10 +36,35 @@ import java.util.Iterator;
*/
public final class FSMUtil
{
+ private static Method adaptLegacyMethod = initAdaptLegacyMethod();
+
private FSMUtil()
{
}
+ private static Method initAdaptLegacyMethod()
+ {
+ try
+ {
+ Class<?> c = Class.forName("org.eclipse.emf.internal.cdo.CDOCallbackImpl");
+ if (c != null)
+ {
+ final Class<?>[] params = { Object.class, CDOView.class };
+ Method method = c.getDeclaredMethod("adapt", params);
+ if (method != null)
+ {
+ return method;
+ }
+ }
+ }
+ catch (Throwable ignore)
+ {
+ }
+
+ OM.LOG.info("Legacy system not available");
+ return null;
+ }
+
public static boolean isTransient(CDOObject object)
{
CDOState state = object.cdoState();
@@ -82,17 +108,16 @@ public final class FSMUtil
}
}
- try
+ if (adaptLegacyMethod != null)
{
- InternalCDOObject callback = adaptLegacy(object, view);
- if (callback != null)
+ try
{
- return callback;
+ return (InternalCDOObject)adaptLegacyMethod.invoke(null, object, view);
+ }
+ catch (Throwable t)
+ {
+ OM.LOG.info(t);
}
- }
- catch (Throwable t)
- {
- OM.LOG.info(t);
}
if (object instanceof InternalEObject)
@@ -111,32 +136,6 @@ public final class FSMUtil
return null;
}
- public static InternalCDOObject adaptLegacy(Object object, CDOView view) throws Throwable
- {
- if (object instanceof org.eclipse.emf.ecore.impl.CDOAware)
- {
- org.eclipse.emf.ecore.impl.CDOAware aware = (org.eclipse.emf.ecore.impl.CDOAware)object;
- org.eclipse.emf.internal.cdo.CDOCallbackImpl callback = (org.eclipse.emf.internal.cdo.CDOCallbackImpl)aware
- .getCDOCallback();
- if (callback == null)
- {
- InternalEObject instance = (InternalEObject)aware;
- if (instance.eIsProxy())
- {
- instance = (InternalEObject)EcoreUtil.resolve(instance, view.getResourceSet());
- }
-
- callback = new org.eclipse.emf.internal.cdo.CDOCallbackImpl(instance);
- aware.setCDOCallback(callback);
- instance.eAdapters().add(callback);
- }
-
- return callback;
- }
-
- return null;
- }
-
public static Iterator<InternalCDOObject> iterator(Collection<?> instances, final CDOViewImpl view)
{
final Iterator<?> delegate = instances.iterator();

Back to the top