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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
|
// -*- C++ -*-
//=============================================================================
/**
* @file Profile.h
*
* $Id$
*
* @author Fred Kuhns <fredk@cs.wustl.edu>
*/
//=============================================================================
#ifndef TAO_PROFILE_H
#define TAO_PROFILE_H
#include /**/ "ace/pre.h"
#include "tao/Tagged_Components.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "tao/GIOP_Message_Version.h"
#include "tao/Refcounted_ObjectKey.h"
#include "tao/Service_Callbacks.h"
class ACE_Lock;
class TAO_MProfile;
class TAO_Stub;
class TAO_Endpoint;
class TAO_ORB_Core;
namespace CORBA
{
/// Forward declaration of PolicyList
class PolicyList;
}
/**
* @class TAO_Profile
*
* @brief Defines the Profile interface
*
* An abstract base class for representing object location
* information. This is based on the CORBA IOR definitions.
*/
class TAO_Export TAO_Profile
{
public:
/// Constructor
TAO_Profile (CORBA::ULong tag,
TAO_ORB_Core *orb_core,
const TAO_GIOP_Message_Version &version);
/**
* @name Non virtual methods for the profile classes.
*/
//@{
/// The tag, each concrete class will have a specific tag value.
CORBA::ULong tag (void) const;
/// Return a pointer to this profile's version. This object
/// maintains ownership.
const TAO_GIOP_Message_Version &version (void) const;
/// Get a pointer to the TAO_ORB_Core.
TAO_ORB_Core *orb_core (void) const;
/// Increase the reference count by one on this object.
CORBA::ULong _incr_refcnt (void);
/// Decrement the object's reference count. When this count goes to
/// 0 this object will be deleted.
CORBA::ULong _decr_refcnt (void);
/// Keep a pointer to the forwarded profile
void forward_to (TAO_MProfile *mprofiles);
/// MProfile accessor
TAO_MProfile* forward_to (void);
/// Access the tagged components, notice that they they could be
/// empty (or ignored) for non-GIOP protocols (and even for GIOP-1.0)
const TAO_Tagged_Components& tagged_components (void) const;
TAO_Tagged_Components& tagged_components (void);
/// Add the given tagged component to the profile.
void add_tagged_component (const IOP::TaggedComponent &component
ACE_ENV_ARG_DECL);
/**
* Return the current addressing mode for this profile.
* In almost all cases, this is TAO_Target_Specification::Key_Addr.
*/
CORBA::Short addressing_mode (void) const;
/// @deprecated Return a reference to the Object Key.
const TAO::ObjectKey &object_key (void) const;
/// Obtain the object key, return 0 if the profile cannot be parsed.
/// The memory is owned by the caller!
TAO::ObjectKey *_key (void) const;
//@}
/**
* @name Template methods that needs to be implemented by the
* concrete classes. Some of the methods may be overridden only
* under specila circumstances.
*/
//@{
/// Encode this profile in a stream, i.e. marshal it.
virtual int encode (TAO_OutputCDR &stream) const;
/// Initialize this object using the given CDR octet string.
virtual int decode (TAO_InputCDR& cdr);
/**
* This method is used to get the IOP::TaggedProfile. The profile
* information that is received from the server side would have
* already been decoded. So this method will just make a
* IOP::TaggedProfile struct from the existing information and
* return the reference to that. This method is necessary for GIOP
* 1.2.
*/
IOP::TaggedProfile *create_tagged_profile (void);
/// This method sets the client exposed policies, i.e., the ones
/// propagated in the IOR, for this profile.
virtual void policies (CORBA::PolicyList *policy_list
ACE_ENV_ARG_DECL);
/// Accessor for the client exposed policies of this profile.
//virtual CORBA::PolicyList& policies (ACE_ENV_SINGLE_ARG_DECL);
virtual void get_policies (CORBA::PolicyList &policy_list
ACE_ENV_ARG_DECL);
/// Returns true if this profile can specify multicast endpoints.
virtual int supports_multicast (void) const;
/// Returns true if this profile supports non blocking oneways
virtual bool supports_non_blocking_oneways (void) const;
/**
* Set the addressing mode if a remote servant replies with
* an addressing mode exception. If this profile doesn't
* support a particular addressing mode, this method needs to
* be overridden signal the appropriate error.
*
* ** RACE CONDITION NOTE **
*
* Currently, getting and setting the addressing mode is not
* protected by a mutex. Theoretically, this could cause a race
* condition if one thread sends a request, then gets an exception
* from the remote servant to change the addressing mode, and then
* another thread sends a different request to the same servant
* using the wrong addressing mode. The result of this is that
* we'll get another address change exception. (Annoying, but not
* that bad.)
*
* In practice at the current time, the above theoretical case
* never happens since the target specification always uses the
* object key except for MIOP requests. Remote ORBs can't respond
* to MIOP requests even to send exceptions, so even in this case,
* the race condition can't happen.
*
* Therefore, for the time being, there is no lock to protect the
* addressing mode. Given that the addressing mode is checked in
* the critical path, this decision seems like a good thing.
*/
virtual void addressing_mode (CORBA::Short addr_mode
ACE_ENV_ARG_DECL);
/// The object key delimiter.
virtual char object_key_delimiter (void) const = 0;
/// Initialize this object using the given input string.
/// Supports URL style of object references
virtual void parse_string (const char *string
ACE_ENV_ARG_DECL);
/// Return a string representation for this profile. Client must
/// deallocate memory. Only one endpoint is included into the
/// string.
virtual char* to_string (ACE_ENV_SINGLE_ARG_DECL) = 0;
/**
* Encodes this profile's endpoints into a tagged component.
* This is done only if RTCORBA is enabled, since currently this is
* the only case when we have more than one endpoint per profile.
*/
virtual int encode_endpoints (void) = 0;
/**
* Encodes this profile's endpoints into protocol specific tagged
* components. This is used for non-RTCORBA applications that share
* endpoints on profiles. The only known implementation is IIOP, using
* TAG_ALTERNATE_IIOP_ADDRESS components.
*/
virtual int encode_alternate_endpoints (void);
/**
* Return pointer to this profile's endpoint. If the profile
* contains more than one endpoint, i.e., a list, the method returns
* the head of the list.
*/
virtual TAO_Endpoint *endpoint (void) = 0;
/// Return how many endpoints this profile contains.
virtual CORBA::ULong endpoint_count (void) const = 0;
/// Verify profile equivalance.
/**
* Two profiles are equivalent if their tag, object_key, version
* and all endpoints are the same.
*
* @see do_is_equivalent_i()
* @see is_equivalent_hook()
*
* @return @c true if this profile is equivalent to @c other_profile.
*/
CORBA::Boolean is_equivalent (const TAO_Profile* other_profile);
/// Return a hash value for this object.
virtual CORBA::ULong hash (CORBA::ULong max
ACE_ENV_ARG_DECL) = 0;
//@}
//@@ TAO_PROFILE_SPL_PUBLIC_METHODS_ADD_HOOK
protected:
/// If you have a virtual method you need a virtual dtor.
virtual ~TAO_Profile (void);
/**
* @name Protected template methods.
*/
//@{
/// Decode the protocol specific profile details.
virtual int decode_profile (TAO_InputCDR &cdr) = 0;
/// Creates an encapsulation of the ProfileBody struct in the @a cdr
virtual void create_profile_body (TAO_OutputCDR &cdr) const = 0;
/**
* Helper for <decode>. Decodes endpoints from a tagged component.
* Decode only if RTCORBA is enabled. Furthermore, we may not find
* TAO_TAG_ENDPOINTS component, e.g., if we are talking to nonRT
* version of TAO or some other ORB. This is not an error, and we
* must proceed. Return 0 on success and -1 on failure.
*/
virtual int decode_endpoints (void) = 0;
/// Protocol specific implementation of parse_string ()
virtual void parse_string_i (const char *string
ACE_ENV_ARG_DECL) = 0;
//@}
/// To be used by inherited classes
TAO_Profile (CORBA::ULong tag,
TAO_ORB_Core *orb_core,
const TAO::ObjectKey &key,
const TAO_GIOP_Message_Version &version);
/// Helper method that encodes the endpoints for RTCORBA as
/// tagged_components.
void set_tagged_components (TAO_OutputCDR &cdr);
/// Profile equivalence template method invoked on subclasses.
/**
* TAO_Profile subclasses must implement this template method so
* that they can apply their own definition of profile equivalence.
*/
virtual CORBA::Boolean do_is_equivalent (const TAO_Profile * other) = 0;
/// Allow services to apply their own definition of "equivalence."
/**
* This method differs from the @c do_is_equivalent() template
* method in that it has a default implementation that may or not be
* applicable to all TAO_Profile subclasses.
*/
virtual TAO_Service_Callbacks::Profile_Equivalence is_equivalent_hook (
const TAO_Profile * other);
CORBA::ULong hash_service_i (CORBA::ULong m);
private:
/// This object keeps ownership of this object
TAO_MProfile *forward_to_i (void);
/// Verify that the current ORB's configuration supports tagged
/// components in IORs.
void verify_orb_configuration (ACE_ENV_SINGLE_ARG_DECL);
/// Verify that the given profile supports tagged components,
/// i.e. is not a GIOP 1.0 profile.
void verify_profile_version (ACE_ENV_SINGLE_ARG_DECL);
// Profiles should not be copied!
ACE_UNIMPLEMENTED_FUNC (TAO_Profile (const TAO_Profile&))
ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_Profile&))
//@@ TAO_PROFILE_SPL_PROTECTED_METHODS_ADD_HOOK
protected:
/// IIOP version number.
TAO_GIOP_Message_Version version_;
/// The tagged components
TAO_Tagged_Components tagged_components_;
/// Flag indicating whether the lazy decoding of the client exposed
/// policies has taken place.
CORBA::Boolean are_policies_parsed_;
/// The current addressing mode.
/// This may be changed if a remote server sends back an address mode
/// exception.
CORBA::Short addressing_mode_;
/// Our tagged profile
IOP::TaggedProfile *tagged_profile_;
/// object_key associated with this profile.
TAO::Refcounted_ObjectKey *ref_object_key_;
private:
/// IOP protocol tag.
CORBA::ULong tag_;
/// Pointer to the ORB core
TAO_ORB_Core *orb_core_;
/// The TAO_MProfile which contains the profiles for the forwarded
/// object.
TAO_MProfile* forward_to_;
/// Mutex to protect reference count.
ACE_Lock *refcount_lock_;
/// Number of outstanding references to this object.
CORBA::ULong refcount_;
//@@ TAO_PROFILE_SPL_PRIVATE_DATA_ADD_HOOK
};
//@@ TAO_PROFILE_SPL_EXTERN_ADD_HOOK
// A helper class to handle the various kinds of octet sequences used
// inside the ORB.
typedef TAO_Unbounded_Sequence<CORBA::Octet> TAO_opaque;
TAO_Export CORBA::Boolean
operator<< (TAO_OutputCDR&, const TAO_opaque&);
TAO_Export CORBA::Boolean
operator>> (TAO_InputCDR&, TAO_opaque&);
/**
* @class TAO_Unknown_Profile
*
* @brief A TAO_Profile class to handle foreign profiles.
*
* The CORBA spec implies that ORBs must be prepared to save and
* pass around profiles for protocols it does not recognize. It is
* not mandatory to *use* those profiles but they shouldn't be
* dropped.
* This class stores the information required to marshal and
* demarshal an unknown profile, but simply returns an error if
* any of the TAO internal methods are invoked.
*/
class TAO_Export TAO_Unknown_Profile : public TAO_Profile
{
public:
/// Create the profile
TAO_Unknown_Profile (CORBA::ULong tag,
TAO_ORB_Core *orb_core);
// = The TAO_Profile methods look above
virtual void parse_string (const char *string
ACE_ENV_ARG_DECL);
virtual char object_key_delimiter (void) const;
virtual char* to_string (ACE_ENV_SINGLE_ARG_DECL);
virtual int decode (TAO_InputCDR& cdr);
virtual int encode (TAO_OutputCDR &stream) const;
virtual int encode_endpoints (void);
virtual const TAO::ObjectKey &object_key (void) const;
virtual TAO::ObjectKey *_key (void) const;
virtual TAO_Endpoint *endpoint (void);
virtual CORBA::ULong endpoint_count (void) const;
virtual CORBA::ULong hash (CORBA::ULong max
ACE_ENV_ARG_DECL);
virtual int decode_profile (TAO_InputCDR &cdr);
virtual int decode_endpoints (void);
protected:
virtual CORBA::Boolean do_is_equivalent (const TAO_Profile* other_profile);
virtual TAO_Service_Callbacks::Profile_Equivalence is_equivalent_hook (
const TAO_Profile* other_profile);
private:
virtual void create_profile_body (TAO_OutputCDR &encap) const;
virtual void parse_string_i (const char *string
ACE_ENV_ARG_DECL);
private:
TAO_opaque body_;
};
//@@ TAO_PROFILE_SPL_EXTERN_HOOK
#if defined (__ACE_INLINE__)
# include "Profile.i"
#endif /* __ACE_INLINE__ */
#include /**/ "ace/post.h"
#endif /* TAO_PROFILE_H */
|