Java

Java Beans is a component API that helps us to create reusable components whose configuration can be manipulated using external builder tools.

Advantage of Java Beans

  • Follows WORA(Write Once Run Anywhere) principle of Java.
  • Auxiliary software can be used to redesign the configuration of a Java Bean but is not required during runtime.
  • Beans can receive events from other objects and generate events for other objects too.

Properties Of Bean

Properties define the behaviour and appearance of a Bean component.

A property is given a value by using a Setter method and we can read the value of the property using a Getter method.

Types of Properties of Bean

  1. Simple
  2. Indexed
  3. Bounded
  4. Constraints

Methods Of Bean

Used to access and manipulate a Java Bean.

Events In Bean

Used to control communication between Java Bean Components.

Main Component Services

– GUI merging : The GUI Tools such as container’s menus and toolbars can be merged together. – Persistence : The state of Java Bean can be saved for later usage. – Event Handling : Defines how components communicate. – Introspection : We can know the details of a bean such as its methods, variables and interfaces while in the design phase. – Application Builder Support : An auxiliary app can be used to manipulate the configuration of a bean and manipulate its features.

Java Beans can be created using Beans Development Kit and Bean Builder Tool. Important files to be created for BDK (Beans Development Kit)

Enterprise Java Beans

Enterprise Java Beans are server side components which are object oriented, distributed and component based. These are used to store the business logic at the server side of the application.

Difference between EJB and JavaBeans is that EJB is for the server side business logic while Java Beans provide the Client side general purpose components.

Architecture of EJB

  • Consists of EJB server , EJB container and EJB components.
  • EJB components contain of the business logic which get stored inside the EJB container.
  • These EJB containers are then stored inside the EJB server itself.

What is JNDI? What is its basic use? When is it used? - Stack Overflow

Types of EJB

  1. Session Beans
    • Stateless
    • Stateful
  2. Entity Beans
    • Object view of Database
    • shared access from multiple users
    • Can live as long as there is data in the database ( means it is persistent )

Advantages

  • Focus on developing business logic and other system services such as transaction management, security would be handled by EJB server.
  • Offers reusablity of already developed EJB.
  • has distributed transaction support.

Disadvantages

  • Requires application server
  • Complex to understand
  • Requires Java