9.5. Sun ONE Studio / NetBeans IDE
Prev | Chapter 9. Third Party Integration Features | Next

## 9.5. Sun ONE Studio / NetBeans IDE

Kodo JDO can integrate with both Sun ONE Studio and NetBeans IDE as an OpenIDE module. The module requires versions 4.0 and 3.4 or higher of Sun ONE Studio and NetBeans IDE respectively. The module provides support for integrating jdo metadata files into the IDE, easy access to the SchemaTool and enhancer, links into the build process to support enhancement, and wizards to help in the creation of JDO specific files.

### 9.5.1. Before Installing Kodo into the IDE

This document will refer to your IDE's home directory, for example, `C:\Program Files\s1studio` or `/usr/local/NetBeansIDE_3.3`. If you are installing on a multi-user installation and want to install it for only a particular user, this home IDE directory can also be the user's directory chosen during the initial execution of the IDE, for example `C:\ide-userdir`. On Linux and Unix, this folder usually automatically set to `~/ffjuser40` and `~/.netbeans/3.4` for SunONE Studio and NetBeans IDE respectively.

Previous Kodo jars should be removed from the IDE's classpath. If Kodo jars had been mounted into the IDE filesystem, unmount those jars in the IDE before continuing. Then remove these jars from the `lib` and `lib/ext` directories of both the user and system IDE home directories before continuing if they are present..

### 9.5.2. Installing Kodo into the IDE

First copy the following jars into the `lib/ext` directory of your IDE's home directory (note the version numbers may be different in your Kodo installation). Do not place the Kodo jars in this directory as we will install this later in the process. Unix and Linux users: do not symlink these jars as your permissions may be incorrect.

- `jakarta-commons-logging-1.0.3.jar`

- `jakarta-commons-lang-1.0.1.jar`

- `xml-apis.jar`

- `jdbc2_0-stdext.jar`

- `jdo1_0.jar`

In addition, one should include the jar for the JDBC driver used to connect to the database used for development. Place `kodo-jdo.jar` in your home IDE directory under `modules`.

Upon starting up the IDE, open the IDE configuration under the menu at `Tools -> Options`. If you have installed Kodo correctly, you should see Kodo listed as a module under `Options -> IDE Configuration -> System -> Modules` . If its not listed, right click on `Modules -> Add -> Module...` and browse to `kodo-jdo.jar` to manually install Kodo as a module.

To begin using the JDO API, open the Filesystems browser. Right click on filesystems, and select `Mount -> Archive` and browse to and select `jdo1_0.jar` which you installed. To explictly use Kodo API extensions, mount `kodo-jdo.jar` in a similar fashion.

NetBeans users who experience a variety of ClassNotFoundExceptions for ant Kodo or other related jar-contained class may have to mount both `kodo-jdo.jar` as well as those installed at `lib/ext`. In addition, an XML SAX Parser should be mounted (e.g. `xerces.jar` in `lib/ext` of the IDE base directory) and configured (if not using Xerces).

### 9.5.3. Configuring the Kodo Module

Configuring Kodo is integrated into the IDE. In the Options dialog, Kodo's options are listed under `Options -> JDO -> Kodo Settings`. You must enter your license key, and configure the connection info to point to your development database.

You can optionally provide under Configuration Wizard Defaults defaults for new kodo.properties files. If you don't see the option, we have seen that the IDE often needs to be restarted after installation of new Modules for all options to be visible.

### 9.5.4. Kodo Template Wizards

The Kodo Module provides a pair of templates to help you get started and use Kodo and JDO. These templates are activated by right clicking on a folder in your project or filesystem, and selecting `New -> Kodo`.

The Kodo Properties wizard will assist in the run-time configuration of Kodo, both for development-time and deployment-time. The wizard will create new .properties files to use through Properties.load (). Options are convienently seperated into logical groupings. You can optionally test this new configuration by pressing the test button on the lower right corner

The JDO Metadata wizard provides a set of dialogs to walk the developer through metadata generation. In addition, to JDO standard options, most Kodo extensions are seamlessly integrated into the wizard. Simply select the type of metadata file to generate, add the classes you want described by the metadata, and then configure each class. The resulting jdo file can now be used both as a proper `.jdo file` and in your project as outlined below.

### 9.5.5. JDO DataObject

Kodo provides integrated support for JDO files as OpenIDE DataObjects. You can treat them like any other file. Right clicking on a JDO file marked by the Kodo "K" will present a variety of options. To edit the file in XML view, select `Edit`. To open and edit the file in a JDO Metadata editor, select `Open`.

In addition, the module integrates support for enhancing and running SchemaTool over classes in your project and in your metadata file. To accompish either task, right click on any JDO Metadata file node, or Java class node in the explorer. You can select one or more of either node as long as no non-applicable nodes are selected. Select `Tools -> Kodo` to see the available tools.

SchemaTool will provide the additional option of modifying the database. Selecting `No` will simply walk through SchemaTool's actions without actually changing, creating, or dropping any database columns or tables.

### 9.5.6. Kodo Integration into the Build Process

By installing the Kodo Module, Kodo will integrate into the project build process. By adding your JDO files to the project, Kodo will make sure that your dependent classes are compiled before enhancement occurs.

Kodo also integrates via Ant. See the Ant integration section for more details.

### 9.5.7. SunONE / NetBeans Sample

To build and run the sample, first following installation instructions above. Mount the samples/swing/petshop directory for your Kodo JDO installation onto the `Filesystem` explorer pane ( right click on `FileSystems`, select `Add Existing`, and browse and select the directory). In a similar manner, mount `kodo-jdo.jar` from the `modules` directory of the IDE home directory. To run the sample, do the following:

- Build the sample by selecting the `petshop` directory node (a root node), and selecting from the menu `Build -> Build All` This will also run the JDO enhancer on `Animal`.

- Expand the `petshop` directory node in the explorer. This will expose the classes in the sample and the `Animal.jdo` metadata file.

- Right-click on the `Animal.jdo` file in the top left pane, and select `Tools --> Kodo --> SchemaTool - Refresh` from the menu. Before selecting yes, ensure that your Kodo module configuration matches the `kodo.properties` in the current directory. By selecting to modify the database, this action will create the tables necessary for the sample. By selecting No, the SchemaTool will go through the motions without altering the true database schema.

- Right-click on the `PetShop` node in the explorer and select `Execute` from the menu. This will run the Pet Shop example.

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.

Prev | Up | Next
9.4. Borland JBuilder | Home | 9.6. Eclipse / WebSphere Studio Integration