Java PrimerRMI Over IIOPWhen the Java and CORBA Worlds Collide

Java Primer
RMI Over IIOP
When the Java and CORBA Worlds Collide

Salih Ergül
Listing 6. Reworked InternetFaxServer to explicitly make the fax machine available to both JRMP and IIOP clients.

package fax.dual;

import javax.naming.*;
import java.util.Properties;
import fax.dual.*;

public class InternetFaxServer {
  public static void main(String[] args) {
    try {
    CanonInternetFax faxObj = new 
CanonInternetFax();

    	// Export the object to both JRMP and IIOP
    java.rmi.server.UnicastRemoteObject.exportObject(faxObj);
    
    javax.rmi.PortableRemoteObject.exportObject(faxObj);

    // Bind the object to RMI registry (JRMP)
    Properties regProps = new Properties();
    regProps.put("java.naming.factory.initial",
    "com.sun.jndi.rmi.registry.RegistryContextFactory"); 
    Context regContext = 
    new InitialContext (regProps);
    regContext.rebind ("CanonInternetFaxServer",
     faxObj);

    // Bind the object to CosNaming (IIOP)
    Properties cosProps = new Properties();
    cosProps.put("java.naming.factory.initial",
    "com.sun.jndi.cosnaming.CNCtxFactory"); 
    Context cosContext = 
    new InitialContext (cosProps);
    cosContext.rebind ("CanonInternetFaxServer",
    faxObj);

    } catch (Exception e) {
                    e.printStackTrace();
    }
  }
}

Upcoming Training Events

0 AM
Visual Studio Live! San Diego
September 8-12, 2025
Live! 360 Orlando
November 16-21, 2025
Cloud & Containers Live! Orlando
November 16-21, 2025
Data Platform Live! Orlando
November 16-21, 2025
Visual Studio Live! Orlando
November 16-21, 2025