Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / tests / Bug_3683_Regression / Echo_i.cpp
blobc96b220634c26204998b55411e6c8603ed460409
1 #include "Echo_i.h"
3 // Constructor.
5 Echo_i::Echo_i (void)
9 // Destructor.
11 Echo_i::~Echo_i (void)
15 // Set the ORB pointer.
17 void
18 Echo_i::orb (CORBA::ORB_ptr o)
20 this->orb_ = CORBA::ORB::_duplicate (o);
23 // Return a list of object references.
25 Echo::List *
26 Echo_i::echo_list (const char *)
28 Echo::List_var list;
31 Echo::List *tmp = 0;
32 ACE_NEW_RETURN (tmp,
33 Echo::List (3),
34 0);
35 // Pass ownership to the _var, pitty that ACE_NEW_RETURN cannot
36 // assign to T_vars directly.
37 list = tmp;
40 list->length (3);
42 // Just do something to get a list of object references.
43 list[CORBA::ULong(0)] =
44 orb_->resolve_initial_references ("NameService");
46 list[CORBA::ULong(1)] =
47 orb_->resolve_initial_references ("NameService");;
49 list[CORBA::ULong(2)] =
50 orb_->resolve_initial_references ("NameService");
52 return list._retn ();
55 // Return the mesg string from the server
57 char *
58 Echo_i::echo_string (const char *mesg)
60 // The pointer mesg was NULL, return.
61 if (mesg == 0)
62 return 0;
64 CORBA::String_var str = CORBA::string_dup (mesg);
66 // if <CORBA::string_dup> returns a 0 pointer, an exception is
67 // raised.
69 if (str.in () == 0)
70 throw CORBA::NO_MEMORY ();
72 // Got thru! now, make a deep copy of the mesg string and send it
73 // back to the client.
75 return str._retn ();
76 // The _retn is used as it allows the conversion of
77 // CORBA::String_var to char* without causing any compiler errors.
80 // Shutdown the server application.
82 void
83 Echo_i::shutdown (void)
85 ACE_DEBUG ((LM_DEBUG,
86 ACE_TEXT ("\nThe echo server is shutting down\n")));
88 // Instruct the ORB to shutdown.
89 this->orb_->shutdown ();