Friday, September 01, 2006

what are EJBs

An EJB is a server-side component that executes specific business logic. EJBs run on a server and are invoked by local or remote clients. A standardized contract exists between an application server and its EJB components that enables a component to run within any application server. The application server provides clearly-defined services while the components adhere to a standard interface. EJBs are not GUI components; rather, they sit behind the GUIs and perform all the business logic, e.g. database CRUD operations. GUIs such as rich clients, web-based clients, and web services are the clients that can make connections to EJBs.

The original JavaBeans specification is based on the java.beans package which is a standard package in the JDK. Components built in the JavaBeans specification are intraprocess components that stay in one address space and are typically used for Graphical User Interface (GUI) visual widgets such as buttons, tables, HTML viewers, etc. On the other hand, the EJB specification is based on the javax.ejb package, which is a standard extension package. EJB is one of several specifications grouped into Sun Microsystem's Java 2 Enterprise Edition (J2EE) specification. Components built in the EJB specification are interprocess components that stay in multiple address spaces as distributed objects. These components are used as transactional business objects that are accessed as remote objects.

So we have:

  • EJB is a framework for writing distributed programs.
  • EJB involves a standardized agreement that enables a component to run within any application server (increasing code reuse).
  • The agreement is accomplished by implementing a set of Java interfaces from the EJB API.
  • EJBs are not GUI components.

EJB is a heavyweight framework. Deciding to implement EJB on your next project should only be done after weighting their pros and cons versus more lightweight solutions, such as Hibernate, JDO, or straight SQL. If you need a distributed solution, consider adding RMI-IIOP or CORBA options to the mix. Following are some things to consider when making the decision of whether or not to use EJB:

Advantages of EJB:

  • Many vendor application servers conform to the J2EE specification allowing one to select a best-of-breed solution.
  • To handle fluctuations in resource demand server-side resources can easily be scaled by adding or removing servers.
  • Application servers provide access to complex services, namely transaction and security management, resource pooling, JNDI (Java Naming and Directory Interface), component lifecycle management, etc.

Disadvanatges of EJB:

  • EJB has a large and complicated specification.
  • EJBs take longer to develop. Also, when things go wrong they can be more difficult to debug. Occasionally the bug may not be in your code but in the application server itself.
  • No sooner have you deployed your EJB application than you see a new specification coming down the pipe with newer features, rendering your application obsolete. This situation, however, is unavoidable with cutting-edge technologies.

Some rules of thumb for when not to use EJB include:

  • Do not choose EJB when there is no need for scalability, transaction management, or security.
  • Do not choose EJB if you anticipate low numbers of read-only users.
  • Do not choose EJB if your team lacks EJB experience or cannot quickly obtain that experience. The EJB learning curve is steep and overcoming it can easily derail an otherwise viable project.

The EJB Ecosystem

To have an EJB deployment up and running, one needs more than an application server and components. There are six more parties that are involved:

  1. The Bean provider: The bean provider supplies the business components to the enterprise applications. These business components are not complete applications but can be combined to form complete enterprise applications. These bean providers could be an ISV selling components or an internal component provider.
  2. The Application Assembler: The application assembler is responsible for integrating the components. This party writes applications to combine components so as to develop the target application that can be deployed under various environments.
  3. The EJB Deployer: After the application developer builds the application, the application must be deployed on the server. This involves configuring the security parameter settings, performance tuning, etc. An application assembler is not familiar with these issues. This is where the EJB deployer comes into play.
  4. The System Administrator: The system administrator is responsible for the upkeep and monitoring of the deployed system and may make use of monitoring and management tools to closely observe the deployed system.
  5. The Container and Server providers: The container provider supplies the EJB container (an application server). This is the runtime environment where the beans live. The container supplies the middleware services to the beans and manages them. Some of the various containers are: BEA's WebLogic, iPlanet's iPlanet Application Server, IBM's WebSphere, Oracle's Oracle 9i Application Server and Oracle 10g Application Server, and the JBoss open source Application Server. The server provider is the same as the container provider.
  6. The Tool Vendors: There are various IDEs available to assist the developer in rapidly building and debugging components, for example Eclipse, NetBeans, and JBuilder. For the modeling of components one can use Rational Rose. There are many other tools, some used for testing (JUnit) and others used for building (Ant, XDoclet).

Different Beans for Different Tasks

There are three different types of beans in EJB: session, entity, and message-driven. Each has a specific purpose:
  1. Session Beans: Represent an action or process that must be executed synchronously, such as making a reservation or validating a credit card.
  2. Message-Driven Beans: Also represent an action or process. But, message-driven beans are executed asynchronously.
  3. Entity Beans: Represent data; each entity bean represents a unique record in the database.

Tags: , , , , , , , , , , , , , , , , , ,

Can't find what you're looking for? Try Google Search!
Google
 
Web eshwar123.blogspot.com

Comments on "what are EJBs"