3 //=============================================================================
5 * @file Transport_Acceptor.h
7 * Interface for the Acceptor component of the TAO pluggable protocol
10 * @author Fred Kuhns <fredk@cs.wustl.edu>
12 //=============================================================================
14 #ifndef TAO_ACCEPTOR_H
15 #define TAO_ACCEPTOR_H
17 #include /**/ "ace/pre.h"
19 #include /**/ "tao/TAO_Export.h"
21 #if !defined (ACE_LACKS_PRAGMA_ONCE)
23 #endif /* ACE_LACKS_PRAGMA_ONCE */
25 #include "ace/Acceptor.h"
26 #include "tao/Basic_Types.h"
28 // Forward declarations.
29 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
32 ACE_END_VERSIONED_NAMESPACE_DECL
34 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
51 //@@ TAO_ACCEPTOR_SPL_INCLUDE_FORWARD_DECL_ADD_HOOK
53 // ****************************************************************
55 /// The TAO-specific OMG assigned value for the TAG_ORB_TYPE tagged
58 * This number was assigned by the OMG. Do *NOT* change. The ASCII
59 * representation is "TA\x00". If necessary, we can request more ORB
62 const CORBA::ULong TAO_ORB_TYPE
= 0x54414f00U
;
64 // ****************************************************************
69 * @brief Abstract Acceptor class used for pluggable transports.
71 * Base class for the Acceptor bridge class.
73 * @todo Need to rename the class as TAO_Transport_Acceptor.
75 class TAO_Export TAO_Acceptor
78 TAO_Acceptor (CORBA::ULong tag
);
81 virtual ~TAO_Acceptor (void);
83 /// The tag, each concrete class will have a specific tag value.
84 CORBA::ULong
tag (void) const;
86 /// Set the amount of time to delay accepting new connections in the
87 /// event that we encounter an error that may be transient.
88 void set_error_retry_delay (time_t delay
);
90 /// Method to initialize acceptor for address.
91 virtual int open (TAO_ORB_Core
*orb_core
,
96 const char *options
= 0) = 0;
99 * Open an acceptor with the given protocol version on a default
102 virtual int open_default (TAO_ORB_Core
*,
103 ACE_Reactor
*reactor
,
106 const char *options
= 0) = 0;
108 /// Closes the acceptor
109 virtual int close (void) = 0;
112 * Create the corresponding profile for this endpoint.
113 * If share_profile is set to true, the pluggable protocol
114 * implementation should try to add the endpoint to a profile
115 * in the mprofile that is of the same type. Currently, this
116 * is used when RT CORBA is enabled.
118 virtual int create_profile (const TAO::ObjectKey
&object_key
,
119 TAO_MProfile
&mprofile
,
120 CORBA::Short priority
) = 0;
122 /// Return 1 if the @a endpoint has the same address as the acceptor.
123 virtual int is_collocated (const TAO_Endpoint
*endpoint
) = 0;
126 * Returns the number of endpoints this acceptor is listening on. This
127 * is used for determining how many profiles will be generated
130 virtual CORBA::ULong
endpoint_count (void) = 0;
133 * This method fetches the @a key from the @a profile. Protocols that
134 * are pluggable can send data that are specific in the
135 * @c profile_data field encapsulated as a octet stream. This method
136 * allows those protocols to get the object key from the
139 virtual int object_key (IOP::TaggedProfile
&profile
,
140 TAO::ObjectKey
&key
) = 0;
142 /// This method is not directly associated with the method of the same
143 /// name on the ACE_Acceptor template class. However, it is called by
144 /// the TAO_Strategy_Acceptor method of the same name.
145 int handle_accept_error (ACE_Event_Handler
* base_acceptor
);
147 /// Perform the handle_timeout functionality to put this acceptor back
148 /// into the reactor to try accepting again.
149 int handle_expiration (ACE_Event_Handler
* base_acceptor
);
152 * Hook to add public methods from derived acceptor classes onto
155 //@@ TAO_ACCEPTOR_SPL_PUBLIC_METHODS_ADD_HOOK
158 /// IOP protocol tag.
159 CORBA::ULong
const tag_
;
161 time_t error_retry_delay_
;
164 * Hook to add data members from concrete acceptor implementations onto
167 //@@ TAO_ACCEPTOR_SPL_DATA_MEMBERS_ADD_HOOK
170 /// This is a drop-in replacement class for the ACE_Strategy_Acceptor.
171 /// It provides all of the same functionality and the additional
172 /// functionality of handling accept() errors with some sort of
173 /// configured action. All of the actual code is in the TAO_Acceptor
174 /// to avoid multiply-instantiated code that would be, in effect,
177 /// It is not declared nested within TAO_Acceptor as I originally wanted
178 /// because it caused an internal compiler error for the Tornado 2.2.1
180 template <class SVC_HANDLER
, ACE_PEER_ACCEPTOR_1
>
181 class TAO_Strategy_Acceptor
:
182 public ACE_Strategy_Acceptor
<SVC_HANDLER
, ACE_PEER_ACCEPTOR_2
>
185 TAO_Strategy_Acceptor (TAO_Acceptor
* acceptor
)
186 : acceptor_ (acceptor
)
190 virtual int handle_accept_error (void)
192 return this->acceptor_
->handle_accept_error (this);
195 virtual int handle_timeout (const ACE_Time_Value
&, const void*)
197 return this->acceptor_
->handle_expiration (this);
201 TAO_Acceptor
* acceptor_
;
204 //@@ TAO_ACCEPTOR_SPL_EXTERN_ADD_HOOK
206 TAO_END_VERSIONED_NAMESPACE_DECL
208 #if defined (__ACE_INLINE__)
209 # include "tao/Transport_Acceptor.inl"
210 #endif /* __ACE_INLINE__ */
212 #include /**/ "ace/post.h"
214 #endif /* TAO_ACCEPTOR_H */