Chapter 3. Using Eclipse 3.0 With Keel

3.1. Initial Setup

Eclipse allows the use of multiple workspaces. It is not mandatory, but recommended that a separate workspace be used per Keel project. In earlier sections the Keel project directory was introduced. The Eclipse workspace should be the parent of $KEEL_PROJ. In fact, it makes things easier if this thought is applied when creating the Keel project for the first time, the directory should be chosen as <some-path>/<myworkspace>/<myproject>.

Eclipse can be started to use a specific workspace as follows:

eclipse -data <some-path>/<myworkspace>

A window-manager/desktop shortcut with a similar command as above makes starting Eclipse much simpler.

Since Keel works with Java-1.4, Eclipse must be setup to conform. As shown in Figure 3.1, “Eclipse Preferences”, select "Preferences" from Eclipse's "Window" menu. In the Preferences dialig, navigate to Java->Compiler-Compliance and Classfiles. As shown in Figure 3.2, “Java-1.4 Preferences”, set the comliance level to 1.4. Uncheck "Use default compliance settings", and set the other selections to "1.4", "1.4" and "Error". Click OK.

Eclipse Preferences

Figure 3.1. Eclipse Preferences

Java-1.4 Preferences

Figure 3.2. Java-1.4 Preferences

3.2. Creating a Eclipse Project For Your Keel Project

The first thing that needs to happen is for us to create a project. As shown in Figure 3.3, “Creating a New Project”, create a new project from Eclipse's File->New->Project in Eclipse:

Creating a New Project

Figure 3.3. Creating a New Project

In the new project dialog, select "Java Project" as shown in Figure 3.4, “Creating a New Java Project” and click the "Next >" button. In the resulting dialog, type the name of the project (mykeel, in this case) as shown in Figure 3.5, “Assigning a Name to the New Project” and click "Next >".

Creating a New Java Project

Figure 3.4. Creating a New Java Project

Assigning a Name to the New Project

Figure 3.5. Assigning a Name to the New Project

In the Java Settings dialog, select the Source tab. Select the only source folder defined by default, and click on the "Remove" button to delete it (since the project itself will never have any source associated with it).

Now navigate to the "Libraries" tab, and click on the "Add Library ..." button. As shown in Figure 3.6, “Adding User Libraries”, select "User Library" in the "Add Library" dialog, and click on "Next >".

Adding User Libraries

Figure 3.6. Adding User Libraries

In the "User Library" dialog, click on "User Libraries...", and in the resulting "User Libraries" dialog click on "New...". As shown in Figure 3.7, “Define Keel Libraries”, a prompt for the user lirary name pops up. Type "KEEL_SERVER" and click on OK. Click on the "New..." button again, but this time define a "KEEL_CLIENT" library.

Define Keel Libraries

Figure 3.7. Define Keel Libraries

Back in the "User Libraries" dialog, select the just added "KEEL_SERVER" lib and select "Add JARs...". In the dialog that opens up, as shown in Figure 3.8, “Add Keel Server JARs”, navigate to the Keel server side lib directory. In general, this will be a path in your project that is referred to in the ant.properties file with the "keel.server.path". For webapps deploys, this path will be $KEEL_PROJ/webapp/WEB-INF/keel/server/lib. Select all the JARs in this directory and click on "Open".

Add Keel Server JARs

Figure 3.8. Add Keel Server JARs

Again in the "User Libraries" dialog, select the "KEEL_CLIENT" library and select "Add JARs..." again. This time, as shown in Figure 3.9, “Add Keel Client JARs”, navigate to $KEEL_PROJ/webapp/WEB-INF/lib, select all the JARs and click "Open".

Add Keel Client JARs

Figure 3.9. Add Keel Client JARs

Make sure that both the KEEL_SERVER and KEEL_CLIENT checkboxes are selected and click OK, as shown in Figure 3.10, “Selected User Libraries”.

Selected User Libraries

Figure 3.10. Selected User Libraries

Back in the "Java Settings" dialog, as in Figure 3.11, “Finishing Project Dialog”, click on the "Finish" button.

Finishing Project Dialog

Figure 3.11. Finishing Project Dialog

Your Keel project should now be setup, and look like the project in Figure 3.12, “New Keel Project”.

New Keel Project

Figure 3.12. New Keel Project

3.3. Adding Source for User Modules

For every user application or service module that is added to the project, the module's source path must be defined in Eclipse, as well s an output directory for the compiled classes. Select the Keel project, "mykeel" in our example, and right-click the mouse to get to the "Properties" menu item, as shown in Figure 3.13, “Keel Project Properties”.

Keel Project Properties

Figure 3.13. Keel Project Properties

In the Source tab of the properties dialog, click on the "Add Folder..." button and navigate to project's source directories. In the example shown in Figure 3.14, “Keel Module Source”, we navigated to $KEEL_PROJ/app-hoj/src/ and clicked the checkboxes next to the java and test folders.

Keel Module Source

Figure 3.14. Keel Module Source

As shown in Figure 3.15, “Keel Module Source”, define the output folder of each source directory to be the "build/classes" directory within that module.

Keel Module Source

Figure 3.15. Keel Module Source

3.4. Defining Source for Keel Internals

If you want to navigate source for Keel internals, then expand the KEEL_SERVER and/or the KEEL_CLIENT and navigate to the JAR of interest and right-click on it to alter properties. As shown in the example in Figure 3.16, “Keel JAR Properties”, we will attach source to the "keel-core" module.

Keel JAR Properties

Figure 3.16. Keel JAR Properties

Click "External Folder...", navigate to the Keel distribution, $KEEL_HOME, and find the src/java directory in the keel-core (or, other Keel module, as appropriate), as shown in Figure 3.17, “Keel JAR Source”.

Keel JAR Source

Figure 3.17. Keel JAR Source

3.5. Debugging Keel with Eclipse

To setup Eclipse to debug Keel, a debug launch configuration must be setup. In the Java perspective, make sure the Keel project is selected. Click the "Debug.." menu item under the little "bug" icon in Eclipse, as shown in Figure 3.18, “Setup Launch Configuration”.

Setup Launch Configuration

Figure 3.18. Setup Launch Configuration

Select "Remote Java Application" and click "New". In the Connect tab, as shown in Figure 3.19, “Setup Launch Configuration”, make sure that the correct Keel project is listed in the "Project:" field (important when you have multiple projects in the workspace). In the Common tab, as shown in Figure 3.20, “Show Launch Config in Debug Menu”, make sure the the checkbox next to "Debug" is selected. Click "Apply", then "Close".

Setup Launch Configuration

Figure 3.19. Setup Launch Configuration

Show Launch Config in Debug Menu

Figure 3.20. Show Launch Config in Debug Menu

Now you can start Tomcat, or the Keel server when using the standalone Keel server deployment, for remote JPDA debugging. For instance, you can start Tomcat as follows (in Unix):

cd $KEEL_HOME/keel-build/deploy/jakarta-tomcat-5.0.19
bin/catalina.sh jpda start

or, in Windows as:

cd %KEEL_HOME%\keel-build\deploy\jakarta-tomcat-5.0.19
bin\catalina.bat jpda start

Once Tomcat starts up, you can connect the Eclipse debugger by using the Keel launch configuration previosuly defined, as shown in Figure 3.21, “Launch Debug Session”. If everything goes correctly, you should see something similar to Figure 3.19, “Setup Launch Configuration”.

Launch Debug Session

Figure 3.21. Launch Debug Session

Connected Debug Session

Figure 3.22. Connected Debug Session