PI_ORBInitializer.cpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 #include "tao/PI/PI_ORBInitializer.h"
00004 
00005 #if TAO_HAS_INTERCEPTORS == 1
00006 
00007 #include "tao/PI/PI_PolicyFactory.h"
00008 #include "tao/PI/ProcessingModePolicyC.h"
00009 #include "tao/ORB_Core.h"
00010 #include "tao/PI/ORBInitInfoC.h"
00011 
00012 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00013 
00014 ACE_RCSID (tao,
00015            PI_ORBInitializer,
00016            "PI_ORBInitializer.cpp,v 1.3 2006/03/10 07:19:12 jtc Exp")
00017 
00018 void
00019 TAO_PI_ORBInitializer::pre_init (PortableInterceptor::ORBInitInfo_ptr info
00020                                  ACE_ENV_ARG_DECL_NOT_USED)
00021   ACE_THROW_SPEC ((CORBA::SystemException))
00022 {
00023   ACE_UNUSED_ARG (info);
00024 }
00025 
00026 
00027 void
00028 TAO_PI_ORBInitializer::post_init (
00029   PortableInterceptor::ORBInitInfo_ptr info
00030   ACE_ENV_ARG_DECL)
00031   ACE_THROW_SPEC ((CORBA::SystemException))
00032 {
00033   // The PI policy factory is stateless and reentrant, so share a
00034   // single instance between all ORBs.
00035   if (CORBA::is_nil (this->policy_factory_.in ()))
00036     {
00037       PortableInterceptor::PolicyFactory_ptr policy_factory;
00038       ACE_NEW_THROW_EX (policy_factory,
00039                         TAO_PI_PolicyFactory,
00040                           CORBA::NO_MEMORY (
00041                             CORBA::SystemException::_tao_minor_code (
00042                               TAO::VMCID,
00043                               ENOMEM),
00044                             CORBA::COMPLETED_NO));
00045       ACE_CHECK;
00046 
00047       this->policy_factory_ = policy_factory;
00048     }
00049 
00050 
00051   this->register_policy_factories (info
00052                                    ACE_ENV_ARG_PARAMETER);
00053   ACE_CHECK;
00054 }
00055 
00056 
00057 void
00058 TAO_PI_ORBInitializer::register_policy_factories (
00059   PortableInterceptor::ORBInitInfo_ptr info
00060   ACE_ENV_ARG_DECL)
00061 {
00062   // Register the PI policy factory.
00063 
00064   // Bind the same policy factory to all PortableInterceptor related policy
00065   // types since a single policy factory is used to create each of the
00066   // different types of PortableInterceptor policies.
00067   CORBA::PolicyType type[] = {
00068     PortableInterceptor::PROCESSING_MODE_POLICY_TYPE
00069   };
00070 
00071   const CORBA::PolicyType *end = type + sizeof (type) / sizeof (type[0]);
00072 
00073   for (CORBA::PolicyType *i = type; i != end; ++i)
00074     {
00075       ACE_TRY
00076         {
00077           info->register_policy_factory (*i,
00078                                          this->policy_factory_.in ()
00079                                          ACE_ENV_ARG_PARAMETER);
00080           ACE_TRY_CHECK;
00081         }
00082       ACE_CATCH (CORBA::BAD_INV_ORDER, ex)
00083         {
00084           if (ex.minor () == (CORBA::OMGVMCID | 16))
00085             {
00086               // The factory is already there, it happens because the
00087               // magic initializer in PI_Initializer.cpp registers
00088               // with the ORB multiple times.  This is an indication
00089               // that we should do no more work in this
00090               // ORBInitializer.
00091               return;
00092             }
00093           ACE_RE_THROW;
00094         }
00095       ACE_CATCHANY
00096         {
00097           // Rethrow any other exceptions...
00098           ACE_RE_THROW;
00099         }
00100       ACE_ENDTRY;
00101       ACE_CHECK;
00102     }
00103 }
00104 
00105 TAO_END_VERSIONED_NAMESPACE_DECL
00106 
00107 #endif  /* TAO_HAS_INTERCEPTORS == 1 */

Generated on Thu Nov 9 12:51:39 2006 for TAO_PI by doxygen 1.3.6