Package org.omg.PortableServer

Examples of org.omg.PortableServer.POAManager


        String location = address.getLocation();

        org.omg.CORBA.Object obj = null;
        try {
            POA rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
            POAManager poaManager = rootPOA.the_POAManager();

            Policy[] policies = new Policy[3];
            policies[0] = rootPOA
                    .create_lifespan_policy(
                        org.omg.PortableServer.LifespanPolicyValue.PERSISTENT);
            policies[1] = rootPOA
                    .create_implicit_activation_policy(
                        org.omg.PortableServer.ImplicitActivationPolicyValue.NO_IMPLICIT_ACTIVATION);
            policies[2] = rootPOA
                    .create_id_uniqueness_policy(
                        org.omg.PortableServer.IdUniquenessPolicyValue.UNIQUE_ID);

            POA bindingPOA = rootPOA.create_POA("BindingPOA", poaManager, policies);
           // CorbaDSIServant servant = new CorbaDSIServant(orb, bindingPOA, this, observer);
            CorbaDSIServant servant = new CorbaDSIServant();
            servant.init(orb, bindingPOA, this, observer);
            byte[] objectId = bindingPOA.activate_object(servant);
            obj = bindingPOA.id_to_reference(objectId);
           
            // Register the object reference so we can support passing references as
            // parameters and return types.  Note that we need the actual endpoint that
            // this object reference has been created on.  This is available through the
            // endpointInfo object passed during construction.
            CorbaObjectReferenceHelper.addReference(endpointInfo.getAddress(), obj);
          
            if (location.startsWith("relfile:")) {
                String iorFile = location.substring("relfile:".length(), location.length());
                // allow for up to 3 '/' to match common uses of relfile url format
                for (int n = 0; n < 3; n++) {
                    if (iorFile.charAt(0) != '/') {
                        break;
                    } else {
                        iorFile = iorFile.substring(1);
                    }
                }

                CorbaUtils.exportObjectReferenceToFile(obj, orb, iorFile);
            } else if (location.startsWith("file:")) {
                String iorFile = location.substring("file:".length(), location.length());
                // allow for up to 3 '/' to match common uses of file url format
                for (int n = 0; n < 3; n++) {
                    if (iorFile.charAt(0) != '/') {
                        break;
                    } else {
                        iorFile = iorFile.substring(1);
                    }
                }
                // to match the ORB, file must have complete path information, therefore we add
                // a '/' prefix to the address
                //iorFile = "/" + iorFile;
                CorbaUtils.exportObjectReferenceToFile(obj, orb, iorFile);
            } else if (location.startsWith("corbaloc")) {
                // Try add the key to the boot manager.  This is required for a corbaloc
                try {
                    int keyIndex = location.indexOf('/');
                    String key = location.substring(keyIndex + 1);
                    org.apache.yoko.orb.OB.BootManager bootManager =
                        org.apache.yoko.orb.OB.BootManagerHelper.narrow(
                            orb.resolve_initial_references("BootManager"));
                    bootManager.add_binding(key.getBytes(), obj);
                    LOG.info("Added key " + key + " to bootmanager");
                } catch (Exception ex) {
                    // TODO: Continue without for now
                }
                String ior = orb.object_to_string(obj);
                address.setLocation(ior);
                String iorFile = "endpoint.ior";
                CorbaUtils.exportObjectReferenceToFile(obj, orb, iorFile);
            } else {
                String ior = orb.object_to_string(obj);
                address.setLocation(ior);
                String iorFile = "endpoint.ior";
                CorbaUtils.exportObjectReferenceToFile(obj, orb, iorFile);
                LOG.info("Object Reference: " + orb.object_to_string(obj));
            }
            // TODO: Provide other export mechanisms?
           
            poaManager.activate();
        } catch (Exception ex) {
            // TODO: Throw appropriate exception
            throw new CorbaBindingException("Unable to activate CORBA servant", ex);
        }
    }   
View Full Code Here


    static int run(ORB orb, String[] args) throws UserException {
        // Resolve Root POA
        POA rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));

        // Get a reference to the POA manager
        POAManager manager = rootPOA.the_POAManager();

        // Create implementation object
        HelloWorldImpl hwImpl = new HelloWorldImpl(rootPOA);
        HelloWorld hello = hwImpl._this(orb);

        // Add reference to the boot manager
        try {
            byte[] oid = ("hw").getBytes();
            BootManager bootManager = BootManagerHelper.narrow(
                orb.resolve_initial_references("BootManager"));
            bootManager.add_binding(oid, hello);
        } catch (InvalidName ex) {
            throw new RuntimeException();
        } catch (AlreadyExists ex) {
            throw new RuntimeException();
        }

        // Run implementation
        manager.activate();
        System.out.println("Server ready...");
        orb.run();

        return 0;
    }
