dropwizard-guicey
dropwizard-guicey copied to clipboard
Registering a Jersey ModelProcessor
How do I register a ModelProcessor using dropwizard-guicey?
@Provider
//@LazyBinding
class CoroutineModelProcessor @Inject constructor(
private val injectionManager: InjectionManager,
private val asyncContextProvider: javax.inject.Provider<AsyncContext>
) : ModelProcessor { ... }
As you can see I tried to use @LazyBinding but it didn't work (CoroutineModelProcessor was never instantiated).
ModelProcessor extension is not supported by guicey jersey installers, so the only way is to manually install it into jersey context in application run method:
environment.register(InjectorLookup.getInstance(this, CoroutineModelProcessor.class).get());
Normally it should be supported by the installer, so I'll mark this issue as enhancement and implement it in the next version.
A similar workaround worked for me (remove class annotations and register it in jersey environment).