
Home
.. Links
.. Search
.. Plugins
.. Help
.. Irc Faq
Projects
.. Platform/Faq
.. JDT/Faq/Plan
.. PDE/Faq
.. SWT/Faq
.. RCP/Faq
Tools Projects
.. CDT/Faq
.. GEF/Faq
.. EMF/Faq
Wiki Tutorials
Hosted Projects
.. MTJ
.. Google Summer Of Code 2007
.. Update Manager 2.0
.. EasyEclipse
.. Stylebase for Eclipse
Archives
| |
Many people are now moving over to the possibilities opened up by using Java Data Objects (JDO) as the principle method of working with persistent objects.
More information on JDO can be found at http://www.jdocentral.com
Most implementations of JDO require you to run a byte code enhancer across your classes, prinicpally because there is a lot of boilerplate java code that needs to be added into classes that need to become persistent, and quite frankly, it's boring and error-prone to do this by hand.
Eclipse comes with the perfect complement of tools to allow you to develop software using JDO, you just need to tweak a few settings. Here's how....
The implementation of JDO used here is TJDO - (open source) available at http://tjdo.sourceforge.net this in turn relies on the Sun JDO reference enhancer which is available in the package from http://jcp.org/aboutJava/communityprocess/final/jsr012/index2.html
The basic thing is to swap from the internal compiler to using ant to compile. Doing this enables your compile step to then go on and run the byte code enhancement - with a build.xml running externally through ant, your enhanced classes won't ever get out of step with what you are editing in the environment.
Your build.xml should have an extra enhance target which is run after the normal compile target. It might look something like this: <!-- enhance --> <target name="enhance" depends="compile" description="Run JDO byte Code enhancer"> <echo>Enhancing JDO files</echo> <pathconvert targetos="windows" property="project.classpath.windows" refid="project.classpath"> </pathconvert> <copy todir="${dir.build}"> <fileset dir="${dir.src}" includes="**/*.jdo" /> </copy> <apply executable="java" parallel="false" failonerror="true"> <arg value="-cp"/> <arg value="${project.classpath.windows}"/> <arg value="com.triactive.jdo.enhance.SunReferenceEnhancer" /> <arg value="-d" /> <arg value="${dir.build}" /> <fileset dir="${dir.build}" includes="**/*.jdo" /> </apply> <echo>Completed Enhancing JDO files</echo> </target> Commercial implementations of JDO usually have slicker Ant integration with their own extensions, but the concept is the same.
In Eclipse you can now set up ant as the external compiler to run, and the default target to run as enhance.
• Right click on your project, select properties. • Select the second tree node 'External Tools Builders' • select 'new' • Main tab field location is set to ${workspace_loc:/YourProject?/build.xml} • Targets tab has enhance selected • build options tab is set to full and incremental builds
and that's it!
.
Last Modified 5/17/04 7:49 AM
| Hide Tools
|