Usage of META-INF/Services ?

613 views
Skip to first unread message

Leonel Gayard

unread,
Feb 2, 2021, 9:58:01 AM2/2/21
to Quarkus Development mailing list
I am updating an application from pre-historic Quarkus 1.2 to modern 1.11.1

This app has a requirement to respond to the HTTP header Content-Type for "text/csv" using the CSV format.

This was done with Jackson's jackson-dataformat-csv

In order to achieve CSV in Quarkus 1.2, we had added a new Jax-RS Provider. The way to do that in 1.2 was to add an entry with the class name in the file META-INF/services/javax.ws.rs.ext.Providers

Back in 1.2, I was surprised about this file, because I expected it to be similar to the Java ServiceLoader mechanism ; that is, the class implements the interface with the same name of the file. In this case, the file has the name javax.ws.rs.ext.Providers, so the class should implement this interface.

But no. To make it work in Quarkus 1.2, the class implements the interface javax.ws.rs.ext.MessageBodyWriter instead.

Fast forward to Quarkus 1.11.1, and the file in META-INF/services is no longer needed. I can simply annotate the class with @javax.ws.rs.ext.Provider and it is discovered at runtime.

My questions:
  1. Are files in directory META-INF/services regarded? When is it scanned by the runtime?
  2. What about annotation @Provider? Is there a spec on how to use it, and does Quarkus deviate from that?
Thanks and regards,



Georgios Andrianakis

unread,
Feb 2, 2021, 10:03:54 AM2/2/21
to leonel...@gmail.com, Quarkus Development mailing list
META-INF/services work as expected. META-INF/services/javax.ws.rs.ext.Providers is indeed a little unique in that it looks like a Java ServiceProvider file but not being one.
 
  1. What about annotation @Provider? Is there a spec on how to use it, and does Quarkus deviate from that?

@Provider annotations are found at build time and corresponding classes registered as Providers with RESTEasy
 
Thanks and regards,



--
You received this message because you are subscribed to the Google Groups "Quarkus Development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quarkus-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/02533dd8-5f4f-44d0-9559-4db5a6be7224n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages