For posterity:

1. Implement a Feature (or easier, extend AbstractFeature).
2. In the initialize(Bus) method, get the FactoryBeanListenerManager instance 
through bus.getExtension(FactoryBeanListenerManager.class).
3. Implement a FactoryBeanListener and register it through 
FactoryBeanListenerManager.addListener(FactoryBeanListener).
4. The FactoryBeanListener intercepts the Event.START_CREATE event, and from 
there you can manipulate the REST resource metadatas (i.e. 
JAXRSServiceFactoryBean.getClassResourceInfo() -> 
ClassResourceInfo.getMethodDispatcher().getOperationResourceInfos()).

On 2020/08/27 12:17:09, Maxence Dewil <[email protected]> wrote: 
> Hi,
> 
> I have developed a generic MessageBodyWriter<Object> that produces a tabular 
> view of my response body.
> if the request 'Accept' header is:
> - 'application/pdf' -> .pdf file
> - 'text/csv' -> .csv file
> - 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' -> 
> .xlsx file
> 
> So far so good.
> 
> My problem is that I don't want to add these 3 MIME types to the @Produces 
> annotation of all the endpoints that will offer this generic export.
> I would like to add these MIME types dynamically, for instance, based on a 
> URL pattern and/or HTTP Method.
> 
> DynamicFeature seemed to be a good fit, but I don't see how I can add MIME 
> types there..
> 

Reply via email to