how to get corbaloc from an IOR?

2.6k Views Asked by At

If I have the IOR available, is it possible to form the corbaloc from it?

Are there any tools that can do it automatically.

(I am using JacORB 3.5)

3

There are 3 best solutions below

0
On

IOR is the way that you can access the host. In CORBA we use IOR instead of a readable host:port. I think that CORBA JDK has a IORInterpreter or IORReader, but Jacorb don't have it.

Why doesn't JacORB use host names in it's IOR?

The reason we're using IP numbers instead of human readable host names is that the jdk doesn't provide a way (unless implementing the DNS protocol ourselves / using an external library) to get the fully qualified hostname (that is e.g. z1.inf.fu-berlin.de instead of just z1). But using only the unqualified hostname renders the IOR useless outside of the domain.

from: JacORB's FAQ

If you still want a host:port to connect, you can use:

  //Server
  java.util.Properties props = new java.util.Properties();
  props.setProperty("OAIAddr","myMachine");
  props.setProperty("OAPort","3555");
  org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, props)

  //Client
  org.omg.CORBA.Object obj = orb.string_to_object("corbaloc:iiop:myMachine:3555/MyServant");
  MyServant goodDay = MyServantHelper.narrow( obj );
0
On

If you obtain the IOR string, you could convert it to corbaloc format. One example as below:

Input: IOR String:

IOR:000000000000001949444C3A4D6F6E65792F4163636F756E74616E743A312E300000000000000001000000000000007C000102000000000D3139322E3136382E35362E31000022B8000000285374616E64617264496D706C4E616D652F4D6E7124242F5F4D6F6E65795F4163636F756E74616E74000000020000000000000008000000004A414300000000010000001C00000000000100010000000105010001000101090000000105010001  

Then you could use one tool (e.g. UCS Tools , or you could use the dior.bat tools provided by jacorb) to parse this string, the result is shown as below:

Parse IOR Output:
------IOR components-----
TypeId  :   IDL:Money/Accountant:1.0
TAG_INTERNET_IOP Profiles:
    Profile Id:     0
    IIOP Version:       1.2
    Host:           192.168.56.1
    Port:           8888
    Object key (URL):   StandardImplName/Mnq$$/_Money_Accountant
    Object key (hex):   0x53 74 61 6E 64 61 72 64 49 6D 70 6C 4E 61 6D 65 2F 4D 6E 71 24 24 2F 5F 4D 6F 6E 65 79 5F 41 63 63 6F 75 6E 74 61 6E 74 
    -- Found 2 Tagged Components--
    #0: TAG_ORB_TYPE
        Type: 1245790976 (JacORB)
    #1: TAG_CODE_SETS
        ForChar native code set Id: ISO8859_1
        Char Conversion Code Sets: UTF8
        ForWChar native code set Id: UTF16
        WChar Conversion Code Sets: UTF8  

Then, you could obtain the necessary info for corbaloc (e.g., IIOP version, host, port, Object key).
Then, you could produce the final corbaloc format:

corbaloc:iiop:[email protected]:8888/StandardImplName/Mnq$$/_Money_Accountant
0
On

You could use the JacORB internal API org.jacorb.orb.util.Corbaloc::generateCorbaloc (org.omg.CORBA.ORB, org.omg.CORBA.Object)

e.g.

corbaLoc = "corbaloc:" + CorbaLoc.generateCorbaloc(orb,xxx._this_object());