15.6. Eclipse / WebSphere Studio Integration

15.6.1. Installing the Kodo Eclipse Plugin
15.6.2. Configuring the Plugin
15.6.3. Using Kodo in Eclipse IDEs
15.6.4. Eclipse Sample

The versions that the plugin has been tested are 1.0, 2.x, and 3.0 of the Eclipse IDE, and version 4 and 5 of WebSphere Studio Application Developer. While the plugin may work on other IDEs/ versions based upon Eclipse technology, they have not been tested and may not be fully supported.

Kodo JDO integrates as a plugin to IDEs based upon the open source Eclipse technology. The plugin provides quick access to many of Kodo's features, including metadata enhancement, MappingTool, and building projects.

15.6.1. Installing the Kodo Eclipse Plugin


Completely uninstall previous versions of the Kodo plugin as it may interfere with the new plugin.

First copy the directory kodo.eclipse_2.1.0 directory from the eclipse directory in your Kodo installation to the plugins directory of the IDE base directory. For example, if you installed Kodo at C:\Kodo and Eclipse at C:\Eclipse, one would take C:\Kodo\eclipse\kodo.eclipse_2.1.0 directory and place it such that the new directory structure would be: C:\Eclipse\plugins\kodo.eclipse_2.1.0.

Copy all the jars from the lib directory of your Kodo installation into this new directory. In addition, copy the JDBC driver of your choice into this directory as well. Keep the driver filename in mind as you will need it later.

In the Kodo plugin directory, modify the marked portion of plugin.xml to point to your JDBC driver .jar file.

Start the IDE. You should see a Kodo menu item, and Kodo listed as an available view. If not, you may need to configure your perspective to include those items. To manually configure your perspective for WSAD 4, perform the following steps. These steps are likely to work for other versions of Eclipse, but have been written with WSAD 4 in mind.

  1. Click on Perspective -> Customize... to open the Customize Perspective dialog box.

  2. Open up the Views checkbox.

  3. Select Kodo from the list of available views (under Java) if it's unselected. This will add the Kodo Java view to the views available to your perspective.

  4. Next, collapse the Views checkbox and open up the Other checkbox.

  5. Select Kodo Actions if it's unselected. This will add the Kodo menu to the menu bar.

  6. Hit OK to close out of the customization dialog box. You should now see the Kodo menu item, and a Kodo view in the Perspective -> Views menu.

15.6.2. Configuring the Plugin

First, configure Kodo's development time options by editing your license key and database options. To do this, go into Window->Preferences and select Kodo Preferences. Edit to match your configuration and select Apply, and then OK. The plugin should now be configured.

To access the full range of Kodo configuration options, or to load defaults for configuration values (which can be overridden in the IDE), you can enter the path to your kodo.properties file in this window.

To have JDO and Kodo available to your program, you should add all the Kodo jars either from the plugin directory or your Kodo installation directory under your project properties.

15.6.3. Using Kodo in Eclipse IDEs

By selecting a file in a project, you can add and remove Kodo's enhancer to the project's build process. This builder will sequentially enhance any .jdo files only on full project builds and rebuilds.

You can also manually enhance your .jdo files by selecting them in the explorer pane and selecting either the Enhance icon in the toolbar or selecting Kodo->Enhance from the main menu bar.

To run the Mapping Tool To run the SchemaTool, similarly select one or more .jdo file(s) and select one of the Mapping Tool icons, or the corresponding menu item. A dialog will ask you what schema operations to do in parallel with the mapping action you selected. In addition, you can redirect the schema changes to a schema XML file.

15.6.4. Eclipse Sample

To build and run the sample, first install the plugin following the instructions above. Create a new Java project or use an existing one. Right click on the project, select properties. In the properties window, select in the left navigation, Java Build Path. In the tabs that opens up, select the library tab. Press the Add External Jars... button and browse to your plugin directory or the lib directory in your Kodo installation. Select all the jars (in some operating systems, you may have to add them one at a time). and select ok.

Right click again on your project, but this time select Import (Some IDEs have this option only on the main File menu). Select File System on the screen that allows you to specify what sort of resources you are adding. Browse to the samples/swing/petshop directory. Note that you must select petshop, not examples or the Kodo installation directory inside the file browser. Select all the files in the directory, making sure to include .jdo and .properties files if they are filtered. Select OK and you should see Animal.java among other files inside a folder called default.package underneath your project.

First, right click on a source file such as Animal.java. Under the Kodo menu, select Add Enhancer To Build to add the enhancement process to the build. Now select Project->Rebuild All. This will compile the classes and enhance the metadata files in your project. Now run Mapping Tool on Animal.jdo by selecting the file and either clicking on Kodo->Refresh Mappings from the menu or selecting the icon with the matching tooltip. Select refresh as the schema action to create the necessary tables for the tutorial.

Now alter petshop.properties to match your IDE configuration plus any other options you desire. Select Run->Run, and select Java Application. Press the New button and configure the IDE to run the PetShop class. Select Run and you should soon be seeing the PetShop Swing application run.

The Pet Shop example allows you to create and delete pets in a database. The pets have a string type -- dog, cat, giraffe, etc. -- and a price.

The Pet Shop example code demonstrates how to put together a simple Swing example, and also how to use a Kodo-specific feature to extend the PersistenceManager class to enable Swing updates to happen at the optimal time.