Package org.omg.PortableServer

Examples of org.omg.PortableServer.POA


  }

  void uTestIdToServant(ORB orb, POA root)
  {
    org.omg.CORBA.Object obj;
    POA retain;
    POA defaultPOA;
    byte[] id1;
    byte[] id2;
    byte[] tmpid;
    Policy[] policies;
    Test_impl def;
    Test_impl servant1;
    Test_impl servant2;
    Servant tmpservant;

    POAManager manager = root.the_POAManager();

    //
    // Create POA w/ RETAIN
    //
    policies = new Policy[ 3 ];
    policies [ 0 ] =
      root.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
    policies [ 1 ] =
      root.create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.TRANSIENT);
    policies [ 2 ] =
      root.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
    try
      {
        retain = root.create_POA("retain", manager, policies);
      }
    catch (AdapterAlreadyExists ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (InvalidPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    //
    // Create POA w/ USE_DEFAULT_SERVANT
    //
    policies = new Policy[ 5 ];
    policies [ 0 ] =
      root.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.MULTIPLE_ID);
    policies [ 1 ] =
      root.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
    policies [ 2 ] =
      root.create_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue.USE_DEFAULT_SERVANT);
    policies [ 3 ] =
      root.create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.TRANSIENT);
    policies [ 4 ] =
      root.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);

    try
      {
        defaultPOA = root.create_POA("default", manager, policies);
      }
    catch (AdapterAlreadyExists ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (InvalidPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    def = new Test_impl(orb, "default", false);
    try
      {
        defaultPOA.set_servant(def);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    servant1 = new Test_impl(orb, "test1", false);
    servant2 = new Test_impl(orb, "test2", false);

    //
    // Test: ObjectNotActive exception
    //
    try
      {
        tmpid = ("bad_id").getBytes();
        retain.id_to_servant(tmpid);
        TEST(false); // id_to_servant should not have succeeded
      }
    catch (ObjectNotActive ex)
      {
        // expected
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    id1 = ("test1").getBytes();
    id2 = ("test2").getBytes();
    try
      {
        retain.activate_object_with_id(id1, servant1);
        retain.activate_object_with_id(id2, servant2);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (ServantAlreadyActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (ObjectAlreadyActive ex)
      {
        ex.printStackTrace();
        fail(ex);
        throw new RuntimeException(ex);
      }

    //
    // Test: servant_to_id (RETAIN policy)
    //
    try
      {
        tmpservant = retain.id_to_servant(id1);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (ObjectNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(servant1 == tmpservant);
    try
      {
        tmpservant = retain.id_to_servant(id2);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (ObjectNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(servant2 == tmpservant);

    //
    // Test: id_to_servant (USE_DEFAULT_SERVANT)
    //
    try
      {
        defaultPOA.activate_object_with_id(id1, servant1);
        defaultPOA.activate_object_with_id(id2, servant2);
      }
    catch (ServantAlreadyActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (ObjectAlreadyActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    try
      {
        tmpservant = defaultPOA.id_to_servant(id1);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (ObjectNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(servant1 == tmpservant);
    try
      {
        tmpservant = defaultPOA.id_to_servant(id2);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (ObjectNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(servant2 == tmpservant);

    retain.destroy(true, true);
    defaultPOA.destroy(true, true);
  }
View Full Code Here


    //
    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

        // Create the general communication servant and register it
        // with the ORB
        poa_Servant tester = new poa_Servant();

        POA rootPOA =
          POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
        Object object = rootPOA.servant_to_reference(tester);

        // IOR must contain custom fragment, inserted by interceptor.
        // Sun 1.4 had a bug that was fixed in 1.5.
        String ior = orb.object_to_string(object);

        assertTrue("IOR custom component (bug in 1.4, fixed in 1.5)",
          ior.indexOf(
            "45257200000020000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f"
          ) > 0
        );

        // Create the forwarding target and register it
        // with the ORB
        poa_Servant forw = new poa_Servant();

        tester.theField(15);
        forw.theField(16);

        // Another orb without interceptors.
        final ORB orbf = ORB.init(new String[ 0 ], null);

        POA rootPOA2 =
          POAHelper.narrow(orbf.resolve_initial_references("RootPOA"));

        Object fobject = rootPOA2.servant_to_reference(forw);

        // Storing the IOR reference for general communication.
        fior = fobject;

        rootPOA.the_POAManager().activate();
        rootPOA2.the_POAManager().activate();

        // Intercepting server ready and waiting ...
        new Thread()
          {
            public void run()
View Full Code Here

    TEST(request.env().exception() == null);
  }

  void uTestDefaultServant(ORB orb, POA root, POAManager manager)
  {
    POA poa;
    Servant servant;
    Policy[] policies;

    //
    // Setup policies for default servant
    //
    policies = new Policy[ 6 ];
    policies [ 0 ] =
      root.create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.TRANSIENT);
    policies [ 1 ] =
      root.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
    policies [ 2 ] =
      root.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.NON_RETAIN);
    policies [ 3 ] =
      root.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION);
    policies [ 4 ] =
      root.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.MULTIPLE_ID);
    policies [ 5 ] =
      root.create_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue.USE_DEFAULT_SERVANT);

    //
    // Create POA w/ static Default Servant
    //
    try
      {
        poa = root.create_POA("defaultSSI", manager, policies);
      }
    catch (AdapterAlreadyExists ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (InvalidPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    Test_impl staticServant = new Test_impl(orb, "defaultStaticServant", false);
    try
      {
        poa.set_servant(staticServant);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    uTestPOA(poa);
    poa.destroy(true, true);

    //
    // Since staticServant is a stack-based servant, we need to deactivate
    // it before it goes out of scope
    //
    byte[] id = null;
    try
      {
        id = root.servant_to_id(staticServant);
      }
    catch (ServantNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    try
      {
        root.deactivate_object(id);
      }
    catch (ObjectNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    //
    // Create POA w/ DSI Default Servant
    //
    try
      {
        poa = root.create_POA("defaultDSI", manager, policies);
      }
    catch (AdapterAlreadyExists ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (InvalidPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    servant = new TestDSIRef_impl(orb, "defaultDSIServant", false);
    try
      {
        poa.set_servant(servant);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    uTestPOA(poa);
    poa.destroy(true, true);
    servant = null;

    //
    // Clean up policies
    //
View Full Code Here

      policies [ i ].destroy();
  }

  void uTestServantLocator(ORB orb, POA root, POAManager manager)
  {
    POA poa;
    Servant servant;
    Policy[] policies;

    //
    // Setup policies for servant locator
    //
    policies = new Policy[ 6 ];
    policies [ 0 ] =
      root.create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.TRANSIENT);
    policies [ 1 ] =
      root.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
    policies [ 2 ] =
      root.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.NON_RETAIN);
    policies [ 3 ] =
      root.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION);
    policies [ 4 ] =
      root.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);
    policies [ 5 ] =
      root.create_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue.USE_SERVANT_MANAGER);

    //
    // Create POA w/ Servant Locator
    //
    try
      {
        poa = root.create_POA("servloc", manager, policies);
      }
    catch (AdapterAlreadyExists ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (InvalidPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    TestLocator_impl locatorImpl = new TestLocator_impl(orb);
    ServantLocator locator = locatorImpl._this(orb);
    try
      {
        poa.set_servant_manager(locator);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    uTestPOA(poa);
    poa.destroy(true, true);

    //
    // Clean up policies
    //
    for (int i = 0; i < policies.length; i++)
View Full Code Here

      }
  }

  void uTestServantActivator(ORB orb, POA root, POAManager manager)
  {
    POA poa;
    Servant servant;
    Policy[] policies;

    //
    // Setup policies for servant activator
    //
    policies = new Policy[ 4 ];
    policies [ 0 ] =
      root.create_lifespan_policy(org.omg.PortableServer.LifespanPolicyValue.TRANSIENT);
    policies [ 1 ] =
      root.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
    policies [ 2 ] =
      root.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION);
    policies [ 3 ] =
      root.create_request_processing_policy(org.omg.PortableServer.RequestProcessingPolicyValue.USE_SERVANT_MANAGER);

    //
    // Create POA w/ Servant Activator
    //
    try
      {
        poa = root.create_POA("servant", manager, policies);
      }
    catch (AdapterAlreadyExists ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (InvalidPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    TestActivator_impl activatorImpl = new TestActivator_impl(orb);
    ServantActivator activator = activatorImpl._this(orb);
    try
      {
        poa.set_servant_manager(activator);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    uTestPOA(poa);
    poa.destroy(true, true);

    //
    // Clean up policies
    //
    for (int i = 0; i < policies.length; i++)
View Full Code Here

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

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

    POA root = TestUtil.GetRootPOA(orb);
    POAManager manager = root.the_POAManager();
    try
      {
        manager.activate();
      }
    catch (org.omg.PortableServer.POAManagerPackage.AdapterInactive ex)
View Full Code Here

     
      // create and init 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();

        // test
        String accNum = "0234.234432.50L";
        AccountImpl accountImpl = new AccountImpl(accNum);
        AccountPOATie tie = new AccountPOATie(accountImpl, rootpoa);
View Full Code Here

    // create and init the ORB
    // ORB orb = ORB.init((String[])null, props);
    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();
    LOG.info("RootPOA activated");

    // create the bank
    BankImpl bankImpl = new BankImpl();
    LOG.info("Bank created");

    // get object reference from the servant
    org.omg.CORBA.Object ref = rootpoa.servant_to_reference(bankImpl);
    Bank bankRef = BankHelper.narrow(ref);
    LOG.info("Bank reference created");

    // get the NameService
    org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
View Full Code Here

    public synchronized void start(final StartContext startContext) throws StartException {

        transientPoaMap = Collections.synchronizedMap(new HashMap<String, POA>());
        persistentPoaMap = Collections.synchronizedMap(new HashMap<String, POA>());
        final POA rootPOA = this.rootPOA.getValue();

        // Policies for per-servant transient POAs
        transientPoaPolicies = new Policy[]{rootPOA.create_lifespan_policy(
                LifespanPolicyValue.TRANSIENT),
                rootPOA.create_id_assignment_policy(IdAssignmentPolicyValue.USER_ID),
                rootPOA.create_servant_retention_policy(ServantRetentionPolicyValue.NON_RETAIN),
                rootPOA.create_request_processing_policy(RequestProcessingPolicyValue.USE_DEFAULT_SERVANT),
                rootPOA.create_id_uniqueness_policy( IdUniquenessPolicyValue.MULTIPLE_ID),
        };

        // Policies for per-servant persistent POAs
        persistentPoaPolicies = new Policy[]{
                rootPOA.create_lifespan_policy(
                        LifespanPolicyValue.PERSISTENT),
                rootPOA.create_id_assignment_policy(
                        IdAssignmentPolicyValue.USER_ID),
                rootPOA.create_servant_retention_policy(
                        ServantRetentionPolicyValue.NON_RETAIN),
                rootPOA.create_request_processing_policy(
                        RequestProcessingPolicyValue.USE_DEFAULT_SERVANT),
                rootPOA.create_id_uniqueness_policy(
                        IdUniquenessPolicyValue.MULTIPLE_ID),
        };

        // Create this POARegistry's ServantRegistry implementations
        registryWithTransientPOAPerServant = new ServantRegistryWithTransientPOAPerServant();
View Full Code Here

TOP

Related Classes of org.omg.PortableServer.POA

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.