Information Technology Reference
In-Depth Information
import DateApp.∗;
import org.omg.CosNaming.∗;
import org.omg.CORBA.∗;
import org.omg.PortableServer.∗;
import org.omg.PortableServer.POA;
class HelloImpl extends DatePOA {
private ORB orb;
public void setORB(ORB orb_val) {
orb = orb_val;
}
public String getDate() {
return new java.util.Date().toString();
}
public void shutdown() {
orb.shutdown(false);
}
}
public class DateServer {
public static void main(String args[]) {
try {
ORB orb = ORB.init(args, null);
POA rootpoa =
POAHelper.narrow(orb.resolve_initial_references(
"RootPOA"
));
rootpoa.the_POAManager().activate();
HelloImpl helloImpl = new HelloImpl();
helloImpl.setORB(orb);
org.omg.CORBA.Object ref = rootpoa.servant_to_reference(helloImpl);
Date href = DateHelper.narrow(ref);
org.omg.CORBA.Object objRef =
orb.resolve_initial_references(
"NameService"
);
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
String name =
"Date"
;
NameComponent path[] = ncRef.to_name(name);
ncRef.rebind(path, href);
System.out.println(
"HelloServer ready and waiting \ldots{}"
);
orb.run();
} catch (Exception e) {
System.err.println(
"ERROR: "
+e);
e.printStackTrace(System.out);
}
System.out.println(
"DateServer Exiting \ldots{}"
);
}
}
Figure 2.9. An example of a simple CORBA server. Code in
the shaded area implements Java's CORBA framework.
The Java programming language, however, provides the Remote Method In-
vocation (RMI) distributed system, based on Modula-3 network objects [14], that
allows for the dynamic representation of data and therefore allows for polymorphic
data to be transmitted and received across the network [116]. More recently, the
Jini distributed system [102] builds on the idea of polymorphic data representation
Search WWH ::
Custom Search