Bug 309698 Disposing parent context does not cause objects injected by a child context to be destroyed
The test below fails. static class Target { int pc = 0; int pd = 0; @Inject @Named("o") Object o; @PostConstruct void pc() { pc++; } @PreDestroy void pd() { pd++; } } public void testV() { IEclipseContext context = EclipseContextFactory.create(); IEclipseContext child = EclipseContextFactory.create(context, null); child.set("o", new Object()); Target target = (Target) ContextInjectionFactory.make(Target.class, child); assertEquals(1, target.pc); ((IDisposable) context).dispose(); assertEquals(1, target.pd); }
bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/E4Application.java
} catch (IOException e) {
			
			e.printStackTrace();
		}
	}
	public E4Workbench createE4Workbench(IApplicationContext applicationContext) {
		args = (String[]) applicationContext.getArguments().get(
				IApplicationContext.APPLICATION_ARGS);
		IEclipseContext appContext = createDefaultContext();
		
		
		String lifeCycleURI = getArgValue(E4Workbench.LIFE_CYCLE_URI_ARG,
				applicationContext);
		Object lcManager = null;
		if (lifeCycleURI != null) {
			IContributionFactory factory = (IContributionFactory) appContext
					.get(IContributionFactory.class.getName());
			lcManager = factory.create(lifeCycleURI, appContext);
			if (lcManager != null) {
				
				factory.call(lcManager, null, "postContextCreate", appContext,
						null);
			}
		}
		
		MApplication appModel = loadApplicationModel(applicationContext,
				appContext);
		appModel.setContext(appContext);