summaryrefslogtreecommitdiff
path: root/TAO/tao/DLL_ORB.cpp
blob: 4c95981bc45ab39bf1574f7cc57aababd15bcd69 (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
// -*- C++ -*-

#include "ace/ARGV.h"
#include "ace/Dynamic_Service.h"
#include "tao/DLL_ORB.h"
#include "tao/TAO_Singleton_Manager.h"
#include "tao/debug.h"

ACE_RCSID (tao,
           DLL_ORB,
           "$Id$")

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

TAO_DLL_ORB::TAO_DLL_ORB (void)
  : orb_ ()
{
  // Nothing
}

TAO_DLL_ORB::~TAO_DLL_ORB (void)
{
  // Nothing
}

int
TAO_DLL_ORB::init (int /*argc*/, ACE_TCHAR *argv[])
{
  // This class is deprecated.  See the class documentation in
  // DLL_ORB.h for details explaining why this is so.
  if (TAO_debug_level > 0)
    ACE_DEBUG ((LM_WARNING,
                ACE_LIB_TEXT ("TAO (%P|%t) - The TAO_DLL_ORB class is ")
                ACE_LIB_TEXT ("deprecated.  See the class documentation\n")
                ACE_LIB_TEXT ("TAO (%P|%t) - `tao/DLL_ORB.h' for details ")
                ACE_LIB_TEXT ("explaining why this is so.\n")));


  // Make sure TAO's singleton manager is initialized, and set to not
  // register itself with the ACE_Object_Manager since it is under the
  // control of the Service Configurator.
  int register_with_object_manager = 0;

  if (TAO_Singleton_Manager::instance ()->init (
        register_with_object_manager) == -1)
    return -1;  // No exceptions yet.

  ACE_TRY_NEW_ENV
    {
      ACE_ARGV new_argv;

      if (new_argv.add (ACE_TEXT ("dummy")) == -1
          || new_argv.add (argv) == -1)
        return -1;

      int new_argc = new_argv.argc ();

      // Initialize the ORB.
      this->orb_ = CORBA::ORB_init (new_argc,
                                    new_argv.argv (),
                                    ""
                                     TAO_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      if (CORBA::is_nil (this->orb_.in ()))
        return -1;
    }
  ACE_CATCHANY
    {
      if (TAO_debug_level >= 4)
        ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
                             "TAO_DLL_ORB::init");

      return -1;
    }
  ACE_ENDTRY;

#if defined (ACE_HAS_THREADS)
      // Become an Active Object so that the ORB
      // will execute in a separate thread.
      return this->activate ();
#else
      return 0;
#endif /* ACE_HAS_THREADS */
}

int
TAO_DLL_ORB::fini (void)
{
  ACE_TRY_NEW_ENV
    {
      this->orb_->destroy (TAO_ENV_SINGLE_ARG_PARAMETER);
      ACE_TRY_CHECK;

      if (TAO_Singleton_Manager::instance ()->fini () == -1)
        return -1;
    }
  ACE_CATCHANY
    {
      if (TAO_debug_level >= 4)
        ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
                             "TAO_DLL_ORB::fini");
      return -1;
    }
  ACE_ENDTRY;

  return 0;
}

int
TAO_DLL_ORB::svc (void)
{
  ACE_TRY_NEW_ENV
    {
      // Run the ORB event loop in its own thread.
      this->orb_->run (TAO_ENV_SINGLE_ARG_PARAMETER);
      ACE_TRY_CHECK;
    }
  ACE_CATCHANY
    {
      if (TAO_debug_level >= 4)
        ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
                             "TAO_DLL_ORB::svc");
      return -1;
    }
  ACE_ENDTRY;

  return 0;
}


ACE_STATIC_SVC_DEFINE (TAO_DLL_ORB,
                       ACE_TEXT ("DLL_ORB"),
                       ACE_SVC_OBJ_T,
                       &ACE_SVC_NAME (TAO_DLL_ORB),
                       ACE_Service_Type::DELETE_THIS
                       | ACE_Service_Type::DELETE_OBJ,
                       0)

ACE_FACTORY_DEFINE (TAO, TAO_DLL_ORB)



// Template instantiations necessary for use when dynamically load the
// TAO_DLL_ORB.

#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)

template class ACE_Dynamic_Service<TAO_DLL_ORB>;

#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)

#pragma instantiate ACE_Dynamic_Service<TAO_DLL_ORB>

#endif