Session Bean of EJB programming rules

Source: Internet
Author: User

 


-The Session Bean is used to implement commercial objects that contain specific commercial logic. It cannot directly represent the shared data in the database. The Session object state is non-persistent and does not need to be written to the DB. The Session Bean implements the Bean business logic, while the remote access security parallel and transactions and other shame Bean containers provide
2. Compile EJB rules:
(1) compile Enterprise Bean:
1. One or more ejbCreate methods may exist.
2. The access control modifier must be public and cannot be static.
3. the parameter is a legal type of JavaRMI, And the modifier cannot be static or void.
4. The throws clause can include CreateException and other exceptions of the application.
5. The method cannot conflict with the definition of the EJB structure.
(2) Home interface: defines the required object EJB for client instantiation on the Create interface called by the client.
1. The parameters and return types of the Create method must be of the RMI type.
2. The Create method returns the Remote interface type (but the ejbCreate method returns void ).
3. The throw clause of the Create method must include remoteException and CreateException.
(3) Remote interface: defines commercial methods that can be called by the client.
1. The methods in the remote interface must match the methods implemented in the javasisre Bean class.
2. The methods in the Remote interface must be the same as the implementation methods in the Enterprise Bean class.
3. Parameters and return types must be valid RMI types.
4. The throws clause must include java. rmi. remoteException.
2. Select statful and stateless Session Bean.
1. stateul is designed to maintain objects that represent the client state and present non-persistent storage. A workflow that represents a business object.
It is generally used in the following cases:
(1). Maintain specific storage business objects.
(2) non-persistent storage objects.
(3) shows workflows between commercial objects.
2 stateless is designed to provide server-side behaviors without specific user information. It is generally used in the following cases:
(1) model reusable service objects.
(2) High Performance
(3) Multiple records are operated at a time.
(4) provide the DATE program viewpoint.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.