1 #include "tao/Strategies/COIOP_Connector.h"
3 #if defined (TAO_HAS_COIOP) && (TAO_HAS_COIOP != 0)
5 #include "ace/Connector.h"
7 #include "tao/ORB_Core.h"
8 #include "tao/SystemException.h"
9 #include "ace/OS_NS_strings.h"
10 #include "ace/OS_NS_string.h"
11 #include "tao/Strategies/COIOP_Profile.h"
14 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
16 TAO_COIOP_Connector::TAO_COIOP_Connector ()
17 : TAO_Connector (TAO_TAG_COIOP_PROFILE
)
22 TAO_COIOP_Connector::open (TAO_ORB_Core
*orb_core
)
24 this->orb_core (orb_core
);
26 // Create our connect strategy
27 if (this->create_connect_strategy () == -1)
34 TAO_COIOP_Connector::close ()
40 TAO_COIOP_Connector::set_validate_endpoint (TAO_Endpoint
*endpoint
)
42 TAO_COIOP_Endpoint
*COIOP_endpoint
=
43 this->remote_endpoint (endpoint
);
45 if (COIOP_endpoint
== 0)
52 TAO_COIOP_Connector::make_connection (TAO::Profile_Transport_Resolver
*,
53 TAO_Transport_Descriptor_Interface
&,
54 ACE_Time_Value
* /*max_wait_time*/)
56 // No remote connection possible with COIOP
61 TAO_COIOP_Connector::create_profile (TAO_InputCDR
& cdr
)
63 TAO_Profile
*pfile
= 0;
64 ACE_NEW_RETURN (pfile
,
65 TAO_COIOP_Profile (this->orb_core ()),
68 int const r
= pfile
->decode (cdr
);
71 pfile
->_decr_refcnt ();
79 TAO_COIOP_Connector::make_profile ()
81 // The endpoint should be of the form:
82 // N.n@uuid/object_key
86 TAO_Profile
*profile
= 0;
87 ACE_NEW_THROW_EX (profile
,
88 TAO_COIOP_Profile (this->orb_core ()),
90 CORBA::SystemException::_tao_minor_code (
93 CORBA::COMPLETED_NO
));
99 TAO_COIOP_Connector::check_prefix (const char *endpoint
)
101 // Check for a valid string
102 if (!endpoint
|| !*endpoint
)
103 return -1; // Failure
105 const char *protocol
[] = { "COIOP", "COIOPloc" };
107 size_t const slot
= std::strchr (endpoint
, ':') - endpoint
;
109 size_t const len0
= std::strlen (protocol
[0]);
110 size_t const len1
= std::strlen (protocol
[1]);
112 // Check for the proper prefix in the IOR. If the proper prefix
113 // isn't in the IOR then it is not an IOR we can use.
115 && ACE_OS::strncasecmp (endpoint
, protocol
[0], len0
) == 0)
117 else if (slot
== len1
118 && ACE_OS::strncasecmp (endpoint
, protocol
[1], len1
) == 0)
122 // Failure: not an COIOP IOR
123 // DO NOT throw an exception here.
127 TAO_COIOP_Connector::object_key_delimiter () const
129 return TAO_COIOP_Profile::object_key_delimiter_
;
133 TAO_COIOP_Connector::remote_endpoint (TAO_Endpoint
*endpoint
)
135 if (endpoint
->tag () != TAO_TAG_COIOP_PROFILE
)
138 TAO_COIOP_Endpoint
*COIOP_endpoint
=
139 dynamic_cast<TAO_COIOP_Endpoint
*> (endpoint
);
141 return COIOP_endpoint
;
145 TAO_COIOP_Connector::cancel_svc_handler (
146 TAO_Connection_Handler
* /* svc_handler */)
151 TAO_END_VERSIONED_NAMESPACE_DECL
153 #endif /* TAO_HAS_COIOP && TAO_HAS_COIOP != 0 */