How to init ORB from property file?

ε祈祈猫儿з 提交于 2019-12-02 02:12:38

You have to add -ORBInitRef to the ORB arguments also. Compare it to the commandline you normaly use. ALL the arguments have to be passed to the ORB.init()

config.properties:

ORBInitRef NameService=corbaloc::localhost:2809/NameService 

Java Code using it (ReadProps.java)

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

import org.omg.CORBA.ORB;

public class ReadProps {
    public static void main(String[] args) {
        ORB clientsORB = org.omg.CORBA.ORB.init(readConfigFile(), null);
    }

    static String[] readConfigFile() {
        Properties prop = new Properties();
        String[] orbarg = new String[2];

        try {
            // load a properties file
            prop.load(new FileInputStream("config.properties"));
            // get the property value and print it out  
            orbarg[0] = "-ORBInitRef"; // <---- NEEDED
            orbarg[1] = prop.getProperty("ORBInitRef");

        } catch (IOException ex) {
            ex.printStackTrace();
        }
        return orbarg;
    }

}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!