In my web project, I have these components:
EJB
annotated classUserService
EJB
annotated classUserDAOImpl
SessionScoped
Managed Bean
calledUserStateBean
ViewScoped
ManagedBean
calledAdminDashboardView
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
EJB
classes stateless? (Haven't used any annotation above it, except for@EJB
) If not, should they be? - At the
AdminDashboardView
, I need to access theUserService
EJB
. 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?