Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java')
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java67
1 files changed, 33 insertions, 34 deletions
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