Skip to content

registry: Allow to bind List/Set/Map #3660

@jknack

Description

@jknack
{
// 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());

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions