A Practical Guide for Integrating EJB and Struts : Page 4
EJB and the Struts framework each have received plenty of coverage individually, but what about leveraging EJB and Struts together? This tutorial lays out a complete step-by-step guide to integrating these two technologies.
by Stephen Lum
May 19, 2004
Page 4 of 7
XDoclet to Generate Deployment Descriptors and Interfaces for StockBean
Many good tutorials out there go into further detail on XDoclet, but this article shows you how to use XDoclet only to generate your Web and EJB deployment descriptors and your interfaces for the StockBean.
To generate these files, XDoclet takes the javadoc declared in your StockBean and uses it to generate jboss.xml, ejb-jar.xml, and the interfaces for StockBean:
Right click on your project StrutsEJBTutorial in the package explorer, click properties, and then click XDoclet Configurations.
Right click in the upper white space area on the right-hand side, and click Add.
A popup telling you to enter a configuration name will appear. Type EJB and click OK. Figure 5 shows a screenshot of what you should see.
Right click ejbdoclet in the left white box. Click Add, choose deploymentdescriptor, and click OK. Now select deploymentdecriptor (you may have to expand the ejbdoclet node if you don't see it), check destDir, and set the value to META-INF. See Figure 7 for the results.
Figure 7: Add the deploymentdescriptor to ejbdoclet
Right click ejbdoclet. Click Add, choose jboss, and click OK. Select jboss, check destDir, and set the value to META-INF (see Figure 8).
Right click ejbdoclet. Click Add, choose packageSubstitution, and click OK. Select packageSubstitution, check packages, and set the value to bean. Next, check substituteWith and set the value to interfaces (see Figure 9).
Right click ejbdoclet. Click Add, choose fileset, and click OK. Select fileset, make sure dir is checked, and set the value to WEB-INF/src/java. Uncheck excludes. Next, make sure includes is checked and set the value to **/*Bean.java (see Figure 10).
Right click ejbdoclet. Click Add, choose remoteinterface, and click OK. Right click ejbdoclet again, click Add, and choose homeinterface (see Figure 11). No values need to be checked or set for remoteinterface and homeinterface.
Figure 11: Add homeinterface and remoteinterface to ejbdoclet
Now click OK on the bottom right corner. Eclipse will generate an xdoclet-build.xml file. To run your XDoclet file, right click on your project StrutsEJBTutorial in the package explorer, and click Run XDoclet.
On closer inspection, you will see that XDoclet generated both your home and remote interfaces in lum.stock.ejb.interfaces, and you have jboss.xml and ejb-jar.xml in your /META-INF directory. If you updated your XDoclet definitions, you should have jaws.xml too, but this file is not necessary for this application.