What is EJB all about?

Component-based development

With enterprise javabeans, you can develop building blocks—EJB components—that you or someone else can assemble and reassemble into different applications. For example, you might create a Customer bean (bean is another word for component) that represents a customer in a database. You can use that Customer bean in an accounting program, an e-commerce shopping cart system, a tech support application, or virtually any other application that might need to represent a customer. In fact, with some beans, the bean developer and the application assembler might not work for the same company or have any knowledge of one another.

If you’re a bean developer, you might build an Order bean, or a Payroll bean, or a ShoppingCart bean that developers in some unrelated company can buy and use to construct their own custom applications.

One beauty of component-based development is that you take code reuse to a whole new level. Instead of reusing Java classes, you get to reuse a bigger chunk of functionality. Often, you can modify the way a bean works without ever touching its Java code! You’ll learn in this chapter that when you deploy a bean into a server, you can configure and customize the bean declaratively—through an XML-based deployment descriptor—to change the way the bean behaves at runtime.

With component-based development, you take code reuse to a whole new level. With OO development, you reuse classes, but with components, you reuse a bigger chunk of functionality, and you can customize them without touching code!

image with no caption

Application A: online shopping

Fred assembles an online shopping application using two components he bought from Beans-R-Us, plus a third component Fred developed at his company.

image with no caption

Application B: technical support

Bill assembles a technical support app using two components he bought from Beans-R-Us, plus two components he developed himself.

Get Head First EJB now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.