#include <SubjectManagerImpl.h>
Collaboration diagram for tweek::SubjectManagerImpl:

Public Methods | |
| virtual | ~SubjectManagerImpl () |
| void | registerSubject (SubjectImpl *subject, const char *name) |
| Registers the given SubjectImpl object (a CORBA servant) with this Subject Manager instance. More... | |
| vpr::ReturnStatus | unregisterSubject (const char *name) |
| Attempts to "unregister" the named subject and deactivate it within the local ORB. More... | |
| virtual Subject_ptr | getSubject (const char *name) |
| Returns the named Tweek Subject reference to the caller if the Subject is registered. More... | |
| virtual tweek::SubjectManager::SubjectList * | getAllSubjects () |
| Returns a sequence of all the registered Tweek Subjects packaged in the structure RegisteredSubject. More... | |
| virtual tweek::SubjectManager::SubjectManagerInfoList * | getInfo () |
| Returns a sequence of key/value pairs that provide site-specific information about a given Subject Manager servant. More... | |
| virtual char * | getName () |
| Returns the name of this Subject Manager reference as it is registered with the CORBA Naming Service. More... | |
| void | setName (const std::string &name) |
| void | setApplicationName (const std::string &appName) |
| Assigns the given value for the username informational item. More... | |
| void | setUserName (const std::string &userName) |
| Assigns the given value for the username informational item. More... | |
| void | addInfoItem (const std::string &key, const std::string &value) |
| Returns a sequence of key/value pairs that provide site-specific information about a given Subject Manager servant. More... | |
| const vpr::GUID & | getGUID () const |
Protected Methods | |
| SubjectManagerImpl (const CorbaManager &corba_mgr) | |
| Default constructor. More... | |
| SubjectManagerImpl (const SubjectManagerImpl &sm) | |
| void | operator= (const SubjectManagerImpl &sm) |
| void | registerSubject (Subject_ptr subject, const std::string &name) |
| void | initInfoMap () |
| Intializes the encapsulated map of key/value pairs for this Subject Manager instance. More... | |
Friends | |
| class | tweek::CorbaManager |
C++ implementations of CORBA interfaces (specified with IDL) are registeered with a Subject Manager. This process activates the object (a CORBA servant) within the local ORB. Once registered, remote code can request references to the servant through the Subject Manager. Most details of CORBA reference management are hidden by this class.
Definition at line 67 of file SubjectManagerImpl.h.
|
|
Definition at line 57 of file SubjectManagerImpl.cpp. References tweekDBG_CORBA.
00058 {
00059 subject_map_t::iterator i;
00060 std::string name_str;
00061
00062 for ( i = mSubjects.begin(); i != mSubjects.end(); ++i )
00063 {
00064 vprDEBUG(tweekDBG_CORBA, vprDBG_CRITICAL_LVL)
00065 << "Deactivating subject named '" << (*i).first
00066 << "' in tweek::SubjectManagerImpl destructor\n" << vprDEBUG_FLUSH;
00067
00068 // Deactivate the object in the POA.
00069 name_str = (*i).first;
00070 mCorbaMgr.getChildPOA()->deactivate_object(mSubjectIds[name_str]);
00071 Subject_ptr subj = mSubjects[name_str];
00072 CORBA::release(subj);
00073 }
00074 }
|
|
|
Default constructor. It is protected because only instances of tweek::CorbaManager may create objects of this type. Definition at line 190 of file SubjectManagerImpl.h.
00191 : mCorbaMgr(corba_mgr), mGUID(), mName("")
00192 {
00193 mGUID.generate();
00194 initInfoMap();
00195 }
|
|
|
Definition at line 272 of file SubjectManagerImpl.cpp.
00273 :
00274 #ifdef OMNIORB_VER
00275 omniServant(sm)
00276 , tweek::_impl_SubjectManager(sm)
00277 ,
00278 #endif
00279 PortableServer::ServantBase(sm)
00280 , POA_tweek::SubjectManager(sm)
00281 , PortableServer::RefCountServantBase(sm)
00282 , mCorbaMgr(sm.mCorbaMgr)
00283 , mInfoMap(sm.mInfoMap)
00284 {
00285 /* Do nothing. */ ;
00286 }
|
|
||||||||||||
|
Registers the given SubjectImpl object (a CORBA servant) with this Subject Manager instance. This also performs the necessary steps to activate the servant with CORBA.
Definition at line 76 of file SubjectManagerImpl.cpp. Referenced by tweek::CorbaManager::createSubjectManager.
00078 {
00079 std::string name_str(name);
00080
00081 mSubjectIdsMutex.acquire();
00082 {
00083 // We have to register servant with POA first.
00084 mSubjectIds[name_str] =
00085 mCorbaMgr.getChildPOA()->activate_object(subjectServant);
00086 }
00087 mSubjectIdsMutex.release();
00088
00089 registerSubject(subjectServant->_this(), name_str);
00090 }
|
|
|
Attempts to "unregister" the named subject and deactivate it within the local ORB.
Definition at line 92 of file SubjectManagerImpl.cpp. Referenced by tweek::CorbaManager::shutdown.
00093 {
00094 vpr::ReturnStatus status;
00095 std::string name_str(name);
00096 vpr::Guard<vpr::Mutex> guard(mSubjectsMutex);
00097
00098 if ( mSubjects.count(name_str) > 0 )
00099 {
00100 mSubjectIdsMutex.acquire();
00101 {
00102 // Deactivate the object in the POA.
00103 mCorbaMgr.getChildPOA()->deactivate_object(mSubjectIds[name_str]);
00104 }
00105 mSubjectIdsMutex.release();
00106
00107 Subject_ptr subj = mSubjects[name_str];
00108 CORBA::release(subj);
00109 mSubjects.erase(name_str);
00110 }
00111 else
00112 {
00113 vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL)
00114 << clrOutBOLD(clrRED, "ERROR:")
00115 << " No subject registered under the name '" << name_str
00116 << "'\n" << vprDEBUG_FLUSH;
00117 status.setCode(vpr::ReturnStatus::Fail);
00118 }
00119
00120 return status;
00121 }
|
|
|
Returns the named Tweek Subject reference to the caller if the Subject is registered. If not, a reference equal to CORBA::nil() is returned. Definition at line 134 of file SubjectManagerImpl.cpp. References tweekDBG_CORBA.
00135 {
00136 vprDEBUG_OutputGuard(tweekDBG_CORBA, vprDBG_STATE_LVL,
00137 "tweek::SubjectManagerImpl::getSubject() entered\n",
00138 "tweek::SubjectManagerImpl::getSubject() done\n");
00139
00140 Subject_ptr subject;
00141 std::string name_str(name);
00142 vpr::Guard<vpr::Mutex> guard(mSubjectsMutex);
00143
00144 subject_map_t::iterator i;
00145
00146 i = mSubjects.find(name_str);
00147
00148 if ( i != mSubjects.end() )
00149 {
00150 subject = Subject::_duplicate((*i).second);
00151 vprDEBUG(tweekDBG_CORBA, vprDBG_STATE_LVL)
00152 << "Returning subject named '" << name << "'\n" << vprDEBUG_FLUSH;
00153 }
00154 else
00155 {
00156 subject = Subject::_nil();
00157 vprDEBUG(vprDBG_ALL, vprDBG_WARNING_LVL)
00158 << clrOutBOLD(clrYELLOW, "WARNING:") << " No subject named '" << name
00159 << "' registered with Subject Manager!\n" << vprDEBUG_FLUSH;
00160 }
00161
00162 return subject;
00163 }
|
|
|
Returns a sequence of all the registered Tweek Subjects packaged in the structure RegisteredSubject.
Definition at line 165 of file SubjectManagerImpl.cpp. References tweek::SubjectManager::RegisteredSubject::subject_name, tweek::SubjectManager::RegisteredSubject::subject_ref, tweek::SubjectManager::SubjectList, and tweekDBG_CORBA.
00166 {
00167 vprDEBUG_OutputGuard(tweekDBG_CORBA, vprDBG_STATE_LVL,
00168 "tweek::SubjectManagerImpl::getAllSubjects() entered\n",
00169 "tweek::SubjectManagerImpl::getAllSubjects() done\n");
00170
00171 subject_map_t::iterator i;
00172 CORBA::ULong j;
00173
00174 vprDEBUG(tweekDBG_CORBA, vprDBG_STATE_LVL)
00175 << "Constructing sequence of subjects to return to caller ...\n"
00176 << vprDEBUG_FLUSH;
00177
00178 // Lock mSubjects while we read from it.
00179 vpr::Guard<vpr::Mutex> guard(mSubjectsMutex);
00180
00181 // Create the sequence and size it.
00182 tweek::SubjectManager::SubjectList* subjects =
00183 new tweek::SubjectManager::SubjectList();
00184 subjects->length(mSubjects.size());
00185
00186 vprDEBUG(tweekDBG_CORBA, vprDBG_VERB_LVL)
00187 << "Sequence size: " << subjects->length() << std::endl
00188 << vprDEBUG_FLUSH;
00189
00190 for ( i = mSubjects.begin(), j = 0; i != mSubjects.end(); ++i, ++j )
00191 {
00192 tweek::SubjectManager::RegisteredSubject rs;
00193 rs.subject_name = CORBA::string_dup((*i).first.c_str());
00194 rs.subject_ref = Subject::_duplicate((*i).second);
00195
00196 vprDEBUG(tweekDBG_CORBA, vprDBG_VERB_LVL)
00197 << "Adding subject[" << j << "]: " << rs.subject_name << std::endl
00198 << vprDEBUG_FLUSH;
00199
00200 (*subjects)[j] = rs;
00201 }
00202
00203 return subjects;
00204 }
|
|
|
Returns a sequence of key/value pairs that provide site-specific information about a given Subject Manager servant.
Definition at line 206 of file SubjectManagerImpl.cpp. References tweek::SubjectManager::SubjectMgrInfoItem::key, tweek::SubjectManager::SubjectManagerInfoList, tweekDBG_CORBA, and tweek::SubjectManager::SubjectMgrInfoItem::value.
00207 {
00208 std::map<std::string, std::string>::iterator i;
00209 CORBA::ULong j;
00210
00211 vprDEBUG(tweekDBG_CORBA, vprDBG_STATE_LVL)
00212 << "Constructing sequence of info items to return to caller ...\n"
00213 << vprDEBUG_FLUSH;
00214
00215 // Use a guard here so that the lock is exception safe.
00216 vpr::Guard<vpr::Mutex> lock(mInfoMapMutex);
00217
00218 // Create the sequence and size it.
00219 tweek::SubjectManager::SubjectManagerInfoList* info_items =
00220 new tweek::SubjectManager::SubjectManagerInfoList();
00221 info_items->length(mInfoMap.size());
00222
00223 vprDEBUG(tweekDBG_CORBA, vprDBG_VERB_LVL)
00224 << "Sequence size: " << info_items->length() << std::endl
00225 << vprDEBUG_FLUSH;
00226
00227 for ( i = mInfoMap.begin(), j = 0; i != mInfoMap.end(); ++i, ++j )
00228 {
00229 tweek::SubjectManager::SubjectMgrInfoItem item;
00230 item.key = CORBA::string_dup((*i).first.c_str());
00231 item.value = CORBA::string_dup((*i).second.c_str());
00232
00233 vprDEBUG(tweekDBG_CORBA, vprDBG_VERB_LVL)
00234 << "Adding item[" << j << "]: " << item.key << " => " << item.value
00235 << std::endl << vprDEBUG_FLUSH;
00236
00237 (*info_items)[j] = item;
00238 }
00239
00240 vprDEBUG(tweekDBG_CORBA, vprDBG_STATE_LVL)
00241 << "Returning all info items to caller\n" << vprDEBUG_FLUSH;
00242
00243 return info_items;
00244 }
|
|
|
Returns the name of this Subject Manager reference as it is registered with the CORBA Naming Service.
Definition at line 246 of file SubjectManagerImpl.cpp.
00247 {
00248 return CORBA::string_dup(mGUID.toString().c_str());
00249 }
|
|
|
Definition at line 134 of file SubjectManagerImpl.h. Referenced by tweek::CorbaManager::createSubjectManager.
00135 {
00136 mName = name;
00137 }
|
|
|
Assigns the given value for the username informational item. This can be used to provide remote users with an application-specific identifier for this Subject Manager instance. If this method is not used, the username setting defaults to "unknown".
Definition at line 148 of file SubjectManagerImpl.h. Referenced by tweek::CorbaManager::createSubjectManager.
00149 {
00150 addInfoItem(std::string(APPNAME_KEY), appName);
00151 }
|
|
|
Assigns the given value for the username informational item. This can be used to provide remote users with an application-specific identifier for this Subject Manager instance. If this method is not used, the username setting defaults to the value of the $USER environment varaible.
Definition at line 162 of file SubjectManagerImpl.h.
00163 {
00164 addInfoItem(USERNAME_KEY, userName);
00165 }
|
|
||||||||||||
|
Returns a sequence of key/value pairs that provide site-specific information about a given Subject Manager servant.
Definition at line 171 of file SubjectManagerImpl.h.
00172 {
00173 vpr::Guard<vpr::Mutex> lock(mInfoMapMutex);
00174 mInfoMap[key] = value;
00175 }
|
|
|
Definition at line 177 of file SubjectManagerImpl.h. Referenced by tweek::CorbaManager::createSubjectManager.
00178 {
00179 return mGUID;
00180 }
|
|
|
Definition at line 202 of file SubjectManagerImpl.h.
00203 {
00204 /* Do nothing. */ ;
00205 }
|
|
||||||||||||
|
Definition at line 123 of file SubjectManagerImpl.cpp. References tweekDBG_CORBA.
00125 {
00126 vpr::Guard<vpr::Mutex> guard(mSubjectsMutex);
00127
00128 vprDEBUG(tweekDBG_CORBA, vprDBG_STATE_LVL)
00129 << "Registering subject named '" << name << "'\n" << vprDEBUG_FLUSH;
00130
00131 mSubjects[name] = Subject::_duplicate(subject);
00132 }
|
|
|
Intializes the encapsulated map of key/value pairs for this Subject Manager instance.
Definition at line 251 of file SubjectManagerImpl.cpp.
00252 {
00253 vpr::InetAddr local_addr;
00254 vpr::InetAddr::getLocalHost(local_addr);
00255
00256 mInfoMap["Hostname"] = local_addr.getHostname();
00257
00258 std::string user_name;
00259
00260 if ( vpr::System::getenv("USER", user_name).success() )
00261 {
00262 mInfoMap[USERNAME_KEY] = user_name;
00263 }
00264 else
00265 {
00266 mInfoMap[USERNAME_KEY] = "unknown";
00267 }
00268
00269 mInfoMap[APPNAME_KEY] = "unknown";
00270 }
|
|
|
Definition at line 184 of file SubjectManagerImpl.h. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002