RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:9:30-18:00
你可能遇到了下面的问题
关闭右侧工具栏
SCEA之路--6. Enterprise JavaBeans
  • 作者:zhaozj
  • 发表时间:2020-12-23 10:55
  • 来源:未知

Each EJB session and entity bean must have the following classes and interfaces:• Home (EJBHome) interface• Remote (EJBObject) interface• XML deployment descriptor• Bean class• Context objects

Home (EJBHome) InterfaceThe EJBHome object provides the lifecycle operations (create(), remove(), find()) for an EJB.

Remote (EJBObject) InterfaceThe remote (EJBObject) interface provides access to the business methods within the EJB. An EJBObject represents a client view of the EJB.

XML Deployment DescriptorThe deployment descriptor is an XML (Extensible Markup Language) file provided with each module and application that describes how the parts of a J2EE application should be deployed. The deployment descriptor configures specific container options in your deployment tool of choice.

Business Logic (Bean) ClassThe bean class is developed by the bean developer and contains the implementation and the methods defined in the remote interface.

Context Objects for Session and EntityFor each active EJB instance, the EJB container generates an instance context object to maintain information about the management rules and the current state of the instance.

Distinguish Between Session and Entity BeansA session bean is an EJB that is created by a client and usually exists only for the duration of a single client-server session. A session bean usually performs operations such as calculations or database access on behalf of the client.An entity bean is an object representation of persistent data maintained in a permanent data store such as a database.

When to Use Entity and Session JavaBeans• Use entity beans to persist data. An entity bean is a sharable enterprise data resource that can be accessed and updated by multiple users.• Use stateful session beans when any one of the following conditions is true; otherwise use stateless session beans:  • The session bean must retain data in its member variables across method invocations.  • The state of the bean needs to be initialized when the session bean is instantiated.  • The session bean must retain information about the client across multiple method invocations.  • The session bean is servicing an interactive client whose presence must be known to the applications server or EJB container.

Stateful vs. Stateless Session BeansA stateful session bean will maintain a conversational state with a client. The state of the session is maintained for the duration of the conversation between the client and the stateful session bean.A stateless session bean will not maintain conversational states for specific clients longer than the period of an individual method invocation.

Stateless session bean has more beneficial attributes• Bean pooling Any stateless session bean method instance that is not currently invoked is equally available to be called by an EJB container or application server to service the request of a client. This allows the EJB container to pool stateless bean instances and increase performance.• Scalability Because stateless session beans are able to service multiple clients, they tend to be more scalable when applications have a large number of clients. When compared to stateful session beans, stateless session beans usually require less instantiation.• Performance An EJB container will never move a stateless session bean from RAM out to a secondary storage, which it may do with a stateful session bean; therefore, stateless session beans may offer greater performance than stateful session beans.