Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using RMI–IIOP in the Development of Distributed Applications Dr. P.G.Sarang, President & ABCOM Information Systems Private. Limited.,

Similar presentations


Presentation on theme: "Using RMI–IIOP in the Development of Distributed Applications Dr. P.G.Sarang, President & ABCOM Information Systems Private. Limited.,"— Presentation transcript:

1 Using RMI–IIOP in the Development of Distributed Applications Dr. P.G.Sarang, President & CEO,sarang@abcom.com ABCOM Information Systems Private. Limited., Mumbai, India Ms Nita P. Sarang, Consultant,nita@indiawatch.org.in CMC Limited, Mumbai, India

2 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 2 RMI Remote Method Invocation Suns programming model for distributed objects Java-based

3 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 3 RMI – merits/demerits Advantages –Ease of programming –No complicated Interface Definition Language (IDL) to learn Disadvantages –Uses Proprietary Protocol Java Remote Method Protocol (JRMP) –No cross-language support

4 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 4 IIOP Internet Inter-Operable Protocol OMGs programming model for distributed objects Language neutral

5 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 5 IIOP – merits/demerits Advantages –Interoperability Between different ORB vendors Between different languages Disadvantages –Need to learn Interface Definition Language (IDL) –Complex Programming

6 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 6 RMI/IIOP Suitability A pure RMI Java solution is suitable for new developments For legacy applications, a CORBA wrapper is required for protecting existing investments

7 How do we achieve best of both worlds? RMI-IIOP Marriage

8 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 8 Proposal A new protocol will confuse the user RMI-IIOP Merger should protect investment in existing binaries Reverse Mappings of RMI Interfaces to CORBA IDL OMG is required to support Object by Value (OBV)

9 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 9 Requirements Existing RMI Clients and Servers both need upgrade to support IIOP

10 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 10 RMI-IIOP Scenario RMI-IIOP Client CORBA Client CORBA Server IIOP

11 How do we convert RMI Application to RMI-IIOP Application?

12 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 12 Converting RMI to RMI-IIOP Use PortableRemoteObject class instead of UnicastRemoteObject Use Java Naming & Directory Interface (JNDI) instead of RMIRegistry Use narrow method instead of Java Casts

13 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 13 Tools New rmic compiler –Converts Java Interfaces to IDL –Generates IIOP Stubs and tie classes New idlj compiler –Maps IDL to Java –Generates IIOP Stubs and tie classes

14 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 14 Migration 1. Converting existing RMI applications to RMI-IIOP applications. 2. Using Java-IDL to develop RMI-IIOP applications 3. Converting existing RMI Interfaces to CORBA IDL

15 Migration – Case 1 Existing RMI to RMI-IIOP

16 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 16 RMI to RMI-IIOP IIOP RMI Java Client RMI Java Server tie class rmic -iiop Complier stub class RMI Implementation

17 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 17 RMI to RMI-IIOP 1. Converting Server Extend your implementation class from PortableRemoteObject rather than UnicastRemoteObject: Use JNDI naming service rather than rmiregistry. 2. Converting Client Use JNDI naming service to locate object Use PortableRemoteObject.narrow() method rather than Java type cast.

18 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 18 Converting Server - Step 1 Use PortableRemoteObject rather than UnicastRemoteObject import javax.rmi.PortableRemoteObject; … public class ComputeImpl extends PortableRemoteObject implements Compute { … }

19 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 19 Converting Server - Step 2 Use JNDI import javax.naming.*; … Replace Naming.rebind("//localhost/ComputeServer", obj); with java.util.Properties env = System.getProperties(); env.put ("java.naming.factory.initial", "com.sun.jndi.cosnaming.CNCtxFactory"); env.put ("java.naming.provider.url", "iiop://localhost:900"); Context ic = new InitialContext(env); ic.rebind ("//localhost/ComputeServer", obj);

20 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 20 Converting Client - Step 1 Use JNDI Replace Object obj = Naming.lookup ("ComputeServer"); With java.util.Properties env = System.getProperties(); env.put ("java.naming.factory.initial", "com.sun.jndi.cosnaming.CNCtxFactory"); env.put ("java.naming.provider.url", "iiop://localhost:900"); Context ic = new InitialContext(env); Object obj = ic.lookup ("//localhost/ComputeServer");

21 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 21 Converting Client - Step 2 Replace java typecast with a call to narrow method Replace Compute TaxObj = (Compute)obj; With Compute TaxObj = (Compute)PortableRemoteObject.narrow (obj, Compute.class);

22 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 22 Compiling Compile Java Source Files javac –d. *.java Generate Stub and Tie Classes rmic –iiop Example: rmic –iiop –d. com.abcom.tax.ComputeImpl

23 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 23 Running – Step 1 Use JNDI Name Server rather than rmiregistry Start the JNDI Name Server with following command start tnameserv (on Windows) tnameserv & (on unix)

24 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 24 Running – Step 2 Start the Server java Example: java com.abcom.tax.ComputeImpl Start the client Java Example: java Client

25 Migration – Case 2 IDL to RMI-IIOP

26 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 26 Steps Write Java IDL Use idlj compiler –Generates Java Mappings –Generates stubs and skeletons Implement Server Run Server and register with JNDI service Develop Client and test

27 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 27 Example Sample Java IDL module abcom{ interface tax { float CalculateTax(in float Amount); }; idlj –fall sample.idl

28 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 28 Generated Files Compiler generates following files in abcom Java package –_taxImplBase.java –_taxStub.java –tax.java –taxHelper.java –taxHolder.java –taxOperations.java

29 Migration – Case 3 Existing Java Interfaces to IDL

30 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 30 RMI to IDL Use rmic to produce idl rmic –idl Map the generated idl to the desired language and provide implementation.

31 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 31 RMI to IDL RMI Interface Impl. class rmic -idl IDL IDL to C++ C++ CORBA Server rmic -iiop RMI-IIOP Client IIOP

32 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 32 Sample Java Remote Interface Sample Java Remote Interface package com.abcom.tax; import java.rmi.Remote; import java.rmi.RemoteException; public interface Compute extends Remote { float SalesTax (float Amount) throws RemoteException; }

33 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 33 Generated IDL #include "orb.idl" … module com { module abcom { module tax { interface Compute { float SalesTax(in float arg0 ); }; … };

34 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 34 Limitations RMI supports passing objects by value in both parameters and method return types CORBA 2.3 specification now supports Object by Value (OBV) CORBA inout, out parameters not supported

35 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 35 OBV – Parameter Objects Example public class Server extends PortableRemoteObject implements Compute { … public void printInvoice(Invoice inv)throws RemoteException { … } rmic –idl Server

36 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 36 Parameter Objects – Generated Files Following IDL files are generated –Compute.idl –Invoice.idl

37 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 37 Parameter Objects – Compute.idl valuetype Invoice; … interface Compute { void printInvoice(in ::Invoice arg0 ); };

38 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 38 Parameter Objects – Invoice.idl valuetype Invoice { private long quantity; private long totalAmt; private ::CORBA::WStringValue itemDesc; factory create( ); };

39 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 39 OBV – Returning objects Example public class Server extends PortableRemoteObject implements Compute { … public Invoice computeInvoice()throws RemoteException { … } rmic –idl Server

40 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 40 Return Objects – Generated Files Following IDL files are generated. –Compute.idl –Invoice.idl

41 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 41 Return Objects – Compute.idl valuetype Invoice; … interface Compute { … ::Invoice computeInvoice( ); }; Invoice.idl is same as in previous case

42 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 42 OBV – Dynamic Downloading Remote classes for parameter objects can be dynamically downloaded using RMI class loading mechanism –Requires setting of java.rmi.server.codebase environment variable

43 O'Reilly Conference on Java - Enterprise Java Using RMI-IIOP in the Development of Distributed Applications 43 Support for Objects by Value Supported in CORBA 2.3 specification Initial support by Java IDL ORB Support now added by Major ORB vendors Support defined for Java and C++

44 Conclusions

45 Thank You


Download ppt "Using RMI–IIOP in the Development of Distributed Applications Dr. P.G.Sarang, President & ABCOM Information Systems Private. Limited.,"

Similar presentations


Ads by Google