summaryrefslogtreecommitdiff
path: root/TAO/tao/Pluggable.cpp
blob: 766a2dd06f91cbeb43d86501c603c581e9711aa0 (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
// This may look like C, but it's really -*- C++ -*-
// $Id$

// ============================================================================
//
// = LIBRARY
//
// = FILENAME
//
// = DESCRIPTION
//
// = AUTHOR
//
// ============================================================================

#include "tao/Pluggable.h"
#include "tao/Stub.h"
#include "tao/Environment.h"
#include "tao/GIOP.h"

TAO_Connector_Registry::TAO_Connector_Registry()
  : iiop_connector_(0)
{
}

TAO_Connector_Registry::~TAO_Connector_Registry()
{
}

TAO_Connector *
TAO_Connector_Registry::get_connector (CORBA::ULong tag)
{
  // For now, only IIOP connectors.
  if (tag != TAO_IOP_TAG_INTERNET_IOP)
  {
    ACE_DEBUG ((LM_DEBUG, "Invalid connector tag %d\n", tag));
    return 0;
  }

  return iiop_connector_;
}

CORBA::Boolean
TAO_Connector_Registry::add_connector (TAO_Connector *connector)
{

  if (connector->tag() == TAO_IOP_TAG_INTERNET_IOP)
  {
    // do not copy, but save the reference (i.e. pointer)
    this->iiop_connector_ = connector;
    return 1;
  }
  ACE_DEBUG ((LM_DEBUG, "Invalid connector tag %d\n", connector->tag()));
  return 0;
}

int
TAO_Connector_Registry::open(TAO_Resource_Factory *trf, ACE_Reactor *reactor)
{
  // @@ Once again since we only accept 1 iiop connector, this is easy
  if (iiop_connector_)
    return this->iiop_connector_->open (trf, reactor);
  return 0;
}

int
TAO_Connector_Registry::close_all()
{
  // @@ Loop through all registered connectors ... not too hard
  //    since there is only one!
  if (iiop_connector_)
    return this->iiop_connector_->close ();
  return 0;
}

int
TAO_Connector_Registry::preconnect (const char* the_preconnections)
{
  // It would be good to use auto_ptr<> to guard against premature
  // termination and, thus, leaks.
  int result=0;
  char *preconnections = ACE_OS::strdup (the_preconnections);

  // @@ OK, what we should do is parse the string so that we can gather
  // @@ together addresses of the same protocol together and pass to the
  // @@ appropriate connector.  But, for now we ASSUME they are all
  // @@ INET IP:Port!! HACK. fredk

  if (this->iiop_connector_)
    result = this->iiop_connector_->preconnect(preconnections);

  ACE_OS::free (preconnections);

  return result;

}

TAO_Profile *
TAO_Connector_Registry::connect (STUB_Object *&obj,
                                 CORBA::Environment &env)
{
  TAO_Profile *profile;
  CORBA::ULong req_tag = TAO_IOP_TAG_INTERNET_IOP;

  // @@ FRED _ For now still only support ONE profile!
  if (! (profile = obj->get_fwd_profile ()))
    profile = obj->profile_in_use ();

  // @@ And the profile selection policy is .... ONLY IIOP, and the
  // @@ first one found!
  if (profile->tag () != req_tag)
  {
    TAO_THROW_ENV_RETURN (CORBA::INTERNAL (CORBA::COMPLETED_NO), env, 0);
  }

  // obj->set_profile_in_use (profile);

  // here is where we get the appropriate connector object
  // but we are the Connector Registry so call get_connector(tag)

  TAO_Connector *connector = this->get_connector(req_tag);

  TAO_Transport *transport = connector->connect(profile, env);
  TAO_CHECK_ENV_RETURN (env, 0);

  if (transport == 0)
    return 0;

  return profile;
}

Version::~Version (void)
{
}

Version::Version (const Version &src)
  : major (src.major),
    minor (src.minor)
{
}

Version::Version (CORBA::Octet maj, CORBA::Octet min)
  : major (maj),
    minor (min)
{
}

void
Version::set_version (CORBA::Octet maj, CORBA::Octet min)
{
  this->major = maj;
  this->minor = min;
}

int
Version::operator== (const Version *&src)
{
  return (this->major == src->major && this->minor == src->minor);
}

int
Version::operator== (const Version &src)
{
  return (this->major == src.major && this->minor == src.minor);
}

Version &
Version::operator= (const Version &src)
{
  this->major = src.major;
  this->minor = src.minor;
  return *this;
}

TAO_Profile::~TAO_Profile (void)
{
}

TAO_Transport::~TAO_Transport (void)
{
}

TAO_Connector::~TAO_Connector (void)
{
}

TAO_Acceptor::~TAO_Acceptor (void)
{
}