Package org.omg.CORBA

Examples of org.omg.CORBA.Request


          // The object to handle the requrest is selected randomly.
          // The acceleration factor will be lower than the number
          // of the "parallelized objects". This is sufficient
          // as this is just a test, not a real distribute computing task.
          Request rq =
            objects [ rn ]._create_request(null, "sleep_and_return",
                                           orb.create_list(1), null
                                          );

          rq.set_return_type(orb.get_primitive_tc(TCKind.tk_long));
          rq.add_in_arg().insert_long(times [ i ]);
          reqs [ i ] = rq;
        }

      long started = System.currentTimeMillis();

      orb.send_multiple_requests_deferred(reqs);

      // Be sure the execution has returned correctly.
      assertTrue("Hangs on orb.send_multiple_requests_defferred",
                 System.currentTimeMillis() < started + 199
                );
      assertTrue("orb.send_multiple_requests_defferred:"+
                 "Cannot be ready immediately",
                 !orb.poll_next_response());

      for (int i = 0; i < reqs.length; i++)
        {
          try
            {
              Request a = orb.get_next_response();
              served.clear(a.result().value().extract_long());
            }
          catch (Exception ex)
            {
              ex.printStackTrace();
            }
        }

      // Check the acceleration factor.
      long done_in = System.currentTimeMillis() - started;

      long required = 0;
      for (int i = 0; i < times.length; i++)
        {
          required += times [ i ];
        }

      // Compute the acceleration factor * 100 %.
      int acceleration = (int) ((100 * required) / done_in);

      // With 20 virtual servers and the used algorithm, we should
      // expect at least five-fold acceleration.
      assertTrue("Parallel work is broken :" + acceleration, acceleration > 500);

      assertEquals("Not all tasks served", served.cardinality(), 0);

      // 2. Testing the Request methods.
      Request rq =
        objects [ 0 ]._create_request(null, "sleep_and_return",
                                      orb.create_list(1), null
                                     );

      rq.set_return_type(orb.get_primitive_tc(TCKind.tk_long));

      rq.add_in_arg().insert_long(200);

      long t = System.currentTimeMillis();
      rq.send_deferred();

      // Be sure the execution has returned correctly.
      assertTrue("Hangs on Request.send_defferred",
                 System.currentTimeMillis() < t + 199
                );
      assertTrue("Request.send_defferred:cannot be ready immediately",
                 !rq.poll_response());

      try
        {
          Thread.sleep(300);
        }
      catch (InterruptedException ex)
        {
        }

      assertTrue("Request.send_defferred:Must be ready now",
                 rq.poll_response());
      assertEquals("Request.send_defferred:Result must be ready",
                 rq.result().value().extract_long(), 200);

      orb.shutdown(true);
  }
