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

Bug 329266

Summary: Deprecate and remove IDisposable
Product: z_Archived Reporter: Oleg Besedin <ob1.eclipse>
Component: E4Assignee: Project Inbox <e4.runtime-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ob1.eclipse
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Patch - removes uses of IDisposable from SDK and deprecates it
none
Removes IDisposable none

Description Oleg Besedin CLA 2010-11-02 11:04:28 EDT
IDisposable interface duplicates functionality provided by the "@PreDestory" annotation.

Those were the reasons for IDisposable: 
1) try to hide "control" of the IEclipseContext;
2) provide alternative path to using annotations;
3) provide general placeholder for #dispose() method.

Those no longer apply:
1) try to hide "control" of the IEclipseContext;
 - Instead, the dependency injection hides contexts alltogether, unless developer needs the context.
2) provide alternative path to using annotations;
 - After much headache we decided that annotations are needed to make context dependency injection work; the approaches based on method/field names were too complicated to be useful.
3) provide general placeholder for #dispose() method.
 - This is done (and in more general manner) via "@PreDestroy" annotation.

Hence, this enhancement request is to deprecate and remove IDisposable.
Comment 1 Oleg Besedin CLA 2010-11-02 11:09:16 EDT
Created attachment 182217 [details]
Patch - removes uses of IDisposable from SDK and deprecates it

One other issue with having IDisposable: IEclipseContext inherits from IDisposable which comes from the DI bundle. So, even if DI is not used directly, the bundle needs to be included in the dependencies and the error message is a bit cryptic.

The attached patch removes uses of IDisposable from SDK and deprecates it.

Most uses are trivial typecasts that no longer needed; they were in a need of cleanup regardless of this change:

		((IDisposable) context).dispose();
and
		if (appContext instanceof IDisposable) {
			((IDisposable) appContext).dispose();
		}

weren't needed.

A few non-trivial uses of IDisposable are replaced with "@PreDestroy". I also added #dispose() to the ILookupStrategy. (Note that ILookupStrategy itself is internal and likely be removed.)

Added #dispose() method to IEclipseContext.
Comment 2 Oleg Besedin CLA 2010-11-02 11:11:51 EDT
Patch applied to CVS Head.

I am keeping the bug open to remove now-deprecated IDisposable by the end of 4.1M4.

If your code uses IDisposable:

- The IEclipseContext includes {@link #dispose()} method in its definition, not type conversion or checking is needed; and 
- For injected objects, consider using the "PreDestroy" annotation instead.
Comment 3 Oleg Besedin CLA 2010-11-12 15:11:37 EST
Created attachment 183038 [details]
Removes IDisposable

The patch removes previosuly deprecated IDisposable and RunAndTrack#disposed().
Comment 4 Oleg Besedin CLA 2010-11-12 15:12:34 EST
Patch applied to CVS Head.