Server Side: Writing SIDL classes in Java

Babel also supports calls to SIDL classes implemented in Java. These classes obey the same rules as the client side Java classes, except that is this case the file, class, and method names all end in _Impl.

As is the case with other Babel server side files, only the code written between splicer blocks will be preserved between calls of Babel. Make sure any data and code is kept in the designated areas, otherwise it won't be there after you run Babel on those files.

Another interesting fact of the Server Side is that it inherits from the Client Side Java class. This allows us to call local methods directly. Take this recursive Fibonacci function implementation for example:


class Fib_Impl extends Fib {
  public int getFib_Impl(int x) {
    // DO-NOT-DELETE splicer.begin(ExceptionTest.Fib.getFib) 
    if(x >= 2) {
      return getFib(x-1) + getFib(x-2);
    } else {
      return 1;
    }
    // DO-NOT-DELETE splicer.end(ExceptionTest.Fib.getFib)
  }
}

Here the client side class is name Fib, and therefore the Server Side class is Fib_Impl. The same relation is true for the getFib method. You can also see that we are able to call getFib, the client side method, directly. A call like this will go through Babel glue code, as it should. You should not try to make calls directly to _Impl methods. It won't work at all on different objects, and it breaks the object model if used on methods in the current object. (That is, it is possible to call foo_Impl in the current object, but because the call will not go through Babel, any inheritance information will be lost, and the wrong version of the method may be called. Simply call foo in the standard way.)

This also means there is no way to have Server Side object inherit from non SIDL Java classes, in fact, there are no splicer blocks available for inheritance, so implementing interfaces on the Server Side is also not supported. This is because we feel that having the Server side inherit from non-SIDL classes is probably not a good idea.



babel-0.10.2
users_guide Last Modified 2005-03-23

http://www.llnl.gov/CASC/components
components@llnl.gov