dropwizard-guicey icon indicating copy to clipboard operation
dropwizard-guicey copied to clipboard

Registering a Jersey ModelProcessor

Open muliyul opened this issue 4 years ago • 2 comments

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).

muliyul avatar Oct 31 '21 14:10 muliyul

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.

xvik avatar Oct 31 '21 18:10 xvik

A similar workaround worked for me (remove class annotations and register it in jersey environment).

muliyul avatar Nov 02 '21 08:11 muliyul