summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/ImplRepo_Service/Adapter_Activator.cpp
blob: 960ec06398e247c3921665394e11e57c1b74c925 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// -*- C++ -*-
//=============================================================================
/**
 *  @file   Adapter_Activator.cpp
 *
 *  $Id$
 *
 *  @author Darrell Brunsch <brunsch@cs.wustl.edu>
 */
//=============================================================================

#include "Adapter_Activator.h"

#include "orbsvcs/Log_Macros.h"
#include "tao/PortableServer/Servant_Base.h"

ImR_Adapter::ImR_Adapter (void)
  : default_servant_ (0)
{
}

void
ImR_Adapter::init (TAO_ServantBase * servant)
{
  ORBSVCS_DEBUG ((LM_DEBUG, "ImR_Adapter::init with default servant\n"));
  default_servant_ = servant;
}

CORBA::Boolean
ImR_Adapter::unknown_adapter (PortableServer::POA_ptr parent,
                              const char *name)
{
  ACE_ASSERT (! CORBA::is_nil(parent));
  ACE_ASSERT (name != 0);
  CORBA::PolicyList policies (3);

  const char *exception_message = "Null Message";
  policies.length (3);
  try
    {
      // Servant Retention Policy
      exception_message = "While PortableServer::POA::create_servant_retention_policy";
      policies[0] =
        parent->create_servant_retention_policy (PortableServer::NON_RETAIN);

      // Request Processing Policy
      exception_message = "While PortableServer::POA::create_request_processing_policy";

      policies[1] =
        parent->create_request_processing_policy (PortableServer::USE_DEFAULT_SERVANT);
      policies[2] =
        parent->create_id_uniqueness_policy (PortableServer::MULTIPLE_ID);

      PortableServer::POAManager_var poa_manager =
        parent->the_POAManager ();

      exception_message = "While create_POA";
      PortableServer::POA_var child =
        parent->create_POA (name,
                            poa_manager.in (),
                            policies);

      exception_message = "While policy->destroy";
      for (CORBA::ULong i = 0; i < policies.length (); ++i)
        {
          CORBA::Policy_ptr policy = policies[i];
          policy->destroy ();
        }

      exception_message = "While child->the_activator";
      child->the_activator (this);

      exception_message = "While set_servant";
      child->set_servant (this->default_servant_);
    }
  catch (const CORBA::Exception& ex)
    {
      ORBSVCS_ERROR ((LM_ERROR,
                  "IMR_Adapter_Activator::unknown_adapter - %C\n",
                  exception_message));
      ex._tao_print_exception ("System Exception");
      return 0;
    }

  // Finally, now everything is fine
  return 1;
}