Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 329266 - Deprecate and remove IDisposable
Summary: Deprecate and remove IDisposable
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: E4 (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-02 11:04 EDT by Oleg Besedin CLA
Modified: 2012-12-13 15:00 EST (History)
1 user (show)

See Also:


Attachments
Patch - removes uses of IDisposable from SDK and deprecates it (55.93 KB, patch)
2010-11-02 11:09 EDT, Oleg Besedin CLA
no flags Details | Diff
Removes IDisposable (5.63 KB, patch)
2010-11-12 15:11 EST, Oleg Besedin CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.