IDL Java Code C++ Code

Wafer Databases

Each database is a simple Java application. It mimics the S directory databases, providing methods for querying & modifying the the objects it contains. There are 3 instances of the database running in the demo. The database is a server and is intended to be populated by the Wafer factory client which connects to and invokes the assign() method with a wafer object.

The database is run with the The class jCorbaDatabase is the application class and is invoked via the run script.

The implementation of the actual database table class relies on the Java Hashtable. The methods involve the get() and put() methods and the containsKey(), etc. for that class. As usual in CORBA, we are uninterested in these details from the persecpctive of remote services. The implementation is encapsulated and we only see the IDL-specified methods.

Implementing this class which holds the objects is trickier in Java than it might be due to the lack of multiple inheritance. We would like to inherit the methods for a basic database as well as the skeleton for the CORBA utilities. The simplest approach in this case is to have all the methods locally and extend the CORBA skeleton SServices._WaferDatabaseImplBase generated by compiling the IDL. Using helpers and holders allows us to extend once class and accessing the CORBA skeleton to provide the marshalling across remote invocation.

IDL Specification

Below is the IDL specification for the database class. It is general in that it uses the any class as the type of object which can be stored. In other words, the database is not fussy what it stores. However, different implementations can be more discriminating and reject objects not of a particular class.

To compile both Java and C++ bindings for this IDL module, given the command

make idl

This is contained in the file JavaDatabase/database.idl of the distribution.

module SServices {

 typedef sequence<string> StringSequence;

 interface ObjectDatabase {

     // store the object obj using the specified name.
  boolean assign(in any obj, in string name);

     // query whether there is an entry in the table
     // with the given name.
  boolean exists(in string name);

     // retrieve the object stored under the specified name
  any get(in string name);

     // return a sequence/array of all the names used in the
     // table to index the objects.
  StringSequence objects();

    // remove the entry from the table for the specified name.
  boolean remove(in string name);

     // remove all the entries in one step.
  boolean clear();   
 };
};
Compiling this file using OmniBroker generates several files listed below. These will be created in the SServices subdirectory of the directory in which the .idl file is located.
  1. ObjectDatabase.java
  2. ObjectDatabaseHelper.java
  3. ObjectDatabaseHolder.java
  4. StringSequenceHelper.java
  5. StringSequenceHolder.java
  6. StubForObjectDatabase.java
  7. _ObjectDatabaseImplBase.java
In general you will not need to look at these. The _ObjectDatabaseImplBase would be the class we would extend to implement a distribute Database server class. However, we do this with the
WaferDatabaseImpl class.

Methods

objects()

Converts the Enumeration returned from the keys() method of the included Hashtable to an array of String objects. Again, this is much of what happens in CORBA - convert data from one format to an acceptable format for the client/target object.

assign()

Stores an arbitrary object in the hashtable using the given name. If an entry already exists with that name, it is is overwritten. A client which has a reference to that previous remote object can continue to use it. However, it will no longer be in the database.

The object being stored in the database is presented from a client invoking the assign() method. Thus the data for the object lies outside of the database and the latter just has a reference to the object. This can be overcome by serializing the object or cloning it locally in the database, if supported. Different cloning mechanisms are available - the low-level CORBA clone or a WaferDatabase specific method to copy the fields of the Wafer object (identifiable from the Wafer IDL description).

get()

This retrieves the object in the Hashtable with the specified name. It is returned as is - casting it to CORBA.Any. Since the hashtable stores Java Objects and is a simple generic container, there is no additional processing to convert the resulting object to a known type. The client performs this action when it receives the object. The return value is simply a reference to a remote object since the object does not reside in the database in the current implementation. See assign() for more details on this.

exists()

Takes a string and returns a boolean indicating whether the object exists or not. This is implemented using the containsKey() method of java.util.Hashtable.

remove()

Remove the entry in the hashtable stored with the given name. As with assigning to an already existing key, the remote object reference is discarded, not the remote object and clients can proceed to use the remote object with impunity. Only when all clients have completed using the object will it be discarded.

clear()

Remove all the elements from the hashtable leaving it empty. The same issue about using discarded objects as with the remove method apply - remote object references are still valid.

IDL Inheritance

The IDL defining the database class above provides a suitably general database API. In our example, we wish to extend this to produce a specialized database which stores Wafer objects and can perform some computations locally. (Not all computations should be done locally in the database since we would then not avail of the code developed in S and some are best left to such languages.)

We extend the ObjectDatabase class in IDL to produce a WaferDatabase class. This provides additional methods to get access to components and computations of a specific wafer identified by its name used in the database. The IDL is below and illustrates the idea of inheritance. (The name of the module (SServices) is coincidentally the same as that for the container of the ObjectDatabase interface above. This is neither necessary or probably desireable as there are now two packages with the same name in Java, leading to potential confusion.)

WaferDatabase IDL

For convenience and until we define some generic data types for statistical computing that represent simple arrays, we define and include typedefs for standard sequences. This is the file Sequences.idl. and looks like
module Sequences {
   typedef sequence DoubleSequence;
   typedef sequence StringSequence;
   typedef sequence LongSequence;
};
The WaferDatabase class is defined as follows:
  // include the ObjectDatabase module
#include "database.idl"
  // include a local Sequences definition which we use temporarily
  // until we have definitions of Generic Data Types for statistical
  // computing.
#include "Sequences.idl"

module SServices {
interface WaferDatabase : SServices::ObjectDatabase {

   // Compute the yield for a given lot returning
   // the frequencies/counts of the different failure
   // types/modes.
   
 Sequences::DoubleSequence yield(in string wafer_name);


   // The following are utility methods to allow a client
   // retrieve attributes of a wafer by identifying
   // the object by name rather than a two step
   // approach of retrieving the object (and narrowing it)
   // and then retrieving the data slot from the Wafer object.
   // At present these are used to avoid having to deal with the
   // Wafer object. This is not very difficult but more than we wanted
   // to do.

     void assignWafer(in string name,  
                       in Sequences::LongSequence x,
                       in Sequences::LongSequence y,
      		       in Sequences::StringSequence values,  
                       in Sequences::StringSequence modes); 
    
     Sequences::StringSequence getValues(in string wafer_name);
     Sequences::LongSequence getX(in string wafer_name);
     Sequences::LongSequence getY(in string wafer_name);
     Sequences::StringSequence getModes(in string wafer_name);
 };
};

yield()

This is where the database is specialized for wafers by extending the base database class. This method computes the yield for the wafer stored with a given name in the database. The result is a sequence of doubles indicating the yield for each wafer in the lot. The length of the sequence is the number of wafers in the lot. This allows the computations to be done locally in the database where the data resides rather than moving the data to a client and then performing the computations. In this sense it is an efficiency specialization that illustrates the power of the Object Oriented Remote Server approach.

The implementation of this method of course relies on the representation of the wafer object. In order to do this, we define yield() as a method in the IDL class defining a Wafer. Again, the encapsulation allows the database to know very little about the structure or contents of the objects it stores.

assignWafer

This is a specialization of the general database mechanism which allows clients to avoid having to create the Wafer object which is to be stored. This simplifies the demo but will be done relatively automatically by S in the future based on the IDL description of the Wafer IDL class. This allows the data to be transferred to the database and a Wafer object to be constructed there.
Duncan Temple Lang <duncan@research.bell-labs.com>
Last modified: Wed May 20 15:05:25 EDT 1998