Community
Participate
Working Groups
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.
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.
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.
Created attachment 183038 [details] Removes IDisposable The patch removes previosuly deprecated IDisposable and RunAndTrack#disposed().
Patch applied to CVS Head.