1 / 11

By Dr. Jiang B. Liu

Java Computing. 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. Java IDL Network Computing.

odetta
Download Presentation

By Dr. Jiang B. Liu

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Java Computing 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 • Java IDL provides connectivity and interoperability to the OMG CORBA standard. • 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. • 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 • CORBA network component computing model

  4. Java IDL Client Invocation Model • An Object Invocation from a JavaIDL Client

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

  6. OMG IDL Client Invocation Model • OMG Interface and Implementation Repositories

  7. Java IDL Example: Hello.idl • Idl file module HelloApp { interface hello { string sayHello(); }; }; • Generate Java stubs idltojava -fno-cpp -fclient -fserver -fverbose hello.idl (Generate the following interfaces/classes in the HelloApp directory hello.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 • Start CORBA Object Service (COS) name service nameserv -ORBInitialPort 1050 • Compile and run Hello server object javac helloServer.java helloServant.java HelloApp\_helloImplBase.java HelloApp\_helloStub.java HelloApp\hello.java java helloServer -ORBInitialPort 1050 • 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 • import HelloApp.*; • import org.omg.CosNaming.*; • import org.omg.CosNaming.NamingContextPackage.*; • import org.omg.CORBA.*; • class helloServant extends _helloImplBase • { • public String sayHello() • { • return "\nHello world !!\n"; • } • }

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

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

More Related