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

      System.out.println("ORB initialised\n");

      // get the root naming context
      org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");

      // Use NamingContextExt instead of NamingContext,
      // part of the Interoperable naming Service.
      NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);

      // resolve the Object Reference in Naming
      String name = "Hello1";
      helloImpl = HelloHelper.narrow(ncRef.resolve_str(name));

      System.out.println("Obtained a handle on server object: " + helloImpl);
      System.out.println(helloImpl.sayHello());
      helloImpl.shutdown();

    } catch (Exception e) {
      System.out.println("ERROR : " + e);
      e.printStackTrace(System.out);
    }
  } // end main
Example #2
0
  public void init() {
    add(intitule);
    add(texte);
    add(bouton);
    bouton.addActionListener(this);

    try {
      ORB orb = ORB.init(this, null);
      FileReader file = new FileReader(iorfile.value);
      BufferedReader in = new BufferedReader(file);
      String ior = in.readLine();
      file.close();
      org.omg.CORBA.Object obj = orb.string_to_object(ior);
      annuaire = AnnuaireHelper.narrow(obj);

    } catch (org.omg.CORBA.SystemException ex) {
      System.err.println("Error");
      ex.printStackTrace();
    } catch (FileNotFoundException fnfe) {
      System.err.println(fnfe.getMessage());
    } catch (IOException io) {
      System.err.println(io.getMessage());
    } catch (Exception e) {
      System.err.println(e.getMessage());
    }
  }
Example #3
0
  public void invoke(
      org.omg.CORBA.ServerRequest request) { // Ensure that the operation name is correct
    System.out.println("invocato metodo " + request.operation() + " in AccounManagerImpl");
    Float balance;
    String name = new String(_object_id());

    if (request.operation().equals("open")) {
      org.omg.CORBA.NVList params = orb.create_list(1);
      org.omg.CORBA.Any any = orb.create_any();
      any.insert_string(new String(""));
      params.add_value("nomeFile", any, org.omg.CORBA.ARG_IN.value);
      request.arguments(params);
      try {
        name = params.item(0).value().extract_string();
      } catch (Exception e) {
        System.out.println("ERRORE:");
        e.printStackTrace();
      }
      // Invoke the actual implementation and fill out the result
      org.omg.CORBA.Object account = open(name);
      org.omg.CORBA.Any result = orb.create_any();
      result.insert_Object(account);
      request.set_result(result);
    } else {
      System.out.println("Errore nell'ivocazione dinamica del metodo open");
      throw new org.omg.CORBA.BAD_PARAM();
    }
  }
Example #4
0
  public static void main(String[] args) {
    java.util.Properties props = new Properties();
    props.putAll(System.getProperties());
    props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
    props.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");

    int status = 0;
    ORB orb = null;

    try {
      orb = ORB.init(args, props);
      status = run(orb, false, args);
    } catch (Exception ex) {
      ex.printStackTrace();
      status = 1;
    }

    if (orb != null) {
      try {
        orb.destroy();
      } catch (Exception ex) {
        ex.printStackTrace();
        status = 1;
      }
    }

    System.exit(status);
  }
Example #5
0
  public CryoBay reconnectServer(ORB o, ReconnectThread rct) {

    BufferedReader reader;
    File file;
    ORB orb;
    org.omg.CORBA.Object obj;

    orb = o;

    obj = null;
    cryoB = null;

    try {
      // instantiate ModuleAccessor
      file = new File("/vnmr/acqqueue/cryoBay.CORBAref");
      if (file.exists()) {
        reader = new BufferedReader(new FileReader(file));
        obj = orb.string_to_object(reader.readLine());
      }

      if (obj != null) {
        cryoB = CryoBayHelper.narrow(obj);
      }

      if (cryoB != null) {
        if (!(cryoB._non_existent())) {
          // System.out.println("reconnected!!!!");
          rct.reconnected = true;
        }
      }
    } catch (Exception e) {
      // System.out.println("Got error: " + e);
    }
    return cryoB;
  }
  public static void main(String[] args) {
    try {
      // init ORB
      ORB orb = ORB.init(args, null);

      // init POA
      POA poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));

      poa.the_POAManager().activate();

      // create a Adder object
      AdderImpl adderImpl = new AdderImpl();

      // create the object reference
      org.omg.CORBA.Object adderRef = poa.servant_to_reference(adderImpl);

      org.omg.CORBA.Object nsObject = orb.resolve_initial_references("NameService");
      NamingContextExt nc = NamingContextExtHelper.narrow(nsObject);

      nc.rebind(nc.to_name("Adder"), adderRef);

      // wait for requests
      orb.run();
    } catch (Exception e) {
      System.out.println(e);
    }
  }
