Enterprise Edition JavaBean Discussion

Source: Internet
Author: User
In this article, we will discuss the Enterprise version of JavaBean to help eliminate your fear of creating your own first EJB and help you step into the world of EJB development.
Installing the EJB run and development environment
The EJB must be executed within the EJB container. So we have to install an EJB container that conforms to the Java standard. To help us deploy our own EJB, we also need a deployment tool. The reference implementation from Sun to Java EE includes an EJB container and an EJB deployment tool. This Java-EE reference implementation can be found in the Sun-released Java EE Developer Toolkit.
The Java EE Development package relies on the development kit for the 2 SDK, Standard Edition (Standard edition,j2se), so you need to download it as well. You need the J2SE SDK to run the Java EE server referencing the implementation and to create and run the EJB application.
Once you have downloaded the development packages, you will install them and choose the ideal location for each development package. You first define an environment variable called Java_home and point it to the installation directory of the J2SE development package. Then, define an environment variable called J2ee_home and point it to the installation directory of the Java development package.
Now you're ready to start writing your EJB.
Write a simple session EJB
Most of the steps and concepts involved in developing an EJB are the same, with only a few differences, that we use to develop traditional Java objects (Plain-old java object,pojo). The following is a basic step in developing and deploying EJBS:
1. Write classes and interfaces for your EJB.
2. Write a deployment descriptor for your EJB.
3. Package the EJB and associated files into a jar file.
4. Deploy EJB.
There are two different types of session beans. Before we start writing code, let's look at the similarities and differences between them.
Status Session EJB Overview
The state session EJB maintains a conversation state with the client during a single session. This means that the state session EJB can maintain instance variables that span multiple invocations from one client during a single session.
Once the client completes the interaction with the EJB, and the EJB easily deletes the EJB, the EJB session ends and all state data for the EJB is deleted.
Non-stateful session EJB overview
Stateless session EJBS do not maintain a state of conversation for each individual client. Each invocation of a stateless session EJB should be treated as a request for a completely new object instance. Because any instance-variable state will be lost between calls.
Stateless session EJBs are not saved to the second storage field by the EJB container, so the programmer must know that all data between each invocation of each client is instantaneous. The transient nature of a stateless session EJB allows the EJB container to reuse the EJB instance, and therefore often optimizes the performance of the EJB.
The relationship between session beans
Figure A illustrates the relationship between the EJB client, the EJB container, and several session EJBS.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.