package planning
- Alphabetic
- Public
- All
Package Members
- package extensions
- package gc
Type Members
- class AssignableFromAutoSetHook[INSTANCE, BINDING] extends PlanningHook
A hook that will collect all implementations with types that are
A hook that will collect all implementations with types that are
_ <: T
into a
Set[T]
set binding available for summoningUsage:
val collectCloseables = new AssignableFromAutoSetHook[AutoCloseable, AutoCloseable](identity) val injector = Injector(new BootstrapModuleDef { many[PlanningHook] .add(collectCloseables) })
Then, in any class created from
injector
:class App(allCloseables: Set[AutoCloseable]) { ... }
These Auto-Sets can be used to implement custom lifetimes:
val locator = injector.produce(modules) val closeables = locator.get[Set[AutoCloseable]] try { locator.get[App].runMain() } finally { // reverse closeables list, Auto-Sets preserve order, in the order of *initialization* // Therefore resources should closed in the *opposite order* // e.g. if C depends on B depends on A, create: A -> B -> C, close: C -> B -> A closeables.reverse.foreach(_.close()) }
Auto-Sets are NOT subject to Garbage Collection, they are assembled *after* garbage collection is done, as such they can't contain garbage by construction.
_ <: T }}} available for summoning
Usage:
val collectCloseables = new AssignableFromAutoSetHook[AutoCloseable, AutoCloseable](identity) val injector = Injector(new BootstrapModuleDef { many[PlanningHook] .add(collectCloseables) })
Then, in any class created from
injector
:class App(allCloseables: Set[AutoCloseable]) { ... }
These Auto-Sets can be used to implement custom lifetimes:
val locator = injector.produce(modules) val closeables = locator.get[Set[AutoCloseable]] try { locator.get[App].runMain() } finally { // reverse closeables list, Auto-Sets preserve order, in the order of *initialization* // Therefore resources should closed in the *opposite order* // e.g. if C depends on B depends on A, create: A -> B -> C, close: C -> B -> A closeables.reverse.foreach(_.close()) }
Auto-Sets are NOT subject to Garbage Collection, they are assembled *after* garbage collection is done, as such they can't contain garbage by construction.
- abstract class AutoSetModule extends BootstrapModuleDef
Auto-Sets collect all bindings with static types <:
T
into a summonableSet[T]
Auto-Sets collect all bindings with static types <:
T
into a summonableSet[T]
- See also
same concept in MacWire: https://github.com/softwaremill/macwire#multi-wiring-wireset
- trait BindingTranslator extends AnyRef
- class BindingTranslatorImpl extends BindingTranslator
- class ForwardingRefResolverDefaultImpl extends ForwardingRefResolver
- class PlanAnalyzerDefaultImpl extends PlanAnalyzer
- class PlanMergingPolicyDefaultImpl extends PlanMergingPolicy with WithResolve
- final class PlannerDefaultImpl extends Planner
- final class PlanningHookAggregate extends PlanningHook
- final class PlanningObserverAggregate extends PlanningObserver
- class SanityCheckerDefaultImpl extends SanityChecker
Value Members
- object AutoSetModule