Example #7
0
  public static void main(String args[]) {
    if (args.length == 0) {
      System.out.println("Koordinator Namen eingeben...");
    } else {

      try {
        // ORB Eigenschaften setzen
        Properties props = new Properties();
        props.put("org.omg.CORBA.ORBInitialPort", "1050");
        props.put("org.omg.CORBA.ORBInitialHost", "localhost");
        orb = ORB.init(args, props);

        // Referenz von rootPOA holen und POA Manager aktivieren
        POA rootPoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
        rootPoa.the_POAManager().activate();

        // NamingContext besorgen
        NamingContextExt nc =
            NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService"));

        // Objektreferenz mit Namen "koordinator" besorgen
        org.omg.CORBA.Object obj = nc.resolve_str(args[1]);

        // Referenz fuer den Servant besorgen
        ggt.Koordinator koord = KoordinatorHelper.narrow(obj);

        // Servant erzeugen
        StarterImpl starter = new StarterImpl(args[0], koord, rootPoa);

        // Referenz fuer den Servant besorgen
        org.omg.CORBA.Object ref = rootPoa.servant_to_reference(starter);

        // Downcast Corba-Objekt -> koordinator
        ggt.Starter href = StarterHelper.narrow(ref);

        // starter bei koordinator anmelden
        koord.activateStarter(href, args[0]);

        // binde die Object Reference an einen Namen
        String name = args[0];
        NameComponent path[] = nc.to_name(name);
        nc.rebind(path, href);
        System.out.println("Koordinator laeuft ...");

        // Orb starten und auf Clients warten
        orb.run();
      } catch (Exception e) {
        System.err.println("Fehler: " + e);
        e.printStackTrace(System.out);
      }
      System.out.println("BankServer Exit");
    }
  }
Example #8
0
  public static void main(String[] args) {
    java.util.Properties props = new Properties();
    props.putAll(System.getProperties());
    props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
    props.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");

    int status = 0;
    ORB orb = null;

    try {
      Client.ClientRegisterInterceptors(props, true);
      Server.ServerRegisterInterceptors(props);

      props.put("yoko.orb.id", "myORB");
      orb = ORB.init(args, props);
      status = Server.ServerRun(orb, true, args);

      if (status == 0) {
        status = Client.ClientRun(orb, true, args);

        //
        // The ORB must be totally shutdown before the servants
        // are deleted.
        //
        orb.shutdown(true);

        Server.ServerCleanup();
      }
    } catch (Exception ex) {
      ex.printStackTrace();
      status = 1;
    }

    if (orb != null) {
      try {
        orb.destroy();
      } catch (Exception ex) {
        ex.printStackTrace();
        status = 1;
      }
    }

    System.exit(status);
  }
 /*    */ public static synchronized TypeCode type() /*    */ {
   /* 57 */ if (__typeCode == null)
   /*    */ {
     /* 59 */ __typeCode =
         ORB.init()
             .create_enum_tc(
                 id(), "SetOverrideType", new String[] {"SET_OVERRIDE", "ADD_OVERRIDE"});
     /*    */ }
   /* 61 */ return __typeCode;
   /*    */ }
  public static void main(String args[]) {
    try {
      // 创建和初始化ORB
      ORB orb = ORB.init(args, null);

      // 获得命名服务的Context
      org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
      NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);

      // 获得名为“HelloService”的HelloService对象的远程引用
      String name = "HelloService";
      helloServiceImpl = HelloServiceHelper.narrow(ncRef.resolve_str(name));

      // 调用HelloService对象的远程方法
      System.out.println("Obtained a handle on server object: " + helloServiceImpl);
      System.out.println(helloServiceImpl.sayHello());
      helloServiceImpl.shutdown();
    } catch (Exception e) {
      System.out.println("ERROR : " + e);
      e.printStackTrace(System.out);
    }
  }
