Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 247226

Summary: Transparently support legacy models (CDOLegacyAdapter)
Product: [Modeling] EMF Reporter: Eike Stepper <stepper>
Component: cdo.legacyAssignee: Martin Fluegge <martin.fluegge>
Status: CLOSED FIXED QA Contact: Eike Stepper <stepper>
Severity: enhancement    
Priority: P2 CC: erche, hjoensson, joachim.rietz, mikael.barbero, smcduff, stefan, taifun.oreilly, Thomas.M.Crockett, vroldanbet
Version: 3.0Flags: stepper: documentation+
stepper: galileo+
stepper: helios+
stepper: review+
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: Appealing to a Broader Community
Bug Depends on: 247130    
Bug Blocks: 237067, 247227    
Attachments:
Description Flags
Patch v1
none
EMF Patch v1
none
Contains UMLTest.launch
none
LegacyAdapter Patch
none
LegacyAdapter Patch v2
none
LegacyTests v1
none
Legacy Tests v2
none
LegacyAdapter Patch V3
none
mylyn/context/zip
none
LegacyAdapter Patch v4 - ready to be committed
none
Legacy Tests v3 - ready to be committed
none
LegacyAdapter Patch v5
none
Legacy Tests Patch v4
none
LegacyAdapter Patch v6 - ready to be committed
none
LegacyAdapter Patch v7 - ready to be committed
none
LegacyAdapter Patch v7 - ready to be committed none

Description Eike Stepper CLA 2008-09-14 05:05:11 EDT
This includes making CDO un-invasive to non-native models!
It depends on bug #247130: Provide vetoable notification for read and write access
Comment 1 Eike Stepper CLA 2008-09-14 12:07:03 EDT
Created attachment 112514 [details]
Patch v1

Removal of all weaver/conversion related stuff.

Addition of the CDOLegacyWrapper based on the new EMF pre-notifications.
Comment 2 Eike Stepper CLA 2008-09-16 03:13:19 EDT
Simon, I think I have fixed the containment mess in CDOLegacyWrapper. Can you please verify it?
Comment 3 Eike Stepper CLA 2008-09-16 09:01:00 EDT
I removed all evidence of CDOID.LEGACY.

I think proxying and resolving works now in principle.
But there's an issue with inverse updates:

java.lang.UnsupportedOperationException: eInverseRemove
	at org.eclipse.emf.internal.cdo.CDOLegacyWrapper$LegacyProxyInvocationHandler.invoke(CDOLegacyWrapper.java:740)
	at org.eclipse.emf.internal.cdo.$Proxy4.eInverseRemove(Unknown Source)
	at org.eclipse.emf.ecore.util.EcoreEList.inverseRemove(EcoreEList.java:329)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.setUnique(NotifyingListImpl.java:1234)
	at org.eclipse.emf.common.util.BasicEList.set(BasicEList.java:584)
	at org.eclipse.emf.ecore.util.DelegatingInternalEList.set(DelegatingInternalEList.java:364)
	at org.eclipse.emf.internal.cdo.CDOLegacyWrapper.resolveProxies(CDOLegacyWrapper.java:600)
	at org.eclipse.emf.internal.cdo.CDOLegacyWrapper.resolveAllProxies(CDOLegacyWrapper.java:573)
	at org.eclipse.emf.internal.cdo.CDOLegacyWrapper.handleRead(CDOLegacyWrapper.java:200)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eFireRead(BasicEObjectImpl.java:2014)
	at org.eclipse.emf.ecore.util.DelegatingInternalEList.readAccess(DelegatingInternalEList.java:41)
	at org.eclipse.emf.ecore.util.DelegatingInternalEList.size(DelegatingInternalEList.java:370)
	at org.eclipse.emf.cdo.tests.LegacyTest.testReferences(LegacyTest.java:117)
Comment 4 Eike Stepper CLA 2008-09-16 09:02:12 EDT
Just a test to see if the Bugzilla web client is smarter for long lines:

