Package org.omg.CORBA

Examples of org.omg.CORBA.ORB


    poaName = "main";
    t = a_t;
    try
      {
        // Create and initialize the ORB.
        final ORB orb = org.omg.CORBA.ORB.init(new String[ 0 ], null);

        // Create the servant and register it with the ORBs root POA.
        POA root_poa =
          POAHelper.narrow(orb.resolve_initial_references("RootPOA"));

        POA poa = root_poa.create_POA("1", null, policies_1(root_poa));

        poa.the_activator(new gnuAdapterActivator());

        POA npoa = poa.find_POA("xactivated", true);

        npoa.activate_object_with_id(new byte[] { 7, 5 }, new poa_Servant());
        write_reference(orb, npoa.id_to_reference(new byte[] { 7, 5 }),
                        "xactivated"
                       );

        root_poa.the_POAManager().activate();
        poa.the_POAManager().activate();

        poa_Servant once_activated_servant = new poa_Servant();

        org.omg.CORBA.Object servantObject =
          poa.create_reference_with_id(new byte[] { 4, 5, 2, 5, 7, 2 },
                                       poa_comTesterHelper.id()
                                      );

        org.omg.CORBA.Object localTestServant =
          poa.create_reference_with_id(new byte[] { 1, 2, 3, 4 },
                                       poa_comTesterHelper.id()
                                      );

        once_activated = new poa_Server(poa.the_name());
        poa.set_servant_manager(once_activated);

        write_reference(orb, servantObject, "IOR.txt");

        // Add a single servant POA.
        POA sspoa = root_poa.create_POA("2", null, policies_2(root_poa));

        poa_Servant always_same_servant = new poa_Servant();
        sspoa.set_servant(always_same_servant);

        org.omg.CORBA.Object sservantObject1 =
          sspoa.create_reference_with_id(new byte[] { 5, 4, 3, 2, 1 },
                                         poa_comTesterHelper.id()
                                        );

        write_reference(orb, sservantObject1, "ssIOR1.txt");

        org.omg.CORBA.Object sservantObject2 =
          sspoa.create_reference_with_id(new byte[] { 1, 2, 3, 4, 5 },
                                         poa_comTesterHelper.id()
                                        );

        write_reference(orb, sservantObject2, "ssIOR2.txt");

        sspoa.the_POAManager().activate();

        // Add a single servant POA that also allows to introduce the
        // explicitly activated alternative servant.
        POA sspoa_a = root_poa.create_POA("2a", null, policies_2a(root_poa));

        s2a = new poa_Servant();
        sspoa_a.set_servant(s2a);

        org.omg.CORBA.Object sservantObject1adefault1 =
          sspoa_a.create_reference_with_id(new byte[] { 4, 4, 4, 1 },
                                           poa_comTesterHelper.id()
                                          );

        org.omg.CORBA.Object sservantObject1adefault2 =
          sspoa_a.create_reference_with_id(new byte[] { 4, 4, 4, 2 },
                                           poa_comTesterHelper.id()
                                          );

        sspoa_a.activate_object_with_id(new byte[] { 4, 4, 4, 5, 5, 5, 5 },
                                        new poa_Servant()
                                       );

        org.omg.CORBA.Object sservantObject1aother =
          sspoa_a.id_to_reference(new byte[] { 4, 4, 4, 5, 5, 5, 5 });

        sspoa_a.the_POAManager().activate();

        // Activate the servant that would handle the redirections.
        poa_Servant redirection_handler =
          new poa_Servant()
          {
            /**
             * Just prints the hello message.
             */
            public String sayHello()
            {
              return "{redirection handler} " + array(super._object_id());
            }
          };
        poa.activate_object_with_id(new byte[] { 7, 7, 7 }, redirection_handler);
        write_reference(orb, poa.servant_to_reference(redirection_handler),
                        "redirector"
                       );

        org.omg.CORBA.Object o1;
        org.omg.CORBA.Object o2;
        org.omg.CORBA.Object o3;

        poa_comTester t1 =
          poa_comTesterHelper.narrow(o1 = sservantObject1adefault1);
        poa_comTester t2 =
          poa_comTesterHelper.narrow(o2 = sservantObject1adefault2);
        poa_comTester tx =
          poa_comTesterHelper.narrow(o3 = sservantObject1aother);

        String s1 = t1.sayHello();
        String s2 = t2.sayHello();
        String sx = tx.sayHello();

        String h1 = s1.substring(s1.lastIndexOf(":"));
        String h2 = s2.substring(s2.lastIndexOf(":"));
        String hx = sx.substring(sx.lastIndexOf(":"));

        t.check(h1, h2, "Must be same default servant");
        t.check(!h1.equals(hx), "Must be different servant");
        t.check(!h2.equals(hx), "Must be different servant");

        // Save them.
        write_reference(orb, t1, "T1");
        write_reference(orb, t2, "T2");
        write_reference(orb, tx, "TX");

        remotePoaControlServant control = new remotePoaControlServant();

        control.target_object_id = poa.reference_to_id(servantObject);

        org.omg.CORBA.Object controlObject =
          root_poa.servant_to_reference(control);

        write_reference(orb, controlObject, "Control.txt");

        POA subpoa = sspoa.create_POA("sub", null, policies_3(sspoa));

        m575 = new poa_Server(subpoa.the_name());
        subpoa.set_servant_manager(m575);

        org.omg.CORBA.Object sub =
          subpoa.create_reference_with_id(new byte[] { 5, 7, 5 },
                                          poa_comTesterHelper.id()
                                         );
        subpoa.the_POAManager().activate();
        write_reference(orb, sub, "ssIOR3.txt");

        poa_comTester s = poa_comTesterHelper.narrow(localTestServant);

        try
          {
            s.throwException(64);
            t.fail("LOCAL:User exception is not thrown");
          }
        catch (ourUserException ex)
          {
            t.check(64, ex.ourField, "LOCAL: user exception field value");
          }

        Request rq =
          s._create_request(null, "passCharacters", orb.create_list(2), 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();

        String rt = rq.result().value().extract_wstring();
        t.check("return 'narrow string' and 'wide string'", rt, "LOCAL:DII:");

        poa_comTesterHelper.narrow(sub).sayHello();

        s.theField(55);
        t.check(55, s.theField(), "LOCAL: field accessing");
        s.theField(17);

        String r = s.passCharacters("abba", "baba");
        t.check("return 'baba' and 'abba'", r);

        // The objects with such key will receive redirection exceptions.
        // We force the redirection exception the be throw by activator...
        org.omg.CORBA.Object willBeRedirected =
          poa.create_reference_with_id(new byte[] { 0x7F, 0, 0, 0, 8 },
                                       poa_comTesterHelper.id()
                                      );

        write_reference(orb, willBeRedirected, "willRedirActivator.txt");

        // ..and by locator.
        willBeRedirected =
          subpoa.create_reference_with_id(new byte[] { 0x7F, 0, 0, 0, 9 },
                                          poa_comTesterHelper.id()
                                         );

        write_reference(orb, willBeRedirected, "willRedirLocator.txt");

        new Thread()
          {
            public void run()
            {
              // Start the thread, serving the invocations from clients.
              orb.run();
            }
          }.start();

        started = true;

View Full Code Here


                    throws org.omg.PortableServer.ForwardRequest
  {
    // Handle "hello" on redirector for all objects with key starting 0xFF.
    if (key [ 0 ] == 0x7F)
      {
        ORB orb = ORB.init(new String[ 0 ], null);
        org.omg.CORBA.Object redir = poa_POA_test.readIOR("redirector", orb);
        throw new ForwardRequest("redirecting", redir);
      }

    String s = array(key) + "/" + poa.the_name();
View Full Code Here

                    throws org.omg.PortableServer.ForwardRequest
  {
    // Handle "hello" on redirector for all objects with key starting 0xFF.
    if (key [ 0 ] == 0x7F)
      {
        ORB orb = ORB.init(new String[ 0 ], null);
        org.omg.CORBA.Object redir = poa_POA_test.readIOR("redirector", orb);
        throw new ForwardRequest("redirecting", redir);
      }

    String s = array(key) + method + "/" + poa.the_name();
View Full Code Here

public class RMI_IIOP
  implements Testlet
{
  public void test(TestHarness harness)
  {
    ORB client_orb = null;
    // Set the loader of this class as a context class loader, ensuring that the
    // CORBA implementation will be able to locate the RMI stubs and ties.
    ClassLoader previous = Thread.currentThread().getContextClassLoader();
    Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
    try
      {
        client_orb = ORB.init(new String[0], null);

        String ior = startServer(harness);

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

        RMI_test r = (RMI_test) PortableRemoteObject.narrow(object,
          RMI_test.class);

        harness.check("null", r.sayHello(null), "First call");

        harness.check(r.multiply((byte) 4, 6), 24, "Multiplying 4*6=");

        harness.check("'String one' and 'String two'", r.joinStrings(
          "String one", "String two"), "Joining strings");

        harness.check("'null' and 'null'", r.joinStrings(null, null),
          "Passing null");

        harness.check(

          "byte 1, double 2.34, int 5, string  six, float 7.89, char A(41), short 11",
          r.passPrimitives((byte) 1, 2.34, 5, "six", (float) 7.89, 'A',
            (short) 11), "Passing primitives");

        harness.check(25, r.passArray(new int[] { 1, 2, 4, 8, 10 }),
          "Passing primitive array");

        String[] arr = new String[] { "a", "b", null, "abc" };
        harness.check("a.b.null.abc.", r.passStringArray(arr),
          "Passing String array");

        harness.check("1 2 three", r.passStructure(new myStructure()),
          "Passing structure");

        cmInfoImpl c1 = new cmInfoImpl();
        c1.message = "msg";
        c1.name = "nm";

        harness.check(r.passCorbaCMValueType(c1), "nm;msg", "CustomMarshal");

        InfoImpl c2 = new InfoImpl();
        c2._message = "_msg";
        c2._name = "_nm";

        harness.check(r.passCorbaValueType(c2), "_nm--_msg", "Streamable");

        myStructure[] a = new myStructure[4];

        // First element will be null.
        for (int i = 1; i < a.length; i++)
          {
            a[i] = new myStructure();
            a[i].a = 100 * i;
            a[i].c = "c" + i;
          }
        harness.check("null:100 2 c1:200 2 c2:300 2 c3:",
          r.passStructureArray(a), "Structure array");

        Info i1 = new InfoImpl();
        i1._message = "m1";
        i1._name = "n1";
        Info i2 = new InfoImpl();
        i2._message = "m2";
        i2._name = "n2";

        harness.check("n1--m1:null:n2--m2:",
          r.passCorbaValueTypeArray(new Info[] { i1, null, i2 }),
          "Value type array");

        harness.check("null passed", r.passCorbaObject(null),
          "null as CORBA object");

        String s = r.exchangeNodeObject(NodeObject.create1()).toString();
        harness.check(s, NodeObject.create2().toString(), "Graph");

        // Instantiate another RMI_test here.
        POA rootPOA = POAHelper.narrow(client_orb.resolve_initial_references("RootPOA"));

        rootPOA.the_POAManager().activate();

        RMI_testImpl impl = new RMI_testImpl();
        impl.ego = "Local client object";

        NodeObject n = new NodeObject("x");

        Tie tie = Util.getTie(impl);

        org.omg.CORBA.Object l_object = rootPOA.servant_to_reference((Servant) tie);

        RMI_test l_r = (RMI_test) PortableRemoteObject.narrow(l_object,
          RMI_test.class);

        n.z_anotherTest = l_r;

        harness.check("Local client object", l_r.getEgo(), "Local client");

        // The server should returns its own object in return:
        RMI_test rt = r.exchangeNodeObject(n).z_anotherTest;
        harness.check("Server side object", rt.getEgo(), "Server side object");

        // The server should echo the name of the passed object:
        harness.check("Local client object", r.sayHello(l_r), "Local client");

        RMI_testImpl impl2 = new RMI_testImpl();
        impl2.ego = "Client implementation instance";

        harness.check("Client implementation instance", r.sayHello(impl2),
          "Client implementation");

        n.anotherTestArray = new RMI_test[] { impl, null, impl2, rt };
        n.z_anotherTest = null;

        // Verifying array of remotes that is a field in the structure being
        // passed.
        String rts = r.exchangeNodeObject(n).label;
        harness.check(
          "Local client object.null.Client implementation instance.Server side object.",
          rts, "Passed array of 4 Remotes in a structure field.");

        harness.check("ab (Server side object:Local client object)",
          r.passReturnRemote(l_r).getEgo(), "Pass/return remote, stub");

        harness.check("ab (Server side object:Client implementation instance)",
          r.passReturnRemote(impl2).getEgo(),
          "Pass/return remote, implementation");

        harness.check(r.passReturnRemote(null) == null, "pass/get null");

        // If the verification of the server side succeeds, the "ok" is
        // returned. Otherwise, the mismatching entry is returned.
        harness.check("ok", r.passArrayOfRemotes(new RMI_test[] { impl, impl2,
          null, l_r, rt }), "Pass Remote[]");

        Collection ar = new ArrayList();

        ar.add("one");
        ar.add("two");
        ar.add("three");

        Externa e = new Externa();
        e.a = 17;
        e.b = 64;
        ar.add(e);

        ar.add(null);
        // Make a graph.
        ar.add(e);
        ar.add(e);

        Externa b = new Externa();
        b.a = 55;
        b.b = 56;
        ar.add(b);
        ar.add(e);
        ar.add("last");

        harness.check(
          "java.util.ArrayList:one.two.three.(ex 17:64).null.(ex 17:64).(ex 17:64).(ex 55:56).(ex 17:64).last.",
          r.passCollection(ar), "Pass ArrayList");

      }
    catch (Exception e)
      {
        harness.fail("Exception: "
          + e
          + ". If this is Sun's jre, note theat at least jdk 1.5.0_04-b05 required.");
      }
    finally
      {
        Thread.currentThread().setContextClassLoader(previous);
        try
          {
            if (server_orb != null)
              server_orb.destroy();
            if (client_orb != null)
              client_orb.destroy();
          }
        catch (Throwable t)
          {
            // Failed to destroy.
            harness.fail("Unable to destroy the ORBs: "+t);
View Full Code Here

  public void testIt()
  {
    java.util.Properties props = System.getProperties();

    ORB orb = null;

    orb = ORB.init(new String[ 0 ], props);

    POA root = TestUtil.GetRootPOA(orb);

    run(orb, root);

    if (orb != null)
      {
        orb.destroy();
      }
  }
View Full Code Here

  public void testIt()
  {
    java.util.Properties props = System.getProperties();

    ORB orb = null;

    //
    // Create ORB
    //
    orb = ORB.init(new String[ 0 ], props);

    POA root = TestUtil.GetRootPOA(orb);

    //
    // Run the tests using the root POA
    //
    runtests(orb, root);

    //
    // Create a child POA and run the tests again using the
    // child as the root
    //
    Policy[] policies = new Policy[ 0 ];
    POAManager manager = root.the_POAManager();
    POA child = null;
    try
      {
        child = root.create_POA("child", manager, policies);
      }
    catch (AdapterAlreadyExists ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (InvalidPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    runtests(orb, child);

    if (orb != null)
      orb.destroy();
  }
View Full Code Here

  {
    poa_comTester object;

    try
      {
        ORB orb = org.omg.CORBA.ORB.init(new String[ 0 ], null);

        object = poa_comTesterHelper.narrow(readIOR(ssTARGET_IOR_FILE0, orb));
        control = remotePoaControlHelper.narrow(readIOR(CONTROL_IOR_FILE, orb));

        object = poa_comTesterHelper.narrow(readIOR(ssTARGET_IOR_FILE1, orb));
View Full Code Here

  public static void main(String[] args)
  {
    Properties props = System.getProperties();

    final ORB orb;

    //
    // Create ORB
    //
    orb = ORB.init(args, props);

    // Start the ORB in separate thread.

    POA root = TestUtil.GetRootPOA(orb);

    POA poa;
    Policy[] policies;

    POAManager manager = root.the_POAManager();

    //
    // Create POA
    //
    policies = new Policy[ 4 ];
    policies [ 0 ] =
      root.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
    policies [ 1 ] =
      root.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);
    policies [ 2 ] =
      root.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
    policies [ 3 ] =
      root.create_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue.USE_SERVANT_MANAGER);

    try
      {
        poa = root.create_POA("poa", manager, policies);
      }
    catch (InvalidPolicy ex)
      {
        throw new RuntimeException(ex);
      }
    catch (AdapterAlreadyExists ex)
      {
        throw new RuntimeException(ex);
      }

    TestLocationForwardActivator_impl activatorImpl =
      new TestLocationForwardActivator_impl();
    ServantActivator activator = activatorImpl._this(orb);
    try
      {
        poa.set_servant_manager(activator);
      }
    catch (WrongPolicy ex)
      {
        throw new RuntimeException(ex);
      }

    byte[] oid = ("test").getBytes();
    final org.omg.CORBA.Object reference =
      poa.create_reference_with_id(oid, TestLocationForwardHelper.id());

    //"IDL:Test:1.0");
    String impl = null;

    //
    // Read all object references from file
    //
    try
      {
        String refFile = "Test.ref";
        FileInputStream file = new FileInputStream(refFile);
        BufferedReader in = new BufferedReader(new InputStreamReader(file));
        impl = in.readLine();
        file.close();
      }
    catch (IOException ex)
      {
        System.err.println("Can't read from `" + ex.getMessage() + "'");
        System.exit(1);
      }

    org.omg.CORBA.Object obj = orb.string_to_object(impl);
    TestLocationForwardServer server =
      TestLocationForwardServerHelper.narrow(obj);

    if (server == null)
      throw new RuntimeException("Server is null");

    org.omg.CORBA.Object servant = server.get_servant();

    activatorImpl.setForwardRequest(servant);

    TestLocationForward_impl testImpl = new TestLocationForward_impl(orb);
    activatorImpl.setActivatedServant(testImpl);

    try
      {
        manager.activate();
      }
    catch (org.omg.PortableServer.POAManagerPackage.AdapterInactive ex)
      {
        throw new RuntimeException(ex);
      }

    server.setForwardRequest(reference);

    //
    // Run some calls
    //
    TestLocationForward local = TestLocationForwardHelper.narrow(reference);

    //
    // First should be local
    //
    local.aMethod();
    local.deactivate_servant();

    //
    // Second, should be remote
    //
    local.aMethod();
    local.deactivate_servant();

    //
    // Third should be local again
    //
    local.aMethod();
    local.deactivate_servant();

    //
    // Clean up
    //
    poa.destroy(true, true);

    server.deactivate();

    orb.destroy();
  }
View Full Code Here

  public void testCustomValue()
  {
    h.checkPoint("Custom value");

    ORB orb = ORB.init(new String[ 0 ], null);

    Any sc = orb.create_any();

    org.omg.CORBA_2_3.portable.OutputStream out =
      (org.omg.CORBA_2_3.portable.OutputStream) sc.create_output_stream();

    cmInfoImpl orig = new cmInfoImpl("first", "second");

    out.write_value(orig);

    Any b = orb.create_any();

    InputStream ou = out.create_input_stream();

    b.read_value((org.omg.CORBA_2_3.portable.InputStream) ou,
                 cmInfoHelper.type()
View Full Code Here

  {
    h.checkPoint("Streamable value");

    try
      {
        ORB orb = ORB.init(new String[ 0 ], null);

        for (int holder_mode = 0; holder_mode < 3; holder_mode++)
          {
            for (int helper_mode = 0; helper_mode < 4; helper_mode++)
              {
                InfoHolder.testMode = holder_mode;
                InfoHelper.testMode = helper_mode;

                String mode = holder_mode + ":" + helper_mode;

                Any sc = orb.create_any();

                org.omg.CORBA_2_3.portable.OutputStream out =
                  (org.omg.CORBA_2_3.portable.OutputStream) sc.create_output_stream();

                InfoImpl orig = new InfoImpl("first", "second");

                out.write_value(orig);

                Any b = orb.create_any();

                InputStream ou = out.create_input_stream();
                TypeCode type = orig._type();

                b.read_value((org.omg.CORBA_2_3.portable.InputStream) ou, type);
View Full Code Here

TOP

Related Classes of org.omg.CORBA.ORB

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.