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
|
// -*- C++ -*-
//=============================================================================
/**
* @file Container_Impl.h
*
* $Id$
*
* This file contains implementation for the servant of
* Components::Deployment::Container interface.
*
* @author Nanbor Wang <nanbor@cs.wustl.edu>
* @author Gan Deng <gan.deng@vanderbilt.edu>
*/
//=============================================================================
#ifndef CIAO_CONTAINER_IMPL_H
#define CIAO_CONTAINER_IMPL_H
#include /**/ "ace/pre.h"
#include "CIAO_NodeApplication_export.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "ciao/Deployment_ContainerS.h"
#include "ciao/Deployment_NodeApplicationC.h"
#include "ciao/Container_Base.h"
#include "ace/SString.h"
#include "ciao/Server_init.h" // write_IOR function & NameUtility
#include "ciao/CIAO_common.h" // CIAO::debug_level
namespace CIAO
{
/**
* @class Container_Impl
*
* @brief Servant implementation for the interface Deployment::Container
*
* This class implements the Deployment::Container
* interface which is not defined by the CCM DnC specification.
* As the interface implies, this is actually part of the deployment
* interface and is used to manage the lifecycle of the installed
* components and homes.
*/
class NODEAPPLICATION_Export Container_Impl
: public virtual POA_Deployment::Container
{
public:
/// Constructor
Container_Impl (CORBA::ORB_ptr o,
PortableServer::POA_ptr p,
::Deployment::NodeApplication_ptr server,
const Static_Config_EntryPoints_Maps* static_entrypts_maps =0);
/// Destructor
virtual ~Container_Impl (void);
/*-------------------------------------------------------------*/
/*-------------------- IDL operations (idl) ------------------*/
/// Initialize the container.
virtual CORBA::Long init (const CORBA::PolicyList *policies)
ACE_THROW_SPEC ((CORBA::SystemException));
/// Install all homes and components
Deployment::ComponentInfos *
install (const ::Deployment::ContainerImplementationInfo & container_impl_info)
ACE_THROW_SPEC ((CORBA::SystemException,
Deployment::UnknownImplId,
Deployment::ImplEntryPointNotFound,
Deployment::InstallationFailure,
Components::InvalidConfiguration));
/// Remove all homes and components
virtual void
remove ()
ACE_THROW_SPEC ((CORBA::SystemException,
Components::RemoveFailure));
/// Deployment::Container interface defined attributes/operations.
virtual ::Deployment::Properties *
properties ()
ACE_THROW_SPEC ((CORBA::SystemException));
virtual ::Deployment::NodeApplication_ptr
get_node_application ()
ACE_THROW_SPEC ((CORBA::SystemException));
/*-------------------------------------------------------------*/
/*------------------- C++ help methods (c++) -----------------*/
/// Get the containing POA. This operation does *not*
/// increase the reference count of the POA.
virtual PortableServer::POA_ptr _default_POA (void);
// Install the home of this particular component
virtual ::Components::CCMHome_ptr
install_home (const ::Deployment::ComponentImplementationInfo & impl_info)
ACE_THROW_SPEC ((CORBA::SystemException,
Deployment::UnknownImplId,
Deployment::ImplEntryPointNotFound,
Deployment::InstallationFailure,
Components::InvalidConfiguration));
/**
* @@Note: I don't know how to remove a home right now.
* I assume that user will only call remove instead.
* This is true at least for DnC run time.
*
* Right now, in this implementation I assumpe that there will be
* same number of homes as the components even if the components
* are of the same type. I don't think that we have the modeling
* side support of this either. So bear me if you think I avoid
* the real thinking for easiness.
*/
// Remove the home of this particular component
virtual void
remove_home (const char * comp_ins_name)
ACE_THROW_SPEC ((CORBA::SystemException,
Components::RemoveFailure));
bool
register_with_ns (const char * obj_name,
CORBA::ORB_ptr orb,
Components::CCMObject_ptr obj);
bool
unregister_with_ns (const char * obj_name,
CORBA::ORB_ptr orb);
// ------------------- CIAO Internal Operations ------------------------
// These below two are helper methods to clean up components
// should only be called when we are sure that there is no
// active connection on this component.
virtual void remove_components ()
ACE_THROW_SPEC ((CORBA::SystemException,
Components::RemoveFailure));
virtual void remove_component (const char * comp_ins_name)
ACE_THROW_SPEC ((CORBA::SystemException,
Components::RemoveFailure));
/// Set the cached object reference.
void set_objref (Deployment::Container_ptr o);
/// Get the cached object reference. This operation will invoke
/// _this if there's no cached reference available. Notice that
/// this method does *NOT* increase the reference count of the
/// cached reference.
/// @@ Gan, caller should own memory. In this case you shoudl
/// return a duplicate OR add a const to the operation
/// signature. This is simply bad programming.
Deployment::Container_ptr get_objref ();
protected:
/// Keep a pointer to the managing ORB serving this servant.
CORBA::ORB_var orb_;
/// Keep a pointer to the managing POA.
PortableServer::POA_var poa_;
/// Internal container implementation.
// @@ Gan/Jai, heard of auto_ptr <>?
CIAO::Container *container_;
/// Cached ConfigValues.
Deployment::Properties properties_;
/// Cached Container reference (of ourselves.)
Deployment::Container_var objref_;
/// Cached NodeApplication.
Deployment::NodeApplication_var nodeapp_;
/// To store all created CCMHome object
typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
Components::CCMHome_ptr,
ACE_Hash<ACE_CString>,
ACE_Equal_To<ACE_CString>,
ACE_Null_Mutex> CCMHome_Map;
typedef CCMHome_Map::iterator Home_Iterator;
CCMHome_Map home_map_;
/// To store all created Component object.
// @@Gan, see how this caching is duplicated..
typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
Components::CCMObject_var,
ACE_Hash<ACE_CString>,
ACE_Equal_To<ACE_CString>,
ACE_Null_Mutex> CCMComponent_Map;
typedef CCMComponent_Map::iterator Component_Iterator;
CCMComponent_Map component_map_;
typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
ACE_CString,
ACE_Hash<ACE_CString>,
ACE_Equal_To<ACE_CString>,
ACE_Null_Mutex> CCMNaming_Map;
CCMNaming_Map naming_map_;
const Static_Config_EntryPoints_Maps* static_entrypts_maps_;
};
}
#if defined (__ACE_INLINE__)
# include "Container_Impl.inl"
#endif /* __ACE_INLINE__ */
#include /**/ "ace/post.h"
#endif /* CIAO_CONTAINER_IMPL_H */
|