java.lang.UnsupportedOperationException: eInverseRemove
	at org.eclipse.emf.internal.cdo.CDOLegacyWrapper$LegacyProxyInvocationHandler.invoke(CDOLegacyWrapper.java:740)
	at org.eclipse.emf.internal.cdo.$Proxy4.eInverseRemove(Unknown Source)
	at org.eclipse.emf.ecore.util.EcoreEList.inverseRemove(EcoreEList.java:329)
	at org.eclipse.emf.common.notify.impl.NotifyingListImpl.setUnique(NotifyingListImpl.java:1234)
	at org.eclipse.emf.common.util.BasicEList.set(BasicEList.java:584)
	at org.eclipse.emf.ecore.util.DelegatingInternalEList.set(DelegatingInternalEList.java:364)
	at org.eclipse.emf.internal.cdo.CDOLegacyWrapper.resolveProxies(CDOLegacyWrapper.java:600)
	at org.eclipse.emf.internal.cdo.CDOLegacyWrapper.resolveAllProxies(CDOLegacyWrapper.java:573)
	at org.eclipse.emf.internal.cdo.CDOLegacyWrapper.handleRead(CDOLegacyWrapper.java:200)
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eFireRead(BasicEObjectImpl.java:2014)
	at org.eclipse.emf.ecore.util.DelegatingInternalEList.readAccess(DelegatingInternalEList.java:41)
	at org.eclipse.emf.ecore.util.DelegatingInternalEList.size(DelegatingInternalEList.java:370)
	at org.eclipse.emf.cdo.tests.LegacyTest.testReferences(LegacyTest.java:117)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at junit.framework.TestCase.runTest(TestCase.java:164)
	at org.eclipse.net4j.tests.AbstractOMTest.runTest(AbstractOMTest.java:69)
	at junit.framework.TestCase.runBare(TestCase.java:130)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:120)
	at junit.framework.TestSuite.runTest(TestSuite.java:230)
	at junit.framework.TestSuite.run(TestSuite.java:225)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

Comment 5 Eike Stepper CLA 2008-09-16 09:02:44 EDT
Not really ;-(
Comment 6 Eike Stepper CLA 2008-09-16 09:19:13 EDT
All tests are passing!!! ;-)

Though with a dirty trick:

            // TODO Is InternalEList.basicSet() needed???
            if (list instanceof DelegatingInternalEList)
            {
              list = ((DelegatingInternalEList)list).getDelegateInternalEList();
            }

            if (list instanceof NotifyingListImpl)
            {
              ((NotifyingListImpl)list).basicSet(i, instance, null);
            }
            else
            {
              list.set(i, instance);
            }

To make this work at least without reflection I needed to make getDelegateInternalEList() public!
InternalEList.basicSet(int, E) would be nicer ;-)
Comment 7 Eike Stepper CLA 2008-09-18 09:00:19 EDT
Committed to HEAD.

Whether the feature can work or not depends on the availablity of the fix to bug #247130.
Normal native models are not affected by that. Only the workspace would have some compile errors tehn.

All tests are now able to run with native orlegacy test models. See AbstractCDOTest.legacyTesting...
Comment 8 Eike Stepper CLA 2008-09-18 09:13:45 EDT
Created attachment 112894 [details]
EMF Patch v1

This one slightly differs from the one in bug #247130
Comment 9 Stefan Winkler CLA 2008-09-23 04:54:19 EDT
It seems you renamed the setSelfPopulatingPackageRegistry and the other method.
Could you please update 
http://wiki.eclipse.org/Run_a_CDO_container_inside_eclipse_runtime
to reflect the change?

Thanx ;-)

Comment 10 Eike Stepper CLA 2008-09-23 06:45:44 EDT
Done.
Comment 11 Eike Stepper CLA 2009-05-07 16:06:09 EDT
Created attachment 134866 [details]
Contains UMLTest.launch
Comment 12 Martin Fluegge CLA 2009-10-31 15:30:32 EDT
Created attachment 151009 [details]
LegacyAdapter Patch

Hi,

I attached a patch to make the legacy adapter mode work. Not yet perfect but workes for the simple library example (Lib, Books, Writers) and for parts auf the GMF notaional model (Diagram, Node, Bounds, ShapeStyle, DiagramStyle ).

Cheers,

Martin
Comment 13 Eike Stepper CLA 2009-11-07 13:58:08 EST
Created attachment 151634 [details]
LegacyAdapter Patch v2

Reformatted. Please ping me that we can discuss...
Comment 14 Martin Fluegge CLA 2009-11-08 12:44:18 EST
Commited to HEAD.
Comment 15 Eike Stepper CLA 2009-11-08 12:44:49 EST
Well done!
Comment 16 Martin Fluegge CLA 2009-11-08 14:27:31 EST
Created attachment 151651 [details]
LegacyTests v1
Comment 17 Martin Fluegge CLA 2009-11-14 13:57:21 EST
Created attachment 152232 [details]
Legacy Tests v2

I attached another patch for the creation of legacy test models. This converts the ?model1?. I only changed the interfaces of the lecagy implementation to the native interface and adjusted some stuff (mostly concerning enums) in the implementations. I think this approach is easier and much cleaner because now we can use different URIs for the packages.

I think this will be important for getting a complete test coverage. I think that in addition to legacy and native mode we will need some sort of a mixed-mode where legacy and native are tested combined. 

This patch also contains a change in the CDOResource. 

?View.getResourceSet().getEObject(uri, true);? always returned the CDOWrapper and not the instance. I think this should be the cdoInternalInstance.

A similar problem occurs with ?View.getObject(cdoid, true);?. In this case returning of the Wrapper seems o.k. But I am not absolutely sure. If this is o.k. the test-cases should be aware of LegacyWrappers. 

We should discuss this. ;)

Cheers,

