J2EE Application Development by bzs12927


									   J2EE Application Development

2/1/2010                      1
     We will show how to develop, deploy
     and run a simple client-server
     application that consists of a currency
     converter enterprise bean and two
     clients: a J2EE client and a web client
     that consists of a JSP page.

2/1/2010                                       2
The Setup
     Source code from
     Get the J2EE1.3 from http://java.sun.com/j2ee
     Get the “ant” build tool from Jakarta. This is similar
     to “make” utility of unix.
     Setup the environment variables:
          JAVA_HOME: location of J2SE installation
          J2EE_HOME: location of J2EE installation
          ANT_HOME: location of ant installation
          PATH : include “bin” directories of J2EE, J2SE and ant

2/1/2010                                                            3
Starting the Server
   J2EE server is a web server, servlet
   server and also an application server.
   You start it by
 j2ee –verbose
   You stop the server by
 J2ee -stop

2/1/2010                                    4
   Has two modes: command line and GUI
   In the case of GUI tool you create an “ear”
   file and the drop the component modules into
   this “ear” (enterprise archive) file.
   In the case of command line you will make
   the components first and then assemble them
   into an “ear” file.
   To start a deploy tool
2/1/2010                                     5
Application source code
     An enterprise bean which represents the
     business logic of an application:
          Remote interface: defines the business methods
           that a client may call.
          Home interface: defines the methods to create,
           find or remove an enterprise bean.
          Enterprise bean class: implements the two
           interfaces and also callbacks for containers.
     Our application is called “converter”. Lets
     study the code representing these files.

2/1/2010                                                    6
Compiling the Source code
   The compile targets for this tutorial are
   available in a file build.xml.
   You compile the “converter” java files
 ant converter

2/1/2010                                   7
     For this example, “ear” file will be:
     This file will contain: EJB JAR file, Web
     client’s WAR file and Application clients JAR
     file/class file
     Deploytool helps in configuring and packaging
     each component. It automatically creates the
     deployment descriptor.

2/1/2010                                        8
Packaging the enterprise bean
     Add the classes that make the bean
     component: Converter.class,
     ConverterHome.class to the “jar”
     Specify properties: bean type (session,
     entity, etc.), transactions etc. The
     deploytool has various tabs and support
     to specify these.
2/1/2010                                  9
Application Client
     Written in Java. Can run on any Java
     runtime (need not be J2EE).
     In this application client requires two
     JAR files: JAR file for the J2EE
     containing client’s deployment
     descriptor and its class files, and the
     second JAR files containing stub classes
     required at run time by the client.
2/1/2010                                   10
Application Client (contd.) and
Web Client
   Basic tasks performed by the client of an
   enterprise bean:
      Locating the home interface

      Creating an enterprise bean instance

      Invoking a business method

      Creates client’s deployment descriptor

      Puts deployment descriptor and client code
       into a JAR file
      Add the JAR file to the applications
       ConverterApp.ear file
   We use JSP for this purpose: contains the
   same tasks as the application client plus web
   display elements.
2/1/2010                                            11
Deployment and Running the
     JNDI: We also specify JNDI names
     using the deploytool.
     Tools  deploy of the tool.
     runclient etc. to run from command line
2/1/2010                                  12

To top