Stateless and Stateful Enterprise Java Beans

后端 未结 7 2082
我在风中等你
我在风中等你 2020-11-28 17:52

I am going through the Java EE 6 tutorial and I am trying to understand the difference between stateless and stateful session beans. If stateless session beans do not retain

7条回答
  •  生来不讨喜
    2020-11-28 18:12

    The major differences between the two major types of session beans are:

    Stateless Beans

    1. Stateless Session Beans are the ones which have no conversational state with the client which has called its methods. For this reason they can create a pool of objects which can be used to interact with multiple clients.
    2. Performance wise stateless beans are better since they don't have states per client.
    3. They can handle multiple requests from multiple clients in parallel.

    Stateful Beans

    1. Stateful session beans can maintain the conversational state with multiple clients at a time and the task is not shared between the clients.
    2. After the session is completed the state is not retained.
    3. The container can serialize and store the state as a stale state for future use. This is done to save resources of the application server and to support bean failures.

提交回复
热议问题