From the course: Java EE 7: Enterprise JavaBeans (EJB)

What is an enterprise bean?

From the course: Java EE 7: Enterprise JavaBeans (EJB)

Start my 1-month free trial

What is an enterprise bean?

- [Instructor] If you've never heard of what is an enterprise bean, or what is sometimes referred as EJB, we'll do an overview of what that is shortly. We'll also spend some time in this chapter covering a few basics, such as the types of beans and when to use enterprise beans. Also, in the next chapter we'll spend some time covering the building blocks of a bean before we get started with session and message-driven beans. So if you're well-aware of what these are and itching to get started with them right away, skip to Chapter Three of this course, otherwise follow along. Essentially, enterprise beans are server-side components that contains business logic for an application. For example, if you had an application that would sell vinyl records, you might have a function that returns the inventory level of your records and do an order. When a front-end client calls these methods, it uses the bean component to execute functions that are hosted on the server. The advantages of using this approach is the ability to isolate the front end from being responsible for these elements. You can have a bean for each element or component of your application to handle specific functions or methods. For example, you could have a bean just responsible for reporting your vinyl sales and returning the latest numbers. The component approach of using beans allows your business logic to be portable from one application to another. It can be hosted on any Java EE server. So when and why should you use them? There are a few reasons. One is scalability. You want to leave room for your application to grow, splitting your business logic into different components will allow your beans to be hosted on different machines local or in the cloud. They're highly transactional, but also many different front-end clients can be connected to them. Think about this when you are considering EJBs. So now that you understand what they are, let's continue exploring what are the types of beans available.

Contents