summaryrefslogtreecommitdiff
path: root/TAO/local/bin/Scheduling_Service/schedule_service.cpp
blob: 8be94d60c933c9e17ac2c6223cf4562e400eb857 (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
//
// $Id$
//

#include "tao/corba.h"

#include "CosNamingC.h"
#include "Config_Scheduler.h"

int main (int argc, char *argv[])
{
  ACE_TRY
    {
      // Initialize ORB.
      CORBA::ORB_ptr orb = 
	CORBA::ORB_init (argc, argv, "internet", ACE_TRY_ENV);
      ACE_CHECK_ENV;

      CORBA::POA_ptr poa =
	orb->POA_init(argc, argv, "POA");
      if (poa == 0)
	{
	  ACE_ERROR_RETURN ((LM_ERROR,
			     " (%P|%t) Unable to initialize the POA.\n"),
			    1);
	}

#if 0
      CORBA::Object_ptr objref =
	orb->resolve_initial_references ("NameService");
      ACE_CHECK_ENV;

      CosNaming::NamingContext_var naming_context = 
        CosNaming::NamingContext::_narrow (objref, ACE_TRY_ENV);
      ACE_CHECK_ENV;
#endif

      // Create an Scheduling service servant...
      RtecScheduler::Scheduler_ptr scheduler = new ACE_Config_Scheduler;
      // CORBA::Object::_duplicate(scheduler);
      ACE_CHECK_ENV;

      CORBA::String str =
	orb->object_to_string (scheduler, ACE_TRY_ENV);
      ACE_OS::puts ((char *) str);

#if 0
      // Register the servant with the Naming Context....
      CosNaming::Name schedule_name (1);
      schedule_name[0].id = CORBA::string_dup ("ScheduleService");
      schedule_name.length (1);
      naming_context->bind (schedule_name, scheduler, ACE_TRY_ENV);
      ACE_CHECK_ENV;
#endif

      ACE_DEBUG ((LM_DEBUG, "running scheduling service\n"));
      if (orb->run () == -1)
	{
	  ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "run"), 1);
	}

      CORBA::release (scheduler);
    }
  ACE_CATCHANY
    {
      ACE_TRY_ENV.print_exception ("schedule_service");
    }
  ACE_ENDTRY;

  return 0;
}