View Full Code Here


    testWideNarrowStrings();
  }

  public void testParameters()
  {
    Request r =
      object._create_request(null, "passSimple", orb.create_list(0), null);

    ByteHolder a_byte = new ByteHolder((byte) 0);
    ShortHolder a_short = new ShortHolder((short) 3);
    StringHolder a_string = new StringHolder("[string 4]");

    // This is an 'out' parameter; the value must not be passed to servant.
    DoubleHolder a_double = new DoubleHolder(56.789);

    r.add_inout_arg().insert_octet((byte) 0);
    r.add_in_arg().insert_long(2);
    r.add_inout_arg().insert_short((short) 3);
    r.add_inout_arg().insert_string("[string 4]");
    r.add_out_arg().type(orb.get_primitive_tc(TCKind.tk_double));

    NVList para = r.arguments();

    try
      {
        assertEquals("octet", para.item(0).value().extract_octet(), 0);
        assertEquals("long (in parameter)",
                     para.item(1).value().extract_long(), 2
                    );
        assertEquals("short", para.item(2).value().extract_short(), 3);
        assertEquals("string", para.item(3).value().extract_string(),
                     "[string 4]"
                    );
      }
    catch (Exception ex)
      {
        fail("Unexpected " + ex.getClass().getName() + ":" + ex.getMessage());
      }

    // For the last parameter, the value is not set.
    r.set_return_type(orb.get_primitive_tc(TCKind.tk_long));

    r.invoke();

    assertEquals("Returned value", r.result().value().extract_long(), 452572);

    para = r.arguments();

    try
      {
        assertEquals("octet", para.item(0).value().extract_octet(), 1);
        assertEquals("long (in parameter)",
View Full Code Here

    try
      {
        ExceptionList exList = orb.create_exception_list();
        exList.add(ourUserExceptionHelper.type());

        Request rq =
          object._create_request(null, "throwException", orb.create_list(1),
                                 null, exList, null
                                );

        rq.add_in_arg().insert_long(-55);

        rq.invoke();

        fail("The BAD_OPERATION is not thrown");
      }
    catch (BAD_OPERATION ex)
      {
View Full Code Here

  }

  public void testWideNarrowStrings()
                             throws BAD_OPERATION
  {
    Request rq =
      object._create_request(null, "passCharacters", orb.create_list(0), null);

    rq.add_in_arg().insert_wstring("wide string");
    rq.add_in_arg().insert_string("narrow string");

    rq.set_return_type(orb.get_primitive_tc(TCKind.tk_wstring));

    rq.invoke();

    assertEquals("Returned value", rq.result().value().extract_wstring(),
                 "return 'narrow string' and 'wide string'"
                );
  }
View Full Code Here

    ORB client_orb = ORB.init(args, null);

    org.omg.CORBA.Object object =
      (org.omg.CORBA.Object) client_orb.string_to_object(ior);

    Request r =
      object._create_request(null, "pass", server_orb.create_list(0), null);

    // Write the test values.
    r.add_in_arg().insert_octet((byte) 0x77);
    r.add_in_arg().insert_long(1);
    r.add_in_arg().insert_longlong(2);
    r.add_in_arg().insert_short((short) 3);
    r.add_in_arg().insert_string("[string 4]");
    r.add_in_arg().insert_double(45.689);
    r.add_in_arg().insert_octet((byte) 0xFE);

    // This will serve as EOF marker.
    r.add_in_arg().insert_octet((byte) 0xFF);

    // For the last parameter, the value is not set.
    r.set_return_type(server_orb.create_sequence_tc(0,
                                                    server_orb.get_primitive_tc(TCKind.tk_octet)
                                                   )
                     );

    r.invoke();

    byte[] reflection = OctetSeqHelper.extract(r.result().value());

    assertEquals("length", expected.length, reflection.length);

    for (int i = 0; i < reflection.length; i++)
      {
View Full Code Here

        String hello = Tester2.sayHello();

        assertEquals("Local and remote must return the same", lHello, hello);

        // Saying remote hello via DII.
        Request rq =
          Tester2._create_request(null, "sayHello", orb2.create_list(0),
            orb2.create_named_value("", orb.create_any(), 0)
          );
        rq.set_return_type(orb2.get_primitive_tc(TCKind.tk_string));

        rq.invoke();

        assertEquals("Remote Stub and DII call must return the same", hello,
          rq.return_value().extract_string()
        );

        // Saying local hello via DII.
        rq =
          Tester._create_request(null, "sayHello", orb2.create_list(0),
            orb2.create_named_value("", orb.create_any(), 0)
          );
        rq.set_return_type(orb2.get_primitive_tc(TCKind.tk_string));

        rq.invoke();

        assertEquals("Local Stub and DII call must return the same", hello,
          rq.return_value().extract_string()
        );

        // Throw remote system exception
        try
          {
View Full Code Here

  void uTestPOA(POA poa)
  {
    byte[] id;
    org.omg.CORBA.Object obj;
    Request request;
    Test test;

    //
    // Invoke twice on each object - statically & DII
    //
    id = ("test").getBytes();
    obj = poa.create_reference_with_id(id, "IDL:test/poa/Test:1.0");
    test = TestHelper.narrow(obj);
    test.aMethod();
    request = obj._request("aMethod");
    request.invoke();
    TEST(request.env().exception() == null);

    id = ("testDSI").getBytes();
    obj = poa.create_reference_with_id(id, "IDL:test/poa/Test:1.0");
    test = TestHelper.narrow(obj);
    test.aMethod();
    request = obj._request("aMethod");
    request.invoke();
    TEST(request.env().exception() == null);
  }
View Full Code Here

     */
    public synchronized boolean poll_next_response()
    {
        checkShutdownState();

        Request currRequest;

        // poll on each pending request
        Enumeration ve = dynamicRequests.elements();
        while (ve.hasMoreElements() == true) {
            currRequest = (Request)ve.nextElement();
            if (currRequest.poll_response() == true) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

        while (true) {
            // check if there already is a response
            synchronized ( dynamicRequests ) {
                Enumeration elems = dynamicRequests.elements();
                while ( elems.hasMoreElements() ) {
                    Request currRequest = (Request)elems.nextElement();
                    if ( currRequest.poll_response() ) {
                        // get the response for this successfully polled Request
                        currRequest.get_response();
                        dynamicRequests.removeElement(currRequest);
                        return currRequest;
                    }
                }
            }
View Full Code Here

            Object[] tcs = exceptions.keySet().toArray();
            for (int i = 0; i < exceptions.size(); ++i) {
                exList.add((TypeCode) tcs[i]);
            }

            Request request =
                target._create_request(ctx,
                                       (String)objectCtx.get(ObjectMessageContext.WSDL_OPERATION),
                                       list,
                                       ret,
                                       exList,
                                       ctxList);
            request.invoke();

            mc.put(ObjectMessageContext.MESSAGE_INPUT, Boolean.FALSE);
            java.lang.Exception ex = request.env().exception();
            if (ex == null) {
                if (retVal != null) {
                    message.setStreamableReturnValue(retVal.getObject());
                }
View Full Code Here

TOP

Related Classes of org.omg.CORBA.Request

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.