Ejemplo n.º 1
0
  /**
   * Given a IOR string this will decode it and output a corbaloc::... string.
   *
   * <p>Split off into a separate function from main so its easier to be called programmatically.
   */
  public static String printCorbalocIOR(org.omg.CORBA.ORB orb, String iorString) {
    if (!(orb instanceof org.jacorb.orb.ORB)) {
      throw new RuntimeException("ORB must be a JacORB ORB.");
    }
    final ParsedIOR pior = new ParsedIOR((org.jacorb.orb.ORB) orb, iorString);

    StringBuffer result = new StringBuffer();

    result.append("corbaloc:iiop:");

    ProfileBase profile = (ProfileBase) pior.getEffectiveProfile();
    if (profile instanceof IIOPProfile) {
      result.append(((IIOPAddress) ((IIOPProfile) profile).getAddress()).getOriginalHost());
      result.append(':');
      result.append(((IIOPAddress) ((IIOPProfile) profile).getAddress()).getPort());
      result.append('/');
      result.append(CorbaLoc.parseKey(pior.get_object_key()));
    } else {
      throw new RuntimeException("Sorry, only print corbaloc strings for IIOP profiles.");
    }
    return result.toString();
  }