Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added more details on the injector side of things

...

To a first degree, you can think of this structure as the following stack:

 

LevelInjector structure
Task
taskInjector = activeContextInjector.fork(taskConfiguration)
task = taskInjector.getInstance(Task.class)
ActiveContext
activeContextInjector = rootContextInjector.fork(contextConfiguration)
RootContext
rootContextInjector = Tang.newInjector(rootContextConfiguration)

This illustrates how objects and configuration from the lower contexts are shared with the upper contexts in the stack. We rely on Tang to make this happen. However, the above simplifies one core issue: When forking injectors in Tang, the same rules apply as when merging Configuration instances. Most crucially, one cannot override bindings already present in an Injector when forking it. This presents a problem with the above design: every context has its own (injectable) ID using the same named parameter. Hence, one of the fork calls above work. To circumvent this, we use two Configurations and Injectors: One that is local to this Context called ContextConfiguration and one that is shared with subsequent contexts called ServiceContext. In the stack above, this looks like this:

LevelCode on the DriverEvaluator side
Task
activeContext.submit(taskConfiguration)
taskInjector = activeContextInjector.fork(taskConfiguration)task = taskInjector.getInstance(Task.class)
ActiveContext
activeContext.submitContextAndService(contextConfiguration, serviceConfiguration)
activeServiceInjector = rootServiceInjector.fork(serviceConfiguration)
activeContextInjector = activeServiceInjector.fork(contextConfiguration)
RootContext
allocatedEvaluator.submitContextAndService(rootContextConfiguration, rootServiceConfiguration)
rootServiceInjector = Tang.newInjector(rootServiceConfiguration)
rootContextInjector = rootServiceInjector.fork(rootContextConfiguration)

Note that only the content of the ServiceInjector(s) is shared with downstream contexts.