|
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
- References
- Implementing A Server - ImplBase
- The TIE Approach
- The Server
- The Client
OrbixWeb Programmer's Guide, IONA Technologies PLC, November 1997,
chapter 7 Using and Implementing IDL Interfaces pp 141-172
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; }
}
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!
The IDL compiler produces the files:
Greeter.java
GreeterPackage/ | _GreeterSkeleton.java |
GreeterHelper.java
_GreeterImplBase.java | _GreeterStub.java |
GreeterHolder.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;
}
}
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);
}
}
}
_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;
}
}
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() );
}
}
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