📄 initrefs.cc
字号:
// -*- Mode: C++; -*-// Package : omniORB// initRefs.cc Created on: 20/08/98// Author : Sai-Lai Lo//// Copyright (C) 1996-2000 AT&T Laboratories Cambridge//// This file is part of the omniORB library//// The omniORB library is free software; you can redistribute it and/or// modify it under the terms of the GNU Library General Public// License as published by the Free Software Foundation; either// version 2 of the License, or (at your option) any later version.//// This library is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU// Library General Public License for more details.//// You should have received a copy of the GNU Library General Public// License along with this library; if not, write to the Free// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA////// Description:// *** PROPRIETARY INTERFACE ***// /* $Log: initRefs.cc,v $ Revision 1.2.2.15 2003/03/13 14:53:25 dgrisby Log DefaultInitRef properly. Thanks Matej Kenda. Revision 1.2.2.14 2002/08/16 17:47:39 dgrisby Documentation, message updates. ORB tweaks to match docs. Revision 1.2.2.13 2001/11/13 14:11:45 dpg1 Tweaks for CORBA 2.5 compliance. Revision 1.2.2.12 2001/11/09 16:14:02 dpg1 Fix server-side boostrap agent. Revision 1.2.2.11 2001/10/17 16:44:06 dpg1 Update DynAny to CORBA 2.5 spec, const Any exception extraction. Revision 1.2.2.10 2001/08/21 11:02:16 sll orbOptions handlers are now told where an option comes from. This is necessary to process DefaultInitRef and InitRef correctly. Revision 1.2.2.9 2001/08/17 17:12:39 sll Modularise ORB configuration parameters. Revision 1.2.2.8 2001/08/03 17:41:22 sll System exception minor code overhaul. When a system exeception is raised, a meaning minor code is provided. Revision 1.2.2.7 2001/06/11 17:53:23 sll The omniIOR ctor used by genior and corbaloc now has the option to select whether to call interceptors and what set of interceptors to call. Revision 1.2.2.6 2001/06/07 16:24:10 dpg1 PortableServer::Current support. Revision 1.2.2.5 2001/05/29 17:03:51 dpg1 In process identity. Revision 1.2.2.4 2001/04/18 18:18:08 sll Big checkin with the brand new internal APIs. Revision 1.2.2.3 2000/10/03 17:39:25 sll Cleanup the_argsServiceList and the_fileServiceList in module detach(). Revision 1.2.2.2 2000/09/27 18:15:16 sll Use the new omniIOR class and createObjRef() to create the object reference for the bootagent. Revision 1.2.2.1 2000/07/17 10:35:54 sll Merged from omni3_develop the diff between omni3_0_0_pre3 and omni3_0_0. Revision 1.3 2000/07/13 15:25:57 dpg1 Merge from omni3_develop for 3.0 release. Revision 1.1.2.5 2000/06/30 14:12:07 dpg1 Minor fixes for FreeBSD. Revision 1.1.2.4 2000/06/27 16:15:11 sll New classes: _CORBA_String_element, _CORBA_ObjRef_Element, _CORBA_ObjRef_tcDesc_arg to support assignment to an element of a sequence of string and a sequence of object reference. Revision 1.1.2.3 2000/06/22 10:40:15 dpg1 exception.h renamed to exceptiondefs.h to avoid name clash on some platforms. Revision 1.1.2.2 2000/06/19 13:56:25 dpg1 Explicit cast to (const char*) when using String_var with logger. Revision 1.1.2.1 2000/04/27 10:50:04 dpg1 Interoperable Naming Service Moved from bootstrap_i.cc and extended with INS functions. Revision 1.9.6.4 1999/12/10 12:33:16 djr Fixed deadlock in bootstrap agent. Revision 1.9.6.3 1999/10/04 17:08:31 djr Some more fixes/MSVC work-arounds. Revision 1.9.6.2 1999/09/24 15:01:32 djr Added module initialisers, and sll's new scavenger implementation. Revision 1.9.6.1 1999/09/22 14:26:42 djr Major rewrite of orbcore to support POA. Revision 1.8 1999/05/25 17:24:39 sll CORBA::ORB::ObjectIdList and CORBA_InitialReferences::ObjIdList are now different types. Previously they are the same template type instance. Revision 1.7 1999/03/11 16:25:51 djr Updated copyright notice Revision 1.6 1999/02/01 15:13:04 djr Replace copy-initialisation of _var types with direct initialisation. Revision 1.5 1999/01/11 09:45:53 djr *** empty log message *** Revision 1.4 1999/01/07 15:13:08 djr Added singleton class omniInitialRefLister to list the initial object references found (if traceLevel >= 15). Revision 1.3 1998/08/26 11:19:05 sll Minor upates to remove warnings when compiled with standard C++ compilers. Revision 1.2 1998/08/25 19:01:35 sll Moved auto-variable declaration in set() to make it acceptable to old and new compilers. Revision 1.1 1998/08/21 19:28:16 sll Initial revision */#include <omniORB4/CORBA.h>#ifdef HAS_pch#pragma hdrstop#endif#include <initRefs.h>#include <initialiser.h>#include <exceptiondefs.h>#include <poaimpl.h>#include <poacurrentimpl.h>#include <omniORB4/omniURI.h>#include <orbOptions.h>#include <orbParameters.h>#include <stdio.h>OMNI_NAMESPACE_BEGIN(omni)////////////////////////////////////////////////////////////////////////////// Configuration options //////////////////////////////////////////////////////////////////////////////CORBA::Boolean orbParameters::supportBootstrapAgent = 0;// Applies to the server side. 1 means enable the support for Sun's// bootstrap agent protocol. This enables interoperability between omniORB// servers and Sun's javaIDL clients. When this option is enabled, an// omniORB server will response to a bootstrap agent request.CORBA::String_var orbParameters::bootstrapAgentHostname;// Applies to the client side. Non-zero enables the use of Sun's bootstrap// agent protocol to resolve initial references. The value is the host name// where requests for initial references should be sent. Only uses this// option to interoperate with Sun's javaIDL.CORBA::UShort orbParameters::bootstrapAgentPort = 900;// Applies to the client side. Use this port no. to contact the bootstrap // agent.////////////////////////////////////////////////////////////////////////////static CORBA_InitialReferences_i* the_bootagentImpl = 0;static omni_tracedmutex ba_lock;// When initial references are first set, they contain an id and a// uri. The first time they are resolved, the uri is replaced with an// object reference.struct serviceRecord { CORBA::String_member id; CORBA::String_member uri; CORBA::Object_Member ref;};static _CORBA_PseudoValue_Sequence<serviceRecord> the_argsServiceList;static _CORBA_PseudoValue_Sequence<serviceRecord> the_fileServiceList;static char* the_argsDefaultInitRef = 0;static char* the_fileDefaultInitRef = 0;static CORBA_InitialReferences_ptr the_bootagent = 0;static omni_tracedmutex sl_lock;//////////////////////////////////////////////////////////////////////////////////////////// CORBA_InitialReferences_i ///////////////////////////////////////////////////////////////////////////////////////////class CORBA_InitialReferences_i : public POA_CORBA_InitialReferences {public: CORBA::Object_ptr get(const char* id); CORBA_InitialReferences::ObjIdList* list(); inline CORBA_InitialReferences_i() {} virtual ~CORBA_InitialReferences_i() {}private: CORBA_InitialReferences_i(const CORBA_InitialReferences_i&); CORBA_InitialReferences_i& operator=(const CORBA_InitialReferences_i&);};CORBA::Object_ptrCORBA_InitialReferences_i::get(const char* id){ return omniInitialReferences::resolve(id); // *** What happens if resolve() returns a pseudo object?}CORBA_InitialReferences::ObjIdList*CORBA_InitialReferences_i::list(){ omni_tracedmutex_lock sync(sl_lock); CORBA_InitialReferences::ObjIdList* result = new CORBA_InitialReferences::ObjIdList(the_argsServiceList.length() + the_fileServiceList.length()); CORBA_InitialReferences::ObjIdList& l = *result; l.length(the_argsServiceList.length() + the_fileServiceList.length()); CORBA::ULong i, j; for (i=0,j=0; i < the_argsServiceList.length(); i++,j++) { l[j] = CORBA::string_dup(the_argsServiceList[i].id); } for (i=0; i < the_fileServiceList.length(); i++,j++) { l[j] = CORBA::string_dup(the_fileServiceList[i].id); } // XXX Should we go out to find the listing from the boot agent? return result;}//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////CORBA::BooleanomniInitialReferences::setFromArgs(const char* identifier, const char* uri){ if (!omniURI::uriSyntaxIsValid(uri)) return 0; omni_tracedmutex_lock sync(sl_lock); CORBA::ULong index; for (index=0; index < the_argsServiceList.length(); index++) { if (strcmp((const char*)the_argsServiceList[index].id,identifier) == 0) break; } if (index == the_argsServiceList.length()) { the_argsServiceList.length(index+1); the_argsServiceList[index].id = identifier; } the_argsServiceList[index].uri = uri; the_argsServiceList[index].ref = CORBA::Object::_nil(); return 1;}static voidsetFromArgs(const char* identifier, CORBA::Object_ptr obj){ omni_tracedmutex_lock sync(sl_lock); CORBA::ULong index; for (index=0; index < the_argsServiceList.length(); index++) { if (strcmp((const char*)the_argsServiceList[index].id,identifier) == 0) break; } if (index == the_argsServiceList.length()) { the_argsServiceList.length(index+1); the_argsServiceList[index].id = identifier; } the_argsServiceList[index].uri = (char*)0; the_argsServiceList[index].ref = CORBA::Object::_duplicate(obj);}CORBA::BooleanomniInitialReferences::setFromFile(const char* identifier, const char* uri){ if (!omniURI::uriSyntaxIsValid(uri)) return 0; omni_tracedmutex_lock sync(sl_lock); CORBA::ULong index; for (index=0; index < the_fileServiceList.length(); index++) { if (strcmp((const char*)the_fileServiceList[index].id,identifier) == 0) break; } if (index == the_fileServiceList.length()) { the_fileServiceList.length(index+1); the_fileServiceList[index].id = identifier; } the_fileServiceList[index].uri = uri; the_fileServiceList[index].ref = CORBA::Object::_nil(); return 1;}static voidsetFromFile(const char* identifier, CORBA::Object_ptr obj){ omni_tracedmutex_lock sync(sl_lock); CORBA::ULong index; for (index=0; index < the_fileServiceList.length(); index++) { if (strcmp((const char*)the_fileServiceList[index].id,identifier) == 0) break; } if (index == the_fileServiceList.length()) { the_fileServiceList.length(index+1); the_fileServiceList[index].id = identifier; } the_fileServiceList[index].uri = (char*)0; the_fileServiceList[index].ref = CORBA::Object::_duplicate(obj);}voidomniInitialReferences::setFromORB(const char* identifier, CORBA::Object_ptr obj){ if (!identifier || *identifier == '\0') throw CORBA::ORB::InvalidName(); if (CORBA::is_nil(obj)) OMNIORB_THROW(BAD_PARAM, BAD_PARAM_RegisterNilObject, CORBA::COMPLETED_NO); omni_tracedmutex_lock sync(sl_lock); CORBA::ULong index; for (index=0; index < the_fileServiceList.length(); index++) { if (strcmp((const char*)the_fileServiceList[index].id,identifier) == 0) throw CORBA::ORB::InvalidName(); } for (index=0; index < the_argsServiceList.length(); index++) { if (strcmp((const char*)the_argsServiceList[index].id,identifier) == 0) throw CORBA::ORB::InvalidName(); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -