1 Reply Latest reply on Nov 27, 2001 12:45 AM by Fusayuki Minamoto

    Stateful session bean is not necessary?

    IPOz Newbie

      I am not very clean about stateful session bean.I feel the java bean is enough to hold session information.
      In my application i use
      Jsp+JavaBeans+[stateless session bean + BMP Entity Bean].And it does work fine.

      What suffix is appropriate for a session EJB? i have used the following suffix to name classes:

      xxxBean : a JavaBean
      xxxCMP ; a container management persistence entity -------------bean
      xxxBMP : a bean management persistence entity bean -------------and derived from its corresponding CMP
      xxxDAO : a data access object
      xxxEJB : a stateless session bean(it is not a good -------------name :( )

      Any suggestions are appreciated!

        • 1. Re: Stateful session bean is not necessary?
          Fusayuki Minamoto Apprentice

          When you use a stateful session bean, you can take advantage of EJB features:

          1) Session beans are distributed objects
          While only servlets/JSPs can access session objects in a web container, normal Java clients can access session beans.
          If the EJB server supports RMI-IIOP, even C++ client can access EJBs.

          2) Session beans can control transaction demarcation
          We can change transactional behavior of the stateful session bean without changing the source.
          You just change the ejb-jar.xml. Even if you can implement listAll() method of JavaBeans + UserTransaction,
          it will not be flexible like EJB.

          3) Stateful session beans can implement SessionSynchronization interface.
          It supports usuful callback methods: afterBegin, beforeCompletion and afterCompletion.
          You can do something for your application at the end of the transaction.