Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

DLL_ORB.cpp

Go to the documentation of this file.
00001 #include "tao_pch.h"
00002 // -*- C++ -*-
00003 
00004 #include "tao/DLL_ORB.h"
00005 #include "tao/TAO_Singleton_Manager.h"
00006 #include "tao/Environment.h"
00007 
00008 #include "tao/debug.h"
00009 #include "ace/ARGV.h"
00010 #include "ace/Dynamic_Service.h"
00011 #include "ace/Argv_Type_Converter.h"
00012 
00013 ACE_RCSID (tao,
00014            DLL_ORB,
00015            "$Id: DLL_ORB.cpp,v 1.1.1.2.2.1 2003/03/14 16:05:12 chad Exp $")
00016 
00017 #if !defined (__ACE_INLINE__)
00018 # include "tao/DLL_ORB.inl"
00019 #endif  /* ! __ACE_INLINE__ */
00020 
00021 TAO_DLL_ORB::TAO_DLL_ORB (void)
00022   : orb_ ()
00023 {
00024   // Nothing
00025 }
00026 
00027 TAO_DLL_ORB::~TAO_DLL_ORB (void)
00028 {
00029   // Nothing
00030 }
00031 
00032 int
00033 TAO_DLL_ORB::init (int /*argc*/, ACE_TCHAR *argv[])
00034 {
00035   // This class is deprecated.  See the class documentation in
00036   // DLL_ORB.h for details explaining why this is so.
00037   if (TAO_debug_level > 0)
00038     ACE_DEBUG ((LM_WARNING,
00039                 ACE_LIB_TEXT ("TAO (%P|%t) - The TAO_DLL_ORB class is ")
00040                 ACE_LIB_TEXT ("deprecated.  See the class documentation\n")
00041                 ACE_LIB_TEXT ("TAO (%P|%t) - `tao/DLL_ORB.h' for details ")
00042                 ACE_LIB_TEXT ("explaining why this is so.\n")));
00043 
00044 
00045   // Make sure TAO's singleton manager is initialized, and set to not
00046   // register itself with the ACE_Object_Manager since it is under the
00047   // control of the Service Configurator.
00048   int register_with_object_manager = 0;
00049 
00050   if (TAO_Singleton_Manager::instance ()->init (
00051         register_with_object_manager) == -1)
00052     return -1;  // No exceptions yet.
00053 
00054   ACE_TRY_NEW_ENV
00055     {
00056       ACE_ARGV new_argv;
00057 
00058       if (new_argv.add (ACE_TEXT ("dummy")) == -1
00059           || new_argv.add (argv) == -1)
00060         return -1;
00061 
00062       int new_argc = new_argv.argc ();
00063 
00064 #if defined (ACE_HAS_WINCE)
00065       {
00066           // Copy command line parameter from new_argv.
00067           ACE_Argv_Type_Converter command_line(new_argc, new_argv.argv());
00068 
00069           // Initialize the ORB.
00070           this->orb_ = CORBA::ORB_init (command_line.get_argc(),
00071                                         command_line.get_ASCII_argv(),
00072                                         ""
00073                                          ACE_ENV_ARG_PARAMETER);
00074           // command_line will be destroyed here and new_argv will be updated if necessary
00075       }
00076 #else
00077       // Initialize the ORB.
00078       this->orb_ = CORBA::ORB_init (new_argc,
00079                                     new_argv.argv (),
00080                                     ""
00081                                      ACE_ENV_ARG_PARAMETER);
00082 #endif  // ACE_HAS_WINCE
00083 
00084       ACE_TRY_CHECK;
00085 
00086       if (CORBA::is_nil (this->orb_.in ()))
00087         return -1;
00088     }
00089   ACE_CATCHANY
00090     {
00091       if (TAO_debug_level >= 4)
00092         ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
00093                              "TAO_DLL_ORB::init");
00094 
00095       return -1;
00096     }
00097   ACE_ENDTRY;
00098 
00099 #if defined (ACE_HAS_THREADS)
00100       // Become an Active Object so that the ORB
00101       // will execute in a separate thread.
00102       return this->activate ();
00103 #else
00104       return 0;
00105 #endif /* ACE_HAS_THREADS */
00106 }
00107 
00108 int
00109 TAO_DLL_ORB::fini (void)
00110 {
00111   ACE_TRY_NEW_ENV
00112     {
00113       this->orb_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
00114       ACE_TRY_CHECK;
00115 
00116       if (TAO_Singleton_Manager::instance ()->fini () == -1)
00117         return -1;
00118     }
00119   ACE_CATCHANY
00120     {
00121       if (TAO_debug_level >= 4)
00122         ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
00123                              "TAO_DLL_ORB::fini");
00124       return -1;
00125     }
00126   ACE_ENDTRY;
00127 
00128   return 0;
00129 }
00130 
00131 int
00132 TAO_DLL_ORB::svc (void)
00133 {
00134   ACE_TRY_NEW_ENV
00135     {
00136       // Run the ORB event loop in its own thread.
00137       this->orb_->run (ACE_ENV_SINGLE_ARG_PARAMETER);
00138       ACE_TRY_CHECK;
00139     }
00140   ACE_CATCHANY
00141     {
00142       if (TAO_debug_level >= 4)
00143         ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
00144                              "TAO_DLL_ORB::svc");
00145       return -1;
00146     }
00147   ACE_ENDTRY;
00148 
00149   return 0;
00150 }
00151 
00152 
00153 ACE_STATIC_SVC_DEFINE (TAO_DLL_ORB,
00154                        ACE_TEXT ("DLL_ORB"),
00155                        ACE_SVC_OBJ_T,
00156                        &ACE_SVC_NAME (TAO_DLL_ORB),
00157                        ACE_Service_Type::DELETE_THIS
00158                        | ACE_Service_Type::DELETE_OBJ,
00159                        0)
00160 
00161 ACE_FACTORY_DEFINE (TAO, TAO_DLL_ORB)
00162 
00163 
00164 
00165 // Template instantiations necessary for use when dynamically load the
00166 // TAO_DLL_ORB.
00167 
00168 #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
00169 
00170 template class ACE_Dynamic_Service<TAO_DLL_ORB>;
00171 
00172 #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
00173 
00174 #pragma instantiate ACE_Dynamic_Service<TAO_DLL_ORB>
00175 
00176 #endif

Generated on Mon Jun 16 13:48:14 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002