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

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

Orbit2 modified for use with NOM

File size: 4.0 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 7 : poatest-basic07.c
23 * o POA with MULTIPLE_ID Object Id Uniqueness policy and
24 * IMPLICIT_ACTIVATION Implicit Activation policy.
25 * o implicitly activate two objects with the same servant
26 * using servant_to_reference.
27 * o same as Test 2 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
38static void
39poatest_test_impl (PortableServer_Servant servant, CORBA_Environment *ev) { }
40
41PortableServer_ServantBase__epv base_epv = {
42 NULL, /* _private */
43 NULL, /* finalize */
44 NULL /* default_POA */
45};
46
47POA_poatest__epv poatest_epv = {
48 NULL, /* _private */
49 poatest_test_impl /* test */
50};
51
52POA_poatest__vepv poatest_vepv = {
53 &base_epv, /* _base_epv */
54 &poatest_epv /* poatest_epv */
55};
56
57POA_poatest poatest_servant = {
58 NULL, /* _private */
59 &poatest_vepv /* vepv */
60};
61
62poatest
63poatest_run (PortableServer_POA rootpoa,
64 PortableServer_POAManager rootpoa_mgr)
65{
66 CORBA_Environment ev;
67 poatest poatest_obj1, poatest_obj2;
68 CORBA_PolicyList *poa_policies;
69
70 CORBA_exception_init( &ev );
71
72 /*
73 * Create child POA with MULTIPLE_ID Object Id Uniqueness policy and
74 * IMPLICIT_ACTIVATION Implicit Activation policy.
75 */
76 poa_policies = CORBA_PolicyList__alloc ();
77 poa_policies->_maximum = 2;
78 poa_policies->_length = 2;
79 poa_policies->_buffer = CORBA_PolicyList_allocbuf (2);
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_implicit_activation_policy (
90 rootpoa,
91 PortableServer_IMPLICIT_ACTIVATION,
92 &ev);
93
94 child_poa = PortableServer_POA_create_POA (rootpoa,
95 "Multiple Id POA",
96 rootpoa_mgr,
97 poa_policies,
98 &ev);
99 if (POATEST_EX (&ev)) {
100 POATEST_PRINT_EX ("create_POA : ", &ev);
101 return CORBA_OBJECT_NIL;
102 }
103
104 CORBA_Policy_destroy (poa_policies->_buffer[0], &ev);
105 CORBA_Policy_destroy (poa_policies->_buffer[1], &ev);
106 CORBA_free (poa_policies);
107
108 /*
109 * Initialise the servant.
110 */
111 POA_poatest__init (&poatest_servant, &ev);
112 if (POATEST_EX (&ev)) {
113 POATEST_PRINT_EX ("POA_poatest__init : ", &ev);
114 return CORBA_OBJECT_NIL;
115 }
116
117 /*
118 * Implicitly activate two objects.
119 */
120 poatest_obj1 = PortableServer_POA_servant_to_reference (child_poa,
121 &poatest_servant,
122 &ev);
123 if (POATEST_EX (&ev)) {
124 POATEST_PRINT_EX ("servant_to_reference : ", &ev);
125 return CORBA_OBJECT_NIL;
126 }
127 CORBA_Object_release (poatest_obj1, &ev);
128
129 poatest_obj2 = PortableServer_POA_servant_to_reference (child_poa,
130 &poatest_servant,
131 &ev);
132 if (POATEST_EX (&ev)) {
133 POATEST_PRINT_EX ("servant_to_reference : ", &ev);
134 return CORBA_OBJECT_NIL;
135 }
136
137 /*
138 * Activate the POAManager. POA will now accept requests
139 */
140 PortableServer_POAManager_activate (rootpoa_mgr, &ev);
141 if (POATEST_EX (&ev)) {
142 POATEST_PRINT_EX ("POAManager_activate : ", &ev);
143 return CORBA_OBJECT_NIL;
144 }
145
146 return poatest_obj2;
147}
Note: See TracBrowser for help on using the repository browser.