Skip to content

Get service from service registry with dependency injection? #3200

@gel-hidden

Description

@gel-hidden

Lets say I populate the ServiceRegistry with some class and have a MVC controller like so:

@Path("/my-controller")
@Module
class MyController @Inject constructor(private val myService: MySerivce) {

    @GET
    fun helloWorld(ctx: Context): String {
        val serviceFromRegistry = ctx.require(ServiceFromRegistry::class.java, "serviceFromRegistry")
        ...
    }
}

Do I always need to use the contxt to get my service from the registry (ServiceFromRegistry)? Or is it possible to use guice as with the other service (MyService)?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions