summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Event/EC_TPC_Factory.cpp
blob: ab1cc0a43f7dff7cd3443c9876698ece8ccdf6ba (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
// $Id$

#include "orbsvcs/Event/EC_TPC_Factory.h"

#include "orbsvcs/Event/EC_TPC_Dispatching.h"
#include "orbsvcs/Event/EC_TPC_ProxySupplier.h"
#include "orbsvcs/Event/EC_TPC_ProxyConsumer.h"

#include "tao/ORB_Core.h"

#include "ace/Arg_Shifter.h"
#include "ace/Sched_Params.h"
#include "ace/OS_NS_strings.h"

ACE_RCSID(Event, EC_TPC_Factory, "$Id$")

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

unsigned long EC_TPC_debug_level;

TAO_EC_TPC_Factory::TAO_EC_TPC_Factory (void)
{
  EC_TPC_debug_level = 0;
}

TAO_EC_TPC_Factory::~TAO_EC_TPC_Factory (void)
{
}

int
TAO_EC_TPC_Factory::init_svcs (void)
{
  TAO_EC_Simple_Queue_Full_Action::init_svcs();
  return ACE_Service_Config::static_svcs ()->
    insert (&ace_svc_desc_TAO_EC_TPC_Factory);
}

int
TAO_EC_TPC_Factory::init (int argc, ACE_TCHAR* argv[])
{
  ACE_Arg_Shifter arg_shifter (argc, argv);

  while (arg_shifter.is_anything_left ())
    {
      const ACE_TCHAR *arg = arg_shifter.get_current ();

      if (ACE_OS::strcasecmp (arg, ACE_TEXT("-ECDispatching")) == 0)
        {
          arg_shifter.consume_arg ();

          if (arg_shifter.is_parameter_next ())
            {
              // Here we print out a message indicating that this
              // option isn't valid with this factory and that it's
              // being ignored.

              ACE_DEBUG ((LM_ERROR,
                            "EC_TPC_Factory - "
                          "-ECDispatching not supported with TPC_Factory; ignoring the option and using thread-per-consumer dispatch strategy\n"));
              arg_shifter.consume_arg ();
            }
        }
      if (ACE_OS::strcasecmp (arg, ACE_TEXT("-ECTPCDebug")) == 0)
        {
          arg_shifter.consume_arg ();
          ++EC_TPC_debug_level;
        }
      else
        {
          arg_shifter.ignore_arg ();
        }

    }

  return TAO_EC_Default_Factory::init (argc, argv);
}

// ****************************************************************

TAO_EC_Dispatching*
TAO_EC_TPC_Factory::create_dispatching (TAO_EC_Event_Channel_Base *)
{
  if (EC_TPC_debug_level > 0)
    ACE_DEBUG ((LM_DEBUG, "EC (%P|%t) EC_TPC_Factory::create_dispatching\n"));

  TAO_EC_Queue_Full_Service_Object* so =
    this->find_service_object (this->queue_full_service_object_name_.fast_rep(),
                               TAO_EC_DEFAULT_QUEUE_FULL_SERVICE_OBJECT_NAME);
 
  return new TAO_EC_TPC_Dispatching (so);
}


TAO_EC_ProxyPushSupplier*
TAO_EC_TPC_Factory::create_proxy_push_supplier (TAO_EC_Event_Channel_Base *ec)
{
  if (EC_TPC_debug_level > 0)
    ACE_DEBUG ((LM_DEBUG, "EC (%P|%t) EC_TPC_Factory::create_proxy_push_supplier\n"));
  return new TAO_EC_TPC_ProxyPushSupplier (ec, this->consumer_validate_connection_);
}


TAO_EC_ProxyPushConsumer*
TAO_EC_TPC_Factory::create_proxy_push_consumer (TAO_EC_Event_Channel_Base *ec)
{
  if (EC_TPC_debug_level > 0)
    ACE_DEBUG ((LM_DEBUG, "EC (%P|%t) EC_TPC_Factory::create_proxy_push_consumer\n"));
  return new TAO_EC_TPC_ProxyPushConsumer (ec);
}

TAO_END_VERSIONED_NAMESPACE_DECL

// ****************************************************************

ACE_STATIC_SVC_DEFINE (TAO_EC_TPC_Factory,
                       ACE_TEXT ("EC_Factory"),
                       ACE_SVC_OBJ_T,
                       &ACE_SVC_NAME (TAO_EC_TPC_Factory),
                       ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
                       0)
ACE_FACTORY_DEFINE (TAO_RTEvent_Serv, TAO_EC_TPC_Factory)

// ****************************************************************