Chapter 5. Generation of the EJB related files

To generate the EJB related classes and descriptors, we need to create some XDoclet configurations. With JBoss Eclipse IDE, you can define several XDoclet generation configurations that will be run against the project.

Procedure 5.1. Enable XDoclet

  1. Edit the project properties by right clicking on the project and select Properties.

  2. In the property page, select XDoclet configurations.

  3. At the top of the page there is a check-box labeld Enable XDoclet. Check this check-box.

Procedure 5.2. XDoclet EJB Configuration Creation

  • Right-click in the upper area to pop-up the menu and choose Add. Type EJB in the dialog and click OK.

You have created a new generation configuration named EJB.

Procedure 5.3. Ejbdoclet Configuration

  1. Select the EJB configuration.

  2. In the lower-left area, right-click to popup the menu and choose Add Doclet.

  3. A list of available doclets will appear. Choose ejbdoclet and click OK.

  4. On the lower-right area, you see the properties of the ejbdoclet.

    1. Set the destDir property to src.
    2. Set the ejbSpec property to 2.0.

Our configuration now contains an ejbdoclet that will produce files in src folder and for the EJB 2.0 specifications.

Procedure 5.4. Fileset Configuration

  1. In the lower-left area, right-click on ejbdoclet to popup the menu and choose Add.
  2. A list of available subtasks will appear. Choose fileset and click Ok.
  3. On the lower-right area, you see the properties of the fileset.
    1. Set the dir property to src.
    2. Uncheck excludes
    3. Set the includes property to **/*Bean.java.

Our configuration now contains an ejbdoclet with a fileset that contains the src directory, and all files under it that end in Bean.java.

Procedure 5.5. Deployment Descriptor Configuration

  • Add a new deploymentdescriptor subtask to the ejbdoclet (see above).
    1. Set the destDir property to src/META-INF.

All of the standard EJB deployment descriptors will now be placed in the src/META-INF directory.

Procedure 5.6. JBoss Configuration

  • Add a new jboss subtask to the ejbdoclet (see above).
    1. Set the destDir property to src/META-INF.
    2. Set the Version property to 3.0.

All of the JBoss-specific deployment descriptors will now be placed in the src/META-INF directory.

Procedure 5.7. Package Substitution Configuration

  • Add a new packageSubstitution subtask to the ejbdoclet (see above).
    1. Set the packages property to ejb.
    2. Set the substituteWith property to interfaces.

This will place our generated EJB interfaces in the tutorial.interfaces java package.

Procedure 5.8. Interface Configuration

  1. Add a new remoteInterface subtask to the ejbdoclet (see above).
  2. Add a new homeInterface subtask to the ejbdoclet (see above).

These subtasks will generate the EJB home and remote interfaces.

Click OK and the XDoclet configuration for the Tutorial will be saved. Once the configuration is saved, right-click on the Tutorial project and select Run XDoclet. The XDoclet generation will display its output in the console. The output should look like this:

After the code generation, select the project and refresh it (you can press F5). You should have a project that looks like this. Note that a tutorial.interfaces package has been created with new classes inside. There is also a META-INF folder with the deployment descriptors (both standard and jboss).