WebObjects

WebObjects

WebObjects is a powerful rapid application development environment for building powerful web sites and web services. Built on a three-tier architechure, WebObjects allows you to insulate applications from your database architecture by mapping attributes in a data model. Database access is accomplished by a component called Enterprise Objects Framework (EOF) which maps database records to Java objects using the data model.

In this chapter we are going to cover just the basics on connecting to OpenBase using WebObjects and incorporating the Primary Key Generation Framework into your projects. We would recommend that you visit the Apple website for specific information on how to use WebObjects. Extensive resources are available that document the use of this tool.

Creating a Connection to OpenBase Using WebObjects

To create an OpenBase model in EOModeler using WebObjects 5.0 follow these steps.

1. Launch the the EOModeler application.

2. Choose New from the Model menu.

3. Choose "JDBC" from the New Model Wizard.

A JDBC login window will show up. Enter the following information as it relates to your data source.
• User: (leave blank if not specified in database)
Login: (leave blank if not specified in database)
Driver: com.openbase.jdbc.ObDriver
URL: jdbc:openbase://hostipaddress/databasename

The hostipaddress can be a host name as long as your DNS can resolve it and it either matches the hostname or AddressAliases maps the domain name to the ipaddress.

Using OpenBase Primary Key Framework

WebObjects 5 does not automatically use OpenBase's unique key generation system. By default it uses a table called EO_PK_TABLE to store seed values for generating keys. If you are using database replication with your applications you will need to use the unique key generation provided by OpenBase.

In this section we explain the steps of how to incorporate the primary key framework into your webobjects applications so that your applications will use the OpenBase routines for generating primary keys.

1. Confirm that the "OpenBasePKPlugIn.framework" bundle is installed in /Library/Frameworks. This is installed with OpenBase.

2. Add the OpenBasePKPlugIn framework to your project. In your ProjectBuilder project, select the Add Frameworks menu option. Choose the framework "OpenBasePKPlugIn.framework". Add this file to the 'Application Server' target. This frameworks should now appear in the left panel ('Groups & Files'). You can now move the location of the OpenBasePKPlugIn to the Frameworks folder in your project.

3. Tell your application to use this OpenBase plugin instead of the one that ships by default with WebObjects 5.0. There are 2 ways to do this (option 1 and option 2 below):

Option 1:
In your Application constructor, add the following line:

JDBCPlugIn.setPlugInNameForSubprotocol("com.webobjects.jdbcad aptor.OpenBasePKPlugIn", "openbase");

Here is an example:

public Application() {
super();    
// Use the OpenBase plugin for PK generation
JDBCPlugIn.setPlugInNameForSubprotocol("com.webobjects.jdbcadaptor .OpenBasePKPlugIn", "openbase");
// Additional code here... }

Option 2:
In EOModeler, in the JDBC connection window, add com.webobjects.jdbcadaptor.OpenBasePKPlugIn in the plugin textfield.

Note: For more information about JDBC Plugin, please go to:
http://developer.apple.com/technotes/tn/tn2027.html

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License