Martin
Comment 18 Martin Fluegge CLA 2009-12-05 14:21:51 EST
Created attachment 153867 [details]
LegacyAdapter Patch V3

I fixed a bug in the CDOLegacyWrapper. The previous version did not set the opposite of a bi-directional reference if it was a transient one. Now transient features will also be adjusted.
Comment 19 Martin Fluegge CLA 2009-12-05 14:21:59 EST
Created attachment 153868 [details]
mylyn/context/zip
Comment 20 Eike Stepper CLA 2009-12-25 04:45:20 EST
Created attachment 155030 [details]
LegacyAdapter Patch v4 - ready to be committed
Comment 21 Eike Stepper CLA 2009-12-25 05:11:45 EST
Created attachment 155031 [details]
Legacy Tests v3 - ready to be committed

Please do not send patches for review that create compile errors! See ModelConfig, which I fixed in v3.

The Legacy tests do not pass. E.g. there's an NPE in getAnnotation(), caused by a CDOInvalidationNotification with no feature set...

The normal test suite is not affected.
Comment 22 Eike Stepper CLA 2009-12-25 05:13:14 EST
Martin, please do not attach multiple patches with overlapping changes, like CDOLegacyWrapper, which is part of both patches.
Comment 23 Martin Fluegge CLA 2009-12-27 11:25:01 EST
Committed to HEAD

and sorry for the patch confusion...
Comment 24 Martin Fluegge CLA 2010-01-03 04:59:21 EST
Created attachment 155181 [details]
LegacyAdapter Patch v5

After being frustrated that only ~120 (out of 530) existing tests were passig in legacy mode I spend some time on converting the legacy test models and fixing some bug. 

Now 476 tests are passing when running all tests in legacy mode. :)

Some failures and error rely on feature which are not yet implemented in legacy mode (e.g. locking)

This patch covers the changes in the Legagy wrapper. The patch for the patches will be applied in a minute. 

Code is preformatted ;)
Comment 25 Martin Fluegge CLA 2010-01-03 05:00:27 EST
Created attachment 155182 [details]
Legacy Tests Patch v4

And here is the patch for the tests. Legacy test are still separated from the "AutomatedTests". All valid tests will be executed by running the AllTestsLegacy.java. This also gives an overview about the tests which are still failing (removed from the test execution)
Comment 26 Eike Stepper CLA 2010-01-06 07:11:02 EST
Created attachment 155400 [details]
LegacyAdapter Patch v6 - ready to be committed

Martin, on occasion please revisit the TRACER.format() calls, they expect a format pattern string plus arguments. If you prefer the string concatenation please use TRACER.trace().
Comment 27 Eike Stepper CLA 2010-01-06 07:17:35 EST
The tests patch looks okay, too. BUT you need to regenerate model4 because I just committed some changes to it. Regeneration must always be followed by "Organize Imports" and "Format Sources" of the whole project!

After that you may commit everything ;-)
Comment 28 Martin Fluegge CLA 2010-01-08 15:24:30 EST
Committed to HEAD.
Comment 29 Martin Fluegge CLA 2010-01-09 04:25:35 EST
Committed to HEAD (again).

sorry, I uploaded Legacy Path v5 and not the v6. Now the extended version is checked in.
Comment 30 Tom Crockett CLA 2010-02-09 14:31:33 EST
How is this coming along? This is a much-anticipated feature for us.
Comment 31 Martin Fluegge CLA 2010-02-09 15:16:56 EST
Hi Tom,

we expect to finish the legacy mode in no more than 2-3 month. Please note that legacy will have some drawbacks compared to the native approach:

 - not designed for scalability 
 - due to it?s nature it is a bit slower than the native approach.
 - It has a higher memory footprint. The footprint is even higher than the one of pure EMF objects
Comment 32 Eike Stepper CLA 2010-03-31 04:14:34 EDT
Created attachment 163497 [details]
LegacyAdapter Patch v7 - ready to be committed
Comment 33 Eike Stepper CLA 2010-03-31 04:18:34 EDT
Created attachment 163499 [details]
LegacyAdapter Patch v7 - ready to be committed

Previous patch was corrupted!
Comment 34 Martin Fluegge CLA 2010-03-31 09:49:00 EDT
Committed to HEAD.
Comment 35 Martin Fluegge CLA 2010-04-03 15:22:35 EDT
Legacy Mode is now released.
Comment 36 Eike Stepper CLA 2010-05-08 05:26:25 EDT
Example:

    // Enable legacy support from now on for all views that will be opened by this thread
    CDOUtil.setLegacyModeDefault(true);

    CDOView view = session.openView();
    System.out.println("Legacy model support: " + view.isLegacyModeEnabled());
Comment 37 Eike Stepper CLA 2010-06-29 04:39:58 EDT
Available in 3.0 GA:
http://download.eclipse.org/modeling/emf/cdo/updates/3.0-releases/