Ejen Logo
 
 Project
                         
News
Download
Developer site
Browse CVS
License (GPL)
 
 Documentation
                         
Introduction
Requirements
Installation
Ejen doc
Ejen API
EJB 1.1 demo
EJB 1.1 doc
 
 Links
                         
Xerces-j
Xalan-j
Ant
JavaCC
JBoss
 
 Contact
                         
Author
 
   
 EJB 1.1 Demonstration Notes
                         
Ejen comes with a full EJB 1.1 generation demonstration: it produces a complete implementation of Bean Managed Persistence Entity Beans, as well as test JSPs that give you a basic WEB based database administration tool.

See HTML views of the generated Entity Beans.


 
 Running the EJB 1.1 Demonstration
                         
You need about 15-20 minutes to run this demonstration (provided that everything has been downloaded).


Important notes:
  • The <EJB_DEMO_DIR> path below refers to the ejen-***/examples/ejb-1.1/bmp-jboss-hsqldb (Unix) or ejen-***\examples\ejb-1.1\bmp-jboss-hsqldb (Windows) directory.

  • Do not use any path with spaces.


  1. Install the Ejen demonstration package
  2. Install the JBoss-[Jetty or Tomcat] distribution
  3. Set the JBOSS_[JETTY or TOMCAT]_HOME environment variable
  4. Start JBoss-[Jetty or Tomcat]
  5. Start the HSQLDB manager and create/populate the tables
  6. Generate the EJB 1.1 files
  7. Generate the JSP files
  8. Test the result
  9. What's next ?

  1. Install the Ejen demonstration distribution (see download)

    You need at least ejen-bin-***.zip and ejen-demos-***.zip.

  2. Install the JBoss-[Jetty or Tomcat] distribution (see jboss binaries)

    This demonstration works with the JBoss-2.4.4_Jetty-3.1.3-1, JBoss-2.4.3_Tomcat-3.2.3, JBoss-2.4.4_Tomcat-3.2.3 and JBoss-2.4.4_Tomcat-4.0.1 distributions (other distributions may work as well).

  3. Set the JBOSS_[JETTY or TOMCAT]_HOME environment variable

    • If you want to use the JBoss-Jetty distribution (faster), go to the <EJB_DEMO_DIR> directory. Then, you must edit either the 'jboss-env' file (Unix) or the 'jboss-env.bat' file (Windows) and set the JBOSS_JETTY_HOME environment variable (see comments in those files).

    • If you want to use the JBoss-Tomcat distribution, go to the <EJB_DEMO_DIR> directory. Then, you must edit either the 'jboss-env' file (Unix) or the 'jboss-env.bat' file (Windows), change the USE_JETTY variable to 'false' and set the JBOSS_TOMCAT_HOME environment variable (see comments in those files).

      Important note for JBoss-2.x.x_Tomcat-4.x.x distributions: 'tomcat' directory has been renamed to 'catalina'. You must also adjust the TOMCAT_HOME environment variable (see, again, comments in those files).

  4. Start JBoss-[Jetty or Tomcat]

    • Start JBoss-Jetty

      Unix systems
      $ cd <JBOSS_JETTY_HOME>/jboss/bin
      $ ./run_with_jetty.sh

      Windows systems
      > cd <JBOSS_JETTY_HOME>\jboss\bin
      > run_with_jetty.bat

    • Start JBoss-Tomcat

      Unix systems
      $ cd <JBOSS_TOMCAT_HOME>/jboss/bin
      $ ./run_with_tomcat.sh [or ./run_with_catalina.sh]

      Windows systems
      > cd <JBOSS_TOMCAT_HOME>\jboss\bin
      > run_with_tomcat.bat [or run_with_catalina.bat]

  5. Start the HSQLDB manager and create/populate the tables

    Unix systems
    $ cd <EJB_DEMO_DIR>/hsqldb-util
    $ ./hsqldbmanager

    Windows systems
    > cd <EJB_DEMO_DIR>\hsqldb-util
    > hsqldbmanager.bat

    In the HSQL Database Manager Connect dialog
    - Choose "HSQL Database Engine Server" as "Type".
    - Append ":1476" to the URL (jdbc:hsqldb:hsql://localhost:1476).
    - Click on the "OK" button.

    In the HSQL Database Manager window
    - Choose File->Open Script...
    - Select the "create-tables.script" file.
    - Click on the "Execute" button.
    - (optional) Choose View->Refresh Tree.
    - Choose (again) File->Open Script...
    - Select the "inserts.script" file.
    - Click on the "Execute" button.
    - (optional) Type and execute "select * from position".
    - (optional) Close the HSQL Database Manager.

    This step creates 6 tables and populates them with some data.

  6. Generate the EJB 1.1 files

    Unix systems
    $ cd <EJB_DEMO_DIR>
    $ ./generate

    Windows systems
    > cd <EJB_DEMO_DIR>
    > generate.bat

    This step creates all Java source files (bean managed entity beans following the EJB 1.1 specification) and the deployment descriptor file for the 6 tables created previously . All source files will be then compiled and archived in two jar files (server.jar and client.jar). You can see those files in the <EJB_DEMO_DIR>/out/test directory.

  7. Generate the JSP files

    Unix systems
    $ ./generate jsp

    Windows systems
    > generate.bat jsp

    This step creates 6 basic JSP files for testing purposes (each of them dialoging with the corresponding entity bean) and an index.html file. All those files are packed together with the EJBs and then deployed in the JBoss/Tomcat server (watch the server shell).

  8. Test the result

    Run your internet browser
    - Start your internet browser.
    - Set the URL to http://localhost:8080/ejenjsp.
    - Click on the links...

    Remember that the first access to each of those links is always slow, because the JSP must be transformed to a compiled servlet and the EJB server must create the cache. Reloading the page will significantly improve performance. This is especially true with the POSITION table which contains 650 rows.

  9. What's next ?

    1. Create a new table
    2. Add a findBy method
    3. Generate the EJB documentation (javadoc)
    4. Modifying the generation process

    1. Create a new table

      Create the table
      - Restart the HSQLDB manager.
      - Create a new table.
      - Edit the <EJB_DEMO_DIR>/ejen.xml file and append a line like <entity-bean table-name="???" package="org.ejb.test"/> (where '???' is the name of the new table).
      - Repeat the two generation steps.
      - See the result in your internet browser.

      If your table has a sequence, add sequence="yes" to the line.

      All the EJB/JSPs files will be generated and deployed again. This behaviour could be tuned by changing the generate.xml file.

    2. Add a findBy method

      Edit a bean java source
      - Edit one of the <EJB_DEMO_DIR>/out/test/src/org/ejb/test/EJB_*Bean.java file and append a new findBy method (see limitations below).

      Unix systems
      $ ./generate generate2
      $ ./generate build
      $ ./generate jsp

      Windows systems
      > generate.bat generate2
      > generate.bat build
      > generate.bat jsp

      This will generate the home/remote interfaces and JSP files based on your modification(s). Please note that those files are generated by analysing the bean class (and, more precisely, from a XML representation of a syntactic compilation of the bean). There is however a serious limitation with the JSP generation (remember that those JSPs are only for basic testing purpose) : the new findBy method must only have an actual combination of table field parameters. For example, in the EJB_ADDRESSBean class, you may add something like public Collection ejbFindByFirstnameAndLastname(java.lang.String firstname, java.lang.String lastname). But this limitation only affects the JSP generation.

    3. Generate the EJB documentation (javadoc)

      Unix systems
      $ ./generate doc

      Windows systems
      > generate.bat doc

      The generated documentation will then be available in the <EJB_DEMO_DIR>/out/test/docs/api directory.

    4. Modifying the generation process

      See the documentation.


 

SourceForge.net Logo