summaryrefslogtreecommitdiff
path: root/CIAO/DAnCE/NodeApplication/ComponentAttributesSetter.cpp
blob: 9ea66fc9c78289e6827df7485dcfbe925e675105 (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
// $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 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();

      ::CORBA::Request_var req;

      try
        {
          req = obj->_request (method.c_str ());
          req->add_in_arg ("x") = prop[i].value;

          req->invoke();
        }
      catch (const CORBA::BAD_OPERATION &)
        {
          DANCE_ERROR (1, (LM_WARNING, DLINFO
                        ACE_TEXT("ComponentAttributesSetter::SetComponentAttributes - ")
                        ACE_TEXT("ERROR: BAD_OPERATION while trying to set attribute %C\n"),
                        name.c_str ()));
        }
      catch (const CORBA::Exception &e)
        {
          CORBA::release (req);
          e._tao_print_exception ("ComponentAttributesSetter.cpp::SetComponentAttributes ");
          throw ::Deployment::StartError();
        }
      //Question - How exceptions will be processed, rised by invoked method
    }
}