Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / DevGuideExamples / PortableInterceptors / IOR / ClientInterceptor.cpp
blob36ae3a4bf343f9d17c96350b8fedfa75b2828fa1
1 #include "ClientInterceptor.h"
2 #include "tao/OctetSeqC.h"
3 #include "tao/LocalObject.h"
4 #include "tao/PI/ClientRequestInfo.h"
6 #include <iostream>
8 const CORBA::ULong service_ctx_id = 0xdeed;
10 ClientInterceptor::
11 ClientInterceptor (IOP::CodecFactory_var cf)
12 : myname_ ("Client_Authentication_Interceptor")
14 std::cout << "Calling ClientInterceptor constructor." << std::endl;
16 // Set up a structure that contains information necessary to
17 // create a GIOP 1.2 CDR encapsulation Codec.
18 IOP::Encoding encoding;
19 encoding.format = IOP::ENCODING_CDR_ENCAPS;
20 encoding.major_version = 1;
21 encoding.minor_version = 2;
23 // Obtain the CDR encapsulation Codec.
24 this->codec = cf->create_codec (encoding);
27 ClientInterceptor::~ClientInterceptor ()
31 char *
32 ClientInterceptor::name ()
34 std::cout << "Calling ClientInterceptor name() method" << std::endl;
35 return CORBA::string_dup (this->myname_);
38 void
39 ClientInterceptor::destroy ()
43 void
44 ClientInterceptor::send_poll (
45 PortableInterceptor::ClientRequestInfo_ptr ri)
47 ACE_UNUSED_ARG(ri);
48 std::cout << "Calling send_poll()." << std::endl;
52 void
53 ClientInterceptor::send_request (
54 PortableInterceptor::ClientRequestInfo_ptr ri)
56 std::cout << "Calling send_request()." << std::endl;
58 const CORBA::ULong tagID = 9654;
60 try
62 IOP::TaggedComponent_var myTag = ri->get_effective_component(tagID);
63 char *tag =
64 reinterpret_cast<char*> (myTag->component_data.get_buffer());
66 std::cout << "IOR Tag is : " << tag << std::endl;
68 catch(...)
70 std::cerr << "Tagged Component not found" << std::endl;
73 IOP::ServiceContext sc;
74 sc.context_id = service_ctx_id;
76 const CORBA::Long gid = 9007;
78 std::cout << "GID: " << gid << std::endl;
80 CORBA::Any gid_as_any;
81 gid_as_any <<= gid;
83 sc.context_data = *codec->encode(gid_as_any);
85 // Add this context to the service context list.
86 ri->add_request_service_context (sc, false);
89 void
90 ClientInterceptor::receive_reply (
91 PortableInterceptor::ClientRequestInfo_ptr ri)
93 ACE_UNUSED_ARG(ri);
94 std::cout << "Calling receive_reply()." << std::endl;
97 void
98 ClientInterceptor::receive_other (
99 PortableInterceptor::ClientRequestInfo_ptr ri)
101 ACE_UNUSED_ARG(ri);
102 std::cout << "Calling receive_other()." << std::endl;
105 void
106 ClientInterceptor::receive_exception (
107 PortableInterceptor::ClientRequestInfo_ptr ri)
109 ACE_UNUSED_ARG(ri);
110 std::cout << "Calling receive_exception()." << std::endl;