Earn Money
Trading Forex Online
Paramount Airways
Free Data Recovery
Cargo
Job Portal
HSBC Investment
Management
Cheap Web Hosting
Make Trip
Cheap Air Travel
Leisure Hotel
Free Air Travel
Mutual Fund Informations
Cheapest Cellular Plan
Free Sexy Indians
Call Center Software
Hot Indian
|
Programming Help |
Homework Help |
Counseling
Astrology Advice |
Tarot Advice |
Parenting
Dating Advice |
Love Advice |
Divorce Advice
Legal Advice |
Debt Advice |
Career Advice
Enterprise Beans Tutorial
5
Stateful Session Beans
The state is retained for the duration of the client-bean session.
When the client removes the bean, the session ends and the state disappears.
This transient nature of the state is not a problem, however, because when the conversation between the
client and the bean is over there is no need to retain the state.
Stateless Session Beans
A stateless session bean does not maintain a conversational state for a particular client. When a client invokes the method of a stateless bean, the beans's instance variables may contain a state, but
only for the duration of the invocation.
When the method is finished, the state is no longer retained. Except during method invocation, all instances of a stateless bean are equivalent
, allowing the EJB
container to assign an instance to any client.
Because stateless session beans can support multiple clients, they can offer better scalability for applications
that require large numbers of clients.
Typically, an application requires fewer stateless session beans than stateful session beans to support the
same number of clients.
At times, the EJB container may write a stateful session bean out to secondary storage. However, stateless
session beans are never written out to secondary storage. Therefore, stateless beans may offer better performance
than stateful beans.
The home interface of a stateless session bean must have a single create method with no arguments.
The session bean class must contain one ejbCreate method, also without arguments. (The arguments are
only needed by stateful session beans, which use them to initialize their states.)
Choosing Between Stateful and Stateless Session Beans
consider using a stateful session bean if any of the following conditions are true:
The bean's state must be initialized when it is created. The bean needs to hold information about the client across method invocations. The client is an interactive application.
use stateless session beans:
·
The bean performs a task that is not tailored to the needs of a particular client. For example, you might use a stateless session bean to fetch from a database a commonly used set of data.
·
The bean doesn't need to hold information about the client across method invocations.
The Life Cycle of a Session Bean
·
The life cycle is managed by the EJB container, not by your applications.
The Stateful Session Bean Life Cycle
·
The client initiates the life cycle by invoking the create method.
·
The EJB container instantiates the bean and then invokes the setSessionContext and ejbCreate methods in the session bean. The bean is now ready to have its business methods invoked.
|
|
|
Earn Money
Trading Forex Online
Paramount Airways
Free Data Recovery
Cargo
Job Portal
HSBC Investment
Management
Cheap Web Hosting
Make Trip
Cheap Air Travel
Leisure Hotel
Free Air Travel
Mutual Fund Informations
Cheapest Cellular Plan
Free Sexy Indians
Call Center Software
Hot Indian
|