-
-
Notifications
You must be signed in to change notification settings - Fork 202
Closed
Milestone
Description
{
// Some extension
install(application -> {
var services = application.getServices();
services.listOf(Animal.class).add(new Cat());
});
// From another extension
install(application -> {
var services = application.getServices();
// [Cat, Dog]
services.listOf(Animal.class).add(new Dog());
});
}Access from registry:
{
get("/animals", ctx -> {
return ctx.require(Reified.list(Animal.class));
});
}Access from dependency injection Guice/Avaje
class Animals {
@Inject
public(List<Animal> animals) {
// [Cat, Dog]
}
}Same logic applies for set or map:
var services = application.getServices();
// Set
services.setOf(Animal.class).add(new Dog());
// Map
services.mapOf(String.class, Animal.class).put("dog", new Dog());