JAX-RS Controllers or Resources compared to Spring MVC

Asked

Viewed 30 times

2

I came from Spring and I’m having a hard time understanding how JAX-RS works in a Java EE application. I have an application running on a Wildfly application server. I created a class to use JAX-RS called Schedulemapilcontroller. It basically has a GET method that lists my emails and returns in JSON form.

@Path("emails")
public class AgendamentoEmailController {

@Inject
private AgendamentoEmailServico agendamentoEmailServico;

@GET
@Produces(value = MediaType.APPLICATION_JSON)
public Response listar() {
    return Response.ok(agendamentoEmailServico.listar()).build();
}

I also created a class to extend Application:

@ApplicationPath("/")
public class AgendamentoEmailApplication extends Application {

}

In my studies, it has been said that these classes, such as the Scheduling Controller that have the actions, are commonly called Controllers or Resources. Then came the doubts I couldn’t clear up:

1 - Are each of these JAX-RS classes a Servlet? Even if it doesn’t implement or extend or implement anything referring to a Servlet? I believe so, but the doubt came because of this nomenclature of controllers. In Spring MVC the controllers are not Servlets, there is a central controller with a Servlet Dispatcher that calls our controllers that have the actions.

2 - In JAVA EE along with JAX-RS has some technology that works with a Dispatcher Servlet equal to the Spring MVC that has its central controller, ie a single Servlet?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.