Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 155400 Details for
Bug 247226
Transparently support legacy models (CDOLegacyAdapter)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
LegacyAdapter Patch v6 - ready to be committed
patch.txt (text/plain), 7.76 KB, created by
Eike Stepper
on 2010-01-06 07:11:02 EST
(
hide
)
Description:
LegacyAdapter Patch v6 - ready to be committed
Filename:
MIME Type:
Creator:
Eike Stepper
Created:
2010-01-06 07:11:02 EST
Size:
7.76 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.emf.cdo >Index: src/org/eclipse/emf/internal/cdo/CDOLegacyWrapper.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyWrapper.java,v >retrieving revision 1.33 >diff -u -r1.33 CDOLegacyWrapper.java >--- src/org/eclipse/emf/internal/cdo/CDOLegacyWrapper.java 27 Dec 2009 15:41:16 -0000 1.33 >+++ src/org/eclipse/emf/internal/cdo/CDOLegacyWrapper.java 6 Jan 2010 12:12:54 -0000 >@@ -77,12 +77,12 @@ > * This local ThreadMap stores all pre-registered objects. This avoids a neverending loop when setting the container > * for the object. > */ >- private static ThreadLocal<Map<CDOID, EObject>> preRegisteredObjects = new InheritableThreadLocal<Map<CDOID, EObject>>() >+ private static ThreadLocal<Map<CDOID, CDOLegacyWrapper>> wrapperRegistry = new InheritableThreadLocal<Map<CDOID, CDOLegacyWrapper>>() > { > @Override >- protected Map<CDOID, EObject> initialValue() >+ protected Map<CDOID, CDOLegacyWrapper> initialValue() > { >- return new HashMap<CDOID, EObject>(); >+ return new HashMap<CDOID, CDOLegacyWrapper>(); > } > }; > >@@ -191,6 +191,7 @@ > > public void cdoInternalCleanup() > { >+ // clean(); > } > > @Override >@@ -284,7 +285,7 @@ > Counter counter = recursionCounter.get(); > try > { >- preRegisterObject(this); >+ registerWrapper(this); > counter.increment(); > > revisionToInstanceContainment(); >@@ -306,27 +307,12 @@ > instance.eSetDeliver(true); > } > >- int newThreadCount = counter.decrement(); >- >- if (newThreadCount == 0 && getPreRegisteredObjects() != null) >- { >- // localThread.remove(); // TODO Martin: check why new >- // objects will be created if this list is cleared >- } >- >+ counter.decrement(); >+ unregisterWrapper(this); > underConstruction = false; > } > } > >- /** >- * adds an object to the pre-registered objects list which hold all created objects even if they are not registered in >- * the view >- */ >- private void preRegisterObject(CDOLegacyWrapper wrapper) >- { >- getPreRegisteredObjects().put(wrapper.cdoID(), wrapper); >- } >- > protected void revisionToInstanceContainment() > { > CDOID resourceID = revision.getResourceID(); >@@ -338,11 +324,6 @@ > setInstanceContainer(container, revision.getContainingFeatureID()); > } > >- private Map<CDOID, EObject> getPreRegisteredObjects() >- { >- return preRegisteredObjects.get(); >- } >- > /** > * @since 3.0 > */ >@@ -370,7 +351,7 @@ > > if (TRACER.isEnabled()) > { >- TRACER.format(("Adding " + object + " to feature " + feature + "in instance " + instance)); >+ TRACER.format("Adding " + object + " to feature " + feature + "in instance " + instance); > } > > list.basicAdd(object, null); >@@ -400,25 +381,24 @@ > > int featureID = instance.eClass().getFeatureID(feature); > Class<? extends Object> baseClass = object == null ? null : object.getClass(); >+ EStructuralFeature.Internal internalFeature = (EStructuralFeature.Internal)feature; >+ EReference oppositeReference = cdoID().isTemporary() ? null : internalFeature.getEOpposite(); > >- try >+ if (oppositeReference != null) > { > instance.eInverseAdd((InternalEObject)object, featureID, baseClass, null); >+ >+ if (object != null && !EMFUtil.isPersistent(oppositeReference)) >+ { >+ adjustOppositeReference(instance, (InternalEObject)object, oppositeReference); >+ } > } >- catch (NullPointerException e) >+ else > { >- // TODO: Martin:quick hack, because there is still a problem with the feature id. Should investigate this soon > instance.eSet(feature, object); > } > > // Adjust opposite for transient opposite features >- EStructuralFeature.Internal internalFeature = (EStructuralFeature.Internal)feature; >- EReference oppositeReference = cdoID().isTemporary() ? null : internalFeature.getEOpposite(); >- if (oppositeReference != null && object != null && !EMFUtil.isPersistent(oppositeReference)) >- { >- adjustOppositeReference(instance, (InternalEObject)object, oppositeReference); >- } >- > if (TRACER.isEnabled()) > { > TRACER.format(("Added object " + object + " to feature " + feature + " in instance " + instance)); >@@ -494,27 +474,35 @@ > return null; > } > >+ if (object instanceof CDOLegacyWrapper) >+ { >+ return ((CDOLegacyWrapper)object).cdoInternalInstance(); >+ } >+ > CDOType type = CDOModelUtil.getType(feature.getEType()); > object = type.convertToEMF(feature.getEType(), object); > > if (type == CDOType.OBJECT) > { >- CDOID id = (CDOID)object; >- if (id.isNull()) >+ if (object instanceof CDOID) > { >- return null; >- } >+ CDOID id = (CDOID)object; >+ if (id.isNull()) >+ { >+ return null; >+ } > >- object = getPreRegisteredObjects().get(id); >- if (object != null) >- { >- return ((CDOLegacyWrapper)object).cdoInternalInstance(); >- } >+ object = getRegisteredWrapper(id); >+ if (object != null) >+ { >+ return ((CDOLegacyWrapper)object).cdoInternalInstance(); >+ } > >- object = view.getObject(id); >- if (object instanceof CDOObjectWrapper) >- { >- return ((CDOObjectWrapper)object).cdoInternalInstance(); >+ object = view.getObject(id); >+ if (object instanceof CDOObjectWrapper) >+ { >+ return ((CDOObjectWrapper)object).cdoInternalInstance(); >+ } > } > } > >@@ -569,13 +557,14 @@ > protected InternalEObject getEObjectFromPotentialID(InternalCDOView view, EStructuralFeature feature, > Object potentialID) > { >- if (getPreRegisteredObjects().get(potentialID) != null) >+ CDOLegacyWrapper wrapper; >+ if (potentialID instanceof CDOID && (wrapper = getRegisteredWrapper((CDOID)potentialID)) != null) > { >- potentialID = ((CDOLegacyWrapper)getPreRegisteredObjects().get(potentialID)).instance; >+ potentialID = wrapper.instance; > > if (TRACER.isEnabled()) > { >- TRACER.format(("getting Object (" + potentialID + ") from localThread instead of the view")); >+ TRACER.format("getting Object (" + potentialID + ") from localThread instead of the view"); > } > } > else >@@ -759,6 +748,11 @@ > } > } > >+ public static boolean isLegacyProxy(Object object) >+ { >+ return object instanceof LegacyProxy; >+ } >+ > protected static int getEFlagMask(Class<?> instanceClass, String flagName) > { > Field field = ReflectUtil.getField(instanceClass, flagName); >@@ -766,7 +760,7 @@ > { > field.setAccessible(true); > } >- >+ > try > { > return (Integer)field.get(null); >@@ -777,9 +771,23 @@ > } > } > >- public static boolean isLegacyProxy(Object object) >+ private static CDOLegacyWrapper getRegisteredWrapper(CDOID id) > { >- return object instanceof LegacyProxy; >+ return wrapperRegistry.get().get(id); >+ } >+ >+ /** >+ * adds an object to the pre-registered objects list which hold all created objects even if they are not registered in >+ * the view >+ */ >+ private static void registerWrapper(CDOLegacyWrapper wrapper) >+ { >+ wrapperRegistry.get().put(wrapper.cdoID(), wrapper); >+ } >+ >+ private static void unregisterWrapper(CDOLegacyWrapper wrapper) >+ { >+ wrapperRegistry.get().remove(wrapper.cdoID()); > } > > /**
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 247226
:
112514
|
112894
|
134866
|
151009
|
151634
|
151651
|
152232
|
153867
|
153868
|
155030
|
155031
|
155181
|
155182
|
155400
|
163497
|
163499