Enterprise Java Beans
The course is part of this learning path
In this course, we will learn the concepts of Java EE 7 with a focus on Enterprise Java Beans (EJB).
- Enterprise Java Beans (EJB)
- Anyone looking to get Oracle Java Certification
- Those who want to improve Java 7 EE knowledge
- Java developers
- Have at least 2 years of Java development experience
Hello dear friends. In this video, we will start to examine EJB. Let's begin. Enterprise Java Beans also known as EJB is one of the several Java APIs for standard manufacturer of enterprise software. EJB is a server side software element that summarizes business logic of an application. Enterprise Java Beans web repository yields a runtime domain for web related software elements including computer reliability, Java servlet lifecycle management, transaction procedure and other web services. The EJB enumeration is a subset of the Java EE enumeration. So, what are the advantages of EJB?
The EJB enumeration was originally developed by IBM in 1997 and later adopted by Sun Microsystems in 1999 and enhanced under the Java community process. 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 container, rather than the Bean Developer, is responsible for system level services such as transaction management and security authorization. Second, because the beans rather than the clients contain the applications 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. Provided that they use the standard APIs, these applications can run on any compliant Java EE server. Of course, there are some disadvantages of EJB, like EJB requires an application server and only a Java client. For another language client, you need to go for web service. EJB applications are too complex to understand and develop. EJB performs life cycle management, security, transaction management, and object pooling.
To run EJB application, you need an application server such as JBoss, GlassFish, web logic, web sphere, etc. As you are aware, we have already installed the GlassFish server on our Eclipse. If your application needs remote access to be scalable or encapsulated business logic, you can choose using EJB in your application. To develop an Enterprise Bean, you need some file types, like enterprise bean class, business interfaces, and helper classes. Enterprise bean class implements the business methods of the Enterprise Bean and any lifecycle callback methods. Business interface defines the business methods implemented by the enterprise bean class. A business interface is not required if the enterprise bean exposes a local no interface view. Helper classes are the other classes needed by the enterprise bean class, such as exception and utility classes. You have to package the programming artifacts either into an EJB jar file or within a war module. The image shows us the EJB jar structure. An EJB jar file is portable and can be used for various applications. To assemble a Java EE application, package one or more modules, such as EJB jar files into an ear file, the archive file that holds the application.
When deploying the ear file that contains the Enterprise Beans' EJB jar file, you also deploy the Enterprise Bean to the GlassFish server. You can also deploy an EJB jar that is not contained in an ear file. Before looking at the various types of EJB, I want to discuss the Enterprise Bean naming conventions that we will use in a few of the following code snippets. I want to talk about an employee EJB. So, I will show examples with employee. For an employee EJB, we have to define EJB name with name and EJB keyword like employee EJB. For EJB jar, we will define our name as employee jar, like EJB name. For an enterprise bean class name, we will use bean keyword, so our name will be employee bean. For home interface, we will use home keyword, and our name will be employee home. For remote interface, we don't need any keyword. We will only use interface name, so our name will be employee.
For local home interface, our name must be local employee home. And the last one is local interface. We need local keyword in front of the name, so our name will be local employee. The name conventions are very important for programming. Therefore, we need to pay attention to these naming conventions. Now let's go on with Enterprise Beans types. There are three kinds of Enterprise Beans: Session, Message-Drive, and Entity. Session bean contains business logic that can be invoked by local, remote, or web service client. Like session bean, message-driven bean contains the business logic, but it is invoked by passing message. Entity bean encapsulates the state that can be persisted in the database. It is now deprecated and is replaced with JPA. We will examine all of them one by one in following videos. That's all I have to say about EJB definition. In the next video, we will examine the EJB container. See you in the next video.
OAK Academy is made up of tech experts who have been in the sector for years and years and are deeply rooted in the tech world. They specialize in critical areas like cybersecurity, coding, IT, game development, app monetization, and mobile development.