Interface | Description |
---|---|
OD.Binding |
Binding of (type,tags)->supplier.
|
OD.Predicate<T> |
Similar to Predicate
in Java 8.
|
OD.Supplier<T> |
Similar to Supplier
in Java 8.
|
Class | Description |
---|---|
OD |
A Service Locator library.
|
OD.BindingBuilder<T> |
Builder for creating bindings.
|
OD.Local |
Thread-local bindings.
|
Exception | Description |
---|---|
OD.NotFoundException |
Binding is not found for (type,tags).
|
This library contains bind and lookup operations, based on (type,tags). For example
OD.bind(Foo.class).to(foo); ... OD.get(Foo.class); // lookup
There is a global binding list, which is totally ordered; multiple bindings may match a lookup, the latest binding has priority.
Each thread also contains a local binding list; local bindings are only visible to lookups in the same thread. Local bindings have priority over global bindings.
OD.Local.bind(Foo.class).to(foo2); // later in the same thread OD.get(Foo.class); // sees `foo2`
Type in (type,tags) can be generic; see ClassType
.
Tags in (type,tags) can be arbitrary objects, including `null`. For example
OD.bind(Foo.class).tags("x", 1).to(x1); OD.get(Foo.class, "x", 1); // sees `x1`