Example #11
0
 public static void main(String[] args) {
   ORB orb = null;
   orb = ORB.init(args, null);
   if (orb != null) {
     try {
       new ClientGui(orb);
     } catch (Exception e) {
       System.err.println(e);
       System.exit(-1);
     }
   } else {
     System.err.println("can't initiate orb");
     System.exit(-1);
   }
 } /*end of main*/
Example #12
0
  public ClientGui(ORB o) throws Exception {
    ShutdownFrame sf;
    BufferedReader reader;
    boolean modulePresent;
    File file;
    CryoThread update;

    orb = o;

    obj = null;
    cryoBay = null;

    // System.out.println("running test client.");

    // instantiate ModuleAccessor
    file = new File("/vnmr/acqqueue/cryoBay.CORBAref");
    if (file.exists()) {
      reader = new BufferedReader(new FileReader(file));
      obj = orb.string_to_object(reader.readLine());
    }

    if (obj == null) {
      throw new Exception("string_to_object is null: cryoBay.CORBAref");
    }

    // System.out.println("Got object.");

    cryoBay = CryoBayHelper.narrow(obj);

    if (cryoBay == null) {
      throw new Exception("cryoBay is null");
    }

    if (cryoBay._non_existent()) {
      throw new Exception("cryoBay is not running");
    }

    sf = new ShutdownFrame(cryoBay);
    update = new CryoThread(cryoBay, sf, this);
    sf.show();
    update.start();
  } /*end of constructor*/
Example #13
0
 /**
  * Returns the <code>TypeCode</code> object corresponding to the value held in the Holder.
  *
  * @return the TypeCode of the value held in the holder
  */
 public org.omg.CORBA.TypeCode _type() {
   return ORB.init().get_primitive_tc(TCKind.tk_longlong);
 }
