| 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 9 : poatest-basic09.c
|
|---|
| 23 | * o POA with RETAIN servant retention policy, USE_DEFAULT_SERVANT
|
|---|
| 24 | * request processing policy and MULTIPLE_ID id uniqueness policy.
|
|---|
| 25 | * o activate an object.
|
|---|
| 26 | * o create a reference for an inactive object and invoke method
|
|---|
| 27 | * on this object.
|
|---|
| 28 | */
|
|---|
| 29 |
|
|---|
| 30 | #include <stdio.h>
|
|---|
| 31 | #include <stdlib.h>
|
|---|
| 32 |
|
|---|
| 33 | #include <orbit/orbit.h>
|
|---|
| 34 |
|
|---|
| 35 | #include "poatest-basic-shell.h"
|
|---|
| 36 |
|
|---|
| 37 | static void
|
|---|
| 38 | poatest_test_impl (PortableServer_Servant servant, CORBA_Environment *ev) { }
|
|---|
| 39 |
|
|---|
| 40 | PortableServer_ServantBase__epv base_epv = {
|
|---|
| 41 | NULL, /* _private */
|
|---|
| 42 | NULL, /* finalize */
|
|---|
| 43 | NULL /* default_POA */
|
|---|
| 44 | };
|
|---|
| 45 |
|
|---|
| 46 | POA_poatest__epv poatest_epv = {
|
|---|
| 47 | NULL, /* _private */
|
|---|
| 48 | poatest_test_impl /* test */
|
|---|
| 49 | };
|
|---|
| 50 |
|
|---|
| 51 | POA_poatest__vepv poatest_vepv = {
|
|---|
| 52 | &base_epv, /* _base_epv */
|
|---|
| 53 | &poatest_epv /* poatest_epv */
|
|---|
| 54 | };
|
|---|
| 55 |
|
|---|
| 56 | POA_poatest poatest_servant = {
|
|---|
| 57 | NULL, /* _private */
|
|---|
| 58 | &poatest_vepv /* vepv */
|
|---|
| 59 | };
|
|---|
| 60 |
|
|---|
| 61 | poatest
|
|---|
| 62 | poatest_run (PortableServer_POA rootpoa,
|
|---|
| 63 | PortableServer_POAManager rootpoa_mgr )
|
|---|
| 64 | {
|
|---|
| 65 | CORBA_Environment ev;
|
|---|
| 66 | poatest poatest_obj;
|
|---|
| 67 | CORBA_PolicyList *poa_policies;
|
|---|
| 68 | PortableServer_ObjectId *objid;
|
|---|
| 69 |
|
|---|
| 70 | CORBA_exception_init (&ev);
|
|---|
| 71 |
|
|---|
| 72 | /*
|
|---|
| 73 | * Create child POA with RETAIN servant retention policy, USE_DEFAULT_SERVANT
|
|---|
| 74 | * request processing policy and MULTIPLE_ID id uniqueness policy.
|
|---|
| 75 | */
|
|---|
| 76 | poa_policies = CORBA_PolicyList__alloc ();
|
|---|
| 77 | poa_policies->_maximum = 3;
|
|---|
| 78 | poa_policies->_length = 3;
|
|---|
| 79 | poa_policies->_buffer = CORBA_PolicyList_allocbuf (3);
|
|---|
| 80 | CORBA_sequence_set_release (poa_policies, CORBA_TRUE);
|
|---|
| 81 |
|
|---|
| 82 | poa_policies->_buffer[0] = (CORBA_Policy)
|
|---|
| 83 | PortableServer_POA_create_id_uniqueness_policy (
|
|---|
| 84 | rootpoa,
|
|---|
| 85 | PortableServer_MULTIPLE_ID,
|
|---|
| 86 | &ev);
|
|---|
| 87 |
|
|---|
| 88 | poa_policies->_buffer[1] = (CORBA_Policy)
|
|---|
| 89 | PortableServer_POA_create_request_processing_policy (
|
|---|
| 90 | rootpoa,
|
|---|
| 91 | PortableServer_USE_DEFAULT_SERVANT,
|
|---|
| 92 | &ev);
|
|---|
| 93 |
|
|---|
| 94 | poa_policies->_buffer[2] = (CORBA_Policy)
|
|---|
| 95 | PortableServer_POA_create_servant_retention_policy (
|
|---|
| 96 | rootpoa,
|
|---|
| 97 | PortableServer_RETAIN,
|
|---|
| 98 | &ev);
|
|---|
| 99 |
|
|---|
| 100 | child_poa = PortableServer_POA_create_POA (rootpoa,
|
|---|
| 101 | "Default Servant POA",
|
|---|
| 102 | rootpoa_mgr,
|
|---|
| 103 | poa_policies,
|
|---|
| 104 | &ev);
|
|---|
| 105 | if (POATEST_EX (&ev)) {
|
|---|
| 106 | POATEST_PRINT_EX ("create_POA : ", &ev);
|
|---|
| 107 | return CORBA_OBJECT_NIL;
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | CORBA_Policy_destroy (poa_policies->_buffer[0], &ev);
|
|---|
| 111 | CORBA_Policy_destroy (poa_policies->_buffer[1], &ev);
|
|---|
| 112 | CORBA_Policy_destroy (poa_policies->_buffer[2], &ev);
|
|---|
| 113 | CORBA_free (poa_policies);
|
|---|
| 114 |
|
|---|
| 115 | /*
|
|---|
| 116 | * Initialise the servant.
|
|---|
| 117 | */
|
|---|
| 118 | POA_poatest__init (&poatest_servant, &ev);
|
|---|
| 119 | if (POATEST_EX (&ev)) {
|
|---|
| 120 | POATEST_PRINT_EX ("POA_poatest__init : ", &ev);
|
|---|
| 121 | return CORBA_OBJECT_NIL;
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | /*
|
|---|
| 125 | * Register the default servant.
|
|---|
| 126 | */
|
|---|
| 127 | PortableServer_POA_set_servant (child_poa, &poatest_servant, &ev);
|
|---|
| 128 | if (POATEST_EX (&ev)) {
|
|---|
| 129 | POATEST_PRINT_EX ("set_servant : ", &ev);
|
|---|
| 130 | return CORBA_OBJECT_NIL;
|
|---|
| 131 | }
|
|---|
| 132 |
|
|---|
| 133 | /*
|
|---|
| 134 | * Activate an object.
|
|---|
| 135 | */
|
|---|
| 136 | objid = PortableServer_POA_activate_object (child_poa, &poatest_servant, &ev);
|
|---|
| 137 | if (POATEST_EX (&ev)) {
|
|---|
| 138 | POATEST_PRINT_EX ("activate_object : ", &ev);
|
|---|
| 139 | return CORBA_OBJECT_NIL;
|
|---|
| 140 | }
|
|---|
| 141 | CORBA_free (objid);
|
|---|
| 142 |
|
|---|
| 143 | /*
|
|---|
| 144 | * Create a reference for an inactive object.
|
|---|
| 145 | */
|
|---|
| 146 | poatest_obj = PortableServer_POA_create_reference (child_poa, "IDL:poatest:1.0", &ev);
|
|---|
| 147 | if (POATEST_EX (&ev)) {
|
|---|
| 148 | POATEST_PRINT_EX ("create_reference : ", &ev);
|
|---|
| 149 | return CORBA_OBJECT_NIL;
|
|---|
| 150 | }
|
|---|
| 151 |
|
|---|
| 152 | /*
|
|---|
| 153 | * Activate the POAManager. POA will now accept requests
|
|---|
| 154 | */
|
|---|
| 155 | PortableServer_POAManager_activate (rootpoa_mgr, &ev);
|
|---|
| 156 | if (POATEST_EX (&ev)) {
|
|---|
| 157 | POATEST_PRINT_EX ("POAManager_activate : ", &ev);
|
|---|
| 158 | return CORBA_OBJECT_NIL;
|
|---|
| 159 | }
|
|---|
| 160 |
|
|---|
| 161 | return poatest_obj;
|
|---|
| 162 | }
|
|---|