Package pl.morgwai.base.guice.scopes

Classes for building Guice Scopes, that get automatically transferred when dispatching work to other threads.

Code organization guidelines for deriving libs:

Deriving libs should usually define their "central class" extending Module containing the following:

  • instances of ContextTrackers for all defined TrackableContext subclasses
  • instances of corresponding ContextScopes
  • List<ContextTracker<?>> allTrackers instance var containing all the above ContextTracker instances
  • ContextBinder contextBinder = new ContextBinder(allTrackers) instance var
  • getActiveContexts() method returning ContextTracker.getActiveContexts(allTrackers)
  • configure(binder) method that creates the following bindings:
    • List<ContextTracker<?>> to allTrackers
    • ContextBinder to contextBinder
    • Their respective types to the defined ContextTracker instances
    • Their respective types to Providers of the defined Context instances, usually defined similarly to 1 of the below:
      • for TrackableContexts: respectiveTrackerInstance::getCurrentContext
      • for induced InjectionContexts: () -> inducingContextTracker.getCurrentContext().getRespectiveInducedContext()
See Also:
project homepage