// @(#) $Id: EndpointPolicy.cpp 76995 2007-02-11 12:51:42Z johnnyw $

#include "tao/EndpointPolicy/EndpointPolicy.h"
#include "tao/EndpointPolicy/EndpointPolicy_ORBInitializer.h"
#include "tao/EndpointPolicy/Endpoint_Acceptor_Filter_Factory.h"

#include "tao/ORB_Core.h"
#include "tao/ORBInitializer_Registry.h"

#include "tao/PI/PI.h"

ACE_RCSID (EndpointPolicy, EndpointPolicy, "$Id: EndpointPolicy.cpp 76995 2007-02-11 12:51:42Z johnnyw $")

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

int
TAO_EndpointPolicy_Initializer::init (void)
{
  ACE_Service_Config::process_directive (ace_svc_desc_TAO_Endpoint_Acceptor_Filter_Factory);

  PortableInterceptor::ORBInitializer_ptr temp_orb_initializer =
  PortableInterceptor::ORBInitializer::_nil ();
  PortableInterceptor::ORBInitializer_var orb_initializer;

  try
    {
      /// Register the EndpointPolicy ORBInitializer.
      ACE_NEW_THROW_EX (temp_orb_initializer,
                        TAO_EndpointPolicy_ORBInitializer,
                        CORBA::NO_MEMORY (
                          CORBA::SystemException::_tao_minor_code (
                            TAO::VMCID,
                            ENOMEM),
                          CORBA::COMPLETED_NO));

      orb_initializer = temp_orb_initializer;

      PortableInterceptor::register_orb_initializer (orb_initializer.in ());
    }
  catch (const ::CORBA::Exception& ex)
    {
      if (TAO_debug_level > 0)
        {
          ex._tao_print_exception ("Caught exception:");
        }
      return -1;
    }

  ACE_Service_Config::process_directive
    (ace_svc_desc_TAO_Endpoint_Acceptor_Filter_Factory,1); // force replacement


  return 0;
}

TAO_END_VERSIONED_NAMESPACE_DECL
