/*
* This example is from the book "Java Enterprise in a Nutshell".
* Copyright (c) 1999 by O'Reilly & Associates.
* You may distribute this source code for non-commercial purposes only.
* You may study, modify, and use this example for any purpose, as long as
* this notice is retained. Note that this example is provided "as is",
* WITHOUT WARRANTY of any kind either expressed or implied.
*/
import javax.naming.*;
import java.rmi.*;
import java.util.Hashtable;
// Utility class that registers an account with the local
// RMI registry for remote access
public class IIOPRegAccount {
public static void main(String argv[]) {
try {
// Make an Account with a given name
IIOPAccountImpl acct = new IIOPAccountImpl("JimF");
// Get a reference to CORBA naming service using JNDI
Hashtable props = new Hashtable();
props.put("java.naming.factory.initial",
"com.sun.jndi.cosnaming.CNCtxFactory");
props.put("java.naming.provider.url", "iiop://localhost:900");
Context ctx = new InitialContext(props);
// Register our Account with the CORBA naming service
ctx.rebind("JimF", acct);
System.out.println("Registered account.");
}
catch (Exception e) {
e.printStackTrace();
}
}
}
|