diff options
author | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-08-29 21:28:20 +0000 |
---|---|---|
committer | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-08-29 21:28:20 +0000 |
commit | b16ce964c46595400d1459bbf453fc46e818f4c2 (patch) | |
tree | 5cdebc64f4d5b00c351ec35d52146ae235dda96d | |
parent | cdaaf27641357e3ff99e14f408a33fdcecf95126 (diff) | |
download | ATCD-b16ce964c46595400d1459bbf453fc46e818f4c2.tar.gz |
Forgot to check in these files.
-rw-r--r-- | TAO/tao/Interceptor.h | 160 | ||||
-rw-r--r-- | TAO/tao/Interceptor.i | 157 |
2 files changed, 317 insertions, 0 deletions
diff --git a/TAO/tao/Interceptor.h b/TAO/tao/Interceptor.h new file mode 100644 index 00000000000..fff6d68ec2a --- /dev/null +++ b/TAO/tao/Interceptor.h @@ -0,0 +1,160 @@ +// This may look like C, but it's really -*- C++ -*- +// $Id$ + +// ============================================================================ +// +// = LIBRARY +// TAO +// +// = FILENAME +// Interceptor.h +// +// = DESCRIPTION +// This file contains two helper classes to simplify the support of +// interceptors in tao_idl generated code. All the helper classes +// implementations are in Interceptor.i file. +// +// A series of TAO_INTERCEPTOR* macros are also defined in the file. +// These macros allows us to disable/enable support of interceptors +// easily. +// +// I also put some default no-op implementation of the interceptor +// servants. +// +// = AUTHOR +// Nanbor Wang <nanbor@cs.wustl.edu> +// +// ============================================================================ + +#ifndef TAO_INTERCEPTOR_H +#define TAO_INTERCEPTOR_H + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/InterceptorS.h" + +#if defined (TAO_HAS_INTERCEPTORS) +# define TAO_INTERCEPTOR(X) X +# define TAO_INTERCEPTOR_CHECK ACE_TRY_CHECK +# define TAO_INTERCEPTOR_CHECK_RETURN(X) ACE_TRY_CHECK +# define TAO_INTERCEPTOR_THROW(X) ACE_TRY_THROW(X) +# define TAO_INTERCEPTOR_THROW_RETURN(X,Y) ACE_TRY_THROW(X) +#else +# define TAO_INTERCEPTOR(X) +# define TAO_INTERCEPTOR_CHECK ACE_CHECK +# define TAO_INTERCEPTOR_CHECK_RETURN(X) ACE_CHECK_RETURN (X) +# define TAO_INTERCEPTOR_THROW(X) ACE_THROW(X) +# define TAO_INTERCEPTOR_THROW_RETURN(X,Y) ACE_THROW_RETURN(X,Y) +#endif /* TAO_HAS_INTERCEPTORS */ + +#if defined (TAO_HAS_INTERCEPTORS) +class TAO_Export TAO_ClientRequestInterceptor_Adapter +{ + // = TITLE + // TAO_ClientRequestInterceptor_Adapter + // + // = DESCRIPTION + // A convenient helper class to invoke the client-side request + // interceptor(s) in tao_idl generated code. Currently, TAO only + // supports registerring of one interceptor. The class will only + // invoke the interceptor if there's one. + // + // In the future, when we extend TAO's interceptor registering + // mechanism, this class will be modified to invoke several + // interceptors in series. +public: + TAO_ClientRequestInterceptor_Adapter + (PortableInterceptor::ClientRequestInterceptor_ptr interceptor); + + ~TAO_ClientRequestInterceptor_Adapter (void); + + void preinvoke (CORBA::ULong, + CORBA::Boolean, + CORBA::Object_ptr, + const char *, + IOP::ServiceContextList &, + CORBA::NVList_ptr &, + PortableInterceptor::Cookies &, + CORBA::Environment &); + + void postinvoke (CORBA::ULong, + CORBA::Boolean, + CORBA::Object_ptr, + const char *, + IOP::ServiceContextList &, + CORBA::NVList_ptr &, + PortableInterceptor::Cookies &, + CORBA::Environment &); + + void exception_occurred (CORBA::ULong, + CORBA::Boolean, + CORBA::Object_ptr, + const char *, + //IOP::ServiceContextList &, + //CORBA::Exception_ptr &, + PortableInterceptor::Cookies &, + CORBA::Environment &); + +private: + PortableInterceptor::ClientRequestInterceptor_var interceptor_; +}; + +class TAO_Export TAO_ServerRequestInterceptor_Adapter +{ + // = TITLE + // TAO_ServerRequestInterceptor_Adapter + // + // = DESCRIPTION + // A convenient helper class to invoke the server-side request + // interceptor(s) in tao_idl generated code. Currently, TAO only + // supports registerring of one interceptor. The class will only + // invoke the interceptor if there's one. + // + // In the future, when we extend TAO's interceptor registering + // mechanism, this class will be modified to invoke several + // interceptors in series. +public: + TAO_ServerRequestInterceptor_Adapter + (PortableInterceptor::ServerRequestInterceptor_ptr interceptor); + + ~TAO_ServerRequestInterceptor_Adapter (void); + + void preinvoke (CORBA::ULong, + CORBA::Boolean, + CORBA::Object_ptr, + const char *, + IOP::ServiceContextList &, + CORBA::NVList_ptr &, + PortableInterceptor::Cookies &, + CORBA::Environment &); + + void postinvoke (CORBA::ULong, + CORBA::Boolean, + CORBA::Object_ptr, + const char *, + IOP::ServiceContextList &, + CORBA::NVList_ptr &, + PortableInterceptor::Cookies &, + CORBA::Environment &); + + void exception_occurred (CORBA::ULong, + CORBA::Boolean, + CORBA::Object_ptr, + const char *, + //IOP::ServiceContextList &, + //CORBA::Exception_ptr &, + PortableInterceptor::Cookies &, + CORBA::Environment &); + +private: + PortableInterceptor::ServerRequestInterceptor_var interceptor_; +}; +#endif /* TAO_HAS_INTERCEPTORS */ + +#if defined (__ACE_INLINE__) +#include "tao/Interceptor.i" +#endif /* defined INLINE */ + +#endif /* TAO_INTERCEPTOR_H */ diff --git a/TAO/tao/Interceptor.i b/TAO/tao/Interceptor.i new file mode 100644 index 00000000000..13e6205146c --- /dev/null +++ b/TAO/tao/Interceptor.i @@ -0,0 +1,157 @@ +/* -*- C++ -*- $Id$ */ + +#if defined (TAO_HAS_INTERCEPTORS) +ACE_INLINE +TAO_ClientRequestInterceptor_Adapter::TAO_ClientRequestInterceptor_Adapter + (PortableInterceptor::ClientRequestInterceptor_ptr interceptor) + : interceptor_ (interceptor) +{ +} + +ACE_INLINE +TAO_ClientRequestInterceptor_Adapter::~TAO_ClientRequestInterceptor_Adapter + (void) +{ +} + +ACE_INLINE void +TAO_ClientRequestInterceptor_Adapter:: +preinvoke (CORBA::ULong request_id, + CORBA::Boolean two_way, + CORBA::Object_ptr objref, + const char *operation, + IOP::ServiceContextList &sc, + CORBA::NVList_ptr &args, + PortableInterceptor::Cookies &cookies, + CORBA::Environment &ACE_TRY_ENV) +{ + if (! CORBA::is_nil (this->interceptor_.in ())) + this->interceptor_->preinvoke (request_id, + two_way, + objref, + operation, + sc, + args, + cookies, + ACE_TRY_ENV); +} + +ACE_INLINE void +TAO_ClientRequestInterceptor_Adapter:: +postinvoke (CORBA::ULong request_id, + CORBA::Boolean two_way, + CORBA::Object_ptr objref, + const char *operation, + IOP::ServiceContextList &sc, + CORBA::NVList_ptr &args, + PortableInterceptor::Cookies &cookies, + CORBA::Environment &ACE_TRY_ENV) +{ + if (! CORBA::is_nil (this->interceptor_.in ())) + this->interceptor_->postinvoke (request_id, + two_way, + objref, + operation, + sc, + args, + cookies, + ACE_TRY_ENV); +} + +ACE_INLINE void +TAO_ClientRequestInterceptor_Adapter:: +exception_occurred (CORBA::ULong request_id, + CORBA::Boolean two_way, + CORBA::Object_ptr objref, + const char *operation, + //IOP::ServiceContextList &, + //CORBA::Exception_ptr &, + PortableInterceptor::Cookies &cookies, + CORBA::Environment &ACE_TRY_ENV) +{ + if (! CORBA::is_nil (this->interceptor_.in ())) + this->interceptor_->exception_occurred (request_id, + two_way, + objref, + operation, + cookies, + ACE_TRY_ENV); +} + +ACE_INLINE +TAO_ServerRequestInterceptor_Adapter::TAO_ServerRequestInterceptor_Adapter + (PortableInterceptor::ServerRequestInterceptor_ptr interceptor) + : interceptor_ (interceptor) +{ +} + +ACE_INLINE +TAO_ServerRequestInterceptor_Adapter::~TAO_ServerRequestInterceptor_Adapter + (void) +{ +} + +ACE_INLINE void +TAO_ServerRequestInterceptor_Adapter:: +preinvoke (CORBA::ULong request_id, + CORBA::Boolean two_way, + CORBA::Object_ptr objref, + const char *operation, + IOP::ServiceContextList &sc, + CORBA::NVList_ptr &args, + PortableInterceptor::Cookies &cookies, + CORBA::Environment &ACE_TRY_ENV) +{ + if (! CORBA::is_nil (this->interceptor_.in ())) + this->interceptor_->preinvoke (request_id, + two_way, + objref, + operation, + sc, + args, + cookies, + ACE_TRY_ENV); +} + +ACE_INLINE void +TAO_ServerRequestInterceptor_Adapter:: +postinvoke (CORBA::ULong request_id, + CORBA::Boolean two_way, + CORBA::Object_ptr objref, + const char *operation, + IOP::ServiceContextList &sc, + CORBA::NVList_ptr &args, + PortableInterceptor::Cookies &cookies, + CORBA::Environment &ACE_TRY_ENV) +{ + if (! CORBA::is_nil (this->interceptor_.in ())) + this->interceptor_->postinvoke (request_id, + two_way, + objref, + operation, + sc, + args, + cookies, + ACE_TRY_ENV); +} + +ACE_INLINE void +TAO_ServerRequestInterceptor_Adapter:: +exception_occurred (CORBA::ULong request_id, + CORBA::Boolean two_way, + CORBA::Object_ptr objref, + const char *operation, + //IOP::ServiceContextList &, + //CORBA::Exception_ptr &, + PortableInterceptor::Cookies &cookies, + CORBA::Environment &ACE_TRY_ENV) +{ + if (! CORBA::is_nil (this->interceptor_.in ())) + this->interceptor_->exception_occurred (request_id, + two_way, + objref, + operation, + cookies, + ACE_TRY_ENV); +} +#endif /* TAO_HAS_INTERCEPTORS */ |