summaryrefslogtreecommitdiff
path: root/TAO/CIAO/DAnCE/NodeApplicationManager/NodeApplicationManager_Impl.cpp
blob: e03c0a63744f625625ca78796cad3091ad9a1f82 (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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
// $Id$

#include "NodeApplicationManager_Impl.h"
#include "ace/Process.h"
#include "ace/OS_NS_stdio.h"
#include "ciao/Container_Base.h"
#include "NodeApplication/NodeApplication_Impl.h"

#if !defined (__ACE_INLINE__)
# include "NodeApplicationManager_Impl.inl"
#endif /* __ACE_INLINE__ */


CIAO::NodeApplicationManager_Impl_Base::~NodeApplicationManager_Impl_Base (void)
{
}

void
CIAO::NodeApplicationManager_Impl_Base::
parse_config_value (ACE_CString & str
                    ACE_ENV_ARG_DECL)
  ACE_THROW_SPEC ((CORBA::SystemException,
                   Deployment::InvalidProperty))
{
  // The unused arg is for future improvemnts.
  ACE_UNUSED_ARG (str);

  ACE_THROW ( CORBA::NO_IMPLEMENT() );
}

Deployment::Connections *
CIAO::NodeApplicationManager_Impl_Base::
create_connections (ACE_ENV_SINGLE_ARG_DECL)
  ACE_THROW_SPEC ((CORBA::SystemException,
                   Deployment::ResourceNotAvailable,
                   Deployment::StartError,
                   Deployment::InvalidProperty))
{
  CIAO_TRACE("CIAO::NodeApplicationManager_Impl::create_connections");
  Deployment::Connections_var retv;

  ACE_NEW_THROW_EX (retv,
                    Deployment::Connections (),
                    CORBA::INTERNAL ());
  ACE_CHECK_RETURN (0);

  CORBA::ULong len = retv->length ();

  const Component_Iterator end (this->component_map_.end ());
  for (Component_Iterator iter (this->component_map_.begin ());
       iter != end;
       ++iter)
  {
    // Get all the facets first
    if (CIAO::debug_level () > 9)
      {
        ACE_DEBUG ((LM_DEBUG,
                  "DAnCE (%P|%t) NodeApplicationManager_Impl.cpp -"
                  "CIAO::NodeApplicationManager_Impl::create_connections -"
                  "getting facets for the component "
                  "instance [%s] \n",
                  (*iter).ext_id_.c_str ()));
      }

    Components::FacetDescriptions_var facets =
      ((*iter).int_id_)->get_all_facets (ACE_ENV_SINGLE_ARG_PARAMETER);
    ACE_CHECK_RETURN (0);

    if (CIAO::debug_level () > 9)
      {
        ACE_DEBUG ((LM_DEBUG,
                  "DAnCE (%P|%t) NodeApplicationManager_Impl.cpp -"
                  "CIAO::NodeApplicationManager_Impl::create_connections -"
                  "success getting facets for the component "
                  "instance [%s] \n",
                  (*iter).ext_id_.c_str ()));
      }

    // Get all the event consumers
    if (CIAO::debug_level () > 9)
      {
        ACE_DEBUG ((LM_DEBUG,
                  "DAnCE (%P|%t) NodeApplicationManager_Impl.cpp -"
                  "CIAO::NodeApplicationManager_Impl::create_connections -"
                  "getting consumers for the component "
                  "instance [%s] \n",
                  (*iter).ext_id_.c_str ()));
      }

    Components::ConsumerDescriptions_var consumers =
      ((*iter).int_id_)->get_all_consumers (ACE_ENV_SINGLE_ARG_PARAMETER);
    ACE_CHECK_RETURN (0);

    if (CIAO::debug_level () > 9)
      {
        ACE_DEBUG ((LM_DEBUG,
                  "DAnCE (%P|%t) NodeApplicationManager_Impl.cpp -"
                  "CIAO::NodeApplicationManager_Impl::create_connections -"
                  "success getting consumers for the component "
                  "instance [%s] \n",
                  (*iter).ext_id_.c_str ()));
      }

    const CORBA::ULong facet_len = facets->length ();
    const CORBA::ULong consumer_len = consumers->length ();

    CORBA::ULong curr_len = retv->length ();
    retv->length (curr_len + facet_len + consumer_len);

    CORBA::ULong i = 0;
    for (i = 0; i < facet_len; ++i)
    {
      Deployment::Connection & conn = retv[len];
      conn.instanceName = (*iter).ext_id_.c_str ();
      conn.portName = facets[i]->name ();
      if (CIAO::debug_level () > 9)
        {
          ACE_DEBUG ((LM_DEBUG,
                    "DAnCE (%P|%t) NodeApplicationManager_Impl.cpp -"
                    "CIAO::NodeApplicationManager_Impl::create_connections -"
                    "adding connection for facet [%s] in instance [%s] \n",
                    conn.portName.in (), conn.instanceName.in ()));
        }
      conn.kind = Deployment::Facet;
      conn.endpoint = CORBA::Object::_duplicate (facets[i]->facet_ref ());
      ++len;
    }

    for (i = 0; i < consumer_len; ++i)
    {
      Deployment::Connection & conn = retv[len];
      conn.instanceName = (*iter).ext_id_.c_str ();
      conn.portName = consumers[i]->name ();
      if (CIAO::debug_level () > 9)
        {
          ACE_DEBUG ((LM_DEBUG,
                    "DAnCE (%P|%t) NodeApplicationManager_Impl.cpp -"
                    "CIAO::NodeApplicationManager_Impl::create_connections -"
                    "adding connection for consumer [%s] in instance [%s] \n",
                    conn.portName.in (), conn.instanceName.in ()));
        }
      conn.kind = Deployment::EventConsumer;
      conn.endpoint = CORBA::Object::_duplicate (consumers[i]->consumer ());
      ++len;
    }
  }
  return retv._retn ();
}

Deployment::Application_ptr
CIAO::NodeApplicationManager_Impl_Base::
startLaunch (const Deployment::Properties & configProperty,
             Deployment::Connections_out providedReference,
             CORBA::Boolean start
             ACE_ENV_ARG_DECL)
  ACE_THROW_SPEC ((CORBA::SystemException,
                   Deployment::ResourceNotAvailable,
                   Deployment::StartError,
                   Deployment::InvalidProperty))
{
  ACE_TRY
    {

      CIAO_TRACE("CIAO::NodeApplicationManager_Impl::startLaunch");
      ACE_UNUSED_ARG (configProperty);
      ACE_UNUSED_ARG (start);
      /**
       *  1. First Map properties to TAO/CIAO specific property/configurations
       *  2. Necessary property checking (needed?)
       *  3. Call create_nade_application to spawn new process.
       *  4. Initialize the NodeApplication.
       *  5. get the provided connection endpoints back and return them.
       */

      NodeImplementationInfoHandler handler (this->plan_);

      Deployment::NodeImplementationInfo * node_info =
        handler.node_impl_info ();

      if (!node_info)
        {
          ACE_ERROR ((LM_ERROR, 
                      "DAnCE (%P|%t) NodeApplicationManager.cpp -"
                      "CIAO::NodeApplicationManager_Impl::startLaunch -"
                      "Failed to create Node Implementation Infos!\n"));

          ACE_TRY_THROW 
            (Deployment::StartError ("NodeApplicationManager_Imp::startLaunch",
                                     "Unable to get node level infos"));
        }

      // Now spawn the NodeApplication process.
      // @@TODO: we need to pass arguments to the nodeapplication, ie naming service endpoints, if necessary
      // (will)
      ACE_CString cmd_option (this->nodeapp_command_op_.in ());
      Deployment::NodeApplication_var tmp =
        create_node_application (cmd_option.c_str () ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      if (CIAO::debug_level () > 9)
        {
          CORBA::ULong curr_len = node_info->impl_infos.length ();
          ACE_UNUSED_ARG (curr_len);

          Deployment::ComponentImplementationInfos infos =
            ((node_info->impl_infos)[0]).impl_infos;

          const CORBA::ULong info_len = infos.length ();
          for (CORBA::ULong i = 0; i < info_len; ++i)
            {
              ACE_DEBUG ((LM_DEBUG, 
                          "DAnCE (%P|%t) NodeApplicationManager.cpp -"
                          "CIAO::NodeApplicationManager_Impl::startLaunch -"
                          "The info for installation: "
                          "\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n",
                          infos[i].component_instance_name.in (),
                          infos[i].executor_dll.in (),
                          infos[i].executor_entrypt.in (),
                          infos[i].servant_dll.in (),
                          infos[i].servant_entrypt.in () ));
            }
        }

      // This is what we will get back, a sequence of compoent object refs.
      Deployment::ComponentInfos_var comp_info;

      // This will install all homes and components.
      comp_info = this->nodeapp_->install (*node_info ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      // Now fill in the map we have for the components.
      const CORBA::ULong comp_len = comp_info->length ();
      for (CORBA::ULong len = 0;
           len < comp_len;
           ++len)
        {
          //Since we know the type ahead of time...narrow is omitted here.
          if (this->component_map_.
              bind (comp_info[len].component_instance_name.in(),
                    Components::CCMObject::_duplicate 
                       (comp_info[len].component_ref.in())))
            {
              ACE_CString error ("Duplicate component instance name ");
              error += comp_info[len].component_instance_name.in();

              ACE_TRY_THROW 
                (Deployment::StartError 
                   ("NodeApplicationManager_Impl::startLaunch",
                     error.c_str ()));
            }
        }

      providedReference = 
        this->create_connections (ACE_ENV_SINGLE_ARG_PARAMETER);
      ACE_TRY_CHECK;

      if (providedReference == 0)
        {
          ACE_TRY_THROW 
            (Deployment::StartError 
               ("NodeApplicationManager_Impl::startLaunch",
                "Error creating connections during startLaunch."));
        }
    }
  ACE_CATCH (Deployment::UnknownImplId, e)
    {
      ACE_THROW_RETURN (Deployment::StartError (e.name.in (),
						e.reason.in ()),
			Deployment::Application::_nil());
    }
  ACE_CATCH (Deployment::ImplEntryPointNotFound, e)
    {
      ACE_THROW_RETURN (Deployment::StartError (e.name.in (),
						e.reason.in ()),
			Deployment::Application::_nil());
    }
  ACE_CATCH (Deployment::InstallationFailure,e)
    {
      ACE_THROW_RETURN (Deployment::StartError (e.name.in (),
						e.reason.in ()),
			Deployment::Application::_nil());
    }
  ACE_ENDTRY;
  ACE_CHECK_RETURN (Deployment::Application::_nil());

  return Deployment::NodeApplication::_duplicate (this->nodeapp_.in ());
}


Deployment::Application_ptr
CIAO::NodeApplicationManager_Impl_Base::
perform_redeployment (const Deployment::Properties & configProperty,
                      Deployment::Connections_out providedReference,
                      CORBA::Boolean start
                      ACE_ENV_ARG_DECL)
  ACE_THROW_SPEC ((Deployment::InstallationFailure,
                    Deployment::UnknownImplId,
                    Deployment::ImplEntryPointNotFound,
                    Deployment::InvalidConnection,
                    Deployment::InvalidProperty,
                    ::Components::RemoveFailure))

{
  CIAO_TRACE ("CIAO::NodeApplicationManager_Impl_Base::perform_redeployment");

  ACE_DEBUG ((LM_DEBUG,
              "CIAO (%P|%t) NodeApplicationManager_Impl_Base: "
              "invoked CIAO::NodeApplicationManager_Impl_Base::perform_redeployment \n"));

  return 0;
}

void
CIAO::NodeApplicationManager_Impl_Base::
destroyApplication (Deployment::Application_ptr app
                    ACE_ENV_ARG_DECL)
  ACE_THROW_SPEC ((CORBA::SystemException,
                   Deployment::StopError))
{
  CIAO_TRACE("CIAO::NodeApplicationManager_Impl::destroyApplication");
  ACE_UNUSED_ARG (app);
  printf("Entering NAM_Impl::destroyApplication\n");

  //ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_);
  //@@ Since we know there is only 1 nodeapp so the passed in
  //   parameter is ignored for now.
  if (CORBA::is_nil (this->nodeapp_.in () ))
    ACE_THROW (Deployment::StopError ());

  this->nodeapp_->remove (ACE_ENV_SINGLE_ARG_PARAMETER);
  ACE_CHECK;

  printf("Exiting NAM_Impl::destroyApplication\n");
  return;
}


CIAO::NodeApplicationManager_Impl::~NodeApplicationManager_Impl (void)
{
}

CIAO::NodeApplicationManager_Impl::
NodeApplicationManager_Impl (CORBA::ORB_ptr o,
                             PortableServer::POA_ptr p)
  : NodeApplicationManager_Impl_Base (o, p)
{
}

PortableServer::ObjectId
CIAO::NodeApplicationManager_Impl::init (
    const char *nodeapp_location,
    const char *nodeapp_op,
    const CORBA::ULong delay,
    const Deployment::DeploymentPlan & plan,
    const PortableServer::POA_ptr callback_poa
    ACE_ENV_ARG_DECL)
  ACE_THROW_SPEC ((CORBA::SystemException,
                   Deployment::InvalidProperty))
{
  PortableServer::ObjectId_var oid;

  ACE_TRY
    {
      if (nodeapp_location == 0)
        {
          ACE_ERROR ((LM_ERROR,
                      "DAnCE (%P|%t) NodeApplicationManager_Impl.cpp -"
                      "CIAO::NodeApplicationManager_Impl::init -"
                      "NULL NodeApplication location. \n"));
          ACE_TRY_THROW (CORBA::BAD_PARAM ());
        }
      
      
      if (delay == 0)
        {
          ACE_ERROR ((LM_ERROR, 
                      "DAnCE (%P|%t) NodeApplicationManager_Impl.cpp -"
                      "CIAO::NodeApplicationManager_Impl::init -"
                      "NodeManager must be started with a -d "
                      "of greter than zero.\n"));
          ACE_TRY_THROW (CORBA::BAD_PARAM ());
        }
      
      this->nodeapp_path_.set (nodeapp_location);
      this->spawn_delay_ = delay;
      this->nodeapp_command_op_ = CORBA::string_dup (nodeapp_op);

      // Make a copy of the plan for later usage.
      this->plan_ =  plan;

      // Cache the call back POA for callback object.
      this->callback_poa_ = PortableServer::POA::_duplicate (callback_poa);

      // Activate the ourself.
      oid = this->poa_->activate_object (this
                                         ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      CORBA::Object_var obj =
        this->poa_->id_to_reference (oid.in ()
                                     ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      // And cache the object reference.
      this->objref_ =
        Deployment::NodeApplicationManager::_narrow (obj.in ()
                                                     ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;
    }
  ACE_CATCHANY
    {
      ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
                           "NodeApplicationManager_Impl_Base::init\t\n");
      ACE_RE_THROW;
    }
  ACE_ENDTRY;
  ACE_CHECK_RETURN (0);

  //return this object reference
  return oid.in ();
}

Deployment::NodeApplication_ptr
CIAO::NodeApplicationManager_Impl::
create_node_application (const ACE_CString & options
                         ACE_ENV_ARG_DECL)
  ACE_THROW_SPEC ((CORBA::SystemException,
                   Deployment::ResourceNotAvailable,
                   Deployment::StartError,
                   Deployment::InvalidProperty))
{
  CIAO_TRACE("CIAO::NodeApplicationManager_Impl::create_node_application");
  Deployment::NodeApplication_var retval;
  Deployment::Properties_var prop;

  ACE_NEW_THROW_EX (prop,
                    Deployment::Properties,
                    CORBA::INTERNAL ());
  ACE_CHECK_RETURN (Deployment::NodeApplication::_nil());

  // @@ Create a new callback servant.
  CIAO::NodeApplication_Callback_Impl * callback_servant = 0;
  ACE_NEW_THROW_EX (callback_servant,
                    CIAO::NodeApplication_Callback_Impl (this->orb_.in (),
                                                    this->callback_poa_.in (),
                                                    this->objref_.in (),
                                                    prop.in ()),
                                                    CORBA::NO_MEMORY ());
  ACE_CHECK_RETURN (Deployment::NodeApplication::_nil());

  PortableServer::ServantBase_var servant_var (callback_servant);
  PortableServer::ObjectId_var cb_id
    = this->callback_poa_->activate_object (callback_servant
                                            ACE_ENV_ARG_PARAMETER);
  ACE_CHECK_RETURN (Deployment::NodeApplication::_nil());

  ACE_Process node_application;
  ACE_Process_Options p_options;

  ACE_TRY
    {
      CORBA::Object_var cb_obj =
        this->callback_poa_->id_to_reference (cb_id.in ()
                                              ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      CIAO::NodeApplication_Callback_var cb =
        CIAO::NodeApplication_Callback::_narrow (cb_obj.in ()
                                                 ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      CORBA::String_var cb_ior =
        this->orb_->object_to_string (cb.in ()
                                      ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      // spawn the new NodeApplication.
      p_options.command_line ("%s -k %s "
                              "%s",
                              this->nodeapp_path_.c_str (),
                              cb_ior.in (),
                              options.c_str ());

      p_options.avoid_zombies (1);

      if (node_application.spawn (p_options) == -1)
        {
          if (CIAO::debug_level () > 1)
            {
              ACE_DEBUG ((LM_ERROR, 
                          "Fail to spawn a NodeApplication process\n"));
            }

          ACE_TRY_THROW 
            (Deployment::ResourceNotAvailable 
               ("Failed to spawn process",
                "NodeApplication",
                "",
                "",
                ""));
        }

      // wait for nodeApp to pass back its object reference. with a
      // timeout value. using perform_work and stuff.

      int looping = 1;

      ACE_Time_Value timeout (this->spawn_delay_, 0);

      while (looping)
        {
          this->orb_->perform_work (timeout
                                    ACE_ENV_ARG_PARAMETER);
          ACE_TRY_CHECK;

          retval = callback_servant->get_nodeapp_ref ();

          if (timeout == ACE_Time_Value::zero || !CORBA::is_nil (retval.in ()))
            looping = 0;
        }

      if (CORBA::is_nil (retval.in ()))
        {
          if (CIAO::debug_level () > 1)
            {
              ACE_ERROR ((LM_ERROR, 
                          "Fail to acquire the NodeApplication object\n"));
            }

          ACE_TRY_THROW (Deployment::ResourceNotAvailable ());
        }

      {
        //ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0);
        this->nodeapp_ = 
            Deployment::NodeApplication::_duplicate (retval.in ());
      }
    }
  ACE_CATCHANY
    {
      this->callback_poa_->deactivate_object (cb_id.in ());
      ACE_TRY_CHECK;

      ACE_RE_THROW;
    }
  ACE_ENDTRY;
  ACE_CHECK_RETURN (Deployment::NodeApplication::_nil ());

  this->callback_poa_->deactivate_object (cb_id.in () ACE_ENV_ARG_PARAMETER);
  ACE_CHECK_RETURN (Deployment::NodeApplication::_nil ());

  if (CIAO::debug_level () > 1)
    {
      ACE_DEBUG ((LM_DEBUG, 
            "CIAO::NodeApplicationManager_Impl::NodeApplication spawned!\n"));
    }

  return retval._retn ();
}

CIAO::Static_NodeApplicationManager_Impl::~Static_NodeApplicationManager_Impl (void)
{
}

CIAO::Static_NodeApplicationManager_Impl::
Static_NodeApplicationManager_Impl (CORBA::ORB_ptr o,
                             PortableServer::POA_ptr p,
                             Static_Config_EntryPoints_Maps* static_config_entrypoints_maps)
  : NodeApplicationManager_Impl_Base (o, p),
    static_config_entrypoints_maps_ (static_config_entrypoints_maps)
{
}

PortableServer::ObjectId
CIAO::Static_NodeApplicationManager_Impl::init (
    const char *nodeapp_location,
    const char *nodeapp_op,
    const CORBA::ULong delay,
    const Deployment::DeploymentPlan & plan,
    const PortableServer::POA_ptr callback_poa
    ACE_ENV_ARG_DECL)
  ACE_THROW_SPEC ((CORBA::SystemException,
                   Deployment::InvalidProperty))
{
  PortableServer::ObjectId_var oid;

  ACE_UNUSED_ARG (nodeapp_location);
  ACE_UNUSED_ARG (nodeapp_op);
  ACE_UNUSED_ARG (delay);
  ACE_UNUSED_ARG (callback_poa);

  ACE_TRY
    {
      // Make a copy of the plan for later usage.
      this->plan_ =  plan;

      // Activate the ourself.
      oid = this->poa_->activate_object (this
                                         ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      CORBA::Object_var obj =
        this->poa_->id_to_reference (oid.in ()
                                     ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      // And cache the object reference.
      this->objref_ =
        Deployment::NodeApplicationManager::_narrow (obj.in ()
                                                     ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;
    }
  ACE_CATCHANY
    {
      ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
                           "NodeApplicationManager_Impl_Base::init\t\n");
      ACE_RE_THROW;
    }
  ACE_ENDTRY;
  ACE_CHECK_RETURN (0);

  //return this object reference
  return oid.in ();
}

Deployment::NodeApplication_ptr
CIAO::Static_NodeApplicationManager_Impl::
create_node_application (const ACE_CString & options
                         ACE_ENV_ARG_DECL)
  ACE_THROW_SPEC ((CORBA::SystemException,
                   Deployment::ResourceNotAvailable,
                   Deployment::StartError,
                   Deployment::InvalidProperty))
{
  ACE_UNUSED_ARG(options);

  CIAO::NodeApplication_Impl *nodeapp_servant;

  ACE_DEBUG ((LM_DEBUG, "create_static_node_application\n"));

  ACE_NEW_RETURN (nodeapp_servant,
                   CIAO::NodeApplication_Impl (orb_.in (),
                                               poa_.in (),
                                               configurator_,
                                               this->static_config_entrypoints_maps_),
                  Deployment::NodeApplication::_nil ()
                   );
  if (nodeapp_servant->init (ACE_ENV_SINGLE_ARG_PARAMETER))
    {
      ACE_DEBUG ((LM_DEBUG, "NodeApplication Failed on creating and\
                               initializing the session container!"));
      return Deployment::NodeApplication::_nil ();
    }
  ACE_TRY_CHECK;

  // CONFIGURING NodeApplication
  PortableServer::ObjectId_var nodeapp_oid
    = poa_->activate_object (nodeapp_servant
                            ACE_ENV_ARG_PARAMETER);
  ACE_TRY_CHECK;
  
  CORBA::Object_var
    obj = poa_->id_to_reference (nodeapp_oid.in ()
                              ACE_ENV_ARG_PARAMETER);
  ACE_TRY_CHECK;
  
  Deployment::NodeApplication_var nodeapp_obj =
    Deployment::NodeApplication::_narrow (obj.in ()
                                          ACE_ENV_ARG_PARAMETER);
  ACE_TRY_CHECK;
  
  if (CORBA::is_nil (nodeapp_obj.in ()))
    {
      ACE_ERROR ((LM_ERROR, "Unable to activate NodeApplication object\n"));
      return Deployment::NodeApplication::_nil ();
    }

  this->nodeapp_ = Deployment::NodeApplication::_duplicate (nodeapp_obj.in ());

  return nodeapp_obj._retn ();
}