SDSU CS 696 Emerging Technologies: Distributed Objects
Spring Semester, 1998
TIE

To Lecture Notes Index
© 1998, All Rights Reserved, SDSU & Roger Whitney
San Diego State University -- This page last updated 21-Apr-98

Contents of Doc 23, TIE

  1. References
  2. Implementing A Server - ImplBase
  3. The TIE Approach
    1. The Server
    2. The Client

References


OrbixWeb Programmer's Guide, IONA Technologies PLC, November 1997, chapter 7 Using and Implementing IDL Interfaces pp 141-172


Doc 23, TIE Slide # 2

Implementing A Server - ImplBase

interface Greeter
   {
   string name();
   };

Using the IDL Compiler we get:
public interface Greeter  extends org.omg.CORBA.Object {
    public String name() ;
    public java.lang.Object _deref() ;
}

import IE.Iona.OrbixWeb._OrbixWeb;

public abstract class _GreeterImplBase 
    extends _GreeterSkeleton 
    implements Greeter 
{
    public _GreeterImplBase() {
        org.omg.CORBA.ORB.init().connect(this);
    }

    public _GreeterImplBase(String marker) {
        _OrbixWeb.ORB(org.omg.CORBA.ORB.init()).connect(this,marker);
    }

    public _GreeterImplBase(IE.Iona.OrbixWeb.Features.LoaderClass loader) {
        _OrbixWeb.ORB(org.omg.CORBA.ORB.init()).connect(this,loader);
    }

    public _GreeterImplBase(String marker,IE.Iona.OrbixWeb.Features.LoaderClass loader) {
        _OrbixWeb.ORB(org.omg.CORBA.ORB.init()).connect(this,marker,loader);
    }

    public java.lang.Object _deref() { return this; }

}

Doc 23, TIE Slide # 3
An implementation
class InheritedGreeter extends _GreeterImplBase
   {
   protected String name;
   
   public InheritedGreeter( String name)
      {
      this.name = name;
      }
      
   public String name()
      {
      return name;
      }
   }
Problem

What if we now have:
interface GrouchyGreeter : Greeter
   {
   string message();
   };

The IDL will produce a Java interface GrouchyGreeter and a class _GrouchyGreeterImplBase

To implement the GrouchyGreeter we need to subclass _GrouchyGreeterImplBase

This means we can not inherit the method from our implementation of InheritedGreeter!

Doc 23, TIE Slide # 4

The TIE Approach


The IDL compiler produces the files:
Greeter.java GreeterHelper.java GreeterHolder.java
GreeterPackage/_GreeterSkeleton.java
_GreeterImplBase.java_GreeterStub.java
_GreeterOperations.java_tie_Greeter.java

We will use _GreeterOperations.java and _tie_Greeter.java

We have:
public interface _GreeterOperations  {
    public String name() ;

}

The TIE implementation is:

class TieGreeter implements _GreeterOperations
   {
   protected String name;
   
   public TieGreeter( String name)
      {
      this.name = name;
      }
      
   public String name()
      {
      return name;
      }
   }

Doc 23, TIE Slide # 5

The Server

import IE.Iona.OrbixWeb._CORBA;
import IE.Iona.OrbixWeb.CORBA.ORB;

public class SimpleGreeterServer
   {
   public static void main (String args[])
      {
      org.omg.CORBA.ORB ord =
         org.omg.CORBA.ORB.init();
      
      Greeter upTown = null;
         
      try
         {
         upTown = new _tie_Greeter( new TieGreeter( "Upton"));
         _CORBA.Orbix.impl_is_ready( "Visitor" );
         System.out.println("Server going Down");
         }
      catch ( org.omg.CORBA.SystemException corbaError)
         {
         System.out.println("Exception " + corbaError);
         }
      }
   }


Doc 23, TIE Slide # 6
_tie_Greeter
// Java generated by the OrbixWeb IDL compiler 

import IE.Iona.OrbixWeb._OrbixWeb;

public class _tie_Greeter  extends _GreeterSkeleton 
    implements Greeter 
{
    protected _GreeterOperations m_impl;

    public _tie_Greeter(_GreeterOperations impl) {
        this.m_impl = impl;
        org.omg.CORBA.ORB.init().connect(this);
    }

    public _tie_Greeter(_GreeterOperations impl, String marker) {
        this.m_impl = impl;
        _OrbixWeb.ORB(org.omg.CORBA.ORB.init()).connect(this,marker);
    }

    public _tie_Greeter(_GreeterOperations impl,
                     IE.Iona.OrbixWeb.Features.LoaderClass loader) {
        this.m_impl = impl;
        _OrbixWeb.ORB(org.omg.CORBA.ORB.init()).connect(this,loader);
    }

    public _tie_Greeter(_GreeterOperations impl,
                  String marker, IE.Iona.OrbixWeb.Features.LoaderClass  loader) {
        this.m_impl = impl;
        _OrbixWeb.ORB(org.omg.CORBA.ORB.init()).connect(this,marker,loader);
    }

    public String name() { return m_impl.name(); }

    public java.lang.Object _deref() {
        return m_impl;
    }
}

Doc 23, TIE Slide # 7

The Client

import IE.Iona.OrbixWeb._CORBA;
import org.omg.CORBA.ORB;

public class SimpleGreeterClient
   {
   public static void main(String args[])
      {
      ORB.init();
      
      String hostname = "eli.sdsu.edu";
      String serverLabel = ":Visitor";
      Greeter server = 
         GreeterHelper.bind( serverLabel, hostname);

      System.out.println( server.name() );
      }
   }


Doc 23, TIE Slide # 8
Running the Example

Compile all classes

You start the deamon by the command:
orbixdj -textConsole

Now register the server via:
putit Visitor -java SimpleGreeterServer

Now run the server via
java SimpleGreeterServer

Now run the client via
java SimpleGreeterClient



visitors since 24-Mar-98