Creating JEE Applications with EJB

In the last chapter, we learned some techniques to debug JEE applications from Eclipse. In this chapter, we will shift our focus back to JEE application development and learn how to create and use Enterprise JavaBeans (EJB). If you recall the architecture of database applications in Chapter 4, Creating JEE Database Applications, we had JSP or a JSF page calling a JSP bean or a managed bean. The beans then called DAOs to execute the data access code. This separated code for the user interface, the business logic, and the database nicely. This would work for small or medium applications, but may prove to be a bottleneck in large enterprise applications; the application may not scale very well. If processing of the business logic is time consuming then it would make more sense to distribute it on different servers for better scalability and resilience. If code for the user interface, the business logic, and the data access is all on the same machine, then it may affect scalability of the application; that is, it may not perform well under the load.

Using EJB for implementing the business logic is ideal in scenarios where you want components processing the business logic to be distributed across different servers. However, this is just one of the advantages of EJB. Even if you use EJBs on the same server as the web application, you may gain from a number of services that the EJB container provides; you can specify the security constraints for calling EJB methods declaratively (using annotations) and can easily specify transaction boundaries (specify a set of method calls from a part of one transaction) using annotations. Furthermore, the container handles the life cycle of EJBs, including pooling of certain types of EJB objects so that more objects can be created when load on the application increases.

In Chapter 4, Creating JEE Database Applications, we created a Course Management web application using simple JavaBeans. In this chapter, we will create the same application using EJBs and deploy it on the GlassFish Server. However, before that we need to understand some basic concepts of EJBs.

 We will cover the following broad topics:

  • Understanding different types of EJBs and how they can be accessed from different client deployment scenarios
  • Configuring GlassFish Server for testing EJB applications in Eclipse
  • Creating and testing EJB projects from Eclipse with and without Maven
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.166.255