3 Replies Latest reply on Jul 22, 2011 1:04 PM by Zak S

    Lifecycle\scope of Stateful Session Beans

    Ro Chap Newbie

      Hi,


      If I am not wrong, a SFSB stays dedicated to one client (i.e. session) during its life. This means that if a client updates the state of a SFSB in one request, it will be preserved during the subsequent requests.


      Now what about this managed SFSB:


      @Stateful
      @Model
      public class GreetingBean 
      {
              public String getGreeting()
              {
                      return "Hello world";
              }
      }



      On one hand, it's a SFSB so technically it should not be swapped between different requests in the same session. On the other hand it's @RequestScoped so we are declaring that a new instance should be created between different requests, hence it won't preserve its state during a session.


      Or is it possible to modify the lifecycle/scope of a SFSB in EJB 3.1, so by definition a session won't be necessarily tied to a particular instance of a SFSB anymore?


      Thanks in advance.