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
}
		return contribution;
	}
	protected void processLanguages() {
		languages = new HashMap<String, Object>();
		String extId = "org.eclipse.e4.languages"; 
		IConfigurationElement[] languageElements = registry.getConfigurationElementsFor(extId);
		for (int i = 0; i < languageElements.length; i++) {
			IConfigurationElement languageElement = languageElements[i];
			try {
				languages.put(languageElement.getAttribute("name"), 
						languageElement.createExecutableExtension("contributionFactory")); 
			} catch (InvalidRegistryObjectException e) {
				
				e.printStackTrace();
			} catch (CoreException e) {
				
				e.printStackTrace();
			}
		}
	}
	protected Bundle getBundle(URI platformURI) {
		return Activator.getDefault().getBundleForName(platformURI.segment(1));
	}
	public Bundle getBundle(String uriString) {
		URI uri = URI.createURI(uriString);
		return getBundle(uri);
	}
}