View Full Code Here

    Policy[] policies = new Policy[ 0 ];
    POA poa;
    POA parent;
    POA poa2;
    POA poa3;
    POAManager mgr;
    String str;

    POAManager rootMgr = root.the_POAManager();
    TEST(rootMgr != null);

    //
    // Create child POA
    //
View Full Code Here

    POA root = TestUtil.GetRootPOA(orb);

    POA poa;
    Policy[] policies;

    POAManager manager = root.the_POAManager();

    //
    // Create POAs
    //
    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 (AdapterAlreadyExists ex)
      {
        throw new RuntimeException(ex);
      }
    catch (InvalidPolicy ex)
      {
        throw new RuntimeException(ex);
      }

    TestLocationForwardActivator_impl activatorImpl =
      new TestLocationForwardActivator_impl();
    org.omg.PortableServer.ServantActivator activator =
      activatorImpl._this(orb);

    try
      {
        poa.set_servant_manager(activator);
      }
    catch (WrongPolicy ex)
      {
        throw new RuntimeException(ex);
      }

    byte[] oid = "test".getBytes();
    org.omg.CORBA.Object obj =
      poa.create_reference_with_id(oid, "IDL:Test:1.0");

    TestLocationForward_impl testImpl = new TestLocationForward_impl(orb);

    activatorImpl.setActivatedServant(testImpl);

    Server_impl serverImpl = new Server_impl(orb, activatorImpl, obj);
    TestLocationForwardServer server = serverImpl._this(orb);

    //
    // Save reference
    //
    String refFile = "Test.ref";
    try
      {
        FileOutputStream file = new FileOutputStream(refFile);
        PrintWriter out = new PrintWriter(file);
        out.println(ior = orb.object_to_string(server));
        out.flush();
        file.close();
      }
    catch (IOException ex)
      {
        throw new RuntimeException(ex);
      }

    //
    // Run implementation
    //
    try
      {
        manager.activate();
      }
    catch (org.omg.PortableServer.POAManagerPackage.AdapterInactive ex)
      {
        throw new RuntimeException(ex);
      }
View Full Code Here

    POA root = TestUtil.GetRootPOA(orb);

    //
    // Activate the RootPOA manager
    //
    POAManager rootMgr = root.the_POAManager();
    TEST(rootMgr != null);

    try
      {
        rootMgr.activate();
      }
    catch (org.omg.PortableServer.POAManagerPackage.AdapterInactive ex)
      {
        TEST(false);
      }
View Full Code Here

  // This is a more rigorous test of POA::destroy. We want to ensure
  // that the POA isn't destroyed during a method call.
  //
  void uTestDestroyThreaded(ORB orb, POA root)
  {
    POAManager rootMgr = root.the_POAManager();
    TEST(rootMgr != null);

    Policy[] policies = new Policy[ 1 ];
    policies [ 0 ] =
      root.create_implicit_activation_policy(org.omg.PortableServer.ImplicitActivationPolicyValue.IMPLICIT_ACTIVATION);
View Full Code Here

    Policy[] policies = new Policy[ 0 ];
    POA poa;
    POA parent;
    POA poa2;
    POA poa3;
    POAManager mgr;
    String str;

    POAManager rootMgr = root.the_POAManager();
    TEST(rootMgr != null);

    //
    // Create child POA
    //
View Full Code Here

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

    POA root = TestUtil.GetRootPOA(orb);

    POAManager rootMgr = root.the_POAManager();
    TEST(rootMgr != null);

    try
      {
        rootMgr.activate();
      }
    catch (org.omg.PortableServer.POAManagerPackage.AdapterInactive ex)
      {
        fail(ex);
        throw new RuntimeException(ex);
View Full Code Here

    Policy[] policies = new Policy[ 0 ];
    POA poa;
    POA parent;
    POA poa2;
    POA poa3;
    POAManager mgr;
    String str;

    POAManager rootMgr = root.the_POAManager();
    TEST(rootMgr != null);

    //
    // Test: POAManager should be in HOLDING state
    //
    TEST(rootMgr.get_state() == State.HOLDING);

    //
    // Create child POA
    //
    try
View Full Code Here

    byte[] id1;
    byte[] id2;
    byte[] tmpid;
    Policy[] policies;

    POAManager manager = root.the_POAManager();

    policies = new Policy[ 1 ];
    policies [ 0 ] =
      root.create_id_assignment_policy(org.omg.PortableServer.IdAssignmentPolicyValue.USER_ID);
    try
View Full Code Here

TOP

Related Classes of org.omg.PortableServer.POAManager

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.