summaryrefslogtreecommitdiff
path: root/TAO/tao/DynamicInterface/Dynamic_Adapter_Impl.cpp
blob: bca16588048d4cc191ba713d3145eb017046343e (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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
// $Id$

#include "Dynamic_Adapter_Impl.h"

ACE_RCSID(DynamicInterface, TAO_Dynamic_Adapter_Impl, "$Id$")

#if (TAO_HAS_MINIMUM_CORBA == 0)

#include "Request.h"
#include "Server_Request.h"
#include "tao/Invocation.h"

TAO_Dynamic_Adapter_Impl::TAO_Dynamic_Adapter_Impl (void)
{
}

TAO_Dynamic_Adapter_Impl::~TAO_Dynamic_Adapter_Impl (void)
{
}

void 
TAO_Dynamic_Adapter_Impl::create_request (
    CORBA::Object_ptr obj,
    CORBA::ORB_ptr orb,
    const char *operation,
    CORBA::NVList_ptr arg_list,
    CORBA::NamedValue_ptr result,
    CORBA::ExceptionList_ptr exceptions,
    CORBA::Request_ptr &request,
    CORBA::Flags req_flags,
    CORBA_Environment &ACE_TRY_ENV
  )
{
  ACE_NEW_THROW_EX (request,
                    CORBA::Request (obj,
                                    orb,
                                    operation,
                                    arg_list,
                                    result,
                                    req_flags,
                                    exceptions,
                                    ACE_TRY_ENV),
                    CORBA::NO_MEMORY (
                        CORBA_SystemException::_tao_minor_code (
                            TAO_DEFAULT_MINOR_CODE,
                            ENOMEM
                          ),
                        CORBA::COMPLETED_MAYBE
                      ));
}

CORBA::Request_ptr 
TAO_Dynamic_Adapter_Impl::request (CORBA::Object_ptr obj,
                                   CORBA::ORB_ptr orb,
                                   const char *operation,
                                   CORBA::Environment &ACE_TRY_ENV)
{
  CORBA::Request_ptr req = CORBA::Request::_nil ();
  ACE_NEW_THROW_EX (req,
                    CORBA::Request (obj,
                                    orb,
                                    operation,
                                    ACE_TRY_ENV),
                    CORBA::NO_MEMORY (
                        CORBA_SystemException::_tao_minor_code (
                            TAO_DEFAULT_MINOR_CODE,
                            ENOMEM
                          ),
                        CORBA::COMPLETED_MAYBE
                      ));
  ACE_CHECK_RETURN (CORBA::Request::_nil ());

  return req;
}

CORBA::Boolean
TAO_Dynamic_Adapter_Impl::context_is_nil (CORBA::Context_ptr ctx)
{
  return ctx == 0;
}

void
TAO_Dynamic_Adapter_Impl::context_release (CORBA::Context_ptr ctx)
{
  if (ctx != 0)
    {
      ctx->_decr_refcnt ();
    }
}

CORBA::Boolean
TAO_Dynamic_Adapter_Impl::request_is_nil (CORBA::Request_ptr req)
{
  return req == 0;
}

void
TAO_Dynamic_Adapter_Impl::request_release (CORBA::Request_ptr req)
{
  if (req != 0)
    {
      req->_decr_refcnt ();
    }
}

CORBA::Boolean
TAO_Dynamic_Adapter_Impl::server_request_is_nil (CORBA::ServerRequest_ptr req)
{
  return req == 0;
}

void
TAO_Dynamic_Adapter_Impl::server_request_release (CORBA::ServerRequest_ptr req)
{
  if (req != 0)
    {
      req->_decr_refcnt ();
    }
}

void 
TAO_Dynamic_Adapter_Impl::create_exception_list (
    CORBA::ExceptionList_ptr &list,
    CORBA_Environment &ACE_TRY_ENV
  )
{
  ACE_NEW_THROW_EX (list, 
                    CORBA::ExceptionList,
                    CORBA::NO_MEMORY (
                        CORBA_SystemException::_tao_minor_code (
                            TAO_DEFAULT_MINOR_CODE,
                            ENOMEM
                          ),
                        CORBA::COMPLETED_NO
                      ));
}

CORBA::Exception *
TAO_Dynamic_Adapter_Impl::decode_user_exception (
    CORBA::ExceptionList_ptr exceptions,
    TAO_GIOP_Twoway_Invocation *invocation,
    const char *buf,
    CORBA::Environment &ACE_TRY_ENV
  )
{
  for (CORBA::ULong i = 0;
       exceptions != 0 && i < exceptions->count ();
       i++)
    {
      CORBA::TypeCode_ptr tcp = exceptions->item (i, 
                                                  ACE_TRY_ENV);
      ACE_CHECK_RETURN (0);

      const char *xid = tcp->id (ACE_TRY_ENV);
      ACE_CHECK_RETURN (0);

      if (ACE_OS::strcmp (buf, xid) != 0)
        {
          continue;
        }

      const ACE_Message_Block *cdr = invocation->inp_stream ().start ();

      CORBA_Any any (tcp, 
                     0,
                     invocation->inp_stream ().byte_order (),
                     cdr);

      CORBA_Exception *exception = 0;

      ACE_NEW_RETURN (exception,
                      CORBA_UnknownUserException (any),
                      0);

      return exception;
    }

  return 0;
}

int
TAO_Dynamic_Adapter_Impl::Initializer (void)
{
  ACE_Service_Config::static_svcs ()->insert (
      &ace_svc_desc_TAO_Dynamic_Adapter_Impl
    );
  
  return 0;
}

ACE_STATIC_SVC_DEFINE (
    TAO_Dynamic_Adapter_Impl,
    ACE_TEXT ("Dynamic_Adapter"),
    ACE_SVC_OBJ_T,
    &ACE_SVC_NAME (TAO_Dynamic_Adapter_Impl),
    ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
    0
  )

ACE_FACTORY_DEFINE (TAO_DynamicInterface, TAO_Dynamic_Adapter_Impl)

#endif /* TAO_HAS_MINIMUM_CORBA */