Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tao / IORTable / Async_Table_Adapter.cpp
blob7fb88ec03a52bb26ae1947ac1117a44cf1b01d73
1 /**
2 * @file Async_Table_Adapter.cpp
4 * @author Phil Mesnier <mesnier_p@ociweb.com>
5 */
7 #include "tao/IORTable/Async_Table_Adapter.h"
8 #include "tao/IORTable/Async_IOR_Table_Impl.h"
9 #include "tao/IORTable/Locate_ResponseHandler.h"
11 #include "tao/ORB_Core.h"
12 #include "tao/Server_Strategy_Factory.h"
13 #include "tao/Object.h"
14 #include "tao/Stub.h"
15 #include "tao/ORB.h"
16 #include "tao/Profile.h"
17 #include "tao/TAO_Server_Request.h"
19 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
21 TAO_Async_Table_Adapter::TAO_Async_Table_Adapter (TAO_ORB_Core &orb_core)
22 : TAO_Table_Adapter (orb_core)
26 TAO_Async_Table_Adapter::~TAO_Async_Table_Adapter ()
30 void
31 TAO_Async_Table_Adapter::open ()
33 ACE_GUARD (ACE_Lock, ace_mon, *this->lock_);
34 TAO_Async_IOR_Table_Impl *impl = 0;
35 ACE_NEW_THROW_EX (impl,
36 TAO_Async_IOR_Table_Impl (),
37 CORBA::NO_MEMORY ());
39 this->root_ = impl;
40 this->closed_ = false;
43 int
44 TAO_Async_Table_Adapter::dispatch (TAO::ObjectKey &key,
45 TAO_ServerRequest &request,
46 CORBA::Object_out forward_to)
48 TAO_IOR_Table_Impl_var rootref;
50 ACE_GUARD_RETURN (ACE_Lock,
51 ace_mon,
52 *this->lock_,
53 TAO_Adapter::DS_MISMATCHED_KEY);
54 if (this->closed_)
56 return TAO_Adapter::DS_MISMATCHED_KEY;
58 rootref = this->root_;
61 if (this->root_->async_available ())
63 // construct a callback handler
64 TAO_AMH_Locate_ResponseHandler_ptr rhp;
65 ACE_NEW_RETURN (rhp,
66 TAO_AMH_Locate_ResponseHandler (request),
67 DS_MISMATCHED_KEY);
68 TAO_AMH_Locate_ResponseHandler_var rh (rhp);
69 this->find_object (rh, key);
70 return 0;
73 if (this->TAO_Table_Adapter::find_object (key, forward_to))
75 request.forward_location (forward_to);
76 return TAO_Adapter::DS_FORWARD;
78 else
79 return TAO_Adapter::DS_MISMATCHED_KEY;
82 void
83 TAO_Async_Table_Adapter::find_object (IORTable::Locate_ResponseHandler rh,
84 TAO::ObjectKey &key)
86 CORBA::String_var object_key;
87 TAO::ObjectKey::encode_sequence_to_string (object_key.out (), key);
88 TAO_Async_IOR_Table_Impl * aroot =
89 dynamic_cast<TAO_Async_IOR_Table_Impl *>(this->root_.ptr());
90 if (aroot != 0)
92 aroot->async_find (rh, object_key.in ());
94 else
96 rh->raise_excep (IORTable::NotFound ());
100 // ****************************************************************
102 TAO_Async_Table_Adapter_Factory::TAO_Async_Table_Adapter_Factory ()
106 TAO_Adapter*
107 TAO_Async_Table_Adapter_Factory::create (TAO_ORB_Core *oc)
109 TAO_Adapter* ptr = 0;
110 ACE_NEW_RETURN (ptr,
111 TAO_Async_Table_Adapter (*oc),
113 return ptr;
116 TAO_END_VERSIONED_NAMESPACE_DECL
118 ACE_FACTORY_DEFINE (TAO_Async_IORTable, TAO_Async_Table_Adapter_Factory)
119 ACE_STATIC_SVC_DEFINE (TAO_Async_Table_Adapter_Factory,
120 ACE_TEXT ("TAO_Async_IORTable"),
121 ACE_SVC_OBJ_T,
122 &ACE_SVC_NAME (TAO_Async_Table_Adapter_Factory),
123 ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,