Enterprise Java B19
Enterprise Java B19
What is EJB?
EJB is a server-side component that encapsulates the business logic of an application. Business logic is the code that fulfills the purpose of the application; In Banking application EJB might implement the business logic in methods called transferFund, checkingBalance. EJB is not for end-user, EJB is a middleware for client application
Benefits of EJB
For several reasons, enterprise beans simplify the development of large, distributed applications. First, because the EJB container provides system-level services to enterprise beans, the bean developer can concentrate on solving business problems. The EJB containerand not the bean developeris responsible for system-level services such as transaction management and security authorization.
Second, because the beansand not the clientscontain the application's business logic, the client developer can focus on the presentation of the client. The client developer does not have to code the routines that implement business rules or access databases. As a result, the clients are thinner, a benefit that is particularly important for clients that run on small devices.
Third, because enterprise beans are portable components, the application assembler can build new applications from existing beans. These applications can run on any compliant Java EE server provided that they use the standard APIs
Type of EJB
Session Bean Message-Driven Bean Entity beans have been replaced by Java Persistence API
To improve performance, you might choose a stateless session bean if it has any of these traits:
The bean's state has no data for a specific client. In a single method invocation, the bean performs a generic task for all clients. For example, you might use a stateless session bean to send an email that confirms an online order, etc..
Try it
RemoteInterface
LocalInterface
BeanImplementation
Try it..