Bug 458033 - Make it easier to locate the Root-IEclipseContext for an application
Summary: Make it easier to locate the Root-IEclipseContext for an application
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Runtime (show other bugs)
Version: 4.4   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: 4.6 M4   Edit
Assignee: Lars Vogel CLA
QA Contact:
URL:
Whiteboard:
Keywords: noteworthy
Depends on:
Blocks:
 
Reported: 2015-01-21 07:43 EST by Thomas Schindl CLA
Modified: 2015-11-19 15:52 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Schindl CLA 2015-01-21 07:43:47 EST
Generally the context hierarchy in DI application who use Eclipse DI is:

IEclipseContext (EclipseContextOSGi)
  + IEclipseContext (the one bound to MApplication)

In a multi user env
IEclipseContext (EclipseContextOSGi)
  + IEclipseContext (the one bound to MApplication)
  + IEclipseContext (the one bound to MApplication)
  + ...

Now one can easily retrieve what I call "ApplicationContext" using context.get(MApplication.class).getContext() which has the draw back that one has to have an dependency on the application model which is totally unnecessary

Having access to this information is required to fix bug 458029
Comment 1 Lars Vogel CLA 2015-01-21 07:46:08 EST
+1
Comment 2 Thomas Schindl CLA 2015-01-21 15:54:12 EST
gerrit review https://git.eclipse.org/r/40069
Comment 3 Thomas Schindl CLA 2015-01-21 15:58:34 EST
The patch simply introduces a constant so one can now write

@Inject
@Named(IEclipseContext.APPLICATION_CONTEXT_KEY)
IEclipseContext context;

and one gets the context the application bootstrap code has identified as the the application context.

The following review fixes this for SWT e4 application including the Eclipse IDE
https://git.eclipse.org/r/40071
Comment 4 Paul Webster CLA 2015-01-21 16:03:21 EST
(In reply to Thomas Schindl from comment #3)
> The patch simply introduces a constant so one can now write
> 
> @Inject
> @Named(IEclipseContext.APPLICATION_CONTEXT_KEY)
> IEclipseContext context;

This probably wouldn't be at the IEclipseContext level, but the E4Application level.

PW
Comment 5 Thomas Schindl CLA 2015-01-21 16:16:57 EST
If it would be "E4Application" this would work only in an e4 application - I want to have access to this without:
a) adding dependency to E4Application
b) make use of this in NONE E4Applications where I use Eclipse DI
Comment 6 Lars Vogel CLA 2015-03-16 07:13:02 EDT
(In reply to Thomas Schindl from comment #5)
> If it would be "E4Application" this would work only in an e4 application - I
> want to have access to this without:
> a) adding dependency to E4Application
> b) make use of this in NONE E4Applications where I use Eclipse DI

You can always define the key directly
Comment 7 Lars Vogel CLA 2015-04-08 17:58:28 EDT
Tom, are you planning to finish this in M7, or should be more the item to 4.6?
Comment 8 Lars Vogel CLA 2015-04-20 04:03:42 EDT
Tom, do you still plan to include that in 4.5? In this case you need to seek PMC approval.
Comment 9 Lars Vogel CLA 2015-04-23 21:59:35 EDT
(In reply to Lars Vogel from comment #8)
> Tom, do you still plan to include that in 4.5? In this case you need to seek
> PMC approval.

Having heard anything from Tom on this, so I move it to 4.6
Comment 10 Eclipse Genie CLA 2015-11-19 10:46:54 EST
New Gerrit change created: https://git.eclipse.org/r/60788
Comment 12 Lars Vogel CLA 2015-11-19 15:52:48 EST
.