views:

65

answers:

2

I've inherited an existing IntelliJ project and after spedning some time with it, I have everything almost figured out.

The one place I am stuck is that I see a ton of EJBs.

I see that there is an EJB (container-managed persistence), and I'd like to make a new bean. Withing that EJB, all of the source files begin with:

/*
* Generated by XDoclet - Do not edit!
*/

How are these files being created? I don't see anything in the UI to use in order to create them.

+1  A: 

XDoclet is a program that takes comments and converts it into XML. Kind of a poor mans annotation. It was cool back before annotations came around for stuff like hibernate (would generate the long boring .xml files hibernate needed for every object).

You can read about it here

http://www.xdoclet.net/xdoclet/index.html

There are various plugins that do xdoclet, but if the project isn't too huge, I would recommend moving away. To move away:

1) Remove all the xdoclet comments (optional but will confuse the next guy less)
2) Take all the .xml files and consider them hand editable... so store them in your version control rather then generate at runtime.
3) In the future when things change, edit the xml by hand instead of changing the xdoclet comment and generating new xml files.
4) Slowly convert over to annotation or something more modernl...

bwawok
OK - so you are saying that the previous person who worked on this project was editing ejb-jar.xml and then from there xdoclet was creating the XML files for the EJB?So if I want to add a new EJB to my project, going forward I would do what, exactly? Edit the XML and then do a File > New CMP Entity Bean?
NinjaCat
I have not used intelliJ in a year or Xdoclet in a few years so not sure. Poke around on the xdoclet site, and maybe the intelliJ site.
bwawok
+1  A: 

Your project is using EJB 2.x and EJB 2.x are pretty verbose. For each EJB, you have to write a Bean implementation, a Remote interface, a Home interface and to maintain entries in the ejb-jar.xml deployment descriptor, etc. That's a lot of stuff, with some redundancies, and it is not easy to maintain.

And that's where XDoclet come into the picture. XDoclet is a code generation engine that originated for creating EJBs (to ease the development). XDoclet parses meta-data that you add to your Java sources using special JavaDoc tag and generates XML descriptors and/or source code from it.

So basically, the idea was to provide the Bean implementation only, to add the special @ejb JavaDoc comments, and to generate the rest from it. And the generation itself was probably done using Ant and the <ejbdoclet .. /> Ant task (or maybe Maven but the idea is similar).

So don't expect to find a special menu entry in IntelliJ, I don't think IntelliJ provide anything special for XDoclet. Instead, look for a build.xml (an Ant build script) or maybe a Maven script and see if you can get those file generated at build time, this is just how it's supposed to be used.

Then, mimic what is already done for an existing bean - look at the bean implementation - to add your new CMP Entity Bean. And I sincerely wish you good luck because your project looks dusty... I thought nobody was using EJB 2.x Entity Beans anymore.

Pascal Thivent
Thanks for the response... Is it fairly easy to port to EJB 3?
John
@John I'd say that EJB 3 are mush easier than EJB 2.x (and also have more value on the job market).
Pascal Thivent