20 package com.generalrobotix.ui.util;
22 import java.util.HashMap;
24 import org.omg.CORBA.*;
25 import org.omg.CORBA.ORBPackage.InvalidName;
26 import org.omg.CosNaming.*;
27 import org.omg.PortableServer.POA;
45 public static org.omg.CORBA.ORB
getORB(String[] argv) {
47 java.util.Properties props =
null;
48 props = System.getProperties();
49 orb_ = ORB.init(argv, props);
97 String nameServiceURL =
"corbaloc:iiop:" + nsHost +
":" + nsPort +
"/NameService";
101 org.omg.CORBA.Object
obj = orb_.string_to_object(nameServiceURL);
102 ncxt = NamingContextHelper.narrow(
obj);
105 ncxt._non_existent();
106 }
catch (Exception excep) {
118 if (namingContextList_ ==
null) {
119 namingContextList_ =
new HashMap<String, NamingContext>();
154 obj = namingContext.resolve(nc);
155 }
catch (Exception excep) {
165 obj =
getORB().string_to_object(
"corbaloc:iiop:" + nsHost +
":" + nsPort +
"/" +
id);
166 }
catch (Exception e) {
183 org.omg.CORBA.Object CORBA_obj =
getORB().resolve_initial_references(
"RootPOA");
184 org.omg.PortableServer.POA rootPOA =
org.omg.PortableServer.POAHelper.narrow(CORBA_obj);
197 }
catch (Exception ex) {
203 public static boolean isConnected(String
id, String nsHost,
int nsPort) {
213 StringBuffer nsHost =
new StringBuffer(
"");
214 StringBuffer nsPort =
new StringBuffer(
"");
216 namingContextList_.remove(
"corbaloc:iiop:" + nsHost +
":" + nsPort +
"/NameService");
231 String nameServiceURL =
"corbaloc:iiop:" +
nsHost() +
":" +
nsPort() +
"/NameService";
232 org.omg.CORBA.Object
obj = orb.string_to_object(nameServiceURL);
233 ret = !
obj._non_existent();
234 }
catch (Exception ex){
235 System.out.println(
"[GrxCorbaUtil] Name server is not alive!");
243 BindingListHolder bl =
new BindingListHolder();
244 BindingIteratorHolder bi =
new BindingIteratorHolder();
248 ret =
new String[bl.value.length];
249 for (
int i = 0;
i < bl.value.length;
i++) {
250 ret[
i] = bl.value[
i].binding_name[0].id;
252 }
catch (Exception ex) {
static org.omg.CORBA.ORB getORB()
initialize and get ORB
static org.omg.CORBA.Object getReference(String id, String kind, String nsHost, int nsPort)
static String [] _getObjectNameList(NamingContext cxt)
static org.omg.PortableServer.POAManager getRootPOAManager()
static org.omg.CORBA.Object getReferenceURL(String id, String nsHost, int nsPort)
#define null
our own NULL pointer
static boolean isAliveNameService()
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
static NamingContext getNamingContext(String nsHost, int nsPort)
get naming context from name server which is running on the specified hostname and port number ...
static String nsHost()
get hostname where naming server is running
static void printErr(String s)
static org.omg.CORBA.ORB getORB(String[] argv)
initialize and get ORB
static org.omg.CORBA.Object getReference(String id, String nsHost, int nsPort)
get CORBA object which is associated with id
static void refNSHostPort(StringBuffer nsHost, StringBuffer nsPort)
static int NAME_SERVER_PORT_
static String NAME_SERVER_HOST_
static boolean isConnected(String id, String nsHost, int nsPort)
static org.omg.CORBA.Object getReference(String id)
get CORBA object which is associated with id
static int nsPort()
get port number where naming server is listening
static boolean isConnected(org.omg.CORBA.Object obj)
static HashMap< String, NamingContext > getNamingContextList()
get map between naming service location and naming context
static String [] getObjectNameList(String nsHost, int nsPort)
static String [] getObjectNameList()
static HashMap< String, NamingContext > namingContextList_
static String getIOR(org.omg.CORBA.Object obj)
static void removeNameServiceFromList()
static NamingContext getNamingContext()
get naming context