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

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

Orbit2 modified for use with NOM

File size: 2.7 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 3 : poatest-basic03.c
23 * o Root POA.
24 * o implicitly activated object with servant_to_id.
25 */
26
27#include <stdio.h>
28#include <stdlib.h>
29
30#include <orbit/orbit.h>
31
32#include "poatest-basic-shell.h"
33
34static void
35poatest_test_impl (PortableServer_Servant servant, CORBA_Environment *ev) { }
36
37PortableServer_ServantBase__epv base_epv = {
38 NULL, /* _private */
39 NULL, /* finalize */
40 NULL /* default_POA */
41};
42
43POA_poatest__epv poatest_epv = {
44 NULL, /* _private */
45 poatest_test_impl /* test */
46};
47
48POA_poatest__vepv poatest_vepv = {
49 &base_epv, /* _base_epv */
50 &poatest_epv /* poatest_epv */
51};
52
53POA_poatest poatest_servant = {
54 NULL, /* _private */
55 &poatest_vepv /* vepv */
56};
57
58poatest
59poatest_run (PortableServer_POA rootpoa,
60 PortableServer_POAManager rootpoa_mgr)
61{
62 CORBA_Environment ev;
63 poatest poatest_obj;
64 PortableServer_ObjectId *objid;
65
66 CORBA_exception_init (&ev);
67
68 /*
69 * Initialise the servant.
70 */
71 POA_poatest__init (&poatest_servant, &ev);
72 if (POATEST_EX (&ev)) {
73 POATEST_PRINT_EX ("POA_poatest__init : ", &ev);
74 return CORBA_OBJECT_NIL;
75 }
76
77 /*
78 * Imlicitly activate the Object.
79 * See sections 11.2.7 and 11.3.8.20.
80 */
81 objid = PortableServer_POA_servant_to_id (rootpoa, &poatest_servant, &ev);
82 if (POATEST_EX (&ev)) {
83 POATEST_PRINT_EX ("servant_to_id : ", &ev);
84 return CORBA_OBJECT_NIL;
85 }
86
87 /*
88 * Get reference for activated object
89 */
90 poatest_obj = PortableServer_POA_id_to_reference (rootpoa, objid, &ev);
91 if (POATEST_EX (&ev)) {
92 POATEST_PRINT_EX ("id_to_reference : ", &ev);
93 return CORBA_OBJECT_NIL;
94 }
95
96 CORBA_free ( objid );
97
98 /*
99 * Activate the POAManager. POA will now accept requests
100 */
101 PortableServer_POAManager_activate (rootpoa_mgr, &ev);
102 if (POATEST_EX (&ev)) {
103 POATEST_PRINT_EX ("POAManager_activate : ", &ev);
104 return CORBA_OBJECT_NIL;
105 }
106
107 return poatest_obj;
108}
Note: See TracBrowser for help on using the repository browser.