Hi everyone,
My name is Carlos Chacin and I started to use MicroProfile a few months ago. I’m doing some code generation based on OpenAPI Specs, which creates interfaces with all the JAX-RS annotations, so after implementing the interface we don’t have to add any JAX-RS annotations to the methods but only worry about the business logic and implementation details.
This works pretty well with JAX-RS, but I tried to do something similar with the MicroProfile Metrics without success and I wanted to discuss here with all of you about if makes sense that the same JAX-RS behavior should be applied to the metrics specification/implementation.
There is a GitHub issue with some details but I’m happy to provide an example project to reproduce the behavior if required: #451
@Timed(name = "GET_pet/{petId}", absolute = true, unit = MetricUnits.NANOSECONDS, displayName = "getPetById", reusable = false, tags = {"action=PetApi.getPetById"}, description = "Find pet by ID")
@GET
@Path("pet/{petId}")
@Produces({ "application/xml", "application/json" })
CompletionStage<Response> getPetById(
@BeanParam GetPetByIdParams params
) throws javax.ws.rs.WebApplicationException;
public class PetResource implements PetApi {
@Override
public CompletionStage<Response> getPetById(
GetPetByIdParams params
) throws WebApplicationException {
return CompletableFuture.supplyAsync(() -> Response.ok("[]").build());
}
}
$ curl http://host:port/pet/1
application_GET_pet/{petId}
NOT METRIC GENERATED
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
bean-discovery-mode="all">
</beans>
@ApplicationPath("/")
public class JAXRSConfiguration extends Application {
}
So you are essentially asking if the interface definition of the method could be checked in addition to the implementation definition of the method.
I’m wondering if that could be expensive at runtime, having to check all those interfaces via reflection. What if there was some kind of maven plugin that could copy the annotations from the interface to the implementation?
Alasdair
> On Oct 1, 2019, at 1:41 PM, Carlos Chacín <cch...@gmail.com> wrote:
>
> S behavior should be
--
You received this message because you are subscribed to the Google Groups "Eclipse MicroProfile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to microprofile...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/1F81141A-C830-4A84-9DD6-3C69D42E873D%40gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/CAN5ya5x6C%3DUpAeF7qMG0abywA0R-FUVFQ%2BUQCMzhAPc0Bmk4aA%40mail.gmail.com.
I think it makes sense to support interfaces.With all annotations, it becomes harder and harder to find the business code in the middle. Most people like Carlos tend to extract all this into an interface acting as a contract. It also makes it possible to create a client jar with model and interfaces and use it for the rest client for instance.I don't think it would be much more expensive. Most specifications like openapi already does that. This is done at deploy time in a CDI Extension usually, and not at runtime.
On Tue, Oct 8, 2019 at 2:28 AM Carlos Chacín <cch...@gmail.com> wrote:
Thanks for reviewing this Alasdair,
On Mon, Oct 7, 2019 at 8:31 AM Alasdair Nottingham <alasdair....@gmail.com> wrote:So you are essentially asking if the interface definition of the method could be checked in addition to the implementation definition of the method.^^ Yes, alá JAX-RS, were the implementation scan the classes and interfaces boot-time and it performs validations as well.
I’m wondering if that could be expensive at runtime, having to check all those interfaces via reflection. What if there was some kind of maven plugin that could copy the annotations from the interface to the implementation?
Alasdair
> On Oct 1, 2019, at 1:41 PM, Carlos Chacín <cch...@gmail.com> wrote:
>
> S behavior should be
--
You received this message because you are subscribed to the Google Groups "Eclipse MicroProfile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to microp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/1F81141A-C830-4A84-9DD6-3C69D42E873D%40gmail.com.
--Carlos ChacinSenior SDE
--
You received this message because you are subscribed to the Google Groups "Eclipse MicroProfile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to microp...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to microprofile...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/6aed99eb-7cc5-47d8-9995-f1936312bfe5%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/6aed99eb-7cc5-47d8-9995-f1936312bfe5%40googlegroups.com.