summaryrefslogtreecommitdiff
path: root/CIAO/DAnCE/NodeApplication/RTNodeApp_Configurator.cpp
blob: 04e7bd91f74f2f0ab4b1dc54ecb1634ffc318790 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// $Id$

#include "RTNodeApp_Configurator.h"
#include "DAnCE/Deployment/CIAO_ServerResourcesC.h"
#include "tao/RTPortableServer/RTPortableServer.h"

CIAO::RTNodeApp_Configurator::~RTNodeApp_Configurator ()
{
}

int
CIAO::RTNodeApp_Configurator::pre_orb_initialize ()
{
  ACE_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::pre_orb_init\n"));

  return 0;
}

int
CIAO::RTNodeApp_Configurator::post_orb_initialize (CORBA::ORB_ptr o)
{
  ACE_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::post_orb_init\n"));

  this->orb_ = CORBA::ORB::_duplicate (o);

  CORBA::Object_var object =
    this->orb_->resolve_initial_references ("RTORB");

  this->rtorb_ =
    RTCORBA::RTORB::_narrow (object.in ());

  this->config_manager_.init (this->rtorb_.in ());

  return 0;
}

int
CIAO::RTNodeApp_Configurator::init_resource_manager
(const ::Deployment::Properties &properties)
{

  //  if (CIAO::debug_level () > 9)
    ACE_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::init_resource_manager\n"));
  // @@ Should we cache the properties that we consumed here?

  for (CORBA::ULong i = 0; i < properties.length (); ++i)
    {
      //      if (CIAO::debug_level () > 9)
      ACE_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::init_resource_manager processing property: %s\n",
                  properties[i].name.in ()));

      if (ACE_OS::strcmp ("CIAOServerResources", properties[i].name.in ()) == 0)
        {
          const CIAO::DAnCE::ServerResource *svr_resource;
          if (properties[i].value >>= svr_resource)
            {
              this->config_manager_.init_resources (*svr_resource);
              //  Now we have the information to initialize the manager.
            }
          else
            ACE_ERROR_RETURN ((LM_ERROR,
                               "ERROR: RTNodeApp_Configurator::init_resource_manager unable to extract CIAOServerResources\n"), -1);
        }

      // Ignore other stuff
    }

  return 0;
}

CORBA::PolicyList *
CIAO::RTNodeApp_Configurator::find_container_policies
(const ::Deployment::Properties &properties)
{
  ACE_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::find_container_policies\n"));
  // @@ Should we cache the properties that we consumed here?

  for (CORBA::ULong i = 0; i < properties.length (); ++i)
    {
      ACE_DEBUG ((LM_DEBUG, "RTNodeApp_Configurator::find_container_policies processing property: %s\n",
                  properties[i].name.in ()));

      if (ACE_OS::strcmp ("ContainerPolicySet", properties[i].name) == 0)
        {
          const char *policy_name = 0;
          if (properties[i].value >>= policy_name)
            {
              return this->config_manager_.find_policies_by_name (policy_name);
            }
          else
            ACE_ERROR_RETURN ((LM_ERROR,
                               "ERROR: RTNodeApp_Configurator::find_container_policies unable to extract ContainerPolicySet\n"), 0);
        }
    }

  return 0;
}


extern "C" CIAO_RTNA_Configurator_Export CIAO::NodeApp_Configurator *create_nodeapp_configurator (void);

CIAO::NodeApp_Configurator *
create_nodeapp_configurator (void)
{
  CIAO::RTNodeApp_Configurator *config = 0;
  ACE_NEW_RETURN (config, CIAO::RTNodeApp_Configurator, 0);
  return config;
}