it_bus_pdk/endpoint.h

00001 #ifndef _IT_BUS_PDK_ENDPOINT_H_
00002 #define _IT_BUS_PDK_ENDPOINT_H_
00003 
00004 // @Copyright 2005 IONA Technologies, Plc. All Rights Reserved.
00005 //
00006 
00007 #include <it_bus/api_defines.h>
00008 
00009 namespace IT_WSDL
00010 {
00011     class WSDLPort;
00012     class WSDLOperation;
00013     class WSDLExtensionElement;
00014 }
00015 
00016 namespace WS_Addressing_2004
00017 {
00018     class AttributedURI;
00019 }
00020 
00021 namespace IT_Bus
00022 {
00023     class String;
00024     class Port;
00025     class SendMessageContext;
00026     class ReceiveMessageContext;
00027     class AnyType;
00028     class SoftStopEndpoint;
00029     class TransactionalEndpoint;
00030     class TransportReadableMessage;
00031     class TransportWritableMessage;
00032     class MessageReader;
00033     class MessageWriter;
00034     class ContextContainer;
00035     class DispatchInfo;
00036 
00037     /*
00038      * The following interface is the base
00039      * class for implementing Endpoint.
00040      * It is also used for implementing
00041      * an asynchronous endpoint.
00042      */
00043     class IT_BUS_API Endpoint
00044     {
00045       public:
00046 
00047         virtual const WS_Addressing_2004::AttributedURI&
00048         get_address() = 0;
00049 
00050         virtual const IT_WSDL::WSDLExtensionElement&
00051         get_configuration() = 0;
00052 
00053         /*
00054          * Sends a message described in the SendMessageContext
00055          * on the endpoint. Optionally returns an AnyType*
00056          * that can hold a message-id understood by the
00057          * caller to correlate with a response received
00058          * via EndpointHandler::message_received()
00059          */
00060         virtual AnyType*
00061         send_message(
00062             SendMessageContext*
00063         ) = 0;
00064 
00065         /*
00066          * close the endpoint
00067          */
00068         virtual void
00069         close() = 0;
00070 
00071         /*
00072          * Returns the underlying softstop endpoint.
00073          * If the endpoint implements a SoftStopEndpoint,
00074          * it could decide to return pointer to itself.
00075          * Alternately, it could simply call the underlying
00076          * endpoint's Endpoint::get_underlying_softstop_endpoint()
00077          * to get an underlying SoftStopEndpoint.
00078          */
00079         virtual SoftStopEndpoint*
00080         get_underlying_softstop_endpoint() = 0;
00081 
00082         /*
00083          * Returns the underlying transactional endpoint.
00084          * If the endpoint implements a TransactionalEndpoint,
00085          * it could decide to return pointer to itself.
00086          * Alternately, it could simply call the underlying
00087          * endpoint's Endpoint::get_underlying_transactional_endpoint()
00088          * to get an underlying SoftStopEndpoint.
00089          */
00090         virtual TransactionalEndpoint*
00091         get_underlying_transactional_endpoint() = 0;
00092 
00093         Endpoint() {}
00094         virtual ~Endpoint();
00095     };
00096 
00097     /*
00098      * The following interface acts as an Observer
00099      * for an asynchronous Endpoint.
00100      */
00101     class IT_BUS_API EndpointHandler
00102     {
00103       public:
00104 
00105        /*
00106         * Notification that the underlying
00107         * endpoint is created.
00108         */
00109         virtual void
00110         endpoint_created(
00111             Endpoint*
00112         ) = 0;
00113 
00114        /*
00115         * When a message is received on the
00116         * underlying asynchronous Endpoint,
00117         * it's delivered via call to
00118         * message_received().
00119         */
00120         virtual void
00121         message_received(
00122             AnyType*,
00123             ReceiveMessageContext*
00124         ) = 0;
00125 
00126        /*
00127         * Notification that the remote
00128         * endpoint is closed.
00129         */
00130         virtual void
00131         remote_endpoint_closed(
00132             const IT_Bus::String& endpoint_id
00133         ) = 0;
00134 
00135        /*
00136         * Notification that the underlying
00137         * endpoint is closed.
00138         */
00139         virtual void
00140         endpoint_closed() = 0;
00141 
00142       protected:
00143 
00144         EndpointHandler() {}
00145         virtual ~EndpointHandler();
00146     };
00147 
00148     /*
00149      * The following interface is used to implement
00150      * a synchronous endpoint.
00151      */
00152     class IT_BUS_API SyncEndpoint
00153         : public Endpoint
00154     {
00155       public:
00156 
00157         /*
00158          * Synchronously sends a request message and
00159          * receives a reply message. Used to implement
00160          * synchronous client endpoints.
00161          */
00162         virtual void
00163         invoke(
00164             SendMessageContext*,
00165             ReceiveMessageContext&
00166         ) = 0;
00167 
00168       protected:
00169 
00170         SyncEndpoint() {}
00171         virtual ~SyncEndpoint();
00172     };
00173 
00174     /*
00175      * The following interface is used to implement
00176      * a SoftStop endpoint.
00177      */
00178     class IT_BUS_API SoftStopEndpoint
00179         : public Endpoint
00180     {
00181       public:
00182 
00183         /*
00184          * Deactivates the endpoint. The caller
00185          * could then either call reactivate() to
00186          * reactivate the endpoint, or call close()
00187          * to close the endpoint
00188          */
00189         virtual void
00190         deactivate() = 0;
00191 
00192         /*
00193          * Reactivates the deactivated endpoint.
00194          */
00195         virtual void
00196         reactivate() = 0;
00197 
00198         virtual void
00199         get_reference_with_id(
00200             const IT_Bus::String& instance_id,
00201             IT_WSDL::WSDLPort&    wsdl_port
00202         ) = 0;
00203 
00204       protected:
00205 
00206         SoftStopEndpoint() {}
00207         virtual ~SoftStopEndpoint();
00208     };
00209 
00210     /*
00211      * The following interface is used to implement
00212      * a Transactional endpoint.
00213      */
00214     class IT_BUS_API TransactionalEndpoint
00215         : public Endpoint
00216     {
00217       public:
00218 
00219         virtual bool
00220         supports_transactions() = 0;
00221 
00222         virtual void
00223         begin() = 0;
00224 
00225         virtual void
00226         commit() = 0;
00227 
00228         virtual void
00229         rollback() = 0;
00230 
00231       protected:
00232 
00233         TransactionalEndpoint() {}
00234         virtual ~TransactionalEndpoint();
00235     };
00236 
00237     /*
00238      * The following interface is used as a factory
00239      * to create synchronous endpoints and asynchronous
00240      * endpoints. The caller passes his implementation
00241      * of an EndpointHandler while requesting for creating
00242      * a Synchronous Endpoint. An Endpoint is created
00243      * either from a WS-Addressing EPR or a WSDLPort.
00244      */
00245     class IT_BUS_API EndpointManager
00246     {
00247       public:
00248 
00249         virtual void
00250         initialize() = 0;
00251 
00252         virtual SyncEndpoint*
00253         create_sync_endpoint(
00254             const IT_WSDL::WSDLPort& wsdl_port,
00255             ContextContainer*        context_container
00256         ) = 0;
00257 
00258         virtual SyncEndpoint*
00259         create_sync_endpoint(
00260             const IT_WSDL::WSDLPort&                 wsdl_port,
00261             const WS_Addressing_2004::AttributedURI& to_address,
00262             ContextContainer*                        context_container
00263         ) = 0;
00264 
00265         virtual Endpoint*
00266         create_async_endpoint(
00267             const IT_WSDL::WSDLPort& wsdl_port,
00268             EndpointHandler*         endpoint_handler,
00269             ContextContainer*        context_container
00270         ) = 0;
00271 
00272         virtual Endpoint*
00273         create_async_endpoint(
00274             const IT_WSDL::WSDLPort&                 wsdl_port,
00275             const WS_Addressing_2004::AttributedURI& listento_address,
00276             EndpointHandler*                         endpoint_handler,
00277             ContextContainer*                        context_container
00278         ) = 0;
00279 
00280         virtual SendMessageContext*
00281         create_send_message_context(
00282             IT_WSDL::WSDLOperation*,
00283             TransportWritableMessage*,
00284             MessageWriter*,
00285             ContextContainer*,
00286             DispatchInfo*,
00287             bool is_request,
00288             bool passthru_enabled
00289         ) = 0;
00290 
00291         virtual ReceiveMessageContext*
00292         create_receive_message_context(
00293             MessageReader*,
00294             ContextContainer*,
00295             DispatchInfo*
00296         ) = 0;
00297 
00298         virtual void
00299         close() = 0;
00300 
00301         virtual bool
00302         transport_acknowledgement_required(
00303             ContextContainer*
00304         ) = 0;
00305 
00306         virtual IT_Bus::String
00307         get_replyto_endpoint_correlation_id(
00308             ContextContainer* incoming_container,
00309             ContextContainer* outgoing_container
00310         ) = 0;
00311 
00312       protected:
00313 
00314         EndpointManager() {}
00315         virtual ~EndpointManager();
00316     };
00317 
00318     class IT_BUS_API EndpointManagerFactory
00319     {
00320       public:
00321 
00322         virtual const IT_Bus::String&
00323         get_name() = 0;
00324 
00325         virtual EndpointManager*
00326         create_endpoint_manager(
00327             IT_Bus::Port&
00328         ) = 0;
00329 
00330       protected:
00331 
00332         EndpointManagerFactory() {}
00333         virtual ~EndpointManagerFactory();
00334     };
00335 }
00336 
00337 #endif  

Generated on Thu Sep 7 11:39:33 2006 for Artix by  doxygen 1.4.7