blob: b40edcb49b9857bded06a0b4f67396f154a96016 (
plain)
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
|
#include "AMI_server.h"
AMI_server::AMI_server (CORBA::ORB_ptr orb, ::CCM_AMI::AMI_foo_ptr foo_receiver)
: orb_ (CORBA::ORB::_duplicate (orb)),
foo_receiver_ (::CCM_AMI::AMI_foo::_duplicate (foo_receiver))
{
}
int AMI_server::svc ()
{
try
{
CORBA::Object_var poa_object =
orb_->resolve_initial_references("RootPOA");
if (CORBA::is_nil (poa_object.in ()))
{
printf ("Server :\tERROR creating POA \n");
return 1;
}
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (poa_object.in ());
PortableServer::POAManager_var poa_manager =
root_poa->the_POAManager ();
AMI_internal_i ami_internal_i (orb_.in (), foo_receiver_);
PortableServer::ObjectId_var id =
root_poa->activate_object (&ami_internal_i);
CORBA::Object_var object = root_poa->id_to_reference (id.in ());
INTERNAL_CCM_AMI::AMI_foo_var ami_foo_var =
INTERNAL_CCM_AMI::AMI_foo::_narrow (object.in ());
CORBA::String_var ior =
orb_->object_to_string (ami_foo_var.in ());
printf ("Server :\tActivated as <%s>\n", ior.in ());
// If the ior_output_file exists, output the ior to it
FILE *output_file= ACE_OS::fopen ("server.ior", "w");
if (output_file == 0)
{
printf ("Cannot open output file for writing IOR: server.ior\n");
return 1;
}
ACE_OS::fprintf (output_file, "%s", ior.in ());
ACE_OS::fclose (output_file);
poa_manager->activate ();
orb_->run ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("Caught exception:");
return 1;
}
return 0;
}
|