1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
// ============================================================================
//
// = LIBRARY
// CORBA Tao marshal benchmark
//
// = FILENAME
// tao_marshal_server.cpp
//
// = AUTHOR
// Aniruddha Gokhale
//
// ============================================================================
#include "tao_marshal_server.h"
#include <iostream.h>
#include <fstream.h>
#if !defined (__ACE_INLINE__)
#include "tao_marshal_server.i"
#endif /* __ACE_INLINE__ */
int
Tao_Marshal_Server_Proxy::run (CORBA_Marshal_Proxy::OPTIONS &options,
CORBA_Marshal_Proxy::RESULTS &results)
{
char **argv;
int argc;
CORBA_Environment env;
CORBA_String str; // for the IOR string
fstream iorfile; // persistent storage for IOR
// get the argument list to be passed on to the ORB_init method
argv = options.orb_init_args (argc);
// get the orb. Pass any ORB_init arguments
this->orb_ = CORBA_ORB_init (argc, (char *const *)argv, "IOR", env);
if (this->orb_ == 0)
{
ACE_DEBUG ((LM_DEBUG, "ORB_init failed\n"));
return -1;
}
// get the argument list to be passed on to the BOA_init method
argv = options.boa_init_args (argc);
char *foo [] = {"-OAhost","mambo"}; argc = 2;
// get the orb. Pass any ORB_init arguments
this->boa_ = this->orb_->BOA_init (argc, foo, "ROA");//(argc, (char *const *)argv);
if (this->boa_ == 0)
{
ACE_DEBUG ((LM_DEBUG, "ORB_init failed\n"));
return -1;
}
// tell the "results" object what file it must store the results into
results.filename (options.filename ());
// use SII or DII accordingly
switch (options.policy ())
{
case CORBA_Marshal_Options::STATIC : // use SSI
this->ssi_ = new Marshal_SSI_Impl (options.object_name ());
// register with the BOA
// this->boa_->obj_is_ready (this->ssi_);
// get a stringified representation of the object reference created above
str = this->orb_->object_to_string (this->dsi_, env);
if (env.exception() != 0)
{
// print_exception (env.exception(), "object_to_string", stdout);
return 1;
}
// save the IOR in persistent storage so that clients can read this and obtain
// object references. We need to do this since we do not yet have some kind
// of a naming service that will allow clients to "bind" to desired objects
iorfile.open ("./ior.txt", ios::out);
iorfile << ((char *)str) << endl;
iorfile.close ();
break;
case CORBA_Marshal_Options::DYNAMIC : // use DSI
this->dsi_ = new Marshal_DSI_Impl (this->orb_, ACE_OS::strdup (options.object_name ()));
// register with the BOA
// this->boa_->obj_is_ready (this->dsi_);
// get a stringified representation of the object reference created above
str = this->orb_->object_to_string (this->dsi_, env);
if (env.exception() != 0)
{
ACE_DEBUG ((LM_ERROR, "cannot get IOR from DSI object" ));
// print_exception (env.exception(), "object_to_string", stdout);
return 1;
}
// save the IOR in persistent storage so that clients can read this and obtain
// object references. We need to do this since we do not yet have some kind
// of a naming service that will allow clients to "bind" to desired objects
iorfile.open ("./ior.txt", ios::out);
iorfile << ((char *)str) << endl;
iorfile.close ();
break;
default:
ACE_DEBUG ((LM_DEBUG, "bad policy\n"));
return -1;
}
ACE_Reactor::run_event_loop (); // should be replaced by impl_is_ready
return 0;
}
|