Perhaps the most important step in developing applications with DataNucleus is the enhancement of
compiled classes. NetBeans provides a convenient way of integrating
this procedure into the build process without the need for any additional tool or plugin. This is
possible because NetBeans (4.x) stores project information in
relies on Ant for the build process. Class enhancement thus becomes
a simple matter of adding a new task to the existing
generated by NetBeans.
This tutorial shows how to integrate JPOX with NetBeans (4.x) to simplify the development of
JPOX is the predecessor to DataNucleus, and any change should be a simple change of "jpox" for
"datanucleus". Please contribute any updates to this guide that you have since the developers of
DataNucleus don't use Netbeans
The following components are required to complete this tutorial successfully:
The first thing to do is to register the JPOX components in the
of NetBeans 4.x so
that these become available to any project created with the IDE. This involves creating a new library and adding
the JAR files to it, as shown in the following screenshots.
Once this is done, the NetBeans 4.x will add the JAR files to the classpath whenever the newly-created JPOX library
is selected for a project.
Now create a new project and add the JPOX library to it. This is done by viewing the properties for
the project (right-click on the project and select
). Click on
and select the JPOX library that we created in the previous section.
Note that I store the properties for the
and for Log4j in
files within the source root folder. This varies according to
personal preferences, but I have found this to be very efficient.
The next step is to write the code for the classes and the meta-data. This is a straightforward
exercise left to the reader. One note of advice, however. Because NetBeans (4.x) does not recognise
file, it does not auto-complete XML code as it is being entered.
The reader may wish to edit the file as
and instruct Ant, through an
entry in the
file to rename that file to
just before the enhancement is performed.
This tutorial does not show how to do this.
Once the code and the metadata has been written, the enhancement process needs to be defined and
integrated into the build process. As stated in the introduction, this requires a simple change
Click on the
tab, expand the project tree, then open
task/target with the following Ant instructions.
<echo message="Enhancing the MODULE files"/>
This target is the most convenient for enhancing classes because it occurs just after all classes
have been compiled and is called in any case, whether the project is being built, tested or deployed.
This ensures that classes are always enhanced.
The project can now be built, with the knowledge that the classes will be enhanced in the process.
This concludes our tutorial on how to integrate JPOX with NetBeans 4.x. As can be seen, thanks to
NetBeans project system based on Ant, development of JDO applications is largely simplified.
This tutorial was provided by a user of this software, Eddy Young.