ACE+TAO-7_0_8
[ACE_TAO.git] / TAO / orbsvcs / ImplRepo_Service / Forwarder.h
blob23e81669c28ee8f4d366bc185c8710804eb1f626
1 // -*- C++ -*-
2 //=============================================================================
3 /**
4 * @file Forwarder.h
6 * @brief This class implements ImR's forwarding ServantLocator
8 * @author Darrell Brunsch <brunsch@cs.wustl.edu>
9 * @author Priyanka Gontla <pgontla@doc.ece.uci.edu>
11 //=============================================================================
13 #ifndef IMR_FORWARDER_H
14 #define IMR_FORWARDER_H
16 #include "tao/PortableServer/PortableServer.h"
17 #include "tao/PortableServer/ServantLocatorC.h"
18 #include "tao/DynamicInterface/Dynamic_Implementation.h"
19 #include "tao/DynamicInterface/AMH_DSI_Response_Handler.h"
20 #include "tao/Messaging/Messaging.h"
22 #if !defined (ACE_LACKS_PRAGMA_ONCE)
23 # pragma once
24 #endif /* ACE_LACKS_PRAGMA_ONCE */
26 #include "tao/LocalObject.h"
27 #include "ImR_ResponseHandler.h"
28 #include "locator_export.h"
30 class ImR_Locator_i;
32 //----------------------------------------------------------------------------
33 /**
34 * @class ImR_DSI_ReplyHandler
36 * @brief specialized reply handler for forward requests that need to send an
37 * ior
39 * Used to send either a Location_Forward exception, or some other error
40 * exception.
43 // forward declare the types used to manage AMH/DSI coupling
44 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
45 class TAO_AMH_DSI_Response_Handler;
46 typedef TAO_AMH_DSI_Response_Handler * TAO_AMH_DSI_Response_Handler_ptr;
47 class TAO_AMH_DSI_Response_Handler_var;
48 TAO_END_VERSIONED_NAMESPACE_DECL
50 class ImR_DSI_ResponseHandler : public ImR_ResponseHandler
52 public:
53 ImR_DSI_ResponseHandler (const char *key,
54 const char *server_name,
55 CORBA::ORB_ptr orb,
56 TAO_AMH_DSI_Response_Handler_ptr resp);
58 virtual ~ImR_DSI_ResponseHandler (void);
60 void send_ior (const char *pior);
61 void send_exception (CORBA::Exception *ex);
63 private:
64 void invoke_excep_i (CORBA::Exception *ex);
66 CORBA::String_var key_str_;
67 CORBA::String_var server_name_;
68 CORBA::ORB_var orb_;
69 TAO_AMH_DSI_Response_Handler_var resp_;
73 //---------------------------------------------------------------------------
74 /**
75 * @class ImR_Forwarder
77 * @brief Implementation Repository Forwarder for AMH
79 * This class provides a Default servant implementation that is used to handle
80 * arbitrary calls and forward them to the correct place. Combinds DSI with
81 * AMH to ensure the handling thread is never blocked waiting for an upcall
82 * if one is necessary
84 class Locator_Export ImR_DSI_Forwarder : public virtual TAO_DynamicImplementation
86 public:
87 ImR_DSI_Forwarder (ImR_Locator_i& imr_impl);
88 virtual ~ImR_DSI_Forwarder (void);
90 virtual void _dispatch (TAO_ServerRequest& request,
91 TAO::Portable_Server::Servant_Upcall *context);
93 void invoke (CORBA::ServerRequest_ptr request);
95 char * _primary_interface(const PortableServer::ObjectId&,
96 PortableServer::POA_ptr);
98 void invoke (CORBA::ServerRequest_ptr request,
99 TAO_AMH_DSI_Response_Handler_ptr rh);
101 void invoke_get_interface(CORBA::ServerRequest_ptr request);
103 void invoke_primary_interface(CORBA::ServerRequest_ptr request);
106 void init(CORBA::ORB_ptr orb);
108 private:
109 /// Where we find out where to forward to.
110 ImR_Locator_i& locator_;
112 /// POA reference.
113 PortableServer::Current_var poa_current_var_;
115 /// Variable to save the ORB reference passed to the constr.
116 CORBA::ORB_ptr orb_;
120 #endif /* IMR_FORWARDER_H */