Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

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.


advertisement
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:

  1. Right click on your project StrutsEJBTutorial in the package explorer, click properties, and then click XDoclet Configurations.
  2. Right click in the upper white space area on the right-hand side, and click Add.
  3. 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.
  4. Figure 5: EJB Configuration for XDoclet
  5. Make sure EJB is highlighted in the upper box, and then right click in the lower left white space. Select ejbdoclet and click OK.
  6. Make sure that ejbdoclet is checked, and then check the box for destDir and set the value to WEB-INF/src/java. Next, check ejbSpec and set that value to 2.0. Figure 6 shows the results.

    Figure 6: Ejbdoclet Has Been Added
  7. 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
  8. Right click ejbdoclet. Click Add, choose jboss, and click OK. Select jboss, check destDir, and set the value to META-INF (see Figure 8).

    Figure 8: Add jboss to ejbdoclet
  9. 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).

    Figure 9: Add packageSubstitution to ejbdoclet
  10. 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).

    Figure 10: Add fileset to ejbdoclet
  11. 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
  12. 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.
  13. 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.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap