Java PrimerRMI Over IIOPWhen the Java and CORBA Worlds Collide
- By Salih Ergül
- May 13, 2000
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();
}
}
}