Types and use of EJB

xiaoxiao2021-03-06  24

EJB is distinguished in accordance with the difference in characteristics. 1 session bean: The main purpose is to let program developers extract logic layers, these "logic" is usually Business logic in an application, accounting for considerable part of the entire system development. System developers can use session beans to place complex logic in the method of Session Bean. 1.1 Stateful session bean: You can record the status of the caller, so in general, a user will have an entity of the corresponding stateful session bean. 1.2 Stateless Session Bean: It is also a logic element, but he is not responsible for recording the user status, that is, when the user calls Stateless Session bean, EJB Container does not look for a specific STATELESS SESSION bean entity to perform this Method. 2 Entity Bean: Its role is mainly data components, the main purpose is to provide information, allow system developers to directly use the information to be used in the program; as for the Entity Bean to access a RELATIONAL DATABSE or LDAP, Can be used as another independent thing. 2.1 Bean-managed persistence (BMP): You can directly understand that BMP is consistent by the BEAN's own maintenance information. `And Bean After obtaining information from the database, BMP requires self-declaration fields to store these materials, and the relevant JDBC grammar and other programs must also be written. Suitable for developers to completely control the data access behavior of BMP. 2.2 Container-Managed Persistence (CMP): CMP is responsible for maintenance information with EJB Container relative to BMP. The programming designer written by CMP does not need to write most JDBC syntax, usually only need to write deployment description, you can generate CMP; the actual program code is generated when the EJB Container is generated when deploy EJB. CMP seems to help the rapid development system (most of the work is handed over to EJB Container), but it is necessary to cooperate with the Application Server that supports CMP, and as of now, each different Application Server has the degree of support for CMP. Large. 3 Message Driven Bean: The main purpose is to respond to events in Message Queue. When there is a message in Message Queue, the Message Driven Bean can be triggered, and the corresponding reaction is made; so the Message Driven Bean can be said to be active reactions, and Not "calling a Method" passive trigger. Where the session bean has existed when the EJB specification is 1.x, and the Message Driven Bean appears in the specifications of EJB 2.0.

转载请注明原文地址:https://www.9cbs.com/read-65319.html

New Post(0)