Presentation is loading. Please wait.

Presentation is loading. Please wait.

By Dr. Jiang B. Liu 11. Java IDL and CORBA  Generic ORB Core  idltojava development tool  CORBA Object Service (COS) name service - nameserv  Java.

Similar presentations


Presentation on theme: "By Dr. Jiang B. Liu 11. Java IDL and CORBA  Generic ORB Core  idltojava development tool  CORBA Object Service (COS) name service - nameserv  Java."— Presentation transcript:

1 By Dr. Jiang B. Liu 11. Java IDL and CORBA  Generic ORB Core  idltojava development tool  CORBA Object Service (COS) name service - nameserv  Java IDL Hello Example

2 Java IDL Network Computing n Java IDL provides connectivity and interoperability to the OMG CORBA standard. n IDL: specifies interfaces for objects (services,components, etc...) available anywhere in a network. The IDL definitions can be compiled with the idltojava stub generator tool to generate Java interface definitions and Java client and server stubs. n IIOP is a CORBA network protocol. Java IDL uses IIOP version 1.0 and it is based on a portable Java ORB core.

3 Network Computing: CORBA n CORBA network component computing model

4 Java IDL Client Invocation Model n An Object Invocation from a JavaIDL Client

5 ORB Client Invocation Model n The Structure of Object Request Broker Interfaces

6 OMG IDL Client Invocation Model n OMG Interface and Implementation Repositories

7 Java IDL Example: Hello.idl n Idl file module HelloApp { interface hello { string sayHello(); }; }; n Generate Java stubs idltojava -fno-cpp -fclient -fserver -fverbose hello.idl (Generate the following interfaces/classes in the HelloApp directoryhello.java - interface (client/server) helloHolder.java - Holder class for each interface providing out/inout parameter passing modes. (not used in this example)helloHelper.java - Helper class for for each interface providing static methods such as read, write, insert, extract, id. (client)_helloImplBase - Implementation base (server) -helloStub - Stub (client/server)

8 Java IDL Example: Hello.idl n Start CORBA Object Service (COS) name service nameserv -ORBInitialPort 1050 n Compile and run Hello server object javac helloServer.java helloServant.java HelloApp\_helloImplBase.java HelloApp\_helloStub.java HelloApp\hello.java java helloServer - ORBInitialPort 1050 n Compile and run Hello client object javac helloClient.java HelloApp\helloHelper.java HelloApp\_helloStub.java HelloApp\hello.java java helloClient -ORBInitialPort 1050

9 Java IDL Example: Hello.idl n import HelloApp.*; n import org.omg.CosNaming.*; n import org.omg.CosNaming.NamingContextPackage.*; n import org.omg.CORBA.*; n class helloServant extends _helloImplBase n { n public String sayHello() n { n return "\nHello world !!\n"; n }

10 n public class helloServer { n public static void main(String args[]) { n try{ // create and initialize the ORB n ORB orb = ORB.init(args, null); n // create servant and register it with the ORB n helloServant helloRef = new helloServant(); orb.connect(helloRef); n // get the root naming context n org.omg.CORBA.Object objRef = n orb.resolve_initial_references("NameService"); n NamingContext ncRef = NamingContextHelper.narrow(objRef); n // bind the Object Reference in Naming n NameComponent nc = new NameComponent("Hello", ""); n NameComponent path[] = {nc}; n ncRef.rebind(path, helloRef); n // wait for invocations from clients n java.lang.Object sync = new java.lang.Object(); n synchronized (sync) {sync.wait();} …}

11 n public class helloClient { n public static void main(String args[]){ n try{// create and initialize the ORB n ORB orb = ORB.init(args, null); n // get the root naming context n org.omg.CORBA.Object objRef = n orb.resolve_initial_references("NameService"); n NamingContext ncRef = NamingContextHelper.narrow(objRef); n // resolve the Object Reference in Naming n NameComponent nc = new NameComponent("Hello", ""); n NameComponent path[] = {nc}; n hello helloRef = helloHelper.narrow(ncRef.resolve(path)); n // call the hello server object and print results n String hello = helloRef.sayHello(); n System.out.println(hello); n … }


Download ppt "By Dr. Jiang B. Liu 11. Java IDL and CORBA  Generic ORB Core  idltojava development tool  CORBA Object Service (COS) name service - nameserv  Java."

Similar presentations


Ads by Google