In my web project, I have these components:
EJBannotated classUserServiceEJBannotated classUserDAOImplSessionScopedManaged BeancalledUserStateBeanViewScopedManagedBeancalledAdminDashboardView
The EJB UserService, is created at the init method (that is annotated with PostConstruct) of the UserStateBean and the UserDAOImpl is created at the init method of UserService, likewise.
Questions:
- Are these
EJBclasses stateless? (Haven't used any annotation above it, except for@EJB) If not, should they be? - At the
AdminDashboardView, I need to access theUserServiceEJB. Which is the proper way of doing that?
What I've already tried for (2):
At the AdminDashboardView, I declared it as a member, like this:
@EJB
private UserService userService;
At the init function I have this: userService = new UserService();.
This worked just fine, and succeeded with what I wanted to do, but, is this the correct way of doing that?
My thoughts on this, is that it could be correct, as the new instance of the UserService EJB I get, is from a pool that the container has (source). Is this correct?