summaryrefslogtreecommitdiff
path: root/modules/CIAO/DAnCE/NodeApplication/ComponentAttributesSetter.cpp
blob: 21783684313158f932ed4b9415320591a84b3cfd (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
// $Id$

#include "tao/DynamicInterface/Request.h"

#include "ComponentAttributesSetter.h"
#include "tao/DynamicInterface/DII_CORBA_methods.h"
#include "tao/DynamicInterface/Context.h"
#include "tao/AnyTypeCode/NVList.h"
#include "tao/AnyTypeCode/TypeCode_Constants.h"
#include "DAnCE/Logger/Log_Macros.h"
#include "Deployment/Deployment_ApplicationC.h"

ComponentAttributesSetter::ComponentAttributesSetter()
{
}

ComponentAttributesSetter::~ComponentAttributesSetter()
{
}

void
ComponentAttributesSetter::SetComponentAttributes (ACE_CString /*componentName*/,
                                                   ::CORBA::Object_ptr obj,
                                                   const Deployment::Properties& prop,
                                                   CORBA::ORB_ptr )
{
  DANCE_TRACE ("ComponentAttributesSetter::SetComponentAttributes");

  for (CORBA::ULong i = 0; i < prop.length(); i++)
    {
      ACE_CString const name = prop[i].name.in();

      // Ignore configuration properties, since attributes can't have . in them, this seems like a good method.
      if (name.find (".") != ACE_CString::npos)
        {
          continue;
        }

      DANCE_DEBUG (6, (LM_DEBUG, DLINFO
                    ACE_TEXT("ComponentAttributesSetter::SetComponentAttributes - ")
                    ACE_TEXT("Populating attribute name <%C>\n"), name.c_str()));
      ACE_CString method = "_set_";
      method += prop[i].name.in();

      try
        {
          ::CORBA::Request_var req = obj->_request (method.c_str ());
          req->add_in_arg ("x") = prop[i].value;
          req->invoke();
        }
      catch (const CORBA::Exception &e)
        {
          DANCE_ERROR (1, (LM_ERROR, DLINFO
                        ACE_TEXT("ComponentAttributesSetter::SetComponentAttributes - ")
                        ACE_TEXT("ERROR: Exception while trying to set attribute <%C>\n"),
                        name.c_str ()));
          e._tao_print_exception ("ComponentAttributesSetter.cpp::SetComponentAttributes - ");
          throw ::Deployment::StartError();
        }
    }
}