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
|
/* -*- C++ -*- */
//=============================================================================
/**
* @file Adapter.h
*
* $Id$
*
* @author Carlos O'Ryan (coryan@uci.edu)
*/
//=============================================================================
#ifndef TAO_ADAPTER_H
#define TAO_ADAPTER_H
#include "ace/pre.h"
#include "tao/corbafwd.h"
#include "tao/Exception.h"
#include "ace/Service_Object.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#if defined(_MSC_VER)
#if (_MSC_VER >= 1200)
#pragma warning(push)
#endif /* _MSC_VER >= 1200 */
#pragma warning(disable:4250)
#endif /* _MSC_VER */
class TAO_ORB_Core;
class TAO_Stub;
class TAO_MProfile;
class TAO_ServerRequest;
class TAO_Export TAO_Adapter
{
public:
virtual ~TAO_Adapter (void);
/// Initialize the Adapter
virtual void open (CORBA::Environment &) = 0;
/// The ORB is shutting down, destroy any resources attached to this
/// adapter.
virtual void close (int wait_for_completion,
CORBA::Environment &) = 0;
/// Check if the adapter can be closed in the current context, raise
/// an exception if not.
virtual void check_close (int wait_for_completion,
CORBA::Environment &) = 0;
/**
* Return the priority assigned to this adapter.
* Adapters at higher priority are used first, the first adapter
* that matches a key is used to dispatch a request.
*/
virtual int priority (void) const = 0;
/// Return the status....
virtual int dispatch (TAO_ObjectKey &key,
TAO_ServerRequest &request,
void *context, /* unused? */
CORBA::Object_out forward_to,
CORBA::Environment &ACE_TRY_ENV)
ACE_THROW_SPEC ((CORBA::SystemException)) = 0;
enum {
DS_OK,
// The operation was successfully dispatched, an exception may
// have been raised, but that is a correct execution too.
DS_FAILED,
// There was a problem in dispatching the operation.
DS_MISMATCHED_KEY,
// The key is not in the right format for this Adapter, try the
// next one.
DS_FORWARD
// Forward the request to another object reference, this decouples
// the ORB from the PortableServer::ForwardRequest exception
};
/// Return the name, i.e. the object id used to resolve it in the
/// ORB.
virtual const char *name (void) const = 0;
/**
* Rerturn the root of the Object Adapter.
* Each adapter defines its own IDL interface accessed through the
* method above.
*/
virtual CORBA::Object_ptr root (void) = 0;
/// Create a collocated object using the given profile and stub.
virtual CORBA::Object_ptr create_collocated_object (TAO_Stub *,
const TAO_MProfile &) = 0;
};
// ****************************************************************
// @@ Move to its own file
class TAO_Export TAO_Adapter_Registry
{
public:
TAO_Adapter_Registry (TAO_ORB_Core *orb_core);
/// Close the
~TAO_Adapter_Registry (void);
/**
* Close each of of the Adapters and then cleanup the Registry.
* It is possible that an Adapter will reject a close() call if it
* is invoked in an innapropriate context (think shutting down the
* POA while performing an upcall).
*/
void close (int wait_for_completion,
CORBA::Environment &ACE_TRY_ENV);
/**
* Verify if the close() call can be invoked in the current
* context for *all* adapters.
* Raise the right exception if not.
*/
void check_close (int wait_for_completion,
CORBA::Environment &ACE_TRY_ENV);
/// Insert a new adapter into the registry.
void insert (TAO_Adapter *adapter,
CORBA::Environment &ACE_TRY_ENV);
/**
* Dispatch the request to all the adapters.
* It tries the adapters ordered by priority, stopping when the
* adapter returns a status different from DS_MISMATCHED_KEY
*/
void dispatch (TAO_ObjectKey &key,
TAO_ServerRequest &request,
void *context, /* unused? */
CORBA::Object_out forward_to,
CORBA::Environment &ACE_TRY_ENV)
ACE_THROW_SPEC ((CORBA::SystemException));
/// Create a collocated object using the given profile and stub.
CORBA::Object_ptr create_collocated_object (TAO_Stub *,
const TAO_MProfile &);
/// Fetch the adapter named <name>
TAO_Adapter *find_adapter (const char *name) const;
private:
/// The ORB Core
TAO_ORB_Core *orb_core_;
/// A simple array of adapters.
size_t adapters_capacity_;
size_t adapters_count_;
TAO_Adapter **adapters_;
};
// ****************************************************************
class TAO_Export TAO_Adapter_Factory : public ACE_Service_Object
{
public:
/// Destructor
virtual ~TAO_Adapter_Factory (void);
/// Create a new adapter
virtual TAO_Adapter *create (TAO_ORB_Core *orb_core) = 0;
};
#if defined (__ACE_INLINE__)
# include "Adapter.i"
#endif /* __ACE_INLINE__ */
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
#pragma warning(pop)
#endif /* _MSC_VER */
#include "ace/post.h"
#endif /* TAO_OBJECT_ADAPTER_H */
|