summaryrefslogtreecommitdiff
path: root/TAO/tests/TransportCurrent/IIOP/IIOP_Server_Request_Interceptor.h
blob: 76f300cf32c83917e2d95d6d7eb96dce057c23ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// -*- C++ -*-

//=============================================================================
/**
 * @file IIOP_Server_Request_Interceptor.h
 *
 * $Id$
 *
 * Implementation header for the server request interceptor for the
 * IIOP_Threading test.
 *
 * @author Iliyan Jeliazkov <iliyan@ociweb.com>
 * @author Ciju John <johnc@ociweb.com>
 */
//=============================================================================

#ifndef ISERVER_REQUEST_INTERCEPTOR_H
#define ISERVER_REQUEST_INTERCEPTOR_H

#include "ace/config-all.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "tao/TransportCurrent/IIOP_Transport_Current.h"

#include "Server_Request_Interceptor.h"

namespace Test
{

  class IIOP_Server_Request_Interceptor
    : public virtual Test::Server_Request_Interceptor
    , public virtual TAO_Local_RefCounted_Object
  {
  public:

    /// Constructor.
    IIOP_Server_Request_Interceptor (const char* orbid, TEST test);

    /// Destructor.
    virtual ~IIOP_Server_Request_Interceptor ();

    /// queries the status of the test
    virtual bool self_test ();

    /**
     * @name Methods Required by the Server Request Interceptor
     * Interface
     *
     * These are methods that must be implemented since they are pure
     * virtual in the abstract base class.  They are the canonical
     * methods required for all server request interceptors.
     */
    //@{
    /// Return the name of this ServerRequestinterceptor.
    virtual char * name (void);

    /// incomming interception point
    virtual void receive_request_service_contexts (PortableInterceptor::ServerRequestInfo_ptr);

    /// outgoing interception point
    virtual void send_reply (PortableInterceptor::ServerRequestInfo_ptr ri);

    /// outgoing interception point
    virtual void send_exception (PortableInterceptor::ServerRequestInfo_ptr ri);

    /// outgoing interception point
    virtual void send_other (PortableInterceptor::ServerRequestInfo_ptr ri);
    //@}

  protected:

    /// process incomming requests context
    void inbound_process_context
    (PortableInterceptor::ServerRequestInfo_ptr ri);

    /// process outgoing requests context
    void outbound_process_context
    (PortableInterceptor::ServerRequestInfo_ptr ri);

    /// saves the incomming request info
    void push_request_info (size_t requestID);

    /// clears the outgoing request info
    void pop_request_info (size_t requestID);

    TAO::Transport::IIOP::Current_ptr resolve_iiop_transport_current (const char* orbid);

  private:

    /// transport ID dtata structure
    typedef struct EP {
      CORBA::UShort port_;
      CORBA::String_var host_;

      EP ()
        : port_(0)
        , host_ ()
      {};

      EP (CORBA::UShort port, const char* host)
        : port_(port)
        , host_ (host)
      {};

      bool operator== (const struct EP &ep) const
      {
        return (this->port_ == ep.port_) &&
          (strcmp (this->host_.in (), ep.host_.in ()) == 0);
      };
      bool operator!= (const struct EP &ep) const
      {
        return !(this->operator== (ep));
      };

    } EndPoint;

  private:

    /// IIOPTraits test status
    bool iiop_test_successful_;

    /// Multi-threaded test status
    bool mult_thr_test_successful_;

    /// Endpoints hash table
    EndPoint endPoints_[1001];
  };

} // namespace Test

#endif  /* ISERVER_REQUEST_INTERCEPTOR_H */