PortableServer_ORBInitializer.cpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 #include "tao/PI_Server/PortableServer_ORBInitializer.h"
00004 #include "tao/PI_Server/PortableServer_PolicyFactory.h"
00005 #include "tao/debug.h"
00006 #include "tao/ORB_Constants.h"
00007 #include "tao/PortableServer/PortableServer.h"
00008 #include "tao/PI/ORBInitInfo.h"
00009 #include "tao/ORB_Core.h"
00010 
00011 ACE_RCSID (PI_Server,
00012            PortableServer_ORBInitializer,
00013            "$Id: PortableServer_ORBInitializer.cpp 77357 2007-02-24 06:58:14Z johnnyw $")
00014 
00015 
00016 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00017 
00018 void
00019 TAO_PortableServer_ORBInitializer::pre_init (
00020   PortableInterceptor::ORBInitInfo_ptr)
00021 {
00022 }
00023 
00024 void
00025 TAO_PortableServer_ORBInitializer::post_init (
00026   PortableInterceptor::ORBInitInfo_ptr info)
00027 {
00028   this->register_policy_factories (info);
00029 }
00030 
00031 void
00032 TAO_PortableServer_ORBInitializer::register_policy_factories (
00033   PortableInterceptor::ORBInitInfo_ptr info)
00034 {
00035 #if !defined (CORBA_E_MICRO)
00036   // Register the PortableServer policy factories.
00037   PortableInterceptor::PolicyFactory_ptr tmp;
00038   ACE_NEW_THROW_EX (tmp,
00039                     TAO_PortableServer_PolicyFactory,
00040                     CORBA::NO_MEMORY (
00041                       CORBA::SystemException::_tao_minor_code (
00042                         TAO::VMCID,
00043                         ENOMEM),
00044                       CORBA::COMPLETED_NO));
00045 
00046   PortableInterceptor::PolicyFactory_var policy_factory = tmp;
00047 
00048   // Bind the same policy factory to all PortableServer related policy
00049   // types since a single policy factory is used to create each of the
00050   // different types of PortableServer policies.
00051   static CORBA::PolicyType const type[] = {
00052 #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT)
00053     PortableServer::THREAD_POLICY_ID,
00054     PortableServer::IMPLICIT_ACTIVATION_POLICY_ID,
00055     PortableServer::SERVANT_RETENTION_POLICY_ID,
00056     PortableServer::REQUEST_PROCESSING_POLICY_ID,
00057 #endif /* TAO_HAS_MINIMUM_POA == 0 */
00058     PortableServer::LIFESPAN_POLICY_ID,
00059     PortableServer::ID_UNIQUENESS_POLICY_ID,
00060     PortableServer::ID_ASSIGNMENT_POLICY_ID
00061   };
00062 
00063   CORBA::PolicyType const * end =
00064     type + sizeof (type) / sizeof (type[0]);
00065 
00066   for (CORBA::PolicyType const *i = type;
00067        i != end;
00068        ++i)
00069     {
00070       try
00071         {
00072           info->register_policy_factory (*i, policy_factory.in ());
00073         }
00074       catch (const ::CORBA::BAD_INV_ORDER& ex)
00075         {
00076           if (ex.minor () == (CORBA::OMGVMCID | 16))
00077             {
00078               // The factory is already there, it happens because the
00079               // magic initializer in PortableServer.cpp registers
00080               // with the ORB multiple times.  This is an indication
00081               // that we should do no more work in this
00082               // ORBInitializer.
00083               return;
00084             }
00085           throw;
00086         }
00087     }
00088 #else
00089   ACE_UNUSED_ARG (info);
00090 #endif
00091 }
00092 
00093 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Tue Feb 2 17:42:14 2010 for TAO_PI_Server by  doxygen 1.4.7