Bug 317595 Add ability to uninject without specific context
The common pattern for use contexts with UI is: - get a parent context - create a local context parented of the parent context - add some one-time use values in the local context - #make() an object using the local context The problem comes at the end of the life cycle: the local context is not stored and therefore we can't use #uninject(object, localContext). Possible solutions: 1) Add a variable to the object: @Inject IEclipseContext localContext; and use it to dispose the local context, severing links between the parent context, local context, and the object Pros: can be done with no changes to the framework Cons: a new field has to be added to every affected class 2) Keep a map of all contexts injected into the object and add a method static #getInjectedContext() which would return the local context used in #make() and can be used to uninject Cons: memory and performance impact - having a table and that lists all contexts and all injected objects and having to search through them on every context disposal scares me. 3) Create a new #make() / #inject() method that would take two contexts: dynamic and static, the parent context being used as dynamic and local context used as static. localContext = EclipseContextFactory.create(); object = ContextInjectionFactory.make(parentContext, localContext); and then call #uninject(object, parentContext) as there will be no ties established to the local context. Cons: it is RC1 and this will be a substantial change. ---- I'll try (3) to see the impact of changes and if that turns out to be too much at this point, I'll do (2) for the initial release.
bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ReflectionContributionFactory.java
private IExtensionRegistry registry;
	private Map<String, Object> languages;
	/**
	 * Create a reflection factory.
	 * 
	 * @param registry
	 *            to read languages.
	 */
	public ReflectionContributionFactory(IExtensionRegistry registry) {
		this.registry = registry;
		processLanguages();
	}
	public Object create(String uriString, IEclipseContext context) {
		if (uriString == null) {
			return null;
		}
		URI uri = URI.createURI(uriString);
		Bundle bundle = getBundle(uri);
		Object contribution;
		if (bundle != null) {
			contribution = createFromBundle(bundle, context, uri);
		} else {
			contribution = null;
			Activator.log(LogService.LOG_ERROR, "Unable to retrive the bundle from the URI: " 
					+ uriString);
		}
		return contribution;
	}
	protected Object createFromBundle(Bundle bundle, IEclipseContext context, URI uri) {
		Object contribution;