Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Support JAX-RS #5
Conversation
|
Thanks @jlisam for adding me to the review You might want to consider rechecking the readme, there is a spot missing the jaxrs addition: I tried to add a comment on the PR but I cannot comment on any line (only where lines related to the diff happen |
plugin/src/main/java/com/flit/protoc/gen/server/jaxrs/RpcGenerator.java
Outdated
Show resolved
Hide resolved
plugin/src/main/java/com/flit/protoc/gen/server/jaxrs/RpcGenerator.java
Outdated
Show resolved
Hide resolved
.../jaxrs/src/main/java/com/flit/runtime/jaxrs/ProtobufMessageProvider.java
Outdated
Show resolved
Hide resolved
.../jaxrs/src/main/java/com/flit/runtime/jaxrs/ProtobufMessageProvider.java
Outdated
Show resolved
Hide resolved
.../jaxrs/src/test/java/com/flit/runtime/jaxrs/FlitExceptionMapperTest.java
Outdated
Show resolved
Hide resolved
|
This looks pretty legit to me, nice work. Let's get this merged and start getting some proto in fjord |
| import org.slf4j.LoggerFactory; | ||
|
|
||
| @Provider | ||
| public class FlitExceptionMapper implements ExceptionMapper<FlitException> { |
ShaneSaww
Aug 25, 2020
Do we still need these ExceptionMappers?
I know that we're going to need some ExceptionMapper fir Dropwizard, but does it still make sense to have them in Flit or have the app build them as needed?
I can see the InvalidProtobufExceptionMapper being useful, but Idk about the FlitExceptionMapper as the generate code doesn't throw any FlitExceptions.
Also does it make sense to put Dropwizard only code in flit now? I believe that the theExceptionMapper currently only work with Dropwizard as I don't see any @ExceptionHandler(... annotations for springboot.
jlisam
Aug 25, 2020
Author
Collaborator
@ShaneSaww I think we still need them. We could definitely move them over to fjord but the existing pattern is to declare the exception mappers for each server type (spring mvc, undertow and in this case jaxrs).
I can see the InvalidProtobufExceptionMapper being useful, but Idk about the FlitExceptionMapper as the generate code doesn't throw any FlitExceptions.
So the usefulness of these ExceptionMappers is to convert the FlitExceptions to the appropriate response. The application, in this case Fjord, would have to throw FlitException wrapping existing exceptions for this mapper to catch and convert to the response. In aqueduct, we actually wrap the exception to a FlitException here. The only difference is that Spring's exception handler covers both the mappers (Exception and InvalidProtocolException) in one class.
Also does it make sense to put Dropwizard only code in flit now? I believe that the theExceptionMapper currently only work with Dropwizard as I don't see any @ExceptionHandler(... annotations for springboot.
So if you look at the project outline, there are 3 packages under runtime:
- jaxrs
- spring
- undertow
ExceptionMapper is a JAX-RS concept and will work in any of the frameworks (dropwizard, spring, undertow) as long as you are using the JAX-RS library instead of like Spring Rest/MVC. The equivalent of the ExceptionMapper for spring is FlitExceptionHandler, which we currently use.
ShaneSaww
Aug 25, 2020
The application, in this case Fjord, would have to throw FlitException wrapping existing exceptions for this mapper to catch and convert to the response. In aqueduct, we actually wrap the exception to a FlitException here.
ohh, interesting. I fully didn't get that before. Just thinking about it, it makes some sense, but it's also a bit weird to me. It seems like a lot of work to get the correct response code(and error message) back to the client. But nothing we need to change right now.
So if you look at the project outline, there are 3 packages under runtime:
ExceptionMapper is a JAX-RS concept and will work in any of the frameworks (dropwizard, spring, undertow) as long as you are using the JAX-RS library instead of like Spring Rest/MVC. The equivalent of the ExceptionMapper for spring is FlitExceptionHandler, which we currently use.

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.


This PR implements a JAX-RS flavored Twirp RPC server generation. The PR also includes a JAX-RS runtime error mapper
as well as athat will allow reading and writing protobufs.ProtobufMessageProviderThe generated code can be used in both Spring MVC/Boot and Undertow servers as long as they use a JAX-RS implementation instead of relying on the framework specific controllers.
Example:
The above protobuf will generate the following JAX-RS flavored code: