Example #1
0
  public static void main(String[] args) {
    try {
      // Create and initialize the ORB
      org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null);

      // Get the root naming context
      // org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
      // use NamingContextExt instead of NamingContext: this is part of the Interoperable Naming
      // Service.
      // NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);

      // resolve the object reference in Naming
      // String name = "Stock";
      // stockImpl = StockHelper.narrow(ncRef.resolve_str(name));

      // Write stringified object reference to a file
      BufferedReader in = new BufferedReader(new FileReader(args[0]));
      String objName = in.readLine();
      in.close();

      org.omg.CORBA.Object obj = orb.string_to_object(objName);
      stockImpl = StockHelper.narrow(obj);

      // System.out.println("Obtained a handle on server object: " + stockImpl);

      System.out.println("Obtained stock object for company: " + stockImpl.description());
    } catch (Exception e) {
      System.out.println("Stock client error: " + e);
      e.printStackTrace(System.out);
    }
  }
 public org.omg.CORBA.Object _this_object(org.omg.CORBA.ORB orb) {
   this._activate();
   long ref = ProvidesPortStatisticsProviderPOA.new_reference(this.servant_);
   BULKIO.jni._ProvidesPortStatisticsProviderStub stub =
       new BULKIO.jni._ProvidesPortStatisticsProviderStub(ref);
   String ior = omnijni.ORB.object_to_string(stub);
   return orb.string_to_object(ior);
 }
 public org.omg.CORBA.Object _this_object(org.omg.CORBA.ORB orb) {
   this._activate();
   long ref = ProxyPullConsumerPOA.new_reference(this.servant_);
   org.omg.CosEventChannelAdmin.jni._ProxyPullConsumerStub stub =
       new org.omg.CosEventChannelAdmin.jni._ProxyPullConsumerStub(ref);
   String ior = omnijni.ORB.object_to_string(stub);
   return orb.string_to_object(ior);
 }
 private void readObject(java.io.ObjectInputStream s) throws java.io.IOException {
   String str = s.readUTF();
   String[] args = null;
   java.util.Properties props = null;
   org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, props);
   try {
     org.omg.CORBA.Object obj = orb.string_to_object(str);
     org.omg.CORBA.portable.Delegate delegate =
         ((org.omg.CORBA.portable.ObjectImpl) obj)._get_delegate();
     _set_delegate(delegate);
   } finally {
     orb.destroy();
   }
 }
Example #5
0
  @Test
  public void testWithJacORBORB() throws Exception {
    Properties props = new Properties();
    props.setProperty("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB");
    props.setProperty("org.omg.CORBA.ORBSingletonClass", "org.jacorb.orb.ORBSingleton");

    org.omg.CORBA.ORB orb = setup.getAnotherORB(props);

    assertTrue(orb instanceof org.jacorb.orb.ORB);

    ValueServer server = ValueServerHelper.narrow(orb.string_to_object(setup.getServerIOR()));

    String result = server.receive_list(new NodeImpl(1234));
    assertEquals("list of length: 1 -- 1234", result);
  }
  /**
   * Initializes an ORB, converts the stringified OMC object to a real CORBA object, and then
   * narrows that object to an OmcCommunication object.
   *
   * @param stringifiedObjectReference the new up omcc
   */
  private static void setupOmcc(String stringifiedObjectReference) {
    /* Can't remember why this is needed. But it is. */
    String args[] = {null};

    /* set the CORBA read timeout to a larger
     * value as we send huge ammounts of data from OMC to MDT
     */
    System.setProperty("com.sun.CORBA.transport.ORBTCPReadTimeouts", "1:60000:300:1");

    // org.omg.CORBA.ORB.getClass().getClassLoader().getResource("ORB");
    org.omg.CORBA.ORB orb;
    //		ClassLoader cl = Thread.currentThread().getContextClassLoader();
    //		try {
    //			Class.forName("org.omg.CORBA.ORB", true, ClassLoader.getSystemClassLoader()).newInstance();
    //		} catch (InstantiationException e) {
    //			// TODO Auto-generated catch block
    //			e.printStackTrace();
    //		} catch (IllegalAccessException e) {
    //			// TODO Auto-generated catch block
    //			e.printStackTrace();
    //		} catch (ClassNotFoundException e) {
    //			// TODO Auto-generated catch block
    //			e.printStackTrace();
    //		}
    orb = ORB.init(args, null);
    //		orb = ORB.init();

    /* Convert string to object. */
    org.omg.CORBA.Object obj = orb.string_to_object(stringifiedObjectReference);
    logOMCStatus("Corba IOR:" + stringifiedObjectReference);
    /* Convert object to OmcCommunication object. */

    omcc = OmcCommunicationHelper.narrow(obj);
    //		omcc = OmcCommunicationHelper.narrow(new File(getPathToObject()));

  }
  private void init() throws Exception {
    try {
      // initialize the ORB.
      orb = ORB.init(cmdArgs.getCmdArgs(), null);

      obj = orb.string_to_object(cmdArgs.getNsCorbaName());

      // and narrow it to the servant
      // if this fails, a BAD_PARAM will be thrown
      servant = EchoMessageHelper.narrow(obj);

      // got a greeting message from the servant
      log(servant.echo_simple());

    } catch (Exception e) {
      throw new Exception(
          "ConnectNameService thread "
              + threadNum
              + " got an exception in init(): "
              + e.getMessage());
      // e.printStackTrace();
      // terminate();
    }
  }
Example #8
0
  public static void main(String[] args) throws Exception {
    org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null);

    BufferedReader reader = new BufferedReader(new FileReader(args[0]));

    // resolve name to get a reference to our server
    MyServer server = MyServerHelper.narrow(orb.string_to_object(reader.readLine()));

    DoubleHolder doh = new DoubleHolder();
    server.addNums((double) 5, (double) 6, doh);
    System.out.println("addNums 5 and 6 gives: " + doh.value);

    String stringSeq[];
    stringSeqHolder seqHolder = new stringSeqHolder();
    server.op1("hi_there", seqHolder);
    stringSeq = seqHolder.value;
    System.out.println("String array contains: ");
    for (int i = 0; i < stringSeq.length; i++) System.out.println("\t" + i + ": " + stringSeq[i]);

    MyServerHolder h = new MyServerHolder();
    server.op2(h);
    MyServer server2 = h.value;
    server2.print("Who am I talking to?");

    my_structHolder moh = new my_structHolder();
    server.op3(moh);
    my_struct m = moh.value;
    System.out.println("Struct contains: " + m.s + " " + m.l);

    stringArrayHolder sah = new stringArrayHolder();
    server.op4(sah);
    String my_array[] = sah.value;
    System.out.println("Array size: " + my_array.length);

    StringHolder sh1 = new StringHolder();
    String sh2 = server.op5(sh1);
    System.out.println(sh2 + " out: " + sh1.value);

    // an example for a sequence of sequences of sequences of string
    //
    // set up a 3-dimensional string array

    String[][][] string_cube = new String[1][2][3];
    for (int i = 0; i < string_cube.length; i++)
      for (int j = 0; j < string_cube[i].length; j++)
        for (int k = 0; k < string_cube[i][j].length; k++)
          string_cube[i][j][k] = "(" + i + "," + k + "," + j + ")";

    // put it into the appropriate holder for inout semantics

    stringCubeHolder sf = new stringCubeHolder(string_cube);

    // invoke the operation

    server.stringCubeInOut(sf);

    // get the returned string cube

    string_cube = sf.value;

    System.out.println("string_cube after operation: ");

    for (int i = 0; i < string_cube.length; i++)
      for (int j = 0; j < string_cube[i].length; j++)
        for (int k = 0; k < string_cube[i][j].length; k++) System.out.println(string_cube[i][j][k]);

    System.out.println("---Everything went alright, closing down now---");
    server.shutdown();
  }