EJB stands for Enterprise Java Beans. EJB is an essential part of a
J2EE platform. J2EE platform have component based architecture to
provide multi-tiered, distributed and highly transactional features to
enterprise level applications.
EJB provides an architecture to develop and deploy component based
enterprise applications considering robustness, high scalability and
high performance. An EJB application can be deployed on any of the
application server compliant with J2EE 1.3 standard specification. We'll
be discussing EJB 3.0 in this tutorial.
Benefits
- Simplified development of large scale enterprise level application.
- Application Server/ EJB container provides most of the system
level services like transaction handling, logging, load balancing,
persistence mechanism, exception handling and so on. Developer has to
focus only on business logic of the application.
- EJB container manages life cycle of ejb instances thus developer needs not to worry about when to create/delete ejb objects.
Types
EJB are primarily of three types which are briefly described below:
Type | Description |
Session Bean | Session bean stores data of a particular
user for a single session. It can be stateful or stateless. It is less
resource intensive as compared to entity beans. Session bean gets
destroyed as soon as user session terminates. |
Entity Bean | Entity beans represents persistent data
storage. User data can be saved to database via entity beans and later
on can be retrieved from the database in the entity bean. |
Message Driven Bean | Message driven beans are used in
context of JMS (Java Messaging Service). Message Driven Beans can
consumes JMS messages from external entities and act accordingly. |
EJB - Environment Setup
EJB is a framework for Java, so the very first requirement is to have JDK installed in your machine.
System Requirement
JDK | 1.5 or above. |
Memory | no minimum requirement. |
Disk Space | no minimum requirement. |
Operating System | no minimum requirement. |
Step 1 - verify Java installation in your machine
Now open console and execute the following
java command.
OS | Task | Command |
Windows | Open Command Console | c:\> java -version |
Linux | Open Command Terminal | $ java -version |
Mac | Open Terminal | machine:~ joseph$ java -version |
Let's verify the output for all the operating systems:
OS | Output |
Windows |
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
|
Linux |
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
|
Mac |
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
|
If you do not have Java installed, install the Java Software Development Kit (SDK) from
http://www.oracle.com/technetwork/java/javase/downloads/index.html. We are assuming Java 1.6.0_21 as installed version for this tutorial.
Step 2: Set JAVA environment
Set the
JAVA_HOME environment variable to point to the base directory location where Java is installed on your machine. For example
OS | Output |
Windows | Set the environment variable JAVA_HOME to C:\Program Files\Java\jdk1.6.0_21 |
Linux | export JAVA_HOME=/usr/local/java-current |
Mac | export JAVA_HOME=/Library/Java/Home |
Append Java compiler location to System Path.
OS | Output |
Windows | Append the string ;C:\Program Files\Java\jdk1.6.0_21\bin to the end of the system variable, Path. |
Linux | export PATH=$PATH:$JAVA_HOME/bin/ |
Mac | not required |
Verify Java Installation using
java -version command explained above
No comments:
Post a Comment