FileDocCategorySizeDatePackage
OrbSetup.javaAPI DocExample2186Thu Nov 08 00:23:42 GMT 2001com.ora.rmibook.chapter23.corbaaccounts.applications

OrbSetup

public class OrbSetup extends Object

Fields Summary
private static Properties
_properties
Constructors Summary
Methods Summary
public static voidbindAccountServer(java.lang.String name, Account server)

        Properties properties = OrbSetup.getProperties();
        ORB orb = ORB.init((String[]) null, properties);

        orb.connect(server); // This is pretty much a JavaIDL hack
        // JavaIDL doesn't really support servers well
      
        org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
        NamingContext nameServer = NamingContextHelper.narrow(objRef);
      
        NameComponent ourComponent = new NameComponent(name, "");
        NameComponent path[] = {ourComponent};

        nameServer.rebind(path, server);
    
public static AccountgetAccount(java.lang.String name)

        try {
            Properties properties = OrbSetup.getProperties();
            ORB orb = ORB.init((String[]) null, properties);
            org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
            NamingContext nameServer = NamingContextHelper.narrow(objRef);
      
            NameComponent ourComponent = new NameComponent(name, "");
            NameComponent path[] = {ourComponent};
            org.omg.CORBA.Object accountRef = nameServer.resolve(path);

            return AccountHelper.narrow(accountRef);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    
private static java.util.PropertiesgetProperties()

        if (null == _properties) {
            _properties = new Properties();
            _properties.put("org.omg.CORBA.ORBInitialPort", "3500");
            _properties.put("org.omg.CORBA.ORBInitialHost", "localhost");
            //			_properties.put("org.omg.CORBA.ORBClass", "com.sun.CORBA.iiop.ORB");
        }
        return _properties;