diff options
author | Eike Stepper | 2012-04-04 22:35:12 +0000 |
---|---|---|
committer | Eike Stepper | 2012-04-04 22:35:12 +0000 |
commit | 33520c57bddc3bfba3ad7eb6aed0e64a3ec07c60 (patch) | |
tree | adec2fc9aa428f069b0341c6f6bc54623bf98337 | |
parent | c476f38ffbfb9742b035a5b463e0628ac06ebf18 (diff) | |
download | cdo-33520c57bddc3bfba3ad7eb6aed0e64a3ec07c60.tar.gz cdo-33520c57bddc3bfba3ad7eb6aed0e64a3ec07c60.tar.xz cdo-33520c57bddc3bfba3ad7eb6aed0e64a3ec07c60.zip |
[374962] Make CDOStaleReferencePolicy.PROXY robust for eAdapters() calls
https://bugs.eclipse.org/bugs/show_bug.cgi?id=374962
-rw-r--r-- | plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOStaleObject.java | 50 | ||||
-rw-r--r-- | plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOStaleReferencePolicy.java | 32 |
2 files changed, 50 insertions, 32 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOStaleObject.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOStaleObject.java index 6d8b425d72..45d155bedf 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOStaleObject.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOStaleObject.java @@ -1,24 +1,26 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Simon McDuff - initial API and implementation
- */
-package org.eclipse.emf.cdo.view;
-
-/**
- * A marker interface for stale objects as produced by {@link CDOStaleReferencePolicy#PROXY}.
- *
- * @author Simon McDuff
- * @since 3.0
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- * @apiviz.exclude
- */
-public interface CDOStaleObject
-{
-}
+/* + * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others. + * 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: + * Simon McDuff - initial API and implementation + */ +package org.eclipse.emf.cdo.view; + +import org.eclipse.emf.cdo.common.id.CDOWithID; + +/** + * A marker interface for stale objects as produced by {@link CDOStaleReferencePolicy#PROXY}. + * + * @author Simon McDuff + * @since 3.0 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * @apiviz.exclude + */ +public interface CDOStaleObject extends CDOWithID +{ +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOStaleReferencePolicy.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOStaleReferencePolicy.java index 4522a758e3..93cbb57904 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOStaleReferencePolicy.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/view/CDOStaleReferencePolicy.java @@ -17,6 +17,7 @@ import org.eclipse.emf.cdo.util.ObjectNotFoundException; import org.eclipse.emf.internal.cdo.messages.Messages; +import org.eclipse.emf.common.notify.Notifier; import org.eclipse.emf.ecore.EClassifier; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EStructuralFeature; @@ -52,10 +53,19 @@ public interface CDOStaleReferencePolicy }; /** - * Returns a proxy object with the appropriate EClass. The proxy object supports the {@link InternalEObject#eClass() - * eClass()} and {@link InternalEObject#eIsProxy() eIsProxy()} methods. For all invocations to other methods the proxy - * object throws an {@link ObjectNotFoundException}. The receiver can use {@link CDOUtil#isStaleObject(Object)} to - * detect proxy objects. + * Returns a proxy object with the appropriate EClass. The proxy object supports the following methods: + * <ul> + * <li> + * {@link CDOStaleObject#cdoID()} + * <li> + * {@link InternalEObject#eClass()} + * <li> + * {@link InternalEObject#eIsProxy()} + * <li> + * {@link Notifier#eAdapters()} + * </ul> + * For all invocations of other methods the proxy object throws an {@link ObjectNotFoundException}. The receiver can + * use {@link CDOUtil#isStaleObject(Object)} or <code>instanceof {@link CDOStaleObject}</code> to detect proxy objects. */ public static final CDOStaleReferencePolicy PROXY = new CDOStaleReferencePolicy() { @@ -65,19 +75,25 @@ public interface CDOStaleReferencePolicy final EClassifier type = feature.getEType(); InvocationHandler handler = new InvocationHandler() { - public Object invoke(Object arg0, Method arg1, Object[] arg2) throws Throwable + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - if (arg1.getName().equals("eIsProxy")) //$NON-NLS-1$ + String name = method.getName(); + if (name.equals("cdoID")) //$NON-NLS-1$ + { + return target; + } + + if (name.equals("eIsProxy")) //$NON-NLS-1$ { return false; } - if (arg1.getName().equals("eClass")) //$NON-NLS-1$ + if (name.equals("eClass")) //$NON-NLS-1$ { return type; } - if (arg1.getName().equals("eAdapters")) //$NON-NLS-1$ + if (name.equals("eAdapters")) //$NON-NLS-1$ { return source.eAdapters(); } |