Presentation is loading. Please wait.

Presentation is loading. Please wait.

RMI-IIOP.  RMI-IIOP combines RMI-style ease of use with CORBA cross-language interoperability  Java™ Remote Method Invocation (RMI) provides a simple.

Similar presentations


Presentation on theme: "RMI-IIOP.  RMI-IIOP combines RMI-style ease of use with CORBA cross-language interoperability  Java™ Remote Method Invocation (RMI) provides a simple."— Presentation transcript:

1 RMI-IIOP

2  RMI-IIOP combines RMI-style ease of use with CORBA cross-language interoperability  Java™ Remote Method Invocation (RMI) provides a simple mechanism for distributed Java programming. RMI over IIOP (RMI-IIOP) uses the Common Object Request Broker Architecture (CORBA) standard Internet Inter- ORB Protocol (IIOP) to extend the base Java RMI to perform communication. This allows direct interaction with any other CORBA Object Request Brokers (ORBs), whether they were implemented in Java or another programming language.

3  RMI-IIOP is for Java programmers who want to program to the RMI interfaces, but use IIOP as the underlying transport. RMI- IIOP provides interoperability with other CORBA objects implemented in various languages - but only if all the remote interfaces are originally defined as Java RMI interfaces. It is of particular interest to programmers using Enterprise JavaBeans (EJB), since the remote object model for EJBs is RMI-based. RMI-IIOP

4 HelloWorld Application using IIOP

5 HelloInterface.java import java.rmi.Remote; public interface HelloInterface extends java.rmi.Remote { public String sayHello( String from ) throws java.rmi.RemoteException; }

6 HelloImpl.java import javax.rmi.PortableRemoteObject; public class HelloImpl extends PortableRemoteObject implements HelloInterface { public HelloImpl() throws java.rmi.RemoteException { super(); // invoke rmi linking and remote object initialization } public String sayHello( String from ) throws java.rmi.RemoteException { return "Hello from " + from + "!!" ; }

7  By extending PortableRemoteObject, the HelloImpl class can be used to create a remote object that uses IIOP- based transport for communication.

8 HelloServer.java import javax.naming.InitialContext; import javax.naming.Context; public class HelloServer { public static void main(String[] args) { try { HelloImpl helloRef = new HelloImpl(); Context initialNamingContext = new InitialContext(); initialNamingContext.rebind("HelloService", helloRef ); System.out.println("Hello Server: Ready..."); } catch (Exception e) { System.out.println("Trouble: " + e); e.printStackTrace(); }

9 HelloClient.java import java.net.MalformedURLException; import javax.rmi.*; Import java.rmi.*; import java.util.Vector; import javax.naming.*; import java.io.*; public class HelloClient { public static void main( String args[] ) { Context ic; Object objref; HelloInterface hi;

10 try { ic = new InitialContext(); objref = ic.lookup("HelloService"); System.out.println("Client: Obtained a ref. to Hello server."); hi = (HelloInterface) PortableRemoteObject.narrow( objref, HelloInterface.class); System.out.println(hi.sayHello( " MARS " )); } catch( Exception e ) { System.err.println( "Exception " + e + "Caught" ); e.printStackTrace( ); return; }

11 Compilation  Compile all classes. javac *.java  Create stubs and skeletons rmic –iiop HelloImpl

12 Execute  Start Naming Service: start orbd -ORBInitialPort 1050  Start the server: start java - Djava.naming.factory.initial=com.sun.jndi.cosna ming.CNCtxFactory - Djava.naming.provider.url=iiop://localhost:1050 HelloServer  Run the client application java - Djava.naming.factory.initial=com.sun.jndi.cosna ming.CNCtxFactory - Djava.naming.provider.url=iiop://localhost:1050 HelloClient

13 Task:  Create RMI IIOP application in which take a sentence at runtime on the client and let the server return its reverse. E.g. input : distributed computing output: computing distributed.  Deadline : 13 th -September-2013


Download ppt "RMI-IIOP.  RMI-IIOP combines RMI-style ease of use with CORBA cross-language interoperability  Java™ Remote Method Invocation (RMI) provides a simple."

Similar presentations


Ads by Google