Eclipse provides a powerful development environment for Java systems. JPOX provides its own plugin for use within Eclipse, giving access to many features of JPOX from the convenience of your development environment. The JPOX Plugin version 1.1 will work with both JPOX 1.1 and 1.2.
The JPOX plugin requires Eclipse 3.1 or above. To obtain and install the JPOX Eclipse plugin select "Help -> Software Updates -> Find and Install". On the panel that pops up select "Search for new features to install". Select "New Remote Site", and in that new window set the URL as http://www.jpox.org/downloads/eclipse-update/ and the name as JPOX. Now select the site it has added "JPOX", and click "Finish". This will then find the releases of the JPOX plugin, and select the latest. Eclipse then downloads and installs the plugin. Easy!
The JPOX Eclipse plugin allows saving of preferences so that you get nice defaults for all subsequent usage. You can set the preferences at two levels :-
Firstly open the "General" page and configure the libraries needed by JPOX. These are in addition to whatever you already have in your projects CLASSPATH, but to run the JPOX Enhancer you will require ASM/BCEL (depending which you are using), JDO (but you'll likely have this in your project CLASSPATH), JPOX Core/Enhancer/RDBMS jars, as well as LOG4J, and your JDBC driver. Below this you can set the location of a configuration file for Log4j to use. This is useful when you want to debug the Enhancer/SchemaTool operations. ![]()
Open the "Enhancer" page. You have the following settings
![]()
Open the "SchemaTool" page. You have the following settings
![]()
After having configured the plugin you can now add JPOX support on your projects. Simply right-click on your project and select (JPOX->"Add JPOX Support") from the context menu. ![]()
It is standard practice to define the MetaData for your persistable classes in the same package as these classes. You now define your MetaData, by right-click on a package in your project and select "Create JDO 2.0 Metadata File" from JPOX context menu. The dialog prompts for the file name to be used and creates a basic Metadata file for all classes in this package, which can now be adapted to your needs. You can also perform same steps as above on a *.java file, which will create the metadata for the selected file only. Please note that the wizard will overwrite existing files without further notice. ![]()
The JPOX Eclipse plugin allows you to easily byte-code enhance your classes using the JPOX enhancer. Right-click on your project and select "Enable Auto-Enhancement" from the JPOX context menu. Now that you have the enhancer set up you can enable enhancement of your classes. The JPOX Eclipse plugin currently works by enabling/disabling automatic enhancement as a follow on process for the Eclipse build step. This means that when you enable it, every time Eclipse builds your classes it will then enhance the classes defined by the available "jdo" MetaData files. Thereafter every time that you build your classes the JDO enabled ones will be enhanced. Easy! Messages from the enhancement process will be written to the Eclipse Console. Make sure that you have your Java files in a source folder, and that the binary class files are written elsewhere If everything is set-up right, you should see the output below. ![]()
Once your classes have been enhanced you are in a position to create the database schema (assuming you will be using a new schema - omit this step if you already have your schema). Click on the project under "Package Explorer" and under "JPOX" there is an option "Run Schema Tool". This brings up a panel to define your database location (URL, login, password etc). You enter these details and the schema will be generated. ![]() Messages from the SchemaTool process will be written to the Eclipse Console. |