Examples of POA


Examples of org.omg.PortableServer.POA

        }

        disposableManager_.addDisposable(new Disposable() {
            public void dispose()
            {
                final POA _poa = (POA) container_.getComponentInstanceOfType(POA.class);

                _poa.destroy(true, false);
            }
        });

        config_ = (Configuration) container_.getComponentInstanceOfType(Configuration.class);

        logger_ = ((org.jacorb.config.Configuration) config_).getLogger(getClass().getName());

        POA _rootPOA = (POA) container_.getComponentInstanceOfType(POA.class);

        List _ps = new ArrayList();

        _ps.add(_rootPOA.create_id_assignment_policy(IdAssignmentPolicyValue.USER_ID));

        BiDirGiopPOAComponentAdapter.addBiDirGiopPolicy(_ps, orb, config_);

        org.omg.CORBA.Policy[] _policies = (org.omg.CORBA.Policy[]) _ps
                .toArray(new org.omg.CORBA.Policy[_ps.size()]);

        eventChannelFactoryPOA_ = _rootPOA.create_POA(EVENTCHANNEL_FACTORY_POA_NAME, _rootPOA
                .the_POAManager(), _policies);

        for (int x = 0; x < _policies.length; ++x)
        {
            _policies[x].destroy();
View Full Code Here

Examples of org.omg.PortableServer.POA

        _factory.startChannels(props);

        if (startThread)
        {
            POA _poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
            _poa.the_POAManager().activate();

            Thread _orbThread = new Thread(new Runnable()
            {
                public void run()
                {
View Full Code Here

Examples of org.omg.PortableServer.POA

    }

    public Object getComponentInstance(PicoContainer container) throws PicoInitializationException,
            PicoIntrospectionException
    {
        final POA rootPOA = (POA) super.getComponentInstance(container);

        final Configuration config = (Configuration) container.getComponentInstanceOfType(Configuration.class);

        final Logger _logger = LogUtil.getLogger(config, getClass().getName());

        try
        {
            final ORB orb = (ORB) container.getComponentInstanceOfType(ORB.class);

            final List _policyList = new ArrayList();

            _policyList.add(rootPOA.create_implicit_activation_policy(ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION));

            addBiDirGiopPolicy(_policyList, orb, config);

            if (isBiDirGiopEnabled(config) && _logger.isInfoEnabled())
            {
                _logger.info(BIDIR_GIOP_OPTION
                             + " is set:"
                             + " Will enable Bidirectional GIOP.");
            }
           
            org.omg.CORBA.Policy[] _policies = (org.omg.CORBA.Policy[]) _policyList
                    .toArray(new org.omg.CORBA.Policy[_policyList.size()]);

            POA poa = rootPOA.create_POA("NotifyServicePOA", rootPOA.the_POAManager(), _policies);

            for (int x = 0; x < _policies.length; ++x)
            {
                _policies[x].destroy();
            }
View Full Code Here

Examples of org.omg.PortableServer.POA

    {
        try
        {
            ORB orb = (ORB) container.getComponentInstance(ORB.class);

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

            return poa;
        } catch (InvalidName e)
        {
            throw new PicoInitializationException("could not resolve RootPOA", e);
View Full Code Here

Examples of org.omg.PortableServer.POA

            policies[2] =
            rootPOA.create_request_processing_policy(
                RequestProcessingPolicyValue.USE_SERVANT_MANAGER);

            POA nsPOA = rootPOA.create_POA("NameServer-POA",
                                           rootPOA.the_POAManager(),
                                           policies);

            NamingContextImpl.init(orb, rootPOA);
            NameServer.NameServantActivatorImpl servantActivator =
                new NameServer.NameServantActivatorImpl( orb );
            servantActivator.configure(config);

            nsPOA.set_servant_manager( servantActivator );
            nsPOA.the_POAManager().activate();

            for (int i = 0; i < policies.length; i++)
                policies[i].destroy();

            /* export the root context's reference to a file */
            byte[] oid = ( new String("_root").getBytes() );
            try
            {
                org.omg.CORBA.Object obj =
                nsPOA.create_reference_with_id( oid, "IDL:omg.org/CosNaming/NamingContextExt:1.0");

                if( fileName != null && fileName.length() > 0 )
                {
                    PrintWriter out =
                    new PrintWriter( new FileOutputStream( fileName ), true );
View Full Code Here

Examples of org.omg.PortableServer.POA

            _registration =
                RegistrationHelper.narrow( orb.resolve_initial_references("ImplementationRepository"));
            if( _registration == null )
                throw new ConfigurationException("ImR not found");

            POA poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
            poa.the_POAManager().activate();

            ServerStartupDaemon ssd =
                ServerStartupDaemonHelper.narrow(poa.servant_to_reference(this));

            HostInfo _me = new HostInfo(InetAddress.getLocalHost().getHostName(),
                                        ssd,
                                        orb.object_to_string(ssd));
View Full Code Here

Examples of org.omg.PortableServer.POA

   */
  public boolean unknown_adapter(POA parent, String child_name)
  {
    try
      {
        POA n = parent.create_POA(child_name, null, new Policy[ 0 ]);
        n.the_POAManager().activate();
      }
    catch (Exception ex)
      {
        return false;
      }
View Full Code Here

Examples of org.omg.PortableServer.POA

      {
        // 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");

View Full Code Here

Examples of org.omg.PortableServer.POA

  }

  void uTestServantToReference(ORB orb, POA root)
  {
    org.omg.CORBA.Object obj;
    POA unique;
    POA implicit;
    POA multiple;
    byte[] id1;
    byte[] id2;
    byte[] tmpid1;
    byte[] tmpid2;
    Policy[] policies;
    Test_impl servant1;
    Test_impl servant2;

    POAManager manager = root.the_POAManager();

    //
    // Create POA w/ UNIQUE_ID, NO_IMPLICIT_ACTIVATION
    //
    policies = new Policy[ 4 ];
    policies [ 0 ] =
      root.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);
    policies [ 1 ] =
      root.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
    policies [ 2 ] =
      root.create_servant_retention_policy(org.omg.PortableServer.ServantRetentionPolicyValue.RETAIN);
    policies [ 3 ] =
      root.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION);
    try
      {
        unique = root.create_POA("unique_id", manager, policies);
      }
    catch (AdapterAlreadyExists ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (InvalidPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    //
    // Create POA w/ UNIQUE_ID, IMPLICIT_ACTIVATION
    //
    policies = new Policy[ 3 ];
    policies [ 0 ] =
      root.create_id_uniqueness_policy(org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);
    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);
    try
      {
        implicit = root.create_POA("implicit", manager, policies);
      }
    catch (AdapterAlreadyExists ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (InvalidPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    //
    // Create POA w/ MULTIPLE_ID, IMPLICIT_ACTIVATION
    //
    policies = new Policy[ 3 ];
    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_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION);
    try
      {
        multiple = root.create_POA("multiple", manager, policies);
      }
    catch (AdapterAlreadyExists ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (InvalidPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

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

    //
    // Test: ServantNotActive exception
    //
    try
      {
        unique.servant_to_reference(servant1);
        TEST(false); // servant_to_reference should not have succeeded
      }
    catch (ServantNotActive ex)
      {
        // expected
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

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

    //
    // Test: servant_to_reference (UNIQUE_ID policy)
    //
    try
      {
        obj = unique.servant_to_reference(servant1);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (ServantNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(obj != null);
    try
      {
        tmpid1 = unique.reference_to_id(obj);
      }
    catch (WrongAdapter ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(TestUtil.Compare(id1, tmpid1));

    //
    // Test: servant_to_reference (IMPLICIT_ACTIVATION) - servant1 should
    //       be automatically activated
    //
    try
      {
        obj = implicit.servant_to_reference(servant1);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (ServantNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(obj != null);
    try
      {
        tmpid1 = implicit.reference_to_id(obj);
      }
    catch (WrongAdapter ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    //
    // Test: Now that servant1 is activated, and since we have UNIQUE_ID,
    //       we should get the same ID back
    //
    try
      {
        obj = implicit.servant_to_reference(servant1);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (ServantNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(obj != null);
    try
      {
        tmpid2 = implicit.reference_to_id(obj);
      }
    catch (WrongAdapter ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(TestUtil.Compare(tmpid1, tmpid2));

    //
    // Test: Implicitly activating servant2 should produce a new ID
    //
    try
      {
        obj = implicit.servant_to_reference(servant2);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (ServantNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(obj != null);
    try
      {
        tmpid2 = implicit.reference_to_id(obj);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongAdapter ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(!TestUtil.Compare(tmpid1, tmpid2));

    //
    // Test: servant_to_reference (IMPLICIT_ACTIVATION, MULTIPLE_ID) -
    //       servant1 should be automatically activated
    //
    try
      {
        obj = multiple.servant_to_reference(servant1);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (ServantNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(obj != null);
    try
      {
        tmpid1 = multiple.reference_to_id(obj);
      }
    catch (WrongAdapter ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }

    //
    // Test: Since we have MULTIPLE_ID, we should get a new ID
    //
    try
      {
        obj = multiple.servant_to_reference(servant1);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (ServantNotActive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(obj != null);
    try
      {
        tmpid2 = multiple.reference_to_id(obj);
      }
    catch (WrongPolicy ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    catch (WrongAdapter ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
      }
    TEST(!TestUtil.Compare(tmpid1, tmpid2));

    unique.destroy(true, true);
    implicit.destroy(true, true);
    multiple.destroy(true, true);
  }
View Full Code Here

Examples of org.omg.PortableServer.POA

  }

  void uTestIdToReference(ORB orb, POA root)
  {
    org.omg.CORBA.Object obj;
    POA retain;
    POA defaultPOA;
    byte[] id1;
    byte[] id2;
    byte[] tmpid;
    Policy[] policies;
    Test_impl servant1;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.