I want to know if I can use classes annotated with @RequestScoped
instead of @Stateless
to write my business logic.
I have some EJBs
which have some business logic and no database code. The only reason I declared it as an EJB
is to take advantage of interceptors
. Since there is no need for transaction management, I think declaring it as @RequestScoped
will make more sense.
Can anyone please suggest.
Use @Named
and @RequestScoped
if u want to program your business logic depend on the single HTTP request (An object which is defined as @RequestScoped
is created once for every request and is shared by all the bean that inject it throughout a request). But in the case of UserTransaction
,Datasource
,thread safety and inceptor will be an issue then stick with @stateless
.