java.lang.Object
com.telenav.kivakit.configuration.lookup.Registry
The
Registry
class allows code to register and locate objects by class and instance (if there is more than
one instance). The methods register(Object)
and register(Object, Enum)
are used to install an
object in the lookup and lookup(Class)
and lookup(Class, Enum)
are used to find an object that has
been registered.
Example
In this example, the initialize() method and the doit() method may be in different classes or packages. The doit()
method can find the WEB instance of the Server class using lookup(Class, Enum)
enum Servers { WEB, TRAFFIC, MAP } void initialize() { Registry.of(this).register(new Server(), WEB); } [...] void doit() { var server = Registry.of(this).lookup(Server.class, WEB); [...] }
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> T
<T> T
lookup(Class<T> type, InstanceIdentifier instance)
<T> T
<T> T
static Registry
<T> T
register(T object)
Registers the given singleton object in the lookup<T> T
register(T object, InstanceIdentifier instance)
Registers the specified instance of the given object's type in the lookup<T> T
Registers the specified instance of the given object's type in the lookup<T> T
Registers the specified instance of the given object's type in the lookup
-
Constructor Details
-
Registry
public Registry()
-
-
Method Details
-
of
- Returns:
- The lookup for the given object
-
lookup
- Returns:
- Any registered object of the given type
-
lookup
- Returns:
- Any registered object of the given type with the given instance identifier
-
lookup
- Returns:
- Any registered object of the given type with the given instance identifier
-
register
public <T> T register(T object)Registers the given singleton object in the lookup -
register
Registers the specified instance of the given object's type in the lookup -
register
Registers the specified instance of the given object's type in the lookup
-