The best way to expose business logic to reassuring services through @Inject

I read a lot on this topic about SO and the Internet, but there seem to be problems when working with old posts ...

I want to expose my EJB business logic for resting api / embed ejb into a jersey resource.

Using @EJB works fine, but there are people suggesting not using @EJB for local beans.

There are various methods for entering beans in services using @Inject. The easiest (for me) seems to be the following:

@RequestScoped // This line is important!
@Path("service")
    public class Rest {

    @Inject Bean beany;

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String get () {
        return beany.saySomething();
    }

}

Resource annotation since cdi is doing the job.

This discussion helped me solve the problem, but also contains problems (behavior not specified). I would like to know if the situation has become clearer.

I use libraries sent using glass fish 4.

JEE-7? .

!

+4
1

(+1), Java EE 7 , SO . , . , , POJO @Stateless -preferred SOA - @Stateful, ... ?.

-, , phisolophy REST CRUD (: get, post, put, delete), ejb - ( Session Facade), ( , Asynchronous, Message Driven Beans ..).

, EJB - , , , - , , RMI, CDI POJOS. EJB @Inject, , EJB!. ?... . - , @Inject, , beans JSF-.

+1

Source: https://habr.com/ru/post/1523803/


All Articles