| 1 | /*
|
|---|
| 2 | * CORBA POA tests
|
|---|
| 3 | *
|
|---|
| 4 | * This program is free software; you can redistribute it and/or modify it
|
|---|
| 5 | * under the terms of the GNU General Public License as published by the
|
|---|
| 6 | * Free Software Foundation; either version 2, or (at your option) any
|
|---|
| 7 | * later version.
|
|---|
| 8 | *
|
|---|
| 9 | * This program is distributed in the hope that it will be useful,
|
|---|
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 12 | * GNU General Public License for more details.
|
|---|
| 13 | *
|
|---|
| 14 | * You should have received a copy of the GNU General Public License
|
|---|
| 15 | * along with this program; if not, write to the Free Software Foundation,
|
|---|
| 16 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|---|
| 17 | *
|
|---|
| 18 | * Author: Mark McLoughlin <mark@skynet.ie>
|
|---|
| 19 | */
|
|---|
| 20 |
|
|---|
| 21 | /*
|
|---|
| 22 | * Test 8 : poatest-basic08.c
|
|---|
| 23 | * o POA with MULTIPLE_ID Object Id Uniqueness policy and
|
|---|
| 24 | * IMLICIT_ACTIVATION Implicit Activation policy.
|
|---|
| 25 | * o implicitly activate two objects with the same servant
|
|---|
| 26 | * using servant_to_id.
|
|---|
| 27 | * o same as Test 3 except a second object should activated
|
|---|
| 28 | * from the same servant.
|
|---|
| 29 | */
|
|---|
| 30 |
|
|---|
| 31 | #include <stdio.h>
|
|---|
| 32 | #include <stdlib.h>
|
|---|
| 33 |
|
|---|
| 34 | #include <orbit/orbit.h>
|
|---|
| 35 |
|
|---|
| 36 | #include "poatest-basic-shell.h"
|
|---|
| 37 |
|
|---|
| 38 | static void
|
|---|
| 39 | poatest_test_impl (PortableServer_Servant servant, CORBA_Environment *ev) { }
|
|---|
| 40 |
|
|---|
| 41 | PortableServer_ServantBase__epv base_epv = {
|
|---|
| 42 | NULL, /* _private */
|
|---|
| 43 | NULL, /* finalize */
|
|---|
| 44 | NULL /* default_POA */
|
|---|
| 45 | };
|
|---|
| 46 |
|
|---|
| 47 | POA_poatest__epv poatest_epv = {
|
|---|
| 48 | NULL, /* _private */
|
|---|
| 49 | poatest_test_impl /* test */
|
|---|
| 50 | };
|
|---|
| 51 |
|
|---|
| 52 | POA_poatest__vepv poatest_vepv = {
|
|---|
| 53 | &base_epv, /* _base_epv */
|
|---|
| 54 | &poatest_epv /* poatest_epv */
|
|---|
| 55 | };
|
|---|
| 56 |
|
|---|
| 57 | POA_poatest poatest_servant = {
|
|---|
| 58 | NULL, /* _private */
|
|---|
| 59 | &poatest_vepv /* vepv */
|
|---|
| 60 | };
|
|---|
| 61 |
|
|---|
| 62 | poatest
|
|---|
| 63 | poatest_run (PortableServer_POA rootpoa,
|
|---|
| 64 | PortableServer_POAManager rootpoa_mgr)
|
|---|
| 65 | {
|
|---|
| 66 | CORBA_Environment ev;
|
|---|
| 67 | poatest poatest_obj;
|
|---|
| 68 | CORBA_PolicyList *poa_policies;
|
|---|
| 69 | PortableServer_ObjectId *obj1id, *obj2id;
|
|---|
| 70 |
|
|---|
| 71 | CORBA_exception_init( &ev );
|
|---|
| 72 |
|
|---|
| 73 | /*
|
|---|
| 74 | * Create child POA with MULTIPLE_ID Object Id Uniqueness policy and
|
|---|
| 75 | * IMLICIT_ACTIVATION Implicit Activation policy.
|
|---|
| 76 | */
|
|---|
| 77 | poa_policies = CORBA_PolicyList__alloc ();
|
|---|
| 78 | poa_policies->_maximum = 2;
|
|---|
| 79 | poa_policies->_length = 2;
|
|---|
| 80 | poa_policies->_buffer = CORBA_PolicyList_allocbuf (2);
|
|---|
| 81 | CORBA_sequence_set_release (poa_policies, CORBA_TRUE);
|
|---|
| 82 |
|
|---|
| 83 | poa_policies->_buffer[0] = (CORBA_Policy)
|
|---|
| 84 | PortableServer_POA_create_id_uniqueness_policy (
|
|---|
| 85 | rootpoa,
|
|---|
| 86 | PortableServer_MULTIPLE_ID,
|
|---|
| 87 | &ev);
|
|---|
| 88 |
|
|---|
| 89 | poa_policies->_buffer[1] = (CORBA_Policy)
|
|---|
| 90 | PortableServer_POA_create_implicit_activation_policy (
|
|---|
| 91 | rootpoa,
|
|---|
| 92 | PortableServer_IMPLICIT_ACTIVATION,
|
|---|
| 93 | &ev);
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 | child_poa = PortableServer_POA_create_POA (rootpoa,
|
|---|
| 97 | "Multiple Id POA",
|
|---|
| 98 | rootpoa_mgr,
|
|---|
| 99 | poa_policies,
|
|---|
| 100 | &ev);
|
|---|
| 101 | if (POATEST_EX (&ev)) {
|
|---|
| 102 | POATEST_PRINT_EX ("create_POA : ", &ev);
|
|---|
| 103 | return CORBA_OBJECT_NIL;
|
|---|
| 104 | }
|
|---|
| 105 |
|
|---|
| 106 | CORBA_Policy_destroy (poa_policies->_buffer[0], &ev);
|
|---|
| 107 | CORBA_Policy_destroy (poa_policies->_buffer[1], &ev);
|
|---|
| 108 | CORBA_free (poa_policies);
|
|---|
| 109 |
|
|---|
| 110 | /*
|
|---|
| 111 | * Initialise the servant.
|
|---|
| 112 | */
|
|---|
| 113 | POA_poatest__init (&poatest_servant, &ev);
|
|---|
| 114 | if (POATEST_EX (&ev)) {
|
|---|
| 115 | POATEST_PRINT_EX ("POA_poatest__init : ", &ev);
|
|---|
| 116 | return CORBA_OBJECT_NIL;
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | /*
|
|---|
| 120 | * Implicitly activate two objects.
|
|---|
| 121 | */
|
|---|
| 122 | obj1id = PortableServer_POA_servant_to_id (child_poa, &poatest_servant, &ev);
|
|---|
| 123 | if (POATEST_EX (&ev)) {
|
|---|
| 124 | POATEST_PRINT_EX ("servant_to_id : ", &ev);
|
|---|
| 125 | return CORBA_OBJECT_NIL;
|
|---|
| 126 | }
|
|---|
| 127 | CORBA_free (obj1id);
|
|---|
| 128 |
|
|---|
| 129 | obj2id = PortableServer_POA_servant_to_id (child_poa, &poatest_servant, &ev);
|
|---|
| 130 | if (POATEST_EX (&ev)) {
|
|---|
| 131 | POATEST_PRINT_EX ("servant_to_id : ", &ev);
|
|---|
| 132 | return CORBA_OBJECT_NIL;
|
|---|
| 133 | }
|
|---|
| 134 |
|
|---|
| 135 | /*
|
|---|
| 136 | * Get reference for second activated object
|
|---|
| 137 | */
|
|---|
| 138 | poatest_obj = PortableServer_POA_id_to_reference (child_poa, obj2id, &ev);
|
|---|
| 139 | if (POATEST_EX (&ev)) {
|
|---|
| 140 | POATEST_PRINT_EX ("id_to_reference : ", &ev);
|
|---|
| 141 | return CORBA_OBJECT_NIL;
|
|---|
| 142 | }
|
|---|
| 143 |
|
|---|
| 144 | CORBA_free( obj2id );
|
|---|
| 145 |
|
|---|
| 146 | /*
|
|---|
| 147 | * Activate the POAManager. POA will now accept requests
|
|---|
| 148 | */
|
|---|
| 149 | PortableServer_POAManager_activate (rootpoa_mgr, &ev);
|
|---|
| 150 | if (POATEST_EX (&ev)) {
|
|---|
| 151 | POATEST_PRINT_EX ("POAManager_activate : ", &ev);
|
|---|
| 152 | return CORBA_OBJECT_NIL;
|
|---|
| 153 | }
|
|---|
| 154 |
|
|---|
| 155 | return poatest_obj;
|
|---|
| 156 | }
|
|---|