source: trunk/ORBit2-2.14.0/test/poa/poatest-basic10.c

Last change on this file was 92, checked in by cinc, 19 years ago

Orbit2 modified for use with NOM

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