Example #14
0
  public static int run(ORB orb, boolean local, String[] args) throws org.omg.CORBA.UserException {
    //
    // Get TestIntf
    //
    String refFile = "TestIntf.ref";

    //
    // Get the stringified IOR
    //
    String impl;
    try {
      java.io.FileInputStream file = new java.io.FileInputStream(refFile);
      java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(file));
      impl = in.readLine();
      file.close();
    } catch (java.io.IOException ex) {
      System.err.println("Can't read from `" + ex.getMessage() + "'");
      return 1;
    }

    //
    // Run tests
    //

    System.out.print("Testing string_to_object()... ");
    System.out.flush();
    org.omg.CORBA.Object obj = orb.string_to_object(impl);
    System.out.println("Done!");

    System.out.print("Testing narrow()... ");
    System.out.flush();
    ORBTest.Intf ti = ORBTest.IntfHelper.narrow(obj);
    System.out.println("Done!");

    TestObjectBasic test_basic = new TestObjectBasic(orb, ti);
    TestObjectContext test_context = new TestObjectContext(orb, ti);
    TestObjectExceptions test_exceptions = (new TestObjectExceptions(orb, ti));
    TestObjectExceptionsExt_2_0 test_exceptions_ext_2_0 =
        (new TestObjectExceptionsExt_2_0(orb, ti));
    TestObjectWChar test_wchar = new TestObjectWChar(orb, ti);
    TestObjectFixed test_fixed = new TestObjectFixed(orb, ti);
    TestObjectLongLong test_long_long = new TestObjectLongLong(orb, ti);
    TestObjectExceptionsExt_2_3 test_exceptions_ext_2_3 =
        (new TestObjectExceptionsExt_2_3(orb, ti));
    TestObjectStubTimeout test_stub_timeout = (new TestObjectStubTimeout(orb, ti, local));

    ORBTest.TestCase[] test_case_list = ti.get_test_case_list();

    ORBTest.TestDefn test_defns[] = {
      new ORBTest.TestDefn("2.0 types", test_basic),
      new ORBTest.TestDefn("2.0 Contexts", test_context),
      new ORBTest.TestDefn("2.0 Exceptions", test_exceptions),
      new ORBTest.TestDefn("2.0 non-OBE Exceptions", test_exceptions_ext_2_0),
      new ORBTest.TestDefn("2.3 types", test_wchar),
      new ORBTest.TestDefn("2.3 Fixed", test_fixed),
      new ORBTest.TestDefn("2.3 LongLong", test_long_long),
      new ORBTest.TestDefn("2.3 Exceptions", test_exceptions_ext_2_3),
      new ORBTest.TestDefn("timeouts", test_stub_timeout)
    };

    // Run the SII tests
    //
    for (int i = 0; i < test_case_list.length; ++i) {
      for (int j = 0; j < test_defns.length; ++j) {
        if (test_defns[j].test_object().is_supported(test_case_list[i].impl)) {
          System.out.print("Testing the SII with the ");
          System.out.print(test_case_list[i].impl_description + " implementation and ");
          System.out.print(test_defns[j].description() + "... ");
          System.out.flush();
          test_defns[j].test_object().test_SII(test_case_list[i].impl);
          System.out.println("Done!");
        }
      }
    }

    // Run the DII tests
    //
    for (int i = 0; i < test_case_list.length; ++i) {
      for (int j = 0; j < test_defns.length; ++j) {
        if (test_defns[j].test_object().is_supported(test_case_list[i].impl)) {
          System.out.print("Testing the DII with the ");
          System.out.print(test_case_list[i].impl_description + " implementation and ");
          System.out.print(test_defns[j].description() + "... ");
          System.out.flush();
          test_defns[j].test_object().test_DII(test_case_list[i].impl);
          System.out.println("Done!");
        }
      }
    }

    TestPolicyIntf.run(orb);

    //
    // Deactivate the server
    //
    ORBType ORB_type = ti.get_ORB_type();
    if (ORB_type == ORBType.ORBacus3) {
      try {
        ti.deactivate();
      } catch (TRANSIENT ex) {
      }
    } else {
      ti.deactivate();
    }

    return 0;
  }
  public static void main(String[] args) {
    loggedUser = args[0];
    try {
      ORB orb = ORB.init(args, null); // initialize ORB
      o = orb.resolve_initial_references("NameService");

      // get reference to Deal object
      NamingContext ncRef = NamingContextHelper.narrow(o);
      NameComponent[] nc = new NameComponent[1];
      nc[0] = new NameComponent();
      nc[0].id = "Auction";
      nc[0].kind = "";
      a = AuctionHelper.narrow(ncRef.resolve(nc));

      isr = new InputStreamReader(System.in);
      in = new BufferedReader(isr);
      int sel = 0;
      System.out.println("******* You have logged in Successfully! ********");
      while (sel == 0) {
        System.out.println("Please make a selection");
        System.out.println("\t1. Get all the listed auctions");
        System.out.println("\t2. List a new item for auction.");
        System.out.println("\t3. Lookup an auction.");
        System.out.println("\t4. Place a bid on an auction.");
        System.out.println("\t5. Logout.");
        System.out.print("Please make your selection > ");
        String f = in.readLine();
        try {
          sel = Integer.parseInt(f);
        } catch (Exception e) {
          sel = 42;
        }
        switch (sel) {
          case 1:
            allItems();
            sel = 0;
            break;
          case 2:
            newAuction();
            sel = 0;
            break;
          case 3:
            System.out.println("Stub");
            sel = 0;
            break;
          case 4:
            placeBid();
            sel = 0;
            break;
          case 5:
            a.logout(loggedUser);
            System.out.println("BYE!");
            System.exit(0);
          default:
            System.out.println("You have not made a valid selection, please try again.");
            sel = 0;
            break;
        }
      }
    } catch (Exception e) {
      System.out.println("ERROR : " + e);
      e.printStackTrace(System.out);
    }
  }
  public void receive_request(ServerRequestInfo ri) {
    try {
      //
      // Test: get operation name
      //
      String op = ri.operation();

      boolean oneway = (op.equals("noargs_oneway"));

      //
      // Test: Examine arguments
      //
      testArgs(ri, false);

      // TODO: test operation_context

      //
      // Test: result is not available
      //
      try {
        Any result = ri.result();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: exceptions
      //
      try {
        TypeCode[] exceptions = ri.exceptions();
        if (op.equals("userexception")) {
          TEST(exceptions.length == 1);
          TEST(exceptions[0].equal(userHelper.type()));
        } else {
          TEST(exceptions.length == 0);
        }
      } catch (NO_RESOURCES ex) {
        // Expected (if servant is DSI)
      }

      //
      // Test: response expected and oneway should be equivalent
      //
      TEST((oneway && !ri.response_expected()) || (!oneway && ri.response_expected()));

      // TODO: test sync scope

      //
      // Test: reply status is not available
      //
      try {
        ri.reply_status();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: forward reference is not available
      //
      try {
        org.omg.CORBA.Object ior = ri.forward_reference();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      if (op.equals("test_service_context")) {
        //
        // Test: get_request_service_context
        //
        try {
          org.omg.IOP.ServiceContext sc = ri.get_request_service_context(REQUEST_CONTEXT_ID.value);
          TEST(sc.context_id == REQUEST_CONTEXT_ID.value);
        } catch (BAD_PARAM ex) {
          TEST(false);
        }

        //
        // Test: add_reply_service_context
        //
        ReplyContext context = new ReplyContext();
        context.data = "reply2";
        context.val = 102;
        Any any = orb_.create_any();
        ReplyContextHelper.insert(any, context);
        byte[] data = null;
        try {
          data = cdrCodec_.encode_value(any);
        } catch (org.omg.IOP.CodecPackage.InvalidTypeForEncoding ex) {
          TEST(false);
        }

        org.omg.IOP.ServiceContext sc = new org.omg.IOP.ServiceContext();
        sc.context_id = REPLY_CONTEXT_2_ID.value;
        sc.context_data = new byte[data.length];
        System.arraycopy(data, 0, sc.context_data, 0, data.length);

        try {
          ri.add_reply_service_context(sc, false);
        } catch (BAD_INV_ORDER ex) {
          TEST(false);
        }

        //
        // Test: add same context again (no replace)
        //
        try {
          ri.add_reply_service_context(sc, false);
          TEST(false);
        } catch (BAD_INV_ORDER ex) {
          // Expected
        }

        //
        // Test: add same context again (replace)
        //
        try {
          ri.add_reply_service_context(sc, true);
        } catch (BAD_INV_ORDER ex) {
          TEST(false);
        }

        //
        // Test: replace context added in
        // receive_request_service_context
        //
        context.data = "reply4";
        context.val = 114;
        ReplyContextHelper.insert(any, context);
        try {
          data = cdrCodec_.encode_value(any);
        } catch (org.omg.IOP.CodecPackage.InvalidTypeForEncoding ex) {
          TEST(false);
        }

        sc.context_id = REPLY_CONTEXT_4_ID.value;
        sc.context_data = new byte[data.length];
        System.arraycopy(data, 0, sc.context_data, 0, data.length);

        try {
          ri.add_reply_service_context(sc, true);
        } catch (BAD_INV_ORDER ex) {
          TEST(false);
        }
      } else {
        //
        // Test: get_request_service_context
        //
        try {
          org.omg.IOP.ServiceContext sc = ri.get_request_service_context(REQUEST_CONTEXT_ID.value);
          TEST(false);
        } catch (BAD_PARAM ex) {
          // Expected
        }
      }

      //
      // Test: get_reply_service_context
      //
      try {
        org.omg.IOP.ServiceContext sc = ri.get_reply_service_context(REPLY_CONTEXT_1_ID.value);
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: sending exception is not available
      //
      try {
        Any any = ri.sending_exception();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: object id is correct
      //
      byte[] oid = ri.object_id();
      TEST(
          (oid.length == 4 && (new String(oid)).equals("test"))
              || (oid.length == 7 && (new String(oid)).equals("testDSI")));

      //
      // Test: adapter id is correct (this is a tough one to test)
      //
      byte[] adapterId = ri.adapter_id();
      TEST(adapterId.length != 0);

      //
      // Test: servant most derived interface is correct
      //
      String mdi = ri.target_most_derived_interface();
      TEST(mdi.equals("IDL:TestInterface:1.0"));

      //
      // Test: server id is correct
      //
      String serverId = ri.server_id();
      TEST(serverId.equals(""));

      //
      // Test: orb id is correct
      //
      String orbId = ri.orb_id();
      TEST(orbId.equals("myORB"));

      //
      // Test: adapter name is correct
      //
      String[] adapterName = ri.adapter_name();
      TEST(adapterName.length == 1 && adapterName[0].equals("persistent"));

      //
      // Test: servant is a is correct
      //
      TEST(ri.target_is_a("IDL:TestInterface:1.0"));

      //
      // Test: get_server_policy
      //
      Policy policy = ri.get_server_policy(MY_SERVER_POLICY_ID.value);
      MyServerPolicy myServerPolicy = MyServerPolicyHelper.narrow(policy);
      TEST(myServerPolicy != null);
      TEST(myServerPolicy.value() == 10);

      try {
        policy = ri.get_server_policy(1013);
        TEST(false);
      } catch (INV_POLICY ex) {
        // Expected
      }
    } catch (test.common.TestException ex) {
      ex.printStackTrace();
      throw ex;
    }
  }
  public void receive_request_service_contexts(ServerRequestInfo ri) {
    try {
      //
      // Test: get operation name
      //
      String op = ri.operation();

      boolean oneway = (op.equals("noargs_oneway"));

      //
      // Test: Arguments should not be available
      //
      try {
        org.omg.Dynamic.Parameter[] args = ri.arguments();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      // TODO: test operation_context

      //
      // Test: result is not available
      //
      try {
        Any result = ri.result();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: exceptions
      //
      try {
        TypeCode[] exceptions = ri.exceptions();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: response expected and oneway should be equivalent
      //
      TEST((oneway && !ri.response_expected()) || (!oneway && ri.response_expected()));

      // TODO: test sync scope

      //
      // Test: reply status is not available
      //
      try {
        ri.reply_status();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: forward reference is not available
      //
      try {
        org.omg.CORBA.Object ior = ri.forward_reference();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: object id is not available
      //
      try {
        byte[] id = ri.object_id();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: adapter id is not available
      //
      try {
        byte[] id = ri.adapter_id();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: servant_most_derived_interface is not available
      //
      try {
        String mdi = ri.target_most_derived_interface();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: server id is not available
      //
      try {
        String id = ri.server_id();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: orb id is not available
      //
      try {
        String id = ri.orb_id();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: adapter name is not available
      //
      try {
        String[] name = ri.adapter_name();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: servant_is_a is not available
      //
      try {
        ri.target_is_a("");
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      if (op.equals("test_service_context")) {
        //
        // Test: get_request_service_context
        //
        try {
          org.omg.IOP.ServiceContext sc = ri.get_request_service_context(REQUEST_CONTEXT_ID.value);
          TEST(sc.context_id == REQUEST_CONTEXT_ID.value);
          byte[] data = new byte[sc.context_data.length];
          System.arraycopy(sc.context_data, 0, data, 0, sc.context_data.length);

          Any any = null;
          try {
            any = cdrCodec_.decode_value(data, RequestContextHelper.type());
          } catch (org.omg.IOP.CodecPackage.FormatMismatch ex) {
            TEST(false);
          } catch (org.omg.IOP.CodecPackage.TypeMismatch ex) {
            TEST(false);
          }
          RequestContext context = RequestContextHelper.extract(any);
          TEST(context.data.equals("request"));
          TEST(context.val == 10);

          //
          // Test: PortableInterceptor::Current
          //
          Any slotData = orb_.create_any();
          slotData.insert_long(context.val);
          try {
            ri.set_slot(0, slotData);
          } catch (InvalidSlot ex) {
            TEST(false);
          }
        } catch (BAD_PARAM ex) {
          TEST(false);
        }

        //
        // Test: add_reply_service_context
        //
        ReplyContext context = new ReplyContext();
        context.data = "reply1";
        context.val = 101;
        Any any = orb_.create_any();
        ReplyContextHelper.insert(any, context);
        byte[] data = null;
        try {
          data = cdrCodec_.encode_value(any);
        } catch (org.omg.IOP.CodecPackage.InvalidTypeForEncoding ex) {
          TEST(false);
        }

        org.omg.IOP.ServiceContext sc = new org.omg.IOP.ServiceContext();
        sc.context_id = REPLY_CONTEXT_1_ID.value;
        sc.context_data = new byte[data.length];
        System.arraycopy(data, 0, sc.context_data, 0, data.length);

        try {
          ri.add_reply_service_context(sc, false);
        } catch (BAD_INV_ORDER ex) {
          TEST(false);
        }

        //
        // Test: add same context again (no replace)
        //
        try {
          ri.add_reply_service_context(sc, false);
          TEST(false);
        } catch (BAD_INV_ORDER ex) {
          // Expected
        }

        //
        // Test: add same context again (replace)
        //
        try {
          ri.add_reply_service_context(sc, true);
        } catch (BAD_INV_ORDER ex) {
          TEST(false);
        }

        //
        // Test: add second context
        //
        context.data = "reply4";
        context.val = 104;
        ReplyContextHelper.insert(any, context);
        try {
          data = cdrCodec_.encode_value(any);
        } catch (org.omg.IOP.CodecPackage.InvalidTypeForEncoding ex) {
          TEST(false);
        }

        sc.context_id = REPLY_CONTEXT_4_ID.value;
        sc.context_data = new byte[data.length];
        System.arraycopy(data, 0, sc.context_data, 0, data.length);

        // try
        // {
        ri.add_reply_service_context(sc, false);
        // }
        // catch(BAD_INV_ORDER ex)
        // {
        // TEST(false);
        // }
      } else {
        //
        // Test: get_request_service_context
        //
        try {
          org.omg.IOP.ServiceContext sc = ri.get_request_service_context(REQUEST_CONTEXT_ID.value);
          TEST(false);
        } catch (BAD_PARAM ex) {
          // Expected
        }
      }

      //
      // Test: get_reply_service_context
      //
      try {
        org.omg.IOP.ServiceContext sc = ri.get_reply_service_context(REPLY_CONTEXT_1_ID.value);
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: sending exception is not available
      //
      try {
        Any any = ri.sending_exception();
        TEST(false);
      } catch (BAD_INV_ORDER ex) {
        // Expected
      }

      //
      // Test: get_server_policy
      //
      Policy policy = ri.get_server_policy(MY_SERVER_POLICY_ID.value);
      MyServerPolicy myServerPolicy = MyServerPolicyHelper.narrow(policy);
      TEST(myServerPolicy != null);
      TEST(myServerPolicy.value() == 10);

      try {
        policy = ri.get_server_policy(1013);
        TEST(false);
      } catch (INV_POLICY ex) {
        // Expected
      }
    } catch (test.common.TestException ex) {
      ex.printStackTrace();
      throw ex;
    }
  }
  private void testServiceContext(String op, ServerRequestInfo ri, boolean addContext) {
    if (op.equals("test_service_context")) {
      //
      // Test: get_request_service_context
      //
      try {
        org.omg.IOP.ServiceContext sc = ri.get_request_service_context(REQUEST_CONTEXT_ID.value);
        TEST(sc.context_id == REQUEST_CONTEXT_ID.value);
      } catch (BAD_PARAM ex) {
        TEST(false);
      }

      //
      // Test: get_reply_service_context
      //
      org.omg.IOP.ServiceContext sc = null;
      try {
        sc = ri.get_reply_service_context(REPLY_CONTEXT_4_ID.value);
      } catch (BAD_INV_ORDER ex) {
        TEST(false);
      }
      byte[] data = new byte[sc.context_data.length];
      System.arraycopy(sc.context_data, 0, data, 0, sc.context_data.length);

      Any any = null;
      try {
        any = cdrCodec_.decode_value(data, ReplyContextHelper.type());
      } catch (org.omg.IOP.CodecPackage.FormatMismatch ex) {
        TEST(false);
      } catch (org.omg.IOP.CodecPackage.TypeMismatch ex) {
        TEST(false);
      }
      ReplyContext context = ReplyContextHelper.extract(any);
      TEST(context.data.equals("reply4"));
      TEST(context.val == 114);

      if (addContext) {
        //
        // Test: add_reply_service_context
        //
        context.data = "reply3";
        context.val = 103;
        any = orb_.create_any();
        ReplyContextHelper.insert(any, context);
        try {
          data = cdrCodec_.encode_value(any);
        } catch (org.omg.IOP.CodecPackage.InvalidTypeForEncoding ex) {
          TEST(false);
        }

        sc.context_id = REPLY_CONTEXT_3_ID.value;
        sc.context_data = new byte[data.length];
        System.arraycopy(data, 0, sc.context_data, 0, data.length);

        try {
          ri.add_reply_service_context(sc, false);
        } catch (BAD_INV_ORDER ex) {
          TEST(false);
        }

        //
        // Test: add same context again (no replace)
        //
        try {
          ri.add_reply_service_context(sc, false);
          TEST(false);
        } catch (BAD_INV_ORDER ex) {
          // Expected
        }

        //
        // Test: add same context again (replace)
        //
        try {
          ri.add_reply_service_context(sc, true);
        } catch (BAD_INV_ORDER ex) {
          TEST(false);
        }

        //
        // Test: replace context added in receive_request
        //
        context.data = "reply4";
        context.val = 124;
        ReplyContextHelper.insert(any, context);
        try {
          data = cdrCodec_.encode_value(any);
        } catch (org.omg.IOP.CodecPackage.InvalidTypeForEncoding ex) {
          TEST(false);
        }

        sc.context_id = REPLY_CONTEXT_4_ID.value;
        sc.context_data = new byte[data.length];
        System.arraycopy(data, 0, sc.context_data, 0, data.length);

        try {
          ri.add_reply_service_context(sc, true);
        } catch (BAD_INV_ORDER ex) {
          TEST(false);
        }
      }
    } else {
      try {
        org.omg.IOP.ServiceContext sc = ri.get_request_service_context(REQUEST_CONTEXT_ID.value);
        TEST(false);
      } catch (BAD_PARAM ex) {
        // Expected
      }
      try {
        org.omg.IOP.ServiceContext sc = ri.get_reply_service_context(REPLY_CONTEXT_1_ID.value);
        TEST(false);
      } catch (BAD_PARAM ex) {
        // Expected
      }
    }
  }
  /** @param args the command line arguments */
  public static void main(String args[]) {

    try {
      // create and initialize the ORB
      ORB orb = ORB.init(args, null);

      // get reference to rootpoa & activate the POAManager
      POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
      rootpoa.the_POAManager().activate();

      // create servant
      Log_viewerImpl log_viewerImpl = new Log_viewerImpl();
      log_viewerImpl.setORB(orb);

      LogFrame frame = new LogFrame(log_viewerImpl);
      frame.setVisible(true);

      log_viewerImpl.setFrame(frame);

      // get object reference from the servant
      org.omg.CORBA.Object ref = rootpoa.servant_to_reference(log_viewerImpl);
      Log_viewer href = Log_viewerHelper.narrow(ref);

      // read stringified Registry to file
      FileReader fr = new FileReader(IORFILE);
      BufferedReader br = new BufferedReader(fr);
      String remoteRegistryIOR = br.readLine();

      // get the romote Registry
      org.omg.CORBA.Object ncobj = orb.string_to_object(remoteRegistryIOR);
      NamingContext rootNC = NamingContextHelper.narrow(ncobj);
      frame.println("Obtained Name Service reference.");
      log_viewerImpl.serRootNC(rootNC);

      NameComponent[] name = new NameComponent[1];
      name[0] = new NameComponent("Logger", "");

      try {

        rootNC.bind(name, href);

      } catch (org.omg.CORBA.UserException ue) {
        ue.printStackTrace();
        System.exit(-1);
      }

      frame.println("Logger Remote Interface bound in Name Service");

      // wait for invocations from client
      frame.println("Logger ready and waiting ...");
      orb.run();

      frame.println("Logger Exiting ...");
      System.out.println("Logger Exiting ...");

    } catch (Exception e) {
      System.err.println("ERROR: " + e);

      // e.printStackTrace(System.out);
    }
  }