J2ee specification-EJB,
1. What is EJB?
The core of business software is its business logic. Business Logic abstracts the entire business process and uses computer languages to implement it.
......
J2EE extracts the business logic from the client software and encapsulates it in a component. This component runs on an independent server. The client software calls the services provided by the component through the network to implement business logic, the client software is only responsible for sending call requests and displaying processing results. In J2EE, this component runs on an independent server and encapsulates the business logic as an EJB (Enterprise JavaBean) component.
2. A more general understanding of EJB
The classes in the software that need to execute the formulated tasks are not put on the client software, but packaged into a server. EJB is to put those "classes" on a server and call the "classes" on the server using a software client in the form of C/S.
3. EJB Classification
Stateful Session bean
A service that maintains the session state. Each instance is associated with a specific client, and the conversation status is maintained between method calls of the client. The EJB server will not be saved after it crashes. Configure failover.
Stateless Session bean
Do not save the conversation status with a specific customer. Therefore, stateful session beans have more functions than stateless session beans, while stateless Session Bean instances can freely exchange between clients through EJB containers, therefore, a small number of session beans can serve a large number of clients. Do not save the error after the EJB server crashes.
Entity bean
1. display of persistent data in memory
2. The application server can be recovered after it crashes.
3. Support concurrent access from multiple customers
4. synchronous
Message-driven bean
1. asynchronous components that do not maintain status between messages
2. Use of JMS messages
4. EJB interface: EJB has two remote interfaces available to users.
Home Interface
Allows you to create, delete, or locate an EJB instance from a client application. The design principles are as follows:
1. The EJBHome interface must be inherited.
2. to define each create method, you must have a corresponding ejbcreate method in the corresponding EJB class.
3. Follow the rules of java RMI
4. Define the method parameters, which should be valid java RMI type parameters.
5. CreateException and RemoteException should be thrown.
<Span style = "font-family: KaiTi_GB2312; font-size: 18px;"> // The Home interface defines public interface DemoHome extends EJBHome {public Demo create (long x) throws RemoteException, createException ;}</span>
<Span style = "font-family: KaiTi_GB2312; font-size: 18px;"> // The EJB class defines public class DemoBean extends SessionBean {public void ejbCreate (long x) throws CreateException, userExce2 {// implementation }}</span>
Remote Interface
The Remote interface defines the commercial method provided by EJB. Its design principles are as follows:
1. The EJBObject interface must be inherited.
2. to define each method, you must have a corresponding method in the corresponding EJB class.
3. Follow the rules of java RMI
4. Define the method parameters, which should be valid java RMI type parameters.
5. RemoteException is thrown.
// The Remote interface defines public interface Hello extends EJBObject {String busMethod1 (long l, String str) throws RemoteException, user1_1 ;}
// EJB class definition public class DemoBean extends SessionBean {String busMethod1 (long l, String str) throws user=2 {// Implementation }}
Summary
To learn about EJB, you only need to know the basics, what it is, its category, and its remote interfaces. And the combination of remote interfaces and EJB classification. There are still a lot to learn about EJB in the future. I will learn more from it.