Java Reference
In-Depth Information
￿
_HelloImplBase.java
An abstract class comprising the server skeleton. It provides basic CORBA
functionality for the server and implements the Hello interface. Each servant
(interface implementation) that we create for this service must extend _HelloImplBase .
￿
_HelloStub.java
This is the client stub, providing CORBA functionality for the client. Like _
HelloImplBase.java , it implements the Hello interface.
Prior to J2SE 1.3, the method signatures would have been specifi ed within Hello.
java , but are now held within HelloOperations.java .
3. Implement the interface.
Here, we specify the Java implementation of our IDL interface. The implementation
of an interface is called a 'servant', so we shall name our implementation class
HelloServant. This class must extend _HelloImplBase . Here is the code:
class HelloServant extends _HelloImplBase
{
public String getGreeting()
{
return ("Hello there!");
}
}
This class will be placed inside the same fi le as our server code.
4. Create the server.
Our server program will be called HelloServer.java and will subsume the servant
created in the last step. It will reside in the directory immediately above directory
SimpleCORBAExample and will import package SimpleCORBAExample and the
following three standard CORBA packages:
￿
org.omg.CosNaming (for the naming service);
￿
org.omg.CosNaming.NamingContextPackage (for special exceptions thrown by
the naming service);
￿
org.omg.CORBA (needed by all CORBA applications).
There are several steps required of the server…
(i) Create and initialise the ORB .
This is effected by calling static method init of class ORB (from package org.
omg.CORBA ). This method takes two arguments: a String array and a Properties
object. The fi rst of these is usually set to the argument list received by main ,
while the second is almost invariably set to null :
ORB orb = ORB.init(args,null);
[The argument args is not used here (or in many other such programs) in a
Windows environment, but it is simpler to supply it, since replacing it with
null causes an error message, due to ambiguity with an overloaded form of
init that takes an Applet argument and a Properties argument.]
Search WWH ::




Custom Search