Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tests / Bug_2560_Regression / Stock_Factory_i.cpp
blob2b77ffc5c17ae62b26f605acd4c0822e48ef9596
2 #include "Stock_Factory_i.h"
4 #include <iostream>
6 Quoter_Stock_Factory_i::Quoter_Stock_Factory_i ()
8 PortableServer::Servant_var<Quoter_Stock_i> servant1 =
9 new Quoter_Stock_i ("RHAT", "RedHat, Inc.", 210);
10 PortableServer::Servant_var<Quoter_Stock_i> servant2 =
11 new Quoter_Stock_i ("MSFT", "Microsoft, Inc.", 91);
13 PortableServer::POA_var poa1 = servant1->_default_POA ();
14 CORBA::String_var str = servant1->symbol ();
15 PortableServer::ObjectId_var oid1 = PortableServer::string_to_ObjectId (str.in ());
16 poa1->activate_object_with_id (oid1.in(), servant1.in ());
17 CORBA::Object_var obj = poa1->id_to_reference (oid1.in ());
18 ref1_ = Quoter::Stock::_narrow (obj.in ());
20 PortableServer::POA_var poa2 = servant2->_default_POA ();
21 str = servant2->symbol ();
22 PortableServer::ObjectId_var oid2 = PortableServer::string_to_ObjectId (str.in ());
23 poa2->activate_object_with_id (oid2.in(), servant2.in ());
24 obj = poa2->id_to_reference (oid2.in ());
25 ref2_ = Quoter::Stock::_narrow (obj.in ());
28 Quoter::Stock_ptr
29 Quoter_Stock_Factory_i::get_stock (const char *symbol)
31 try {
32 if (ACE_OS::strcmp (symbol, "RHAT") == 0) {
33 return Quoter::Stock::_duplicate(ref1_.in ());
34 } else if (ACE_OS::strcmp (symbol, "MSFT") == 0) {
35 return Quoter::Stock::_duplicate(ref2_.in ());
37 } catch (const CORBA::Exception & e) {
38 std::cerr << "CORBA exception raised: " << e << std::endl;
40 std::cerr << "Invalid_Stock_Symbol: " << symbol << std::endl ;
41 throw Quoter::Invalid_Stock_Symbol ();