Home > Articles > Programming > Java

  • Print
  • + Share This
This chapter is from the book

1.3 Why use EJBs?

It is possible to write applications that support distribution, transaction management, and security without using EJBs. There are many such applications in use already. So what advantages do EJBs have to offer over other techniques?

  • The EJB developer works within the EJB framework to take advantage of its built-in support for features like transaction management and security; once understood, little developer effort is required to make effective use of these features. With suitable servers, EJB applications can even make use of features as sophisticated as distributed transaction management with no coding whatsoever.

  • EJB 2.0 introduces a very powerful persistence management scheme, which supports not only persistent data, but persistent relationships between objects. It takes a while to get used to, but once mastered, this revolutionizes the development of persistent application objects. Again, very little coding is required to implement such objects.

  • The EJB framework presents the EJB with a managed operating environment. For example, the framework ensures that an EJB instance is never executing in more than one concurrent thread,3so the developer does not have to be concerned about the effects of concurrency on data integrity. The container is also responsible for memory and resource management, so EJB developers don't have to be concerned with these issues.

  • EJBs can make use of the full range of Java APIs and class libraries. It is relatively straightforward to code an EJB that parses XML, sends email, and communicates with directory and database servers via standard APIs like JDBC and JNDI.

  • EJBs isolate database implementation from the application's business logic. If we use entity EJBs, for example, as models of the underlying data, then theuse of that data is decoupled from its internal representation. This leads to increased ease of maintenance and portability of code. We can also use EJBs as interfaces to legacy systems, with similar advantages.

  • EJBs are very accessible to Web components such as servlets and JSPs. There are a number of products available that support these components in the same application framework (typically called application servers). This makes it straightforward to provide EJB applications with a Web-based user interface and, perhaps, provide Internet access to the application.

  • + Share This
  • 🔖 Save To Your Account