diff options
Diffstat (limited to 'TAO/orbsvcs')
228 files changed, 18289 insertions, 0 deletions
diff --git a/TAO/orbsvcs/orbsvcs/Notify/Admin.cpp b/TAO/orbsvcs/orbsvcs/Notify/Admin.cpp new file mode 100644 index 00000000000..6236246c655 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Admin.cpp @@ -0,0 +1,59 @@ +// $Id$ + +#include "Admin.h" + +#if ! defined (__ACE_INLINE__) +#include "Admin.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Admin, "$Id$") + +#include "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "orbsvcs/CosNotifyChannelAdminC.h" + +#include "Proxy.h" +#include "EventChannel.h" +#include "EventChannelFactory.h" +#include "Notify_Service.h" + +TAO_NS_Admin::TAO_NS_Admin (ADMIN_TYPE type) + :type_ (type), filter_operator_ (CosNotifyChannelAdmin::OR_OP) +{ + // Initialize all Admin objects to initially be subscribed for all events. + // This is a reasonable default and is ewquired to allow Cos Event consumers/suppliers to send/receive events, + this->subscribed_types_.insert (TAO_NS_EventType::special ()); +} + +TAO_NS_Admin::~TAO_NS_Admin () +{ +} + + +void +TAO_NS_Admin::insert (TAO_NS_Proxy* proxy ACE_ENV_ARG_DECL) +{ + inherited::insert (proxy ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->proxy_id_list_.insert (proxy->id ()); +} + +void +TAO_NS_Admin::remove (TAO_NS_Proxy* proxy ACE_ENV_ARG_DECL) +{ + inherited::remove (proxy ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->proxy_id_list_.remove (proxy->id ()); +} + +void +TAO_NS_Admin::subscribed_types (TAO_NS_EventTypeSeq& subscribed_types ACE_ENV_ARG_DECL) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK; + + // copy + subscribed_types = this->subscribed_types_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Admin.h b/TAO/orbsvcs/orbsvcs/Notify/Admin.h new file mode 100644 index 00000000000..a0b9c439dd0 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Admin.h @@ -0,0 +1,97 @@ +/* -*- C++ -*- */ +/** + * @file Admin.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_ADMIN_H +#define TAO_NS_ADMIN_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Container_T.h" +#include "FilterAdmin.h" +#include "EventTypeSeq.h" + +class TAO_NS_Proxy; +class TAO_NS_EventChannel; + +/** + * @class TAO_NS_Admin + * + * @brief + * + */ +class TAO_Notify_Export TAO_NS_Admin : public virtual TAO_NS_Container_T <TAO_NS_Proxy, TAO_NS_Admin, TAO_NS_EventChannel> +{ + typedef ACE_Unbounded_Set <TAO_NS_Object_Id> TAO_NS_Object_Id_Seq; +public: + enum ADMIN_TYPE + { + CONSUMER_ADMIN, + SUPPLIER_ADMIN + }; + + /// Constuctor + TAO_NS_Admin (ADMIN_TYPE type); + + /// Destructor + ~TAO_NS_Admin (); + + /// Insert object to this container. + virtual void insert (TAO_NS_Proxy* proxy ACE_ENV_ARG_DECL); + + /// Remove type from container_ + virtual void remove (TAO_NS_Proxy* proxy ACE_ENV_ARG_DECL); + + /// Return type. + ADMIN_TYPE type (void); + + /// Access Admin FilterAdmin. + TAO_NS_FilterAdmin& filter_admin (void); + + /// Set Filter operator + void filter_operator (CosNotifyChannelAdmin::InterFilterGroupOperator filter_operator); + + /// Access Filter operator + CosNotifyChannelAdmin::InterFilterGroupOperator filter_operator (void); + + /// Obtain the Admin's subscribed types. + void subscribed_types (TAO_NS_EventTypeSeq& subscribed_types ACE_ENV_ARG_DECL); + +protected: + typedef TAO_NS_Container_T <TAO_NS_Proxy, TAO_NS_Admin, TAO_NS_EventChannel> inherited; + + /// = Data Members + /// List of proxy ID's + TAO_NS_Object_Id_Seq proxy_id_list_; + + /// Type of Admin + ADMIN_TYPE type_; + + /// The types that we've subscribed our proxy objects with the event manager. + TAO_NS_EventTypeSeq subscribed_types_; + + /// Filter Administration + TAO_NS_FilterAdmin filter_admin_; + + /// Filter operator + CosNotifyChannelAdmin::InterFilterGroupOperator filter_operator_; +}; + +#if defined (__ACE_INLINE__) +#include "Admin.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_ADMIN_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Admin.inl b/TAO/orbsvcs/orbsvcs/Notify/Admin.inl new file mode 100644 index 00000000000..814304a558d --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Admin.inl @@ -0,0 +1,25 @@ +// $Id$ + +ACE_INLINE TAO_NS_Admin::ADMIN_TYPE +TAO_NS_Admin::type (void) +{ + return this->type_; +} + +ACE_INLINE TAO_NS_FilterAdmin& +TAO_NS_Admin::filter_admin (void) +{ + return this->filter_admin_; +} + +ACE_INLINE void +TAO_NS_Admin::filter_operator (CosNotifyChannelAdmin::InterFilterGroupOperator filter_operator) +{ + this->filter_operator_ = filter_operator; +} + +ACE_INLINE CosNotifyChannelAdmin::InterFilterGroupOperator +TAO_NS_Admin::filter_operator (void) +{ + return this->filter_operator_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.cpp b/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.cpp new file mode 100644 index 00000000000..0320fccfb30 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.cpp @@ -0,0 +1,66 @@ +// $Id$ + +#include "AdminProperties.h" + +#if ! defined (__ACE_INLINE__) +#include "AdminProperties.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_AdminProperties, "$id$") + +#include "orbsvcs/CosNotificationC.h" + +TAO_NS_AdminProperties::TAO_NS_AdminProperties (void) + : max_queue_length_ (CosNotification::MaxQueueLength, 0), + max_consumers_ (CosNotification::MaxSuppliers, 0), + max_suppliers_ (CosNotification::MaxConsumers, 0), + reject_new_events_ (CosNotification::RejectNewEvents, 0) +{ +} + +TAO_NS_AdminProperties::~TAO_NS_AdminProperties () +{ +} + +int +TAO_NS_AdminProperties::init (const CosNotification::PropertySeq& prop_seq) +{ + if (TAO_NS_PropertySeq::init (prop_seq) != 0) + return -1; + + this->max_queue_length_.set (*this); + this->max_consumers_.set (*this); + this->max_suppliers_.set (*this); + this->reject_new_events_.set (*this); + + //@@ check if unsupported property was set. + // This will happen when number of successfull inits != numbers of items bound in map_. + + return 0; +} + +CORBA::Boolean +TAO_NS_AdminProperties::queue_full (void) +{ + if (this->max_queue_length () == 0) + return 0; + else + if (this->queue_length ().value () > this->max_queue_length ().value ()) + return 1; + + return 0; +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class ACE_Atomic_Op<TAO_SYNCH_MUTEX,int>; +template class ACE_Atomic_Op_Ex<TAO_SYNCH_MUTEX,int>; +template class TAO_Notify_Signal_Property<TAO_SYNCH_MUTEX,int>; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate ACE_Atomic_Op<TAO_SYNCH_MUTEX,int> +#pragma instantiate ACE_Atomic_Op_Ex<TAO_SYNCH_MUTEX,int> +#pragma instantiate TAO_Notify_Signal_Property<TAO_SYNCH_MUTEX,int> + +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.h b/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.h new file mode 100644 index 00000000000..213c73aa55d --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.h @@ -0,0 +1,105 @@ +/* -*- C++ -*- */ +/** + * @file AdminProperties.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_ADMINPROPERTIES_H +#define TAO_NS_ADMINPROPERTIES_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Atomic_Op.h" +#include "tao/orbconf.h" +#include "Types.h" +#include "PropertySeq.h" +#include "Property_T.h" +#include "Property.h" +#include "Property_Boolean.h" +#include "Notify_Signal_Property_T.h" + +/** + * @class TAO_NS_AdminProperties + * + * @brief + * + */ +class TAO_Notify_Export TAO_NS_AdminProperties : public TAO_NS_PropertySeq +{ +public: + /// Constuctor + TAO_NS_AdminProperties (void); + + /// Destructor + ~TAO_NS_AdminProperties (); + + // Init + int init (const CosNotification::PropertySeq& prop_seq); + + // = Accessors + // There was no reason for these not to be const + const TAO_NS_Property_Long& max_queue_length (void) const; + const TAO_NS_Property_Long& max_consumers (void) const; + const TAO_NS_Property_Long& max_suppliers (void) const; + const TAO_NS_Property_Boolean& reject_new_events (void) const; + + TAO_NS_Signal_Property_Long& queue_length (void); + TAO_NS_Atomic_Property_Long& consumers (void); + TAO_NS_Atomic_Property_Long& suppliers (void); + + // = Helper method + /// Returns true if Queue is full + CORBA::Boolean queue_full (void); + +protected: + // @@ Pradeep can you explain why there is any maximum for these + // values? Should they be configurable by the user so the resource + // requirements can be bounded? + + // = Admin. properties + // for all these properties the default O implies no limit + /** + * The maximum number of events that will be queued by the channel before + * the channel begins discarding events or rejecting new events upon + * receipt of each new event. + */ + TAO_NS_Property_Long max_queue_length_; + + /// The maximum number of consumers that can be connected to the channel at + /// any given time. + TAO_NS_Property_Long max_consumers_; + + /// The maximum number of suppliers that can be connected to the channel at + /// any given time. + TAO_NS_Property_Long max_suppliers_; + + /// Reject any new event. + TAO_NS_Property_Boolean reject_new_events_; + + //= Variables + /// This is used to count the queue length across all buffers in the Notify Service + /// to enforce the "MaxQueueLength" property. + TAO_NS_Signal_Property_Long queue_length_; + + /// These are used to count the number of consumers and suppliers connected to + /// the system. + TAO_NS_Atomic_Property_Long consumers_; + TAO_NS_Atomic_Property_Long suppliers_; +}; + +#if defined (__ACE_INLINE__) +#include "AdminProperties.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_ADMINPROPERTIES_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.inl b/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.inl new file mode 100644 index 00000000000..14c4a1e7266 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/AdminProperties.inl @@ -0,0 +1,43 @@ +// $Id$ + +ACE_INLINE const TAO_NS_Property_Long& +TAO_NS_AdminProperties::max_queue_length (void) const +{ + return this->max_queue_length_; +} + +ACE_INLINE const TAO_NS_Property_Long& +TAO_NS_AdminProperties::max_consumers (void) const +{ + return this->max_consumers_; +} + +ACE_INLINE const TAO_NS_Property_Long& +TAO_NS_AdminProperties::max_suppliers (void) const +{ + return this->max_suppliers_; +} + +ACE_INLINE const TAO_NS_Property_Boolean& +TAO_NS_AdminProperties::reject_new_events (void) const +{ + return this->reject_new_events_; +} + +ACE_INLINE TAO_NS_Signal_Property_Long& +TAO_NS_AdminProperties::queue_length (void) +{ + return this->queue_length_; +} + +ACE_INLINE TAO_NS_Atomic_Property_Long& +TAO_NS_AdminProperties::consumers (void) +{ + return this->consumers_; +} + +ACE_INLINE TAO_NS_Atomic_Property_Long& +TAO_NS_AdminProperties::suppliers (void) +{ + return this->suppliers_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/AnyEvent.cpp b/TAO/orbsvcs/orbsvcs/Notify/Any/AnyEvent.cpp new file mode 100644 index 00000000000..4eaaa2555b9 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/AnyEvent.cpp @@ -0,0 +1,87 @@ +// $Id$ + +#include "AnyEvent.h" + +#if ! defined (__ACE_INLINE__) +#include "AnyEvent.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_AnyEvent, "$id$") + +#include "../Consumer.h" +#include "tao/debug.h" + +TAO_NS_EventType TAO_NS_AnyEvent::event_type_; + +TAO_NS_AnyEvent::TAO_NS_AnyEvent (const CORBA::Any &event) + : event_ (event) +{ +} + +TAO_NS_AnyEvent::~TAO_NS_AnyEvent () +{ +} + +const TAO_NS_EventType& +TAO_NS_AnyEvent::type (void) const +{ + return this->event_type_; +} + +void +TAO_NS_AnyEvent::convert (CosNotification::StructuredEvent& notification) +{ + TAO_NS_Event::translate (this->event_, notification); +} + +CORBA::Boolean +TAO_NS_AnyEvent::do_match (CosNotifyFilter::Filter_ptr filter ACE_ENV_ARG_DECL) +{ + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - " + "TAO_Notify_AnyEvent::do_match ()\n")); + + return filter->match(this->event_ ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_AnyEvent::push (TAO_NS_Consumer* consumer ACE_ENV_ARG_DECL) const +{ + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - " + "TAO_Notify_AnyEvent::push \n")); + + consumer->push (this->event_ ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_AnyEvent::push (Event_Forwarder::StructuredProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) +{ + CosNotification::StructuredEvent notification; + + TAO_NS_Event::translate (this->event_, notification); + + forwarder->forward_structured (notification ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_AnyEvent::push_no_filtering (Event_Forwarder::StructuredProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) +{ + CosNotification::StructuredEvent notification; + + TAO_NS_Event::translate (this->event_, notification); + + forwarder->forward_structured_no_filtering (notification ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_AnyEvent::push (Event_Forwarder::ProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) +{ + forwarder->forward_any (this->event_ ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_AnyEvent::push_no_filtering (Event_Forwarder::ProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) +{ + forwarder->forward_any_no_filtering (this->event_ ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/AnyEvent.h b/TAO/orbsvcs/orbsvcs/Notify/Any/AnyEvent.h new file mode 100644 index 00000000000..d77191e05b1 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/AnyEvent.h @@ -0,0 +1,80 @@ +/* -*- C++ -*- */ +/** + * @file AnyEvent.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_ANYEVENT_H +#define TAO_NS_ANYEVENT_H +#include "ace/pre.h" + +#include "../notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "../Event.h" +#include "../EventType.h" +#include "orbsvcs/CosNotificationC.h" + +class TAO_NS_Consumer; + +/** + * @class TAO_NS_AnyEvent + * + * @brief + * + */ +class TAO_Notify_Export TAO_NS_AnyEvent : public TAO_NS_Event +{ + friend class TAO_NS_Builder; +public: + /// Constuctor + TAO_NS_AnyEvent (const CORBA::Any &event); + + /// Destructor + ~TAO_NS_AnyEvent (); + + /// Get the event type. + virtual const TAO_NS_EventType& type (void) const; + + CORBA::Boolean do_match (CosNotifyFilter::Filter_ptr filter ACE_ENV_ARG_DECL); + + /// Convert to CosNotification::Structured type + virtual void convert (CosNotification::StructuredEvent& notification); + + /// Push event to consumer + virtual void push (TAO_NS_Consumer* consumer ACE_ENV_ARG_DECL) const; + + /// Push event to the Event_Forwarder interface + virtual void push (Event_Forwarder::StructuredProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL); + + /// Push event to the Event_Forwarder interface + virtual void push_no_filtering (Event_Forwarder::StructuredProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL); + + /// Push event to the Event_Forwarder interface + virtual void push (Event_Forwarder::ProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL); + + /// Push event to the Event_Forwarder interface + virtual void push_no_filtering (Event_Forwarder::ProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL); + +protected: + /// Any Event + CORBA::Any event_; + + /// Our event type. + static TAO_NS_EventType event_type_; +}; + +#if defined (__ACE_INLINE__) +#include "AnyEvent.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_ANYEVENT_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/AnyEvent.inl b/TAO/orbsvcs/orbsvcs/Notify/Any/AnyEvent.inl new file mode 100644 index 00000000000..4920e03d422 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/AnyEvent.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "AnyEvent.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushConsumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushConsumer.cpp new file mode 100644 index 00000000000..985530caffb --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushConsumer.cpp @@ -0,0 +1,91 @@ +// $Id$ + +#include "CosEC_ProxyPushConsumer.h" + +#if ! defined (__ACE_INLINE__) +#include "CosEC_ProxyPushConsumer.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_CosEC_ProxyPushConsumer, "$id$") + +#include "ace/Refcounted_Auto_Ptr.h" +#include "tao/debug.h" +#include "../Admin.h" +#include "../AdminProperties.h" +#include "AnyEvent.h" +#include "PushSupplier.h" + +TAO_NS_CosEC_ProxyPushConsumer::TAO_NS_CosEC_ProxyPushConsumer (void) +{ +} + +TAO_NS_CosEC_ProxyPushConsumer::~TAO_NS_CosEC_ProxyPushConsumer () +{ +} + +void +TAO_NS_CosEC_ProxyPushConsumer::release (void) +{ + delete this; + //@@ inform factory +} + +void +TAO_NS_CosEC_ProxyPushConsumer::destroy (ACE_ENV_SINGLE_ARG_DECL) +{ + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "In TAO_NS_CosEC_ProxyPushConsumer::destroy \n")); + + this->inherited::destroy (this ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_CosEC_ProxyPushConsumer::push (const CORBA::Any& data ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosEventComm::Disconnected + )) +{ + // Check if we should proceed at all. + if (this->admin_properties_->reject_new_events () == 1 + && this->admin_properties_->queue_full ()) + ACE_THROW (CORBA::IMP_LIMIT ()); + + if (this->is_connected () == 0) + { + ACE_THROW (CosEventComm::Disconnected ()); + } + + // Convert + TAO_NS_Event_var event (new TAO_NS_AnyEvent (data)); + + // Continue processing. + this->TAO_NS_ProxyConsumer::push (event); +} + +void +TAO_NS_CosEC_ProxyPushConsumer::connect_push_supplier (CosEventComm::PushSupplier_ptr push_supplier ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosEventChannelAdmin::AlreadyConnected + )) +{ + // Convert Supplier to Base Type + TAO_NS_PushSupplier *supplier; + ACE_NEW_THROW_EX (supplier, + TAO_NS_PushSupplier (this), + CORBA::NO_MEMORY ()); + + supplier->init (push_supplier ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->connect (supplier ACE_ENV_ARG_PARAMETER); +} + +void TAO_NS_CosEC_ProxyPushConsumer::disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + this->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushConsumer.h b/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushConsumer.h new file mode 100644 index 00000000000..0a54fe04ee6 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushConsumer.h @@ -0,0 +1,85 @@ +/* -*- C++ -*- */ +/** + * @file CosEC_ProxyPushConsumer.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_COSEC_PROXYPUSHCONSUMER_H +#define TAO_NS_COSEC_PROXYPUSHCONSUMER_H +#include "ace/pre.h" + +#include "../notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosEventChannelAdminS.h" +#include "../ProxyConsumer_T.h" +#include "../Destroy_Callback.h" + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/** + * @class TAO_NS_CosEC_ProxyPushConsumer + * + * @brief + * + */ +class TAO_Notify_Export TAO_NS_CosEC_ProxyPushConsumer : public virtual TAO_NS_ProxyConsumer_T <POA_CosEventChannelAdmin::ProxyPushConsumer>, public TAO_NS_Destroy_Callback +{ + friend class TAO_NS_Builder; +public: + /// Constuctor + TAO_NS_CosEC_ProxyPushConsumer (void); + + /// Destructor + ~TAO_NS_CosEC_ProxyPushConsumer (); + + /// TAO_NS_Destroy_Callback methods + virtual void release (void); + + /// Destroy this object. + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL); + +protected: + ///= CosNotifyChannelAdmin::ProxyPushConsumer methods + + void push (const CORBA::Any & data ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosEventComm::Disconnected + )); + + virtual void connect_push_supplier (CosEventComm::PushSupplier_ptr push_supplier ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosEventChannelAdmin::AlreadyConnected + )); + + virtual void disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__ACE_INLINE__) +#include "CosEC_ProxyPushConsumer.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_COSEC_PROXYPUSHCONSUMER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushConsumer.inl b/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushConsumer.inl new file mode 100644 index 00000000000..e787ced2266 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushConsumer.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "CosEC_ProxyPushConsumer.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushSupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushSupplier.cpp new file mode 100644 index 00000000000..401d9e8d604 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushSupplier.cpp @@ -0,0 +1,74 @@ +// $Id$ + +#include "CosEC_ProxyPushSupplier.h" + +#if ! defined (__ACE_INLINE__) +#include "CosEC_ProxyPushSupplier.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_CosEC_ProxyPushSupplier, "$id$") + +#include "tao/debug.h" +#include "PushConsumer.h" +#include "../Proxy.h" +#include "../Admin.h" +#include "../EventChannel.h" +#include "../EventChannelFactory.h" +#include "../Notify_Service.h" + + +TAO_NS_CosEC_ProxyPushSupplier::TAO_NS_CosEC_ProxyPushSupplier (void) +{ +} + +TAO_NS_CosEC_ProxyPushSupplier::~TAO_NS_CosEC_ProxyPushSupplier () +{ +} + +void +TAO_NS_CosEC_ProxyPushSupplier::destroy (ACE_ENV_SINGLE_ARG_DECL) +{ + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "In TAO_NS_ProxyPushConsumer::destroy \n")); + + this->inherited::destroy (this ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_CosEC_ProxyPushSupplier::release (void) +{ + this->consumer_->release (); + + delete this; + //@@ inform factory +} + +void +TAO_NS_CosEC_ProxyPushSupplier::connect_push_consumer (CosEventComm::PushConsumer_ptr push_consumer + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosEventChannelAdmin::AlreadyConnected, + CosEventChannelAdmin::TypeError + )) +{ + // Convert Consumer to Base Type + TAO_NS_PushConsumer* consumer; + ACE_NEW_THROW_EX (consumer, + TAO_NS_PushConsumer (this), + CORBA::NO_MEMORY ()); + + consumer->init (push_consumer ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->connect (consumer ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_CosEC_ProxyPushSupplier::disconnect_push_supplier (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + this->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushSupplier.h b/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushSupplier.h new file mode 100644 index 00000000000..65642a8577d --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushSupplier.h @@ -0,0 +1,82 @@ +/* -*- C++ -*- */ +/** + * @file ProxyPushSupplier.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_COSEC_PROXYPUSHSUPPLIER_H +#define TAO_NS_COSEC_PROXYPUSHSUPPLIER_H +#include "ace/pre.h" + +#include "../notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosEventChannelAdminS.h" +#include "../ProxySupplier_T.h" + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/** + * @class TAO_NS_CosEC_ProxyPushSupplier + * + * @brief + * + */ +class TAO_Notify_Export TAO_NS_CosEC_ProxyPushSupplier : public virtual TAO_NS_ProxySupplier_T <POA_CosEventChannelAdmin::ProxyPushSupplier>, public TAO_NS_Destroy_Callback +{ + friend class TAO_NS_Builder; +public: + /// Constuctor + TAO_NS_CosEC_ProxyPushSupplier (void); + + /// Destructor + ~TAO_NS_CosEC_ProxyPushSupplier (); + + /// Destroy this object. + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL); + + /// TAO_NS_Destroy_Callback methods + virtual void release (void); + + // = Interface methods + virtual void connect_push_consumer ( + CosEventComm::PushConsumer_ptr push_consumer + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosEventChannelAdmin::AlreadyConnected, + CosEventChannelAdmin::TypeError + )); + + virtual void disconnect_push_supplier ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__ACE_INLINE__) +#include "CosEC_ProxyPushSupplier.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_COSEC_PROXYPUSHSUPPLIER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushSupplier.inl b/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushSupplier.inl new file mode 100644 index 00000000000..c6551c656c4 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/CosEC_ProxyPushSupplier.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "CosEC_ProxyPushSupplier.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushConsumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushConsumer.cpp new file mode 100644 index 00000000000..81b2b058d97 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushConsumer.cpp @@ -0,0 +1,100 @@ +// $Id$ + +#include "ProxyPushConsumer.h" + +#if ! defined (__ACE_INLINE__) +#include "ProxyPushConsumer.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_ProxyPushConsumer, "$id$") + +#include "ace/Refcounted_Auto_Ptr.h" +#include "tao/debug.h" +#include "../Admin.h" +#include "../AdminProperties.h" +#include "AnyEvent.h" +#include "PushSupplier.h" + +TAO_NS_ProxyPushConsumer::TAO_NS_ProxyPushConsumer (void) +{ +} + +TAO_NS_ProxyPushConsumer::~TAO_NS_ProxyPushConsumer () +{ +} + +void +TAO_NS_ProxyPushConsumer::release (void) +{ + delete this; + //@@ inform factory +} + +void +TAO_NS_ProxyPushConsumer::destroy (ACE_ENV_SINGLE_ARG_DECL) +{ + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "In TAO_NS_ProxyPushConsumer::destroy \n")); + + this->inherited::destroy (this ACE_ENV_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::ProxyType +TAO_NS_ProxyPushConsumer::MyType (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return CosNotifyChannelAdmin::PUSH_ANY; +} + +void +TAO_NS_ProxyPushConsumer::push (const CORBA::Any& data ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosEventComm::Disconnected + )) +{ + // Check if we should proceed at all. + if (this->admin_properties_->reject_new_events () == 1 + && this->admin_properties_->queue_full ()) + ACE_THROW (CORBA::IMP_LIMIT ()); + + if (this->is_connected () == 0) + { + ACE_THROW (CosEventComm::Disconnected ()); + } + + // Convert + TAO_NS_Event_var event (new TAO_NS_AnyEvent (data)); + + // Continue processing. + this->TAO_NS_ProxyConsumer::push (event); +} + +void +TAO_NS_ProxyPushConsumer::connect_any_push_supplier (CosEventComm::PushSupplier_ptr push_supplier ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosEventChannelAdmin::AlreadyConnected + )) +{ + // Convert Supplier to Base Type + TAO_NS_PushSupplier *supplier; + ACE_NEW_THROW_EX (supplier, + TAO_NS_PushSupplier (this), + CORBA::NO_MEMORY ()); + + supplier->init (push_supplier ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->connect (supplier ACE_ENV_ARG_PARAMETER); +} + +void TAO_NS_ProxyPushConsumer::disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + this->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushConsumer.h b/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushConsumer.h new file mode 100644 index 00000000000..c63e4dd2a61 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushConsumer.h @@ -0,0 +1,90 @@ +/* -*- C++ -*- */ +/** + * @file ProxyPushConsumer.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_PROXYPUSHCONSUMER_H +#define TAO_NS_PROXYPUSHCONSUMER_H +#include "ace/pre.h" + +#include "../notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyChannelAdminS.h" +#include "../ProxyConsumer_T.h" +#include "../Destroy_Callback.h" + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/** + * @class TAO_NS_ProxyPushConsumer + * + * @brief + * + */ +class TAO_Notify_Export TAO_NS_ProxyPushConsumer : public virtual TAO_NS_ProxyConsumer_T <POA_CosNotifyChannelAdmin::ProxyPushConsumer>, public TAO_NS_Destroy_Callback +{ + friend class TAO_NS_Builder; +public: + /// Constuctor + TAO_NS_ProxyPushConsumer (void); + + /// Destructor + ~TAO_NS_ProxyPushConsumer (); + + /// TAO_NS_Destroy_Callback methods + virtual void release (void); + + /// Destroy this object. + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL); + +protected: + ///= CosNotifyChannelAdmin::ProxyPushConsumer methods + + virtual CosNotifyChannelAdmin::ProxyType MyType (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + void push (const CORBA::Any & data ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosEventComm::Disconnected + )); + + virtual void connect_any_push_supplier (CosEventComm::PushSupplier_ptr push_supplier ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosEventChannelAdmin::AlreadyConnected + )); + + virtual void disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__ACE_INLINE__) +#include "ProxyPushConsumer.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_PROXYPUSHCONSUMER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushConsumer.inl b/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushConsumer.inl new file mode 100644 index 00000000000..32c8ecf4355 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushConsumer.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "ProxyPushConsumer.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushSupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushSupplier.cpp new file mode 100644 index 00000000000..47f3a38a8e0 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushSupplier.cpp @@ -0,0 +1,83 @@ +// $Id$ + +#include "ProxyPushSupplier.h" + +#if ! defined (__ACE_INLINE__) +#include "ProxyPushSupplier.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_ProxyPushSupplier, "$id$") + +#include "tao/debug.h" +#include "PushConsumer.h" +#include "../Proxy.h" +#include "../Admin.h" +#include "../EventChannel.h" +#include "../EventChannelFactory.h" +#include "../Notify_Service.h" + + +TAO_NS_ProxyPushSupplier::TAO_NS_ProxyPushSupplier (void) +{ +} + +TAO_NS_ProxyPushSupplier::~TAO_NS_ProxyPushSupplier () +{ +} + +void +TAO_NS_ProxyPushSupplier::destroy (ACE_ENV_SINGLE_ARG_DECL) +{ + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "In TAO_NS_ProxyPushConsumer::destroy \n")); + + this->inherited::destroy (this ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_ProxyPushSupplier::release (void) +{ + this->consumer_->release (); + + delete this; + //@@ inform factory +} + +void +TAO_NS_ProxyPushSupplier::connect_any_push_consumer (CosEventComm::PushConsumer_ptr push_consumer + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosEventChannelAdmin::AlreadyConnected, + CosEventChannelAdmin::TypeError + )) +{ + // Convert Consumer to Base Type + TAO_NS_PushConsumer* consumer; + ACE_NEW_THROW_EX (consumer, + TAO_NS_PushConsumer (this), + CORBA::NO_MEMORY ()); + + consumer->init (push_consumer ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->connect (consumer ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_ProxyPushSupplier::disconnect_push_supplier (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + this->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::ProxyType +TAO_NS_ProxyPushSupplier::MyType (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return CosNotifyChannelAdmin::PUSH_ANY; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushSupplier.h b/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushSupplier.h new file mode 100644 index 00000000000..b98a9980f7a --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushSupplier.h @@ -0,0 +1,88 @@ +/* -*- C++ -*- */ +/** + * @file ProxyPushSupplier.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_PROXYPUSHSUPPLIER_H +#define TAO_NS_PROXYPUSHSUPPLIER_H +#include "ace/pre.h" + +#include "../notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyChannelAdminS.h" +#include "orbsvcs/Event_ForwarderS.h" +#include "../ProxySupplier_T.h" + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/** + * @class TAO_NS_ProxyPushSupplier + * + * @brief + * + */ +class TAO_Notify_Export TAO_NS_ProxyPushSupplier : public virtual TAO_NS_ProxySupplier_T <POA_Event_Forwarder::ProxyPushSupplier>, public TAO_NS_Destroy_Callback +{ + friend class TAO_NS_Builder; +public: + /// Constuctor + TAO_NS_ProxyPushSupplier (void); + + /// Destructor + ~TAO_NS_ProxyPushSupplier (); + + /// Destroy this object. + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL); + + /// TAO_NS_Destroy_Callback methods + virtual void release (void); + + // = Interface methods + virtual CosNotifyChannelAdmin::ProxyType MyType (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void connect_any_push_consumer ( + CosEventComm::PushConsumer_ptr push_consumer + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosEventChannelAdmin::AlreadyConnected, + CosEventChannelAdmin::TypeError + )); + + virtual void disconnect_push_supplier ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__ACE_INLINE__) +#include "ProxyPushSupplier.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_PROXYPUSHSUPPLIER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushSupplier.inl b/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushSupplier.inl new file mode 100644 index 00000000000..dda279acbfc --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/ProxyPushSupplier.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "ProxyPushSupplier.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/PushConsumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Any/PushConsumer.cpp new file mode 100644 index 00000000000..d150a1c1c01 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/PushConsumer.cpp @@ -0,0 +1,70 @@ +// $Id$ + +#include "PushConsumer.h" + +#if ! defined (__ACE_INLINE__) +#include "PushConsumer.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_PushConsumer, "$id$") + +#include "ace/Refcounted_Auto_Ptr.h" +#include "orbsvcs/CosEventCommC.h" +#include "../Event.h" + +TAO_NS_PushConsumer::TAO_NS_PushConsumer (TAO_NS_ProxySupplier* proxy) + :TAO_NS_Consumer (proxy) +{ +} + +TAO_NS_PushConsumer::~TAO_NS_PushConsumer () +{ +} + +void +TAO_NS_PushConsumer::init (CosEventComm::PushConsumer_ptr push_consumer ACE_ENV_ARG_DECL) +{ + this->push_consumer_ = CosEventComm::PushConsumer::_narrow (push_consumer ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + ACE_TRY + { + this->publish_ = CosNotifyComm::NotifyPublish::_narrow (push_consumer ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + // Ignore + // if the client is not running an event loop and _narrow goes remote, we get a transient exception! + } + ACE_ENDTRY; +} + +void +TAO_NS_PushConsumer::release (void) +{ + delete this; + //@@ inform factory +} + +void +TAO_NS_PushConsumer::push_i (const TAO_NS_Event_var& event ACE_ENV_ARG_DECL) +{ + event->push (this ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_PushConsumer::push (const CORBA::Any& payload ACE_ENV_ARG_DECL) +{ + this->push_consumer_->push (payload ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_PushConsumer::push (const CosNotification::StructuredEvent& event ACE_ENV_ARG_DECL) +{ + CORBA::Any any; + + TAO_NS_Event::translate (event, any); + + this->push_consumer_->push (any ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/PushConsumer.h b/TAO/orbsvcs/orbsvcs/Notify/Any/PushConsumer.h new file mode 100644 index 00000000000..5660ddeee77 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/PushConsumer.h @@ -0,0 +1,66 @@ +/* -*- C++ -*- */ +/** + * @file PushConsumer.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_PUSHCONSUMER_H +#define TAO_NS_PUSHCONSUMER_H +#include "ace/pre.h" + +#include "../notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyCommC.h" +#include "../Consumer.h" +#include "../Destroy_Callback.h" + +/** + * @class TAO_NS_PushConsumer + * + * @brief Wrapper for the PushConsumer that connect to the EventChannel. + * + */ +class TAO_Notify_Export TAO_NS_PushConsumer : public TAO_NS_Consumer +{ +public: + /// Constuctor + TAO_NS_PushConsumer (TAO_NS_ProxySupplier* proxy); + + /// Destructor + ~TAO_NS_PushConsumer (); + + /// Init + void init (CosEventComm::PushConsumer_ptr push_consumer ACE_ENV_ARG_DECL); + + /// TAO_NS_Destroy_Callback methods. + virtual void release (void); + + /// Push <event> to this consumer. + void push_i (const TAO_NS_Event_var& event ACE_ENV_ARG_DECL); + + /// Push <event> to this consumer. + virtual void push (const CORBA::Any& event ACE_ENV_ARG_DECL); + + /// Push <event> to this consumer. + virtual void push (const CosNotification::StructuredEvent& event ACE_ENV_ARG_DECL); + +protected: + /// The Consumer + CosEventComm::PushConsumer_var push_consumer_; +}; + +#if defined (__ACE_INLINE__) +#include "PushConsumer.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_PUSHCONSUMER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/PushConsumer.inl b/TAO/orbsvcs/orbsvcs/Notify/Any/PushConsumer.inl new file mode 100644 index 00000000000..e557d6a7eda --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/PushConsumer.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "PushConsumer.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/PushSupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/Any/PushSupplier.cpp new file mode 100644 index 00000000000..964f1e7976a --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/PushSupplier.cpp @@ -0,0 +1,33 @@ +// $Id$ + +#include "PushSupplier.h" + +#if ! defined (__ACE_INLINE__) +#include "PushSupplier.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_PushSupplier, "$id$") + +TAO_NS_PushSupplier::TAO_NS_PushSupplier (TAO_NS_ProxyConsumer* proxy) + :TAO_NS_Supplier (proxy) +{ +} + +TAO_NS_PushSupplier::~TAO_NS_PushSupplier () +{ +} + +void +TAO_NS_PushSupplier::init (CosEventComm::PushSupplier_ptr push_supplier ACE_ENV_ARG_DECL) +{ + this->push_supplier_ = CosEventComm::PushSupplier::_duplicate (push_supplier); + + this->subscribe_ = CosNotifyComm::NotifySubscribe::_narrow (push_supplier ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_PushSupplier::release (void) +{ + delete this; + //@@ inform factory +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/PushSupplier.h b/TAO/orbsvcs/orbsvcs/Notify/Any/PushSupplier.h new file mode 100644 index 00000000000..3ba1c4fb2c0 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/PushSupplier.h @@ -0,0 +1,60 @@ +/* -*- C++ -*- */ +/** + * @file PushSupplier.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_PUSHSUPPLIER_H +#define TAO_NS_PUSHSUPPLIER_H +#include "ace/pre.h" + +#include "../notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + + +#include "orbsvcs/CosNotifyCommC.h" +#include "../Supplier.h" +#include "../Destroy_Callback.h" + +class TAO_NS_ProxyConsumer; + +/** + * @class TAO_NS_StructuredPushSupplier + * + * @brief Wrapper for the PushSupplier that connect to the EventChannel. + * + */ +class TAO_Notify_Export TAO_NS_PushSupplier : public TAO_NS_Supplier +{ +public: + /// Constuctor + TAO_NS_PushSupplier (TAO_NS_ProxyConsumer* proxy); + + /// Destructor + ~TAO_NS_PushSupplier (); + + /// Init + void init (CosEventComm::PushSupplier_ptr push_supplier ACE_ENV_ARG_DECL); + + /// TAO_NS_Destroy_Callback methods + virtual void release (void); + +protected: + /// The Supplier + CosEventComm::PushSupplier_var push_supplier_; +}; + +#if defined (__ACE_INLINE__) +#include "PushSupplier.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_PUSHSUPPLIER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Any/PushSupplier.inl b/TAO/orbsvcs/orbsvcs/Notify/Any/PushSupplier.inl new file mode 100644 index 00000000000..9f9bf75ff2f --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Any/PushSupplier.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "PushSupplier.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.cpp b/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.cpp new file mode 100644 index 00000000000..814ed93b649 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.cpp @@ -0,0 +1,218 @@ +// $Id$ + +#include "Buffering_Strategy.h" + +#if ! defined (__ACE_INLINE__) +#include "Buffering_Strategy.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_Buffering_Strategy, "$id$") + +#include "ace/Message_Queue.h" +#include "orbsvcs/CosNotificationC.h" +#include "Method_Request.h" +#include "Notify_Extensions.h" +#include "AdminProperties.h" +#include "QoSProperties.h" +#include "Notify_Signal_Property_T.h" +#include "tao/debug.h" + +TAO_NS_Buffering_Strategy::TAO_NS_Buffering_Strategy (ACE_Message_Queue<ACE_SYNCH>& msg_queue, TAO_NS_AdminProperties& admin_properties) + : msg_queue_ (msg_queue), + queue_length_ (admin_properties.queue_length ()), + max_queue_length_ (admin_properties.max_queue_length ()), + max_events_per_consumer_ (CosNotification::MaxEventsPerConsumer, 0), + order_policy_ (CosNotification::OrderPolicy, CosNotification::AnyOrder), + discard_policy_ (CosNotification::DiscardPolicy, CosNotification::AnyOrder), + use_max_queue_ (0), + blocking_timeout_ (TAO_Notify_Extensions::BlockingPolicy) +{ +} + +TAO_NS_Buffering_Strategy::~TAO_NS_Buffering_Strategy () +{ +} + +void +TAO_NS_Buffering_Strategy::update_qos_properties (const TAO_NS_QoSProperties& qos_properties) +{ + this->max_events_per_consumer_.set (qos_properties); + this->order_policy_.set (qos_properties); + this->discard_policy_.set (qos_properties); + this->blocking_timeout_.set (qos_properties); +} + +void +TAO_NS_Buffering_Strategy::execute (TAO_NS_Method_Request& method_request, ACE_Time_Value *tv) +{ + // use_max_queue_ may be set to 0. If max_events_per_consumer_ is + // 0, then we are going to use the maximum queue length regardless. + if (this->max_events_per_consumer_ == 0) + this->use_max_queue_ = 1; + + if (TAO_debug_level > 0) + { + if (this->use_max_queue_) + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - Enqueing command " + "priority %d, queue_length = %d, max queue" + " length = %d\n", + method_request.msg_priority (), this->queue_length_.value (), + this->max_queue_length_.value ())); + else + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - Enqueing command " + "priority %d, queue_length = %d, max events" + " per consumer = %d\n", + method_request.msg_priority (), this->queue_length_.value (), + this->max_events_per_consumer_.value ())); + } + + int result = 0; + + // If we decide to use_max_queue_ and max_queue_length_ is not 0 and + // the queue_length_ is more than max_queue_length_. + // Or if we did not decide to use_max_queue_ and max_events_per_consumer_ + // and queue_length_ is more than max_events_per_consumer_. + CORBA::Long current = this->queue_length_.value (); + if ((this->use_max_queue_ && this->max_queue_length_ != 0 && + current > this->max_queue_length_.value ()) || + (!this->use_max_queue_ && this->max_events_per_consumer_ != 0 && + current > this->max_events_per_consumer_.value ())) + { + if (this->blocking_timeout_.is_valid ()) + { + + // I am multiplying blocking_timeout_ by 1 because it is a + // CORBA::ULongLong, which on some platforms doesn't automatically + // convert to the long that the ACE_Time_Value expects. The / + // operator returns a 32-bit integer. + ACE_Time_Value absolute; + + if (this->blocking_timeout_ != 0) + { + absolute = ACE_OS::gettimeofday () + +# if defined (ACE_CONFIG_WIN32_H) + ACE_Time_Value ( + ACE_static_cast (long, + this->blocking_timeout_.value ())); +# else + ACE_Time_Value (this->blocking_timeout_.value () / 1); +# endif /* ACE_CONFIG_WIN32_H */ + + } + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + "Notify (%P|%t) - Blocking\n")); + + if (this->queue_length_.wait_for_change (&absolute) == -1) + { + // We timed out waiting for the queue length to change + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - " + "Timed out blocking on the client\n")); + return; + } + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + "Notify (%P|%t) - Resuming\n")); + } + else + { + if (TAO_debug_level > 0) + { + if (this->use_max_queue_) + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - max queue length " + "reached, discarding event with " + "policy %d\n", + this->discard_policy_.value ())); + else + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - max events per " + "consumer reached, discarding event " + "with policy %d\n", + this->discard_policy_.value ())); + } + + if (this->discard_policy_ == CosNotification::AnyOrder || + this->discard_policy_ == CosNotification::FifoOrder) + { + ACE_Message_Block *first_item; + result = this->msg_queue_.dequeue_head (first_item, tv); + } + else if (this->discard_policy_ == CosNotification::LifoOrder) + { + ACE_Message_Block *last_item; + result = this->msg_queue_.dequeue_tail (last_item, tv); + } + else if (this->discard_policy_ == CosNotification::DeadlineOrder) + { + ACE_Message_Block *dequeued_item; + result = this->msg_queue_.dequeue_deadline (dequeued_item, tv); + } + else if (this->discard_policy_ == CosNotification::PriorityOrder) + { + ACE_Message_Block *dequeued_item; + result = this->msg_queue_.dequeue_prio (dequeued_item, tv); + } + else + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - " + "Invalid discard policy\n")); + result = -1; + } + + if (result == -1) // we could not dequeue successfully. + { + return; // behave as if we discarded this event. + } + else + { + // decrement the global count of events since we successfully + // dequeued an item from the message queue. + this->queue_length_--; + } + } + } + + // Queue according to order policy + if (this->order_policy_ == CosNotification::AnyOrder || + this->order_policy_ == CosNotification::FifoOrder) + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - " + "enqueue in fifo order\n")); + // Insert at the end of the queue. + result = this->msg_queue_.enqueue_tail (&method_request, tv); + } + else if (this->order_policy_ == CosNotification::PriorityOrder) + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - " + "enqueue in priority order\n")); + result = this->msg_queue_.enqueue_prio (&method_request, tv); + } + else if (this->order_policy_ == CosNotification::DeadlineOrder) + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - " + "enqueue in deadline order\n")); + result = this->msg_queue_.enqueue_deadline (&method_request, tv); + } + else + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - Invalid order policy\n")); + result = -1; + } + + if (result == -1) // we could not enqueue successfully + { + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - " + "Panic! failed to enqueue event")); + // behave as if we discarded this event. + } + else + { + // increment the global count of events. + this->queue_length_++; + } +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.h b/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.h new file mode 100644 index 00000000000..94a7263ea9b --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.h @@ -0,0 +1,87 @@ +/* -*- C++ -*- */ +/** + * @file Buffering_Strategy.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_BUFFERING_STRATEGY_H +#define TAO_NS_BUFFERING_STRATEGY_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +class TAO_NS_AdminProperties; + +#include "orbsvcs/TimeBaseC.h" +#include "Property.h" +#include "Property_T.h" +#include "ace/Message_Queue.h" + +class ACE_Activation_Queue; +class TAO_NS_AdminProperties; +class TAO_NS_Method_Request; +class TAO_NS_QoSProperties; + +/** + * @class TAO_NS_Buffering_Strategy + * + * @brief + * + */ +class TAO_Notify_Export TAO_NS_Buffering_Strategy +{ +public: + /// Constuctor + TAO_NS_Buffering_Strategy (ACE_Message_Queue<ACE_SYNCH>& msg_queue, TAO_NS_AdminProperties& admin_properties); + + /// Destructor + ~TAO_NS_Buffering_Strategy (); + + /// Execute this strategy. + void execute (TAO_NS_Method_Request& method_request, ACE_Time_Value *tv); + + /// Update QoS Properties. + void update_qos_properties (const TAO_NS_QoSProperties& qos_properties); + +protected: + /// Message Queue; + ACE_Message_Queue<ACE_SYNCH>& msg_queue_; + + /// The overall queue length. + TAO_NS_Signal_Property_Long& queue_length_; + + /// Discarding policies kicks in when the <queue_length_> exceeds <max_queue_length_> + const TAO_NS_Property_Long& max_queue_length_; + + /// Discarding policies kicks in when the <queue_length_> exceeds <max_events_per_consumer_> + TAO_NS_Property_Long max_events_per_consumer_; + + /// Order of events in internal buffers. + TAO_NS_Property_Short order_policy_; + + /// Policy to discard when buffers are full. + TAO_NS_Property_Short discard_policy_; + + /// Should we use the max queue or max events. + CORBA::Boolean use_max_queue_; + + /// The blocking timeout will be used in place of discarding + /// if use_blocking_timeout_ is set. This is a TAO specific extension. + TAO_NS_Property_Time blocking_timeout_; +}; + +#if defined (__ACE_INLINE__) +#include "Buffering_Strategy.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_BUFFERING_STRATEGY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.inl b/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Buffering_Strategy.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Builder.cpp b/TAO/orbsvcs/orbsvcs/Notify/Builder.cpp new file mode 100644 index 00000000000..e141d3ab337 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Builder.cpp @@ -0,0 +1,665 @@ +// $Id$ +#include "Builder.h" + +#if ! defined (__ACE_INLINE__) +#include "Builder.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Builder, "$Id$") + +#include "ace/Auto_Ptr.h" +#include "ace/Dynamic_Service.h" +#include "tao/PortableServer/PortableServerC.h" +#include "Factory.h" +#include "Properties.h" +#include "POA_Helper.h" +#include "ID_Factory.h" +#include "EventChannelFactory.h" +#include "EventChannel.h" +#include "SupplierAdmin.h" +#include "ConsumerAdmin.h" +#include "Event_Manager.h" +#include "Worker_Task.h" +#include "Reactive_Task.h" +#include "ThreadPool_Task.h" +#include "FilterFactory.h" +#include "Object.h" +#include "Notify_Service.h" +#include "EventType.h" +#include "Event.h" +#include "Any/AnyEvent.h" +#include "Any/ProxyPushConsumer.h" +#include "Any/ProxyPushSupplier.h" +#include "Any/CosEC_ProxyPushConsumer.h" +#include "Any/CosEC_ProxyPushSupplier.h" +#include "Structured/StructuredProxyPushConsumer.h" +#include "Structured/StructuredProxyPushSupplier.h" +#include "Sequence/SequenceProxyPushConsumer.h" +#include "Sequence/SequenceProxyPushSupplier.h" +#include "Dispatch_Observer_T.h" + +TAO_NS_Builder::TAO_NS_Builder (void) +{ + // Init the static members. + TAO_NS_AnyEvent::event_type_ = TAO_NS_EventType::special (); +} + +TAO_NS_Builder::~TAO_NS_Builder () +{ +} + +CosNotifyFilter::FilterFactory_ptr +TAO_NS_Builder::build_filter_factory (ACE_ENV_SINGLE_ARG_DECL) +{ + TAO_NS_FilterFactory* ff = ACE_Dynamic_Service<TAO_NS_FilterFactory>::instance ("TAO_NS_FilterFactory"); + + if (ff == 0) + return CosNotifyFilter::FilterFactory::_nil (); + else + return ff->create (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::EventChannelFactory_ptr +TAO_NS_Builder::build_event_channel_factory (PortableServer::POA_ptr poa ACE_ENV_ARG_DECL) +{ + CosNotifyChannelAdmin::EventChannelFactory_var ecf_ret; + + TAO_NS_Factory* factory = TAO_NS_PROPERTIES::instance ()->factory (); + + TAO_NS_POA_Helper* object_poa = 0; + // Bootstrap initial Object POA + ACE_NEW_THROW_EX (object_poa, + TAO_NS_POA_Helper (), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (ecf_ret._retn ()); + + auto_ptr<TAO_NS_POA_Helper> auto_object_poa (object_poa); + + object_poa->init (poa ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ecf_ret._retn ()); + + // Create ECF + TAO_NS_EventChannelFactory* ecf = 0; + factory->create (ecf ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ecf_ret._retn ()); + + ecf->TAO_NS_EventChannelFactory::init (ACE_ENV_SINGLE_ARG_PARAMETER); + + ecf->destroy_callback (ecf); + + PortableServer::ServantBase_var servant_var (ecf); + + ecf->TAO_NS_Container_T <TAO_NS_EventChannel, TAO_NS_EventChannelFactory, TAO_NS_Notify_Service>::init (object_poa, 0, object_poa, object_poa); + + ecf->init_collection (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (ecf_ret._retn ()); + + // Give ownership of object_poa + ecf->object_poa (object_poa); + + CORBA::Object_var obj = ecf->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (ecf_ret._retn ()); + + // release auto_ref. + auto_object_poa.release (); + + ecf_ret = CosNotifyChannelAdmin::EventChannelFactory::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ecf_ret._retn ()); + + return (ecf_ret._retn ()); +} + +CosNotifyChannelAdmin::EventChannel_ptr +TAO_NS_Builder::build_event_channel (TAO_NS_EventChannelFactory* ecf, const CosNotification::QoSProperties & initial_qos, const CosNotification::AdminProperties & initial_admin, CosNotifyChannelAdmin::ChannelID_out id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + , CosNotification::UnsupportedAdmin + )) +{ + CosNotifyChannelAdmin::EventChannel_var ec_ret; + + TAO_NS_Factory* factory = TAO_NS_PROPERTIES::instance ()->factory (); + + TAO_NS_EventChannel* ec = 0; + factory->create (ec ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ec_ret._retn ()); + + ec->destroy_callback (ec); + + PortableServer::ServantBase_var servant_var (ec); + + // set the admin properties. + ACE_NEW_THROW_EX (ec->admin_properties_, + TAO_NS_AdminProperties (), + CORBA::NO_MEMORY ()); + + // set the parent - + ec->parent_ = ecf; + + ec->TAO_NS_Container::init (ecf->object_poa(), 0, ecf->object_poa(), ecf->object_poa()); + + // Create the default worker task. + TAO_NS_Reactive_Task* worker_task = new TAO_NS_Reactive_Task (); + ec->worker_task_own (worker_task); + + // proxy poa is set next. + ec->init_collection (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (ec_ret._retn ()); + + // insert ec in ecf container. + ecf->insert (ec ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ec_ret._retn ()); + + // create the event manager. @@ use factory + ACE_NEW_THROW_EX (ec->event_manager_, + TAO_NS_Event_Manager (), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (ec_ret._retn ()); + + ec->event_manager_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (ec_ret._retn ()); + + /* Disable Retry Attempts */ + ec->event_manager_->event_dispatch_observer ()->max_retry_attempts (0); + ec->event_manager_->updates_dispatch_observer ()->max_retry_attempts (0); + /* Disable Retry Attempts */ + + ec->set_qos (initial_qos ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ec_ret._retn ()); + + const CosNotification::QoSProperties &default_ec_qos = + TAO_NS_PROPERTIES::instance ()->default_event_channel_qos_properties (); + + ec->set_qos (default_ec_qos ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ec_ret._retn ()); + + ec->set_admin (initial_admin ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ec_ret._retn ()); + + CORBA::Object_var obj = ec->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (ec_ret._retn ()); + + id = ec->id (); + + // perform channel specific init + ec->TAO_NS_EventChannel::init (ACE_ENV_SINGLE_ARG_PARAMETER); + + ec_ret = CosNotifyChannelAdmin::EventChannel::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ec_ret._retn ()); + + return ec_ret._retn (); +} + +CosNotifyChannelAdmin::ConsumerAdmin_ptr +TAO_NS_Builder::build_consumer_admin (TAO_NS_EventChannel* ec, CosNotifyChannelAdmin::InterFilterGroupOperator op, CosNotifyChannelAdmin::AdminID_out id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + CosNotifyChannelAdmin::ConsumerAdmin_var ca_ret; + + TAO_NS_Factory* factory = TAO_NS_PROPERTIES::instance ()->factory (); + + TAO_NS_ConsumerAdmin* ca = 0; + factory->create (ca ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ca_ret._retn ()); + + ca->destroy_callback (ca); + ca->filter_operator (op); + + ca->parent_ = ec; + ca->event_manager_ = ec->event_manager_; + ca->admin_properties_ = ec->admin_properties_; + + PortableServer::ServantBase_var servant_var (ca); + + ca->init (ec->object_poa (), ec->worker_task (), ec->object_poa (), ec->proxy_poa ()); + + ca->init_collection (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (ca_ret._retn ()); + + // insert admin in ec container. + ec->insert (ca ACE_ENV_ARG_PARAMETER); + + CORBA::Object_var obj = ca->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (ca_ret._retn ()); + + id = ca->id (); + + // Pass EC QoS + ec->qos_properties_.transfer (ca->qos_properties_); + ca->qos_changed (); + + ca_ret = CosNotifyChannelAdmin::ConsumerAdmin::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (ca_ret._retn ()); + + return ca_ret._retn (); +} + +CosNotifyChannelAdmin::SupplierAdmin_ptr +TAO_NS_Builder::build_supplier_admin (TAO_NS_EventChannel* ec, CosNotifyChannelAdmin::InterFilterGroupOperator op, CosNotifyChannelAdmin::AdminID_out id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + CosNotifyChannelAdmin::SupplierAdmin_var sa_ret; + + TAO_NS_Factory* factory = TAO_NS_PROPERTIES::instance ()->factory (); + + TAO_NS_SupplierAdmin* sa = 0; + factory->create (sa ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (sa_ret._retn ()); + + sa->destroy_callback (sa); + sa->filter_operator (op); + + sa->parent_ = ec; + sa->event_manager_ = ec->event_manager_; + sa->admin_properties_ = ec->admin_properties_; + + PortableServer::ServantBase_var servant_var (sa); + + sa->init (ec->object_poa (), ec->worker_task (), ec->object_poa (), ec->proxy_poa ()); + + sa->init_collection (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (sa_ret._retn ()); + + // insert admin in ec container. + ec->insert (sa ACE_ENV_ARG_PARAMETER); + + CORBA::Object_var obj = sa->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (sa_ret._retn ()); + + id = sa->id (); + + // Pass EC QoS + ec->qos_properties_.transfer (sa->qos_properties_); + sa->qos_changed (); + + sa_ret = CosNotifyChannelAdmin::SupplierAdmin::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (sa_ret._retn ()); + + return sa_ret._retn (); +} + +CosNotifyChannelAdmin::ProxyConsumer_ptr +TAO_NS_Builder::build_notification_push_consumer (TAO_NS_SupplierAdmin* sa, CosNotifyChannelAdmin::ClientType ctype, CosNotifyChannelAdmin::ProxyID_out proxy_id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )) + +{ + CosNotifyChannelAdmin::ProxyConsumer_var proxy_ret; + + TAO_NS_Factory* factory = TAO_NS_PROPERTIES::instance ()->factory (); + + switch (ctype) + { + case CosNotifyChannelAdmin::STRUCTURED_EVENT: + { + TAO_NS_StructuredProxyPushConsumer* pc = 0; + factory->create (pc ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + pc->destroy_callback (pc); + + PortableServer::ServantBase_var servantbase_var (pc); + + pc->event_manager_ = sa->event_manager_; + pc->admin_properties_ = sa->admin_properties_; + pc->parent_ = sa; + + /// self POA, proxy POA + pc->init (sa->proxy_poa (), sa->proxy_poa (), sa->worker_task ()); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + // insert proxy in admin container. + sa->insert (pc ACE_ENV_ARG_PARAMETER); + + CORBA::Object_var obj = pc->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + proxy_id = pc->id (); + + // Pass SA QoS + sa->qos_properties_.transfer (pc->qos_properties_); + pc->qos_changed (); + + proxy_ret = CosNotifyChannelAdmin::ProxyConsumer::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + } + break; + + case CosNotifyChannelAdmin::ANY_EVENT: + { + TAO_NS_ProxyPushConsumer* pc = 0; + factory->create (pc ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + pc->destroy_callback (pc); + + PortableServer::ServantBase_var servantbase_var (pc); + + pc->event_manager_ = sa->event_manager_; + pc->admin_properties_ = sa->admin_properties_; + pc->parent_ = sa; + + /// self POA, proxy POA + pc->init (sa->proxy_poa (), sa->proxy_poa (), sa->worker_task ()); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + // insert proxy in admin container. + sa->insert (pc ACE_ENV_ARG_PARAMETER); + + CORBA::Object_var obj = pc->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + proxy_id = pc->id (); + + // Pass SA QoS + sa->qos_properties_.transfer (pc->qos_properties_); + pc->qos_changed (); + + proxy_ret = CosNotifyChannelAdmin::ProxyConsumer::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + } + break; + + case CosNotifyChannelAdmin::SEQUENCE_EVENT: + { + TAO_NS_SequenceProxyPushConsumer* pc = 0; + factory->create (pc ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + pc->destroy_callback (pc); + + PortableServer::ServantBase_var servantbase_var (pc); + + pc->event_manager_ = sa->event_manager_; + pc->admin_properties_ = sa->admin_properties_; + pc->parent_ = sa; + + /// self POA, proxy POA + pc->init (sa->proxy_poa (), sa->proxy_poa (), sa->worker_task ()); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + // insert proxy in admin container. + sa->insert (pc ACE_ENV_ARG_PARAMETER); + + CORBA::Object_var obj = pc->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + proxy_id = pc->id (); + + // Pass SA QoS + sa->qos_properties_.transfer (pc->qos_properties_); + pc->qos_changed (); + + proxy_ret = CosNotifyChannelAdmin::ProxyConsumer::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + } + break; + + default: + ACE_THROW_RETURN (CORBA::BAD_PARAM (), + CosNotifyChannelAdmin::ProxyConsumer::_nil ()); + } + + return proxy_ret._retn (); +} + + +CosNotifyChannelAdmin::ProxySupplier_ptr +TAO_NS_Builder::build_notification_push_supplier (TAO_NS_ConsumerAdmin* ca, CosNotifyChannelAdmin::ClientType ctype, CosNotifyChannelAdmin::ProxyID_out proxy_id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )) +{ + CosNotifyChannelAdmin::ProxySupplier_var proxy_ret; + + TAO_NS_Factory* factory = TAO_NS_PROPERTIES::instance ()->factory (); + + switch (ctype) + { + case CosNotifyChannelAdmin::ANY_EVENT: + { + TAO_NS_ProxyPushSupplier* ps = 0; + factory->create (ps ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + ps->destroy_callback (ps); + + PortableServer::ServantBase_var servant (ps); + + ps->event_manager_ = ca->event_manager_; + ps->admin_properties_ = ca->admin_properties_; + ps->parent_ = ca; + + /// self POA, proxy POA + ps->init (ca->proxy_poa (), ca->proxy_poa (), ca->worker_task ()); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + // insert proxy in admin container. + ca->insert (ps ACE_ENV_ARG_PARAMETER); + + CORBA::Object_var obj = ps->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + proxy_id = ps->id (); + + ps->init_ps (ACE_ENV_SINGLE_ARG_PARAMETER); + + // Pass CA QoS + ca->qos_properties_.transfer (ps->qos_properties_); + ps->qos_changed (); + + proxy_ret = CosNotifyChannelAdmin::ProxySupplier::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + } + break; + + case CosNotifyChannelAdmin::STRUCTURED_EVENT: + { + TAO_NS_StructuredProxyPushSupplier* ps = 0; + factory->create (ps ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + ps->destroy_callback (ps); + + PortableServer::ServantBase_var servant (ps); + + ps->event_manager_ = ca->event_manager_; + ps->admin_properties_ = ca->admin_properties_; + ps->parent_ = ca; + + /// self POA, proxy POA + ps->init (ca->proxy_poa (), ca->proxy_poa (), ca->worker_task ()); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + // insert proxy in admin container. + ca->insert (ps ACE_ENV_ARG_PARAMETER); + + CORBA::Object_var obj = ps->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + proxy_id = ps->id (); + + ps->init_ps (ACE_ENV_SINGLE_ARG_PARAMETER); + + // Pass CA QoS + ca->qos_properties_.transfer (ps->qos_properties_); + ps->qos_changed (); + + proxy_ret = CosNotifyChannelAdmin::ProxySupplier::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + } + break; + + case CosNotifyChannelAdmin::SEQUENCE_EVENT: + { + TAO_NS_SequenceProxyPushSupplier* ps = 0; + factory->create (ps ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + ps->destroy_callback (ps); + + PortableServer::ServantBase_var servant (ps); + + ps->event_manager_ = ca->event_manager_; + ps->admin_properties_ = ca->admin_properties_; + ps->parent_ = ca; + + /// self POA, proxy POA + ps->init (ca->proxy_poa (), ca->proxy_poa (), ca->worker_task ()); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + // insert proxy in admin container. + ca->insert (ps ACE_ENV_ARG_PARAMETER); + + CORBA::Object_var obj = ps->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + proxy_id = ps->id (); + + ps->init_ps (ACE_ENV_SINGLE_ARG_PARAMETER); + + // Pass CA QoS + ca->qos_properties_.transfer (ps->qos_properties_); + ps->qos_changed (); + + proxy_ret = CosNotifyChannelAdmin::ProxySupplier::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + } + break; + + default: + ACE_THROW_RETURN (CORBA::BAD_PARAM (), + CosNotifyChannelAdmin::ProxySupplier::_nil ()); + } + + return proxy_ret._retn (); +} + +CosEventChannelAdmin::ProxyPushSupplier_ptr +TAO_NS_Builder::build_push_supplier (TAO_NS_ConsumerAdmin* ca ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + CosEventChannelAdmin::ProxyPushSupplier_var proxy_ret; + + TAO_NS_Factory* factory = TAO_NS_PROPERTIES::instance ()->factory (); + + TAO_NS_CosEC_ProxyPushSupplier* ps = 0; + factory->create (ps ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + ps->destroy_callback (ps); + + PortableServer::ServantBase_var servant (ps); + + ps->event_manager_ = ca->event_manager_; + ps->admin_properties_ = ca->admin_properties_; + ps->parent_ = ca; + + // self POA, proxy POA + ps->init (ca->proxy_poa (), ca->proxy_poa (), ca->worker_task ()); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + // insert proxy in admin container. + ca->insert (ps ACE_ENV_ARG_PARAMETER); + + CORBA::Object_var obj = ps->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + ps->init_ps (ACE_ENV_SINGLE_ARG_PARAMETER); + + // Pass CA QoS + ca->qos_properties_.transfer (ps->qos_properties_); + ps->qos_changed (); + + proxy_ret = CosEventChannelAdmin::ProxyPushSupplier::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + return proxy_ret._retn (); +} + +CosEventChannelAdmin::ProxyPushConsumer_ptr +TAO_NS_Builder::build_push_consumer (TAO_NS_SupplierAdmin* sa ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + CosEventChannelAdmin::ProxyPushConsumer_var proxy_ret; + + TAO_NS_Factory* factory = TAO_NS_PROPERTIES::instance ()->factory (); + + TAO_NS_CosEC_ProxyPushConsumer* pc = 0; + factory->create (pc ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + pc->destroy_callback (pc); + + PortableServer::ServantBase_var servantbase_var (pc); + + pc->event_manager_ = sa->event_manager_; + pc->admin_properties_ = sa->admin_properties_; + pc->parent_ = sa; + + // self POA, proxy POA + pc->init (sa->proxy_poa (), sa->proxy_poa (), sa->worker_task ()); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + // insert proxy in admin container. + sa->insert (pc ACE_ENV_ARG_PARAMETER); + + CORBA::Object_var obj = pc->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + // Pass SA QoS + sa->qos_properties_.transfer (pc->qos_properties_); + pc->qos_changed (); + + proxy_ret = CosEventChannelAdmin::ProxyPushConsumer::_narrow (obj.in() ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (proxy_ret._retn ()); + + return proxy_ret._retn (); +} + +void +TAO_NS_Builder::apply_threadpool_qos (TAO_NS_Object& object, const NotifyExt::ThreadPoolParams& tp_params, TAO_NS_AdminProperties& admin_properties ACE_ENV_ARG_DECL) +{ + // @@ TODO??: check if number of threads is 0, if so, set as reactive. + + TAO_NS_ThreadPool_Task* worker_task; + + ACE_NEW_THROW_EX (worker_task, + TAO_NS_ThreadPool_Task (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + worker_task->init (tp_params, admin_properties ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + object.worker_task_own (worker_task); +} + +void +TAO_NS_Builder::apply_threadpool_lane_qos (TAO_NS_Object& /*object*/, const NotifyExt::ThreadPoolLanesParams& /*tpl_params*/, TAO_NS_AdminProperties& /*admin_properties*/ ACE_ENV_ARG_DECL) +{ + // No lane support + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class ACE_Dynamic_Service<TAO_NS_FilterFactory>; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate ACE_Dynamic_Service<TAO_NS_FilterFactory> + +#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Builder.h b/TAO/orbsvcs/orbsvcs/Notify/Builder.h new file mode 100644 index 00000000000..cfbd3ab64a1 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Builder.h @@ -0,0 +1,104 @@ +/* -*- C++ -*- */ +/** + * @file Builder.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_BUILDER_H +#define TAO_NS_BUILDER_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PortableServer/PortableServer.h" +#include "orbsvcs/CosNotifyChannelAdminC.h" +#include "orbsvcs/NotifyExtC.h" + +class TAO_NS_EventChannelFactory; +class TAO_NS_EventChannel; +class TAO_NS_SupplierAdmin; +class TAO_NS_ConsumerAdmin; +class TAO_NS_FilterFactory; +class TAO_NS_Object; +class TAO_NS_AdminProperties; + +/** + * @class TAO_NS_Builder + * + * @brief Helper class to create and activate CORBA objects. + * + */ +class TAO_Notify_Export TAO_NS_Builder +{ +public: + TAO_NS_Builder (void); + + virtual ~TAO_NS_Builder (); + + ///= Factory Method + CosNotifyChannelAdmin::EventChannelFactory_ptr build_event_channel_factory (PortableServer::POA_ptr poa ACE_ENV_ARG_DECL); + + CosNotifyChannelAdmin::EventChannel_ptr build_event_channel (TAO_NS_EventChannelFactory* ecf, const CosNotification::QoSProperties & initial_qos, const CosNotification::AdminProperties & initial_admin, CosNotifyChannelAdmin::ChannelID_out id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + , CosNotification::UnsupportedAdmin + )); + + CosNotifyChannelAdmin::ConsumerAdmin_ptr build_consumer_admin (TAO_NS_EventChannel* ec, CosNotifyChannelAdmin::InterFilterGroupOperator op, CosNotifyChannelAdmin::AdminID_out id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + CosNotifyChannelAdmin::SupplierAdmin_ptr build_supplier_admin (TAO_NS_EventChannel* ec, CosNotifyChannelAdmin::InterFilterGroupOperator op, CosNotifyChannelAdmin::AdminID_out id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + CosNotifyChannelAdmin::ProxyConsumer_ptr build_notification_push_consumer (TAO_NS_SupplierAdmin* sa, CosNotifyChannelAdmin::ClientType ctype, CosNotifyChannelAdmin::ProxyID_out proxy_id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )); + + CosNotifyChannelAdmin::ProxySupplier_ptr build_notification_push_supplier (TAO_NS_ConsumerAdmin* ca, CosNotifyChannelAdmin::ClientType ctype, CosNotifyChannelAdmin::ProxyID_out proxy_id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )); + + CosNotifyFilter::FilterFactory_ptr build_filter_factory (ACE_ENV_SINGLE_ARG_DECL); + + CosEventChannelAdmin::ProxyPushSupplier_ptr build_push_supplier (TAO_NS_ConsumerAdmin* ca ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + CosEventChannelAdmin::ProxyPushConsumer_ptr build_push_consumer (TAO_NS_SupplierAdmin* sa ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + ///= Helper Methods + + /// Apply Threadpool QoS + virtual void apply_threadpool_qos (TAO_NS_Object& object, const NotifyExt::ThreadPoolParams& tp_params, TAO_NS_AdminProperties& admin_properties ACE_ENV_ARG_DECL); + + /// Apply ThreadpoolLanes QoS + virtual void apply_threadpool_lane_qos (TAO_NS_Object& object, const NotifyExt::ThreadPoolLanesParams& tpl_params, TAO_NS_AdminProperties& admin_properties ACE_ENV_ARG_DECL); +}; + +#if defined (__ACE_INLINE__) +#include "Builder.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_BUILDER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Builder.inl b/TAO/orbsvcs/orbsvcs/Notify/Builder.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Builder.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Constraint_Interpreter.cpp b/TAO/orbsvcs/orbsvcs/Notify/Constraint_Interpreter.cpp new file mode 100644 index 00000000000..8cb1eac6dd0 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Constraint_Interpreter.cpp @@ -0,0 +1,46 @@ +// $Id$ + +#include "Constraint_Interpreter.h" +#include "Constraint_Visitors.h" + +ACE_RCSID(Notify, NS_Constraint_Interpreter, "$Id$") + +TAO_NS_Constraint_Interpreter::TAO_NS_Constraint_Interpreter (void) +{ +} + +TAO_NS_Constraint_Interpreter::~TAO_NS_Constraint_Interpreter (void) +{ +} + +void +TAO_NS_Constraint_Interpreter::build_tree ( + const char *constraints + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC ((CosNotifyFilter::InvalidConstraint, + CORBA::NO_MEMORY)) +{ + if (TAO_ETCL_Interpreter::is_empty_string (constraints)) + { + // Root is deleted in the TAO_Interpreter's destructor. + ACE_NEW_THROW_EX (this->root_, + TAO_ETCL_Literal_Constraint ((CORBA::Boolean) 1), + CORBA::NO_MEMORY ()); + ACE_CHECK; + } + else + { + // root_ is set in this base class call. + if (TAO_ETCL_Interpreter::build_tree (constraints) != 0) + ACE_THROW (CosNotifyFilter::InvalidConstraint ()); + } +} + +CORBA::Boolean +TAO_NS_Constraint_Interpreter::evaluate (TAO_NS_Constraint_Visitor &evaluator) +{ + CORBA::Boolean retval = evaluator.evaluate_constraint (this->root_); + + return retval; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Constraint_Interpreter.h b/TAO/orbsvcs/orbsvcs/Notify/Constraint_Interpreter.h new file mode 100644 index 00000000000..d22ba152b37 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Constraint_Interpreter.h @@ -0,0 +1,62 @@ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file NS_Constraint_Interpreter.h + * + * $Id$ + * + * + * + * + * @author Pradeep Gore <pradeep@cs.wustl.edu> + */ +//============================================================================= + + +#ifndef TAO_NOTIFY_CONSTRAINT_INTERPRETER_H +#define TAO_NOTIFY_CONSTRAINT_INTERPRETER_H + +#include "ace/pre.h" +#include "orbsvcs/ETCL/ETCL_Interpreter.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/ETCL/ETCL_Constraint.h" +#include "orbsvcs/CosNotifyFilterC.h" +#include "notify_export.h" + +class TAO_NS_Constraint_Visitor; + +/** + * @class TAO_NS_Constraint_Interpreter + * + * @brief "ETCL" Interpreter for the Notify queries. + */ +class TAO_Notify_Export TAO_NS_Constraint_Interpreter : public TAO_ETCL_Interpreter +{ +public: + // = Initialization and termination methods. + TAO_NS_Constraint_Interpreter (void); + + /// Destructor + ~TAO_NS_Constraint_Interpreter (void); + + /** + * This method builds an expression tree representing the + * constraint specified in <constraints>, and throws an Illegal + * Constraint exception if the constraint given has syntax errors or + * semantic errors, such as mismatched types. + */ + void build_tree (const char* constraints + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CosNotifyFilter::InvalidConstraint, + CORBA::NO_MEMORY)); + + /// Returns true if the constraint is evaluated successfully by + /// the evaluator. + CORBA::Boolean evaluate (TAO_NS_Constraint_Visitor &evaluator); +}; +#include "ace/post.h" +#endif /* TAO_NOTIFY_CONSTRAINT_INTERPRETER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Constraint_Visitors.cpp b/TAO/orbsvcs/orbsvcs/Notify/Constraint_Visitors.cpp new file mode 100644 index 00000000000..809c52bb05e --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Constraint_Visitors.cpp @@ -0,0 +1,1564 @@ +/* -*- C++ -*- */ +/* $Id$ */ + +#include "Constraint_Visitors.h" +#include "orbsvcs/ETCL/ETCL_Constraint.h" +#include "orbsvcs/ETCL/ETCL_y.h" +#include "tao/DynamicAny/DynArray_i.h" +#include "tao/DynamicAny/DynSequence_i.h" +#include "tao/DynamicAny/DynStruct_i.h" +#include "tao/DynamicAny/DynUnion_i.h" +#include "tao/DynamicAny/DynEnum_i.h" +#include "tao/DynamicAny/DynAnyFactory.h" + +TAO_NS_Constraint_Visitor::TAO_NS_Constraint_Visitor (void) + : implicit_id_ (NONE) +{ + (void) this->implicit_ids_.bind (ACE_CString ("filterable_data", + 0, + 0), + FILTERABLE_DATA); + (void) this->implicit_ids_.bind (ACE_CString ("header", + 0, + 0), + HEADER); + (void) this->implicit_ids_.bind (ACE_CString ("remainder_of_body", + 0, + 0), + REMAINDER_OF_BODY); + (void) this->implicit_ids_.bind (ACE_CString ("fixed_header", + 0, + 0), + FIXED_HEADER); + (void) this->implicit_ids_.bind (ACE_CString ("variable_header", + 0, + 0), + VARIABLE_HEADER); + (void) this->implicit_ids_.bind (ACE_CString ("event_name", + 0, + 0), + EVENT_NAME); + (void) this->implicit_ids_.bind (ACE_CString ("event_type", + 0, + 0), + EVENT_TYPE); + (void) this->implicit_ids_.bind (ACE_CString ("domain_name", + 0, + 0), + DOMAIN_NAME); + (void) this->implicit_ids_.bind (ACE_CString ("type_name", + 0, + 0), + TYPE_NAME); +} + +int +TAO_NS_Constraint_Visitor::bind_structured_event ( + const CosNotification::StructuredEvent &s_event + ) +{ + // The two sequences contained in a structured event are + // copied into hash tables so iteration is done only once. + + CORBA::ULong length = s_event.filterable_data.length (); + CORBA::ULong index = 0; + + for (index = 0; index < length; ++index) + { + ACE_CString name_str (s_event.filterable_data[index].name, 0, 0); + + int status = + this->filterable_data_.bind ( + name_str, + ACE_const_cast (CORBA::Any *, + &s_event.filterable_data[index].value) + ); + + if (status != 0) + { + return -1; + } + } + + length = s_event.header.variable_header.length (); + + for (index = 0; index < length; ++index) + { + ACE_CString name_str (s_event.header.variable_header[index].name, 0, 0); + + int status = + this->variable_header_.bind ( + name_str, + ACE_const_cast (CORBA::Any *, + &s_event.header.variable_header[index].value) + ); + + if (status != 0) + { + return -1; + } + } + + this->domain_name_ = + CORBA::string_dup (s_event.header.fixed_header.event_type.domain_name); + + this->type_name_ = + CORBA::string_dup (s_event.header.fixed_header.event_type.type_name); + + this->event_name_ = + CORBA::string_dup (s_event.header.fixed_header.event_name); + + this->remainder_of_body_ = s_event.remainder_of_body; + + return 0; +} + +CORBA::Boolean +TAO_NS_Constraint_Visitor::evaluate_constraint ( + TAO_ETCL_Constraint* root + ) +{ + CORBA::Boolean result = 0; + this->queue_.reset (); + + // Evaluate the constraint in root_; + if (root != 0) + { + if ((root->accept (this) == 0) && + (! this->queue_.is_empty ())) + { + TAO_ETCL_Literal_Constraint top; + this->queue_.dequeue_head (top); + result = (CORBA::Boolean) top; + } + } + + // If a property couldn't be evaluated we must return 0. + return result; +} + +int +TAO_NS_Constraint_Visitor::visit_literal ( + TAO_ETCL_Literal_Constraint *literal + ) +{ + this->queue_.enqueue_head (*literal); + return 0; +} + +int +TAO_NS_Constraint_Visitor::visit_identifier (TAO_ETCL_Identifier *ident) +{ + int return_value = -1; + const char *name = ident->value (); + ACE_CString key (name, 0, 0); + + CORBA::Any *any = 0; + + if (this->filterable_data_.find (key, any) == 0) + { + if (any != 0) + { + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (any)); + return_value = 0; + } + } + + return return_value; +} + +int +TAO_NS_Constraint_Visitor::visit_union_value ( + TAO_ETCL_Union_Value *union_value + ) +{ + switch (union_value->sign ()) + { + case 0: + this->queue_.enqueue_head (*union_value->string ()); + break; + case -1: + this->queue_.enqueue_head (-(*union_value->integer ())); + break; + case 1: + this->queue_.enqueue_head (*union_value->integer ()); + break; + default: + return -1; + } + + return 0; +} + +int +TAO_NS_Constraint_Visitor::visit_union_pos ( + TAO_ETCL_Union_Pos *union_pos + ) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + if (union_pos->union_value ()->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint disc_val; + this->queue_.dequeue_head (disc_val); + + TAO_DynUnion_i dyn_union; + dyn_union.init (this->current_value_.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::TypeCode_var tc = this->current_value_->type (); + + switch (disc_val.expr_type ()) + { + case TAO_ETCL_INTEGER: + case TAO_ETCL_SIGNED: + case TAO_ETCL_UNSIGNED: + { + CORBA::Any disc_any; + CORBA::TypeCode_var disc_tc = + tc->discriminator_type (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + CORBA::TCKind disc_kind = + TAO_DynAnyFactory::unalias (disc_tc.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + switch (disc_kind) + { + case CORBA::tk_boolean: + disc_any <<= CORBA::Any::from_boolean ((CORBA::Boolean) disc_val); + break; + case CORBA::tk_short: + disc_any <<= (CORBA::Short) ((CORBA::Long) disc_val); + break; + case CORBA::tk_ushort: + disc_any <<= (CORBA::UShort) ((CORBA::ULong) disc_val); + break; + case CORBA::tk_long: + disc_any <<= (CORBA::Long) disc_val; + break; + case CORBA::tk_ulong: + disc_any <<= (CORBA::ULong) disc_val; + break; + case CORBA::tk_enum: + { + TAO_OutputCDR cdr; + cdr.write_ulong ((CORBA::ULong) disc_val); + disc_any._tao_replace (disc_tc.in (), + TAO_ENCAP_BYTE_ORDER, + cdr.begin ()); + break; + } + // @@@ (JP) I don't think ETCL handles 64-bit + // integers at this point, and I also think that + // chars and/or wchars will just come out in the + // constraint as (w)strings of length 1. + case CORBA::tk_longlong: + case CORBA::tk_ulonglong: + case CORBA::tk_char: + case CORBA::tk_wchar: + default: + return -1; + } + + DynamicAny::DynAny_var dyn_any = + TAO_DynAnyFactory::make_dyn_any (disc_any + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + dyn_union.set_discriminator (dyn_any.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + DynamicAny::DynAny_var u_member = + dyn_union.member (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + this->current_value_ = + u_member->to_any (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + break; + } + case TAO_ETCL_STRING: + { + const char *name = (const char *) disc_val; + CORBA::ULong count = + tc->member_count (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + const char *member_name = 0; + CORBA::ULong i = 0; + + for (i = 0; i < count; ++i) + { + member_name = tc->member_name (i + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (ACE_OS::strcmp (name, member_name) == 0) + { + break; + } + } + + // If there's no match, member_label will throw + // CORBA::TypeCode::Bounds and the catch block will + // return -1; + this->current_value_ = tc->member_label (i + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + break; + } + // The TAO_ETCL_Union_Value that was put on the queue + // shouldn't have any other type. + default: + return -1; + } + + TAO_ETCL_Constraint *nested = union_pos->component (); + + // If there's no nested component, then we just want the + // union member value on the queue. Otherwise, we want + // the member value in current_value_ while we visit + // the nested component. + if (nested == 0) + { + TAO_ETCL_Literal_Constraint lit (this->current_value_); + this->queue_.enqueue_head (lit); + return 0; + } + else + { + return nested->accept (this); + } + } + else + { + return -1; + } + } + ACE_CATCHANY + { + return -1; + } + ACE_ENDTRY; + + ACE_NOTREACHED (return 0); +} + +int +TAO_NS_Constraint_Visitor::visit_component_pos ( + TAO_ETCL_Component_Pos *pos + ) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + // If we are here (from visit_component) the Any containing the + // component as found in filterable_data_ will be in current_value_. + CORBA::TypeCode_var tc = this->current_value_->type (); + CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + DynamicAny::DynAny_var member; + CORBA::Boolean success = 0; + CORBA::ULong slot = (CORBA::ULong) *pos->integer (); + + switch (kind) + { + case CORBA::tk_enum: + { + TAO_DynEnum_i dyn_enum; + dyn_enum.init (this->current_value_.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + success = dyn_enum.seek (slot + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (success == 0) + { + return -1; + } + + member = + dyn_enum.current_component (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + break; + } + case CORBA::tk_struct: + { + TAO_DynStruct_i dyn_struct; + dyn_struct.init (this->current_value_.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + success = dyn_struct.seek (slot + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (success == 0) + { + return -1; + } + + member = dyn_struct.current_component (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + break; + } + // @@@ (JP) I think enums and structs are the only two cases handled + // by Component_Pos, since arrays and sequences are handled by + // Component_Array, and unions are handled by Union_Pos. + default: + return -1; + } + + CORBA::Any_var value = member->to_any (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + TAO_ETCL_Constraint *comp = pos->component (); + + if (comp == 0) + { + TAO_ETCL_Literal_Constraint result (value); + this->queue_.enqueue_head (result); + return 0; + } + else + { + this->current_value_ = value._retn (); + return comp->accept (this); + } + } + ACE_CATCHANY + { + return -1; + } + ACE_ENDTRY; + + ACE_NOTREACHED (return 0); +} + +int +TAO_NS_Constraint_Visitor::visit_component_assoc ( + TAO_ETCL_Component_Assoc *assoc + ) +{ + CORBA::Any *any = 0; + ACE_CString name (assoc->identifier ()->value (), + 0, + 0); + + switch (this->implicit_id_) + { + case FILTERABLE_DATA: + if (this->filterable_data_.find (name, any) != 0 + || any == 0) + { + return -1; + } + + break; + case VARIABLE_HEADER: + if (this->variable_header_.find (name, any) != 0 + || any == 0) + { + return -1; + } + + break; + // Only the sequence members of CosNotification::StructuredEvent can be + // treated as associative arrays. + default: + return -1; + } + + TAO_ETCL_Constraint *comp = assoc->component (); + CORBA::Any *any_ptr = 0; + + if (comp == 0) + { + TAO_ETCL_Literal_Constraint result (any); + this->queue_.enqueue_head (result); + + // If we're at the end of the line, put the name into + // current_value_ so visit_exist can use it. + ACE_NEW_RETURN (any_ptr, + CORBA::Any, + -1); + (*any_ptr) <<= name.c_str (); + this->current_value_ = any_ptr; + + return 0; + } + else + { + ACE_NEW_RETURN (any_ptr, + CORBA::Any (*any), + -1); + this->current_value_ = any_ptr; + return comp->accept (this); + } +} + +int +TAO_NS_Constraint_Visitor::visit_component_array ( + TAO_ETCL_Component_Array *array + ) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + // If we are here (from visit_component) the Any containing the + // component as found in filterable_data_ will be in current_value_. + CORBA::TypeCode_var tc = this->current_value_->type (); + CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + DynamicAny::DynAny_var member; + CORBA::Boolean success = 0; + CORBA::ULong slot = (CORBA::ULong) *array->integer (); + + switch (kind) + { + case CORBA::tk_array: + { + TAO_DynEnum_i dyn_array; + dyn_array.init (this->current_value_.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + success = dyn_array.seek (slot + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (success == 0) + { + return -1; + } + + member = dyn_array.current_component (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + break; + } + case CORBA::tk_sequence: + { + TAO_DynStruct_i dyn_sequence; + dyn_sequence.init (this->current_value_.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + success = dyn_sequence.seek (slot + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (success == 0) + { + return -1; + } + + member = + dyn_sequence.current_component (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + break; + } + // Enums and sequences are the only two cases handled + // by Component_Array. + default: + return -1; + } + + CORBA::Any_var value = member->to_any (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + TAO_ETCL_Constraint *comp = array->component (); + + if (comp == 0) + { + TAO_ETCL_Literal_Constraint result (value); + this->queue_.enqueue_head (result); + return 0; + } + else + { + this->current_value_ = value._retn (); + return comp->accept (this); + } + } + ACE_CATCHANY + { + return -1; + } + ACE_ENDTRY; + + ACE_NOTREACHED (return 0); +} + +int +TAO_NS_Constraint_Visitor::visit_special (TAO_ETCL_Special *special) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + CORBA::TypeCode_var tc = this->current_value_->type (); + + switch (special->type ()) + { + case TAO_ETCL_LENGTH: + { + // If the TCKind is not a sequence or an array, the + // call to length() will raise an exception, and the + // catch block will return -1; + CORBA::ULong length = tc->length (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + TAO_ETCL_Literal_Constraint lit (length); + this->queue_.enqueue_head (lit); + return 0; + } + case TAO_ETCL_DISCRIMINANT: + { + // If the TCKind is not a union, the + // call to init() will raise an exception, and the + // catch block will return -1; + TAO_DynUnion_i dyn_union; + dyn_union.init (this->current_value_.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + DynamicAny::DynAny_var disc = + dyn_union.get_discriminator (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Any_var disc_any = disc->to_any (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + TAO_ETCL_Literal_Constraint lit (disc_any); + this->queue_.enqueue_head (lit); + return 0; + } + case TAO_ETCL_TYPE_ID: + { + const char *name = tc->name (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + TAO_ETCL_Literal_Constraint lit (name); + this->queue_.enqueue_head (lit); + return 0; + } + case TAO_ETCL_REPOS_ID: + { + const char *id = tc->id (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + TAO_ETCL_Literal_Constraint lit (id); + this->queue_.enqueue_head (lit); + return 0; + } + default: + return -1; + } + } + ACE_CATCHANY + { + return -1; + } + ACE_ENDTRY; + + ACE_NOTREACHED (return 0); +} + +int +TAO_NS_Constraint_Visitor::visit_component ( + TAO_ETCL_Component *component + ) +{ + TAO_ETCL_Constraint *nested = component->component (); + TAO_ETCL_Identifier *identifier = component->identifier (); + ACE_CString component_name (identifier->value (), + 0, + 0); + CORBA::Any *any_ptr = 0; + + if (this->implicit_ids_.find (component_name, this->implicit_id_) != 0) + { + this->implicit_id_ = NONE; + } + + // If this component has no sub-component, only an identifier, + // then we just visit the identifier, which puts a literal on + // the queue to be handled upon returning from this method call. + // If there is a sub-component, we store the literal's value + // in our member _var for possible examination at a more + // nested level, and visit the sub-component. If the identifier + // matches one of the nested field names in + // CosNotification::StructuredEvent, we just visit the nested + // component, if any. + if (this->implicit_id_ == NONE) + { + if (nested == 0) + { + // If this is the end of the line, we put the component name + // into current_value_ so visit_exist can use it. + ACE_NEW_RETURN (any_ptr, + CORBA::Any, + -1); + (*any_ptr) <<= component_name.c_str (); + this->current_value_ = any_ptr; + return identifier->accept (this); + } + else + { + int result = identifier->accept (this); + + if (result != 0) + { + return result; + } + + TAO_ETCL_Literal_Constraint id; + this->queue_.dequeue_head (id); + ACE_NEW_RETURN (any_ptr, + CORBA::Any (*(const CORBA::Any *) id), + -1); + this->current_value_ = any_ptr; + } + } + + if (nested != 0) + { + return nested->accept (this); + } + else + { + switch (this->implicit_id_) + { + case TYPE_NAME: + { + TAO_ETCL_Literal_Constraint tn (this->type_name_.in ()); + this->queue_.enqueue_head (tn); + return 0; + } + case EVENT_NAME: + { + TAO_ETCL_Literal_Constraint en (this->event_name_.in ()); + this->queue_.enqueue_head (en); + return 0; + } + case DOMAIN_NAME: + { + TAO_ETCL_Literal_Constraint dn (this->domain_name_.in ()); + this->queue_.enqueue_head (dn); + return 0; + } + case REMAINDER_OF_BODY: + { + TAO_ETCL_Literal_Constraint rob (&this->remainder_of_body_); + this->queue_.enqueue_head (rob); + return 0; + } + // The above cases are the leaves of the + // CosNotification::StructuredEvent "tree". Anything else and we + // should have a nested component. otherwise, it's an error. + default: + return -1; + } + } +} + +int +TAO_NS_Constraint_Visitor::visit_dot (TAO_ETCL_Dot *dot) +{ + // If we are here, we know we're headed for a more nested + // level, so we just visit it, there's nothing else in this + // constraint. + return dot->component ()->accept (this); +} + +int +TAO_NS_Constraint_Visitor::visit_eval (TAO_ETCL_Eval *eval) +{ + // Nothing to do but visit the contained component. + return eval->component ()->accept (this); +} + +int +TAO_NS_Constraint_Visitor::visit_default (TAO_ETCL_Default *def) +{ + TAO_ETCL_Constraint *comp = def->component (); + + if (comp == 0) + { + return -1; + } + + if (comp->accept (this) != 0) + { + return -1; + } + + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + CORBA::TypeCode_var tc = this->current_value_->type (); + + // If the current member is not a union, this call will + // throw BadKind and the catch block will return -1. + CORBA::Long default_index = tc->default_index (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + // No default index. + if (default_index == -1) + { + TAO_ETCL_Literal_Constraint result ((CORBA::Boolean) 0); + this->queue_.enqueue_head (result); + return 0; + } + + // Okay, there's a default index, but is it active? + + TAO_ETCL_Literal_Constraint disc; + this->queue_.dequeue_head (disc); + TAO_ETCL_Literal_Constraint default_index_value (default_index); + return (disc == default_index_value); + } + ACE_CATCHANY + { + return -1; + } + ACE_ENDTRY; + + ACE_NOTREACHED (return 0); +} + +int +TAO_NS_Constraint_Visitor::visit_exist (TAO_ETCL_Exist *exist) +{ + TAO_ETCL_Constraint *component = exist->component (); + + if (component->accept (this) == 0) + { + const char *value = 0; + CORBA::Boolean result = 0; + + // For the two cases below, we don't want the item at the top of + // the queue, because it's the result of a hash table lookup. For + // an existence test, we want the key value, which is stored in + // the current_value_ member. + if (this->implicit_id_ == FILTERABLE_DATA + || this->implicit_id_ == VARIABLE_HEADER) + { + TAO_ETCL_Literal_Constraint current ( + &this->current_value_.inout () + ); + value = CORBA::string_dup ((const char *) current); + } + + switch (this->implicit_id_) + { + case FILTERABLE_DATA: + result = + (this->filterable_data_.find (ACE_CString (value, 0, 0)) == 0); + break; + case VARIABLE_HEADER: + result = + (this->variable_header_.find (ACE_CString (value, 0, 0)) == 0); + break; + case TYPE_NAME: + result = (this->type_name_.in () != 0); + break; + case EVENT_NAME: + result = (this->event_name_.in () != 0); + break; + case DOMAIN_NAME: + result = (this->domain_name_.in () != 0); + break; + // Anything other than the above cases is an error. + default: + return -1; + } + + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + + return 0; + } + + return -1; +} + +int +TAO_NS_Constraint_Visitor::visit_unary_expr ( + TAO_ETCL_Unary_Expr *unary_expr + ) +{ + TAO_ETCL_Constraint *subexpr = unary_expr->subexpr (); + + if (subexpr->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint subexpr_result; + CORBA::Boolean result = 0; + int op_type = unary_expr->type (); + + switch (op_type) + { + case TAO_ETCL_NOT: + this->queue_.dequeue_head (subexpr_result); + result = ! (CORBA::Boolean) subexpr_result; + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + return 0; + case TAO_ETCL_MINUS: + // The leading '-' was parsed separately, so we have to pull + // the literal constraint off the queue, apply the class' own + // unary minus operator, and put it back. + this->queue_.dequeue_head (subexpr_result); + this->queue_.enqueue_head (-subexpr_result); + return 0; + case TAO_ETCL_PLUS: + // Leave the literal constraint on the queue. The leading + // '+' was just syntactic sugar - no action is necessary. + return 0; + default: + // The parser should never construct a TAO_ETCL_Unary_Constraint + // behind any operators except the above three. + return -1; + } + } + + return -1; +} + +int +TAO_NS_Constraint_Visitor::visit_binary_expr ( + TAO_ETCL_Binary_Expr *binary_expr + ) +{ + int bin_op_type = binary_expr->type (); + + switch (bin_op_type) + { + case TAO_ETCL_OR: + return this->visit_or (binary_expr); + case TAO_ETCL_AND: + return this->visit_and (binary_expr); + case TAO_ETCL_LT: + case TAO_ETCL_LE: + case TAO_ETCL_GT: + case TAO_ETCL_GE: + case TAO_ETCL_EQ: + case TAO_ETCL_NE: + case TAO_ETCL_PLUS: + case TAO_ETCL_MINUS: + case TAO_ETCL_MULT: + case TAO_ETCL_DIV: + return this->visit_binary_op (binary_expr, + bin_op_type); + case TAO_ETCL_TWIDDLE: + return this->visit_twiddle (binary_expr); + case TAO_ETCL_IN: + return this->visit_in (binary_expr); + default: + return -1; + } +} + +int +TAO_NS_Constraint_Visitor::visit_or ( + TAO_ETCL_Binary_Expr *binary + ) +{ + int return_value = -1; + CORBA::Boolean result = 0; + TAO_ETCL_Constraint *lhs = binary->lhs (); + + if (lhs->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint lhs_result; + this->queue_.dequeue_head (lhs_result); + result = (CORBA::Boolean) lhs_result; + + // Short-circuiting OR. + if (result == 0) + { + TAO_ETCL_Constraint *rhs = binary->rhs (); + + if (rhs->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint rhs_result; + this->queue_.dequeue_head (rhs_result); + result = (CORBA::Boolean) rhs_result; + return_value = 0; + } + } + else + { + return_value = 0; + } + } + + if (return_value == 0) + { + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + } + + return return_value; +} + +int +TAO_NS_Constraint_Visitor::visit_and ( + TAO_ETCL_Binary_Expr *binary + ) +{ + int return_value = -1; + CORBA::Boolean result = 0; + TAO_ETCL_Constraint *lhs = binary->lhs (); + + if (lhs->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint lhs_result; + this->queue_.dequeue_head (lhs_result); + result = (CORBA::Boolean) lhs_result; + + // Short-circuiting AND. + if (result == 1) + { + TAO_ETCL_Constraint *rhs = binary->rhs (); + + if (rhs->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint rhs_result; + this->queue_.dequeue_head (rhs_result); + result = (CORBA::Boolean) rhs_result; + return_value = 0; + } + } + else + { + return_value = 0; + } + } + + if (return_value == 0) + { + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + } + + return return_value; +} + +int +TAO_NS_Constraint_Visitor::visit_binary_op ( + TAO_ETCL_Binary_Expr *binary, + int op_type + ) +{ + int return_value = -1; + TAO_ETCL_Constraint *lhs = binary->lhs (); + CORBA::Boolean result = 0; + + // Perform an operation on the results of evaluating the left and + // right branches of this subtree. + if (lhs->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint left_operand; + this->queue_.dequeue_head (left_operand); + TAO_ETCL_Constraint *rhs = binary->rhs (); + + if (rhs->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint right_operand; + this->queue_.dequeue_head (right_operand); + return_value = 0; + + switch (op_type) + { + case TAO_ETCL_LT: + result = left_operand < right_operand; + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + break; + case TAO_ETCL_LE: + result = left_operand <= right_operand; + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + break; + case TAO_ETCL_GT: + result = left_operand > right_operand; + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + break; + case TAO_ETCL_GE: + result = left_operand >= right_operand; + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + break; + case TAO_ETCL_EQ: + result = left_operand == right_operand; + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + break; + case TAO_ETCL_NE: + result = left_operand != right_operand; + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + break; + case TAO_ETCL_PLUS: + this->queue_.enqueue_head (left_operand + right_operand); + break; + case TAO_ETCL_MINUS: + this->queue_.enqueue_head (left_operand - right_operand); + break; + case TAO_ETCL_MULT: + this->queue_.enqueue_head (left_operand * right_operand); + break; + case TAO_ETCL_DIV: + this->queue_.enqueue_head (left_operand / right_operand); + break; + default: + return_value = -1; + } + } + } + + return return_value; +} + +int +TAO_NS_Constraint_Visitor::visit_twiddle ( + TAO_ETCL_Binary_Expr *binary + ) +{ + int return_value = -1; + TAO_ETCL_Constraint *lhs = binary->lhs (); + + // Determine if the left operand is a substring of the right. + if (lhs->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint left; + this->queue_.dequeue_head (left); + TAO_ETCL_Constraint *rhs = binary->rhs (); + + if (rhs->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint right; + this->queue_.dequeue_head (right); + CORBA::Boolean result = + (ACE_OS::strstr ((const char *) right, + (const char *) left) != 0); + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + return_value = 0; + } + } + + return return_value; +} + +int +TAO_NS_Constraint_Visitor::visit_in ( + TAO_ETCL_Binary_Expr *binary + ) +{ + int return_value = -1; + TAO_ETCL_Constraint *lhs = binary->lhs (); + + // Determine if the left operand is contained in the right. + + if (lhs->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint left; + this->queue_.dequeue_head (left); + + TAO_ETCL_Constraint *rhs = binary->rhs (); + + if (rhs->accept (this) == 0) + { + TAO_ETCL_Literal_Constraint bag; + this->queue_.dequeue_head (bag); + + if (bag.expr_type () == TAO_ETCL_COMPONENT) + { + const CORBA::Any *component = (const CORBA::Any *) bag; + CORBA::TCKind kind = CORBA::tk_null; + + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + CORBA::TypeCode_var tc = component->type (); + kind = TAO_DynAnyFactory::unalias (tc.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + return return_value; + } + ACE_ENDTRY; + + CORBA::Boolean result = 0; + + switch (kind) + { + case CORBA::tk_sequence: + result = this->sequence_does_contain (component, + left); + break; + case CORBA::tk_array: + result = this->array_does_contain (component, + left); + break; + case CORBA::tk_struct: + result = this->struct_does_contain (component, + left); + break; + case CORBA::tk_union: + result = this->union_does_contain (component, + left); + break; + case CORBA::tk_any: + result = this->any_does_contain (component, + left); + break; + default: + return return_value; + } + + this->queue_.enqueue_head (TAO_ETCL_Literal_Constraint (result)); + return_value = 0; + } + } + } + + return return_value; +} + +int +TAO_NS_Constraint_Visitor::visit_preference ( + TAO_ETCL_Preference * + ) +{ + // According to OMG 00-06-20 section 2.4.1, the Notification Service + // does not use the preference operators. The method must be here + // because it is called by the ETCL node, which may be used by other + // CORBA services that do use the preference operators. + return -1; +} + +CORBA::Boolean +TAO_NS_Constraint_Visitor::sequence_does_contain ( + const CORBA::Any *any, + TAO_ETCL_Literal_Constraint &item + ) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + CORBA::TypeCode_var type = any->type (); + CORBA::TCKind kind = TAO_DynAnyFactory::unalias (type.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // The literal and the array elements must be + // of the same simple type. + CORBA::Boolean match = this->simple_type_match (item.expr_type (), + kind); + + if (match == 0) + { + return 0; + } + + TAO_DynSequence_i dyn_seq; + dyn_seq.init (*any + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + DynamicAny::AnySeq_var any_seq = + dyn_seq.get_elements (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::ULong length = any_seq->length (); + + for (CORBA::ULong i = 0; i < length; ++i) + { + TAO_ETCL_Literal_Constraint element (&any_seq[i]); + + if (item == element) + { + return 1; + } + } + } + ACE_CATCHANY + { + return 0; + } + ACE_ENDTRY; + + return 0; +} + +CORBA::Boolean +TAO_NS_Constraint_Visitor::array_does_contain ( + const CORBA::Any *any, + TAO_ETCL_Literal_Constraint &item + ) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + CORBA::TypeCode_var type = any->type (); + CORBA::TCKind kind = TAO_DynAnyFactory::unalias (type.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // The literal and the array elements must be + // of the same simple type. + CORBA::Boolean match = this->simple_type_match (item.expr_type (), + kind); + + if (match == 0) + { + return 0; + } + + TAO_DynArray_i dyn_array; + dyn_array.init (*any + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + DynamicAny::AnySeq_var any_seq = + dyn_array.get_elements (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::ULong length = any_seq->length (); + + for (CORBA::ULong i = 0; i < length; ++i) + { + TAO_ETCL_Literal_Constraint element (&any_seq[i]); + + if (item == element) + { + return 1; + } + } + } + ACE_CATCHANY + { + return 0; + } + ACE_ENDTRY; + + return 0; +} + +CORBA::Boolean +TAO_NS_Constraint_Visitor::struct_does_contain ( + const CORBA::Any *any, + TAO_ETCL_Literal_Constraint &item + ) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + TAO_DynStruct_i dyn_struct; + dyn_struct.init (*any + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + DynamicAny::NameValuePairSeq_var members = + dyn_struct.get_members (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::ULong length = members->length (); + CORBA::TypeCode_var tc; + CORBA::TCKind kind; + + for (CORBA::ULong i = 0; i < length; ++i) + { + tc = members[i].value.type (); + kind = TAO_DynAnyFactory::unalias (tc.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // The literal and the struct member must be + // of the same simple type. + CORBA::Boolean match = this->simple_type_match (item.expr_type (), + kind); + + if (match == 0) + { + continue; + } + + TAO_ETCL_Literal_Constraint element (&members[i].value); + + if (item == element) + { + return 1; + } + } + } + ACE_CATCHANY + { + return 0; + } + ACE_ENDTRY; + + return 0; +} + +CORBA::Boolean +TAO_NS_Constraint_Visitor::union_does_contain ( + const CORBA::Any *any, + TAO_ETCL_Literal_Constraint &item + ) +{ + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + TAO_DynUnion_i dyn_union; + dyn_union.init (*any + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + DynamicAny::DynAny_var cc = + dyn_union.current_component (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Any_var member = cc->to_any (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::TypeCode_var tc = member->type (); + CORBA::TCKind kind = TAO_DynAnyFactory::unalias (tc.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // The literal and the union member must be + // of the same simple type. + CORBA::Boolean match = this->simple_type_match (item.expr_type (), + kind); + + if (match == 0) + { + return 0; + } + + TAO_ETCL_Literal_Constraint element (&member.inout ()); + + return (item == element); + } + ACE_CATCHANY + { + return 0; + } + ACE_ENDTRY; + + ACE_NOTREACHED (return 0); +} + +CORBA::Boolean +TAO_NS_Constraint_Visitor::any_does_contain ( + const CORBA::Any *any, + TAO_ETCL_Literal_Constraint &item + ) +{ + const CORBA::Any *result = 0; + + *any >>= result; + + TAO_ETCL_Literal_Constraint element (ACE_const_cast (CORBA::Any *, + result)); + + return (item == element); +} + +CORBA::Boolean +TAO_NS_Constraint_Visitor::simple_type_match (int expr_type, + CORBA::TCKind tc_kind) +{ + switch (expr_type) + { + case TAO_ETCL_STRING: + if (tc_kind != CORBA::tk_string) + { + return 0; + } + case TAO_ETCL_DOUBLE: + if (tc_kind != CORBA::tk_double + && tc_kind != CORBA::tk_float) + { + return 0; + } + case TAO_ETCL_INTEGER: + case TAO_ETCL_SIGNED: + if (tc_kind != CORBA::tk_short + && tc_kind != CORBA::tk_long + && tc_kind != CORBA::tk_longlong) + { + return 0; + } + case TAO_ETCL_UNSIGNED: + if (tc_kind != CORBA::tk_ushort + && tc_kind != CORBA::tk_ulong + && tc_kind != CORBA::tk_ulonglong) + { + return 0; + } + case TAO_ETCL_BOOLEAN: + if (tc_kind != CORBA::tk_boolean) + { + return 0; + } + default: + return 0; + } +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class ACE_Hash_Map_Manager<ACE_CString, CORBA::Any*, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Manager_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Entry <ACE_CString, CORBA::Any*>; +template class ACE_Hash_Map_Iterator<ACE_CString, CORBA::Any*, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator_Base_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Reverse_Iterator<ACE_CString, CORBA::Any*, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Reverse_Iterator_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>; +template class ACE_Node<TAO_ETCL_Literal_Constraint>; +template class ACE_Unbounded_Queue<TAO_ETCL_Literal_Constraint>; +template class ACE_Unbounded_Queue_Iterator<TAO_ETCL_Literal_Constraint>; + + +template class ACE_Hash_Map_Manager<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Manager_Ex<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Entry <ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field>; +template class ACE_Hash_Map_Iterator<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator_Ex<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator_Base_Ex<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Reverse_Iterator<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Reverse_Iterator_Ex<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX>; +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate ACE_Hash_Map_Manager<ACE_CString, CORBA::Any*, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Manager_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Entry <ACE_CString, CORBA::Any*> +#pragma instantiate ACE_Hash_Map_Iterator<ACE_CString, CORBA::Any*, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator<ACE_CString, CORBA::Any*, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<ACE_CString, CORBA::Any *, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Node<TAO_ETCL_Literal_Constraint> +#pragma instantiate ACE_Unbounded_Queue<TAO_ETCL_Literal_Constraint> +#pragma instantiate ACE_Unbounded_Queue_Iterator<TAO_ETCL_Literal_Constraint> + +#pragma instantiate ACE_Hash_Map_Manager<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Manager_Ex<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Entry <ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field> +#pragma instantiate ACE_Hash_Map_Iterator<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator_Ex<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<ACE_CString, TAO_NS_Constraint_Visitor::structured_event_field, ACE_Hash<ACE_CString>, ACE_Equal_To<ACE_CString>, TAO_SYNCH_MUTEX> + +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Constraint_Visitors.h b/TAO/orbsvcs/orbsvcs/Notify/Constraint_Visitors.h new file mode 100644 index 00000000000..6ca0b2929a5 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Constraint_Visitors.h @@ -0,0 +1,149 @@ +/* -*- C++ -*- */ +//============================================================================= +/** + * @file NS_Constraint_Visitors.h + * + * $Id$ + * + * + * + * + * @author Pradeep Gore <pradeep@cs.wustl.edu> + * @author Jeff Parsons <parsons@cs.wustl.edu> + */ +//============================================================================= + + +#ifndef NOTIFY_CONSTRAINT_VISITORS_H +#define NOTIFY_CONSTRAINT_VISITORS_H + +#include "ace/pre.h" +#include "ace/Hash_Map_Manager.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/ETCL/ETCL_Constraint_Visitor.h" +#include "orbsvcs/CosNotificationC.h" +#include "notify_export.h" + +class TAO_ETCL_Constraint; +class TAO_ETCL_Literal_Constraint; +class TAO_Notify_Property_Constraint; + +class TAO_Notify_Export TAO_NS_Constraint_Visitor + : public TAO_ETCL_Constraint_Visitor +{ +public: + /// Constructor. + TAO_NS_Constraint_Visitor (void); + + /// Put the event data into our hash map. + int bind_structured_event (const CosNotification::StructuredEvent &s_event); + + /** + * Returns 1 if the event satisfies the constraint + * represented by the the expression tree rooted at <root>, 0 if it + * doesn't. If an error occurs during the process, the traversal + * automatically fails. + */ + CORBA::Boolean evaluate_constraint (TAO_ETCL_Constraint *root); + + // The overridden methods. + int visit_literal (TAO_ETCL_Literal_Constraint *); + int visit_identifier (TAO_ETCL_Identifier *); + int visit_union_value (TAO_ETCL_Union_Value *); + int visit_union_pos (TAO_ETCL_Union_Pos *); + int visit_component_pos (TAO_ETCL_Component_Pos *); + int visit_component_assoc (TAO_ETCL_Component_Assoc *); + int visit_component_array (TAO_ETCL_Component_Array *); + int visit_special (TAO_ETCL_Special *); + int visit_component (TAO_ETCL_Component *); + int visit_dot (TAO_ETCL_Dot *); + int visit_eval (TAO_ETCL_Eval *); + int visit_default (TAO_ETCL_Default *); + int visit_exist (TAO_ETCL_Exist *); + int visit_unary_expr (TAO_ETCL_Unary_Expr *); + int visit_binary_expr (TAO_ETCL_Binary_Expr *); + int visit_preference (TAO_ETCL_Preference *); + +protected: + // Sub-methods for visit_binary_expr(). + int visit_or (TAO_ETCL_Binary_Expr *); + int visit_and (TAO_ETCL_Binary_Expr *); + int visit_twiddle (TAO_ETCL_Binary_Expr *); + int visit_in (TAO_ETCL_Binary_Expr *); + int visit_binary_op (TAO_ETCL_Binary_Expr *binary_expr, + int op_type); + + // These use dynamic anys to look inside the ETCL component. + CORBA::Boolean sequence_does_contain (const CORBA::Any *any, + TAO_ETCL_Literal_Constraint &item); + CORBA::Boolean array_does_contain (const CORBA::Any *any, + TAO_ETCL_Literal_Constraint &item); + CORBA::Boolean struct_does_contain (const CORBA::Any *any, + TAO_ETCL_Literal_Constraint &item); + CORBA::Boolean union_does_contain (const CORBA::Any *any, + TAO_ETCL_Literal_Constraint &item); + CORBA::Boolean any_does_contain (const CORBA::Any *any, + TAO_ETCL_Literal_Constraint &item); + + // Utility function to compare a TAO_ETCL_Literal_Constraint type + // and a type code. + CORBA::Boolean simple_type_match (int expr_type, + CORBA::TCKind tc_kind); + + enum structured_event_field + { + FILTERABLE_DATA, + HEADER, + FIXED_HEADER, + EVENT_TYPE, + DOMAIN_NAME, + TYPE_NAME, + EVENT_NAME, + VARIABLE_HEADER, + REMAINDER_OF_BODY, + NONE + }; + + /// Storage for the type of implicit id the component has (if any). + structured_event_field implicit_id_; + + /// Lookup table for the implicit ids, to avoid string comparisons in + /// derived visitors. + ACE_Hash_Map_Manager <ACE_CString, structured_event_field, TAO_SYNCH_MUTEX> + implicit_ids_; + + /// Used to lookup names and values in the event's 'filterable_data' field. + ACE_Hash_Map_Manager <ACE_CString, CORBA::Any *, TAO_SYNCH_MUTEX> + filterable_data_; + + /// Used to lookup names and values in the event's 'variable_header' field. + ACE_Hash_Map_Manager <ACE_CString, CORBA::Any *, TAO_SYNCH_MUTEX> + variable_header_; + + /// Storage for string names under the structured event's + /// 'fixed_header' field. + CORBA::String_var domain_name_; + CORBA::String_var type_name_; + CORBA::String_var event_name_; + + /// Storage for the structured_event's 'remainder_of_body' field. + CORBA::Any remainder_of_body_; + + /// The result of a non_boolean operation. + ACE_Unbounded_Queue <TAO_ETCL_Literal_Constraint> queue_; + + /// Holder for a value found in the event fields filterable_data, + /// variable_header or remainder_of_body. + CORBA::Any_var current_value_; + + /// Holder for a string name in the event fields fixed_header, + /// variable_header, or filterable_data. + CORBA::String_var current_name_; +}; + +#include "ace/post.h" +#endif /* NOTIFY_CONSTRAINT_VISITORS_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Consumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Consumer.cpp new file mode 100644 index 00000000000..d2199303ca2 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Consumer.cpp @@ -0,0 +1,133 @@ +// $Id$ + +#include "Consumer.h" + +#if ! defined (__ACE_INLINE__) +#include "Consumer.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Consumer, "$Id$") + +#include "ace/Refcounted_Auto_Ptr.h" +#include "ace/Unbounded_Queue.h" +#include "tao/debug.h" +#include "ProxySupplier.h" +#include "Dispatch_Observer_T.h" +#include "Proxy.h" +#include "Admin.h" +#include "EventChannel.h" +#include "EventChannelFactory.h" +#include "Notify_Service.h" + +TAO_NS_Consumer::TAO_NS_Consumer (TAO_NS_ProxySupplier* proxy) + :proxy_ (proxy), event_dispatch_observer_ (0), event_collection_ (0), is_suspended_ (0) +{ + this->event_collection_ = new TAO_NS_Event_Collection (); +} + +TAO_NS_Consumer::~TAO_NS_Consumer () +{ + delete this->event_collection_; +} + +TAO_NS_Proxy* +TAO_NS_Consumer::proxy (void) +{ + return this->proxy_supplier (); +} + +void +TAO_NS_Consumer::push (const TAO_NS_Event_var &event ACE_ENV_ARG_DECL) +{ + if (this->is_suspended_ == 1) // If we're suspended, queue for later delivery. + { + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, *this->proxy_lock ()); + this->event_collection_->enqueue_head (event); + } + } + + ACE_TRY + { + this->push_i (event ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (this->event_dispatch_observer_ != 0) + { + this->event_dispatch_observer_->dispatch_success (this ACE_ENV_ARG_PARAMETER); + + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, *this->proxy_lock ()); + this->retry_count_ = 0; + } + } + ACE_CATCHANY + { + if (TAO_debug_level > 0) + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "TAO_NS_Consumer::push: error sending event. informing dispatch observer\n "); + } + //ACE_RE_THROW; + + if (this->event_dispatch_observer_ != 0) + { + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, *this->proxy_lock ()); + + ++this->retry_count_; + this->event_collection_->enqueue_head (event); + } + + this->event_dispatch_observer_->dispatch_failure (this, this->retry_count_ ACE_ENV_ARG_PARAMETER); + } + } + ACE_ENDTRY; +} + +void +TAO_NS_Consumer::dispatch_pending (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + if (this->is_suspended_ == 1) + return; // Do nothing if we're suspended. + + TAO_NS_Event_Collection event_collection_copy; + + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, *this->proxy_lock ()); + event_collection_copy = *this->event_collection_; // Payload is never copied, this is a collection of _vars. + this->event_collection_->reset (); + } + + TAO_NS_ProxySupplier* proxy_supplier = this->proxy_supplier (); + + TAO_NS_Event_var event; + + while (!event_collection_copy.is_empty ()) + { + if (event_collection_copy.dequeue_head (event) == 0) + { + proxy_supplier->push_no_filtering (event); + } + } +} + +void +TAO_NS_Consumer::resume (ACE_ENV_SINGLE_ARG_DECL) +{ + this->is_suspended_ = 0; + + this->dispatch_pending (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +void +TAO_NS_Consumer::dispatch_updates_i (const TAO_NS_EventTypeSeq & added, const TAO_NS_EventTypeSeq & removed + ACE_ENV_ARG_DECL) +{ + CosNotification::EventTypeSeq cos_added; + CosNotification::EventTypeSeq cos_removed; + + added.populate (cos_added); + removed.populate (cos_removed); + + if (!CORBA::is_nil (this->publish_.in ())) + this->publish_->offer_change (cos_added, cos_removed ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Consumer.h b/TAO/orbsvcs/orbsvcs/Notify/Consumer.h new file mode 100644 index 00000000000..c70f93b7a3d --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Consumer.h @@ -0,0 +1,109 @@ +/* -*- C++ -*- */ +/** + * @file Consumer.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_CONSUMER_H +#define TAO_NS_CONSUMER_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyCommC.h" +#include "orbsvcs/CosNotificationC.h" +#include "Peer.h" +#include "Event.h" +#include "Types.h" + +class TAO_NS_ProxySupplier; +class TAO_NS_Proxy; + +/** + * @class TAO_NS_Consumer + * + * @brief Astract Base class for wrapping consumer objects that connect to the EventChannel + * + */ +class TAO_Notify_Export TAO_NS_Consumer : public TAO_NS_Peer +{ +public: + /// Constuctor + TAO_NS_Consumer (TAO_NS_ProxySupplier* proxy); + + /// Destructor + virtual ~TAO_NS_Consumer (); + + /// Access Specific Proxy. + TAO_NS_ProxySupplier* proxy_supplier (void); + + /// Access Base Proxy. + virtual TAO_NS_Proxy* proxy (void); + + /// Push <event> to this consumer. + void push (const TAO_NS_Event_var& event ACE_ENV_ARG_DECL); + + /// Push <event> to this consumer. + virtual void push (const CORBA::Any& event ACE_ENV_ARG_DECL) = 0; + + /// Push <event> to this consumer. + virtual void push (const CosNotification::StructuredEvent& event ACE_ENV_ARG_DECL) = 0; + + /// Set Observer. + void event_dispatch_observer (TAO_NS_Event_Dispatch_Observer* event_dispatch_observer); + + /// Dispatch the pending events + void dispatch_pending (ACE_ENV_SINGLE_ARG_DECL); + + /// Is the connection suspended? + CORBA::Boolean is_suspended (void); + + /// Suspend Connection + void suspend (ACE_ENV_SINGLE_ARG_DECL); + + /// Resume Connection + void resume (ACE_ENV_SINGLE_ARG_DECL); + +protected: + /// Get the shared Proxy Lock + TAO_SYNCH_MUTEX* proxy_lock (void); + + /// Push Implementation. + virtual void push_i (const TAO_NS_Event_var& event ACE_ENV_ARG_DECL) = 0; + + // Dispatch updates implementation. + virtual void dispatch_updates_i (const TAO_NS_EventTypeSeq & added, + const TAO_NS_EventTypeSeq & removed + ACE_ENV_ARG_DECL); + + /// The Proxy that we associate with. + TAO_NS_ProxySupplier* proxy_; + + /// Observer + TAO_NS_Event_Dispatch_Observer* event_dispatch_observer_; + + /// Events pending to be delivered. + TAO_NS_Event_Collection* event_collection_; + + /// Suspended Flag. + CORBA::Boolean is_suspended_; + + /// Interface that accepts offer_changes + CosNotifyComm::NotifyPublish_var publish_; +}; + +#if defined (__ACE_INLINE__) +#include "Consumer.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_CONSUMER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Consumer.inl b/TAO/orbsvcs/orbsvcs/Notify/Consumer.inl new file mode 100644 index 00000000000..aa56593f7ab --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Consumer.inl @@ -0,0 +1,33 @@ +// $Id$ + +#include "ProxySupplier.h" + +ACE_INLINE TAO_SYNCH_MUTEX* +TAO_NS_Consumer::proxy_lock (void) +{ + return &this->proxy_->lock_; +} + +ACE_INLINE TAO_NS_ProxySupplier* +TAO_NS_Consumer::proxy_supplier (void) +{ + return this->proxy_; +} + +ACE_INLINE void +TAO_NS_Consumer::event_dispatch_observer (TAO_NS_Event_Dispatch_Observer* event_dispatch_observer) +{ + this->event_dispatch_observer_ = event_dispatch_observer; +} + +ACE_INLINE CORBA::Boolean +TAO_NS_Consumer::is_suspended (void) +{ + return this->is_suspended_; +} + +ACE_INLINE void +TAO_NS_Consumer::suspend (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->is_suspended_ = 1; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.cpp b/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.cpp new file mode 100644 index 00000000000..b2129957ecf --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.cpp @@ -0,0 +1,337 @@ +// $Id$ + +#include "ConsumerAdmin.h" + +#if ! defined (__ACE_INLINE__) +#include "ConsumerAdmin.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_ConsumerAdmin, "$Id$") + +#include "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "Builder.h" +#include "Subscription_Change_Worker.h" +#include "Proxy.h" +#include "Admin.h" +#include "EventChannel.h" +#include "EventChannelFactory.h" +#include "Notify_Service.h" + +TAO_NS_ConsumerAdmin::TAO_NS_ConsumerAdmin (void) +:TAO_NS_Admin (TAO_NS_Admin::CONSUMER_ADMIN) +{ +} + +TAO_NS_ConsumerAdmin::~TAO_NS_ConsumerAdmin () +{ +} + +PortableServer::Servant +TAO_NS_ConsumerAdmin::servant (void) +{ + return this; +} + +void +TAO_NS_ConsumerAdmin::_add_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->_incr_refcnt (); +} + +void +TAO_NS_ConsumerAdmin::_remove_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->_decr_refcnt (); +} + +void +TAO_NS_ConsumerAdmin::release (void) +{ + delete this; + //@@ inform factory +} + +void +TAO_NS_ConsumerAdmin::destroy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + this->inherited::destroy (this ACE_ENV_ARG_PARAMETER); +} + +::CosNotifyChannelAdmin::ProxySupplier_ptr +TAO_NS_ConsumerAdmin::obtain_notification_push_supplier (CosNotifyChannelAdmin::ClientType ctype, + CosNotifyChannelAdmin::ProxyID_out proxy_id + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )) +{ + return TAO_NS_PROPERTIES::instance()->builder ()->build_notification_push_supplier (this, + ctype, + proxy_id ACE_ENV_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::AdminID +TAO_NS_ConsumerAdmin::MyID (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->id (); +} + +CosNotifyChannelAdmin::EventChannel_ptr +TAO_NS_ConsumerAdmin::MyChannel (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + CORBA::Object_var object = this->parent_->ref (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::EventChannel::_nil ()); + + return CosNotifyChannelAdmin::EventChannel::_narrow (object.in () ACE_ENV_ARG_PARAMETER); +} + +::CosNotifyChannelAdmin::InterFilterGroupOperator +TAO_NS_ConsumerAdmin::MyOperator (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->filter_operator_; +} + +CosNotifyChannelAdmin::ProxyIDSeq* +TAO_NS_ConsumerAdmin::push_suppliers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + CosNotifyChannelAdmin::ProxyIDSeq* seq; + + ACE_NEW_THROW_EX (seq, + CosNotifyChannelAdmin::ProxyIDSeq (), + CORBA::NO_MEMORY ()); + + seq->length (this->proxy_id_list_.size ()); + + TAO_NS_Object_Id_Seq::CONST_ITERATOR iter (this->proxy_id_list_); + + TAO_NS_Object_Id* object_id; + + CORBA::ULong i = 0; + for (iter.first (); iter.next (object_id); iter.advance (), ++i) + seq[i] = *object_id; + + return seq; +} + +CosNotifyChannelAdmin::ProxySupplier_ptr +TAO_NS_ConsumerAdmin::get_proxy_supplier (CosNotifyChannelAdmin::ProxyID proxy_id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::ProxyNotFound + )) +{ + TAO_NS_Object* ns_object = this->find (proxy_id ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::ProxySupplier::_nil ()); + + if (ns_object != 0) + { + CORBA::Object_var object = ns_object->ref (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::ProxySupplier::_nil ()); + + return CosNotifyChannelAdmin::ProxySupplier::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + } + else + ACE_THROW_RETURN (CosNotifyChannelAdmin::ProxyNotFound (), CosNotifyChannelAdmin::ProxySupplier::_nil ()); +} + +CosEventChannelAdmin::ProxyPushSupplier_ptr +TAO_NS_ConsumerAdmin::obtain_push_supplier (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return TAO_NS_PROPERTIES::instance()->builder ()->build_push_supplier (this ACE_ENV_ARG_PARAMETER); +} + +void TAO_NS_ConsumerAdmin::set_qos (const CosNotification::QoSProperties & qos ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )) +{ + this->TAO_NS_Object::set_qos (qos ACE_ENV_ARG_PARAMETER); +} + + +CosNotification::QoSProperties* +TAO_NS_ConsumerAdmin::get_qos (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->TAO_NS_Object::get_qos (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +void +TAO_NS_ConsumerAdmin::subscription_change (const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyComm::InvalidEventType + )) +{ + TAO_NS_EventTypeSeq seq_added (added); + TAO_NS_EventTypeSeq seq_removed (removed); + + { + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK; + + this->subscribed_types_.init (seq_added, seq_removed); + } + + TAO_NS_Subscription_Change_Worker worker (added, removed); + + this->collection_->for_each (&worker ACE_ENV_ARG_PARAMETER); +} + +CosNotifyFilter::FilterID +TAO_NS_ConsumerAdmin::add_filter (CosNotifyFilter::Filter_ptr new_filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->filter_admin_.add_filter (new_filter ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_ConsumerAdmin::remove_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyFilter::FilterNotFound + )) +{ + this->filter_admin_.remove_filter (filter ACE_ENV_ARG_PARAMETER); +} + +::CosNotifyFilter::Filter_ptr +TAO_NS_ConsumerAdmin::get_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyFilter::FilterNotFound + )) +{ + return this->filter_admin_.get_filter (filter ACE_ENV_ARG_PARAMETER); +} + +::CosNotifyFilter::FilterIDSeq* +TAO_NS_ConsumerAdmin::get_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->filter_admin_.get_all_filters (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +void +TAO_NS_ConsumerAdmin::remove_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + this->filter_admin_.get_all_filters (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +/************ UNIMPLMENTED METHODS *************************/ + +CosNotifyFilter::MappingFilter_ptr +TAO_NS_ConsumerAdmin::priority_filter (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CosNotifyFilter::MappingFilter::_nil ()); +} + +void +TAO_NS_ConsumerAdmin::priority_filter (CosNotifyFilter::MappingFilter_ptr /*priority_filter*/ ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) + +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +CosNotifyFilter::MappingFilter_ptr +TAO_NS_ConsumerAdmin::lifetime_filter (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) + +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CosNotifyFilter::MappingFilter::_nil ()); +} + +void +TAO_NS_ConsumerAdmin::lifetime_filter (CosNotifyFilter::MappingFilter_ptr /*lifetime_filter*/ ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +::CosNotifyChannelAdmin::ProxyIDSeq* +TAO_NS_ConsumerAdmin::pull_suppliers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + +CosNotifyChannelAdmin::ProxySupplier_ptr +TAO_NS_ConsumerAdmin::obtain_notification_pull_supplier (CosNotifyChannelAdmin::ClientType /*ctype*/, + CosNotifyChannelAdmin::ProxyID_out /*proxy_id*/ + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )) + +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CosNotifyChannelAdmin::ProxySupplier::_nil ()); +} + +void +TAO_NS_ConsumerAdmin::validate_qos (const CosNotification::QoSProperties & /*required_qos*/, + CosNotification::NamedPropertyRangeSeq_out /*available_qos*/ + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +CosEventChannelAdmin::ProxyPullSupplier_ptr +TAO_NS_ConsumerAdmin::obtain_pull_supplier (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CosEventChannelAdmin::ProxyPullSupplier::_nil ()); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.h b/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.h new file mode 100644 index 00000000000..32470332213 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.h @@ -0,0 +1,217 @@ +/* -*- C++ -*- */ +/** + * @file ConsumerAdmin.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_CONSUMERADMIN_H +#define TAO_NS_CONSUMERADMIN_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyChannelAdminS.h" +#include "Admin.h" +#include "Destroy_Callback.h" + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/** + * @class TAO_NS_ConsumerAdmin + * + * @brief Implementation of CosNotifyChannelAdmin::ConsumerAdmin + * + */ +class TAO_Notify_Export TAO_NS_ConsumerAdmin : public POA_CosNotifyChannelAdmin::ConsumerAdmin, public virtual TAO_NS_Admin, public TAO_NS_Destroy_Callback +{ + friend class TAO_NS_Builder; +public: + + /// Constuctor + TAO_NS_ConsumerAdmin (void); + + /// Destructor + ~TAO_NS_ConsumerAdmin (); + + /// Return servant + virtual PortableServer::Servant servant (void); + + /// ServantBase refcount methods. + virtual void _add_ref (ACE_ENV_SINGLE_ARG_DECL); + virtual void _remove_ref (ACE_ENV_SINGLE_ARG_DECL); + + /// TAO_NS_Destroy_Callback methods + virtual void release (void); + +protected: + + /// = CosNotifyChannelAdmin::ConsumerAdmin methods + virtual CosNotifyChannelAdmin::AdminID MyID (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::EventChannel_ptr MyChannel (ACE_ENV_SINGLE_ARG_DECL + + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::InterFilterGroupOperator MyOperator (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyFilter::MappingFilter_ptr priority_filter (ACE_ENV_SINGLE_ARG_DECL + + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void priority_filter (CosNotifyFilter::MappingFilter_ptr priority_filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyFilter::MappingFilter_ptr lifetime_filter (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void lifetime_filter (CosNotifyFilter::MappingFilter_ptr lifetime_filter + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::ProxyIDSeq * pull_suppliers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::ProxyIDSeq * push_suppliers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::ProxySupplier_ptr get_proxy_supplier (CosNotifyChannelAdmin::ProxyID proxy_id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::ProxyNotFound + )); + + virtual ::CosNotifyChannelAdmin::ProxySupplier_ptr obtain_notification_pull_supplier (CosNotifyChannelAdmin::ClientType ctype, + CosNotifyChannelAdmin::ProxyID_out proxy_id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )); + + virtual ::CosNotifyChannelAdmin::ProxySupplier_ptr obtain_notification_push_supplier (CosNotifyChannelAdmin::ClientType ctype, + CosNotifyChannelAdmin::ProxyID_out proxy_id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )); + + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotification::QoSProperties * get_qos (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void set_qos (const CosNotification::QoSProperties & qos + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )); + + virtual void validate_qos (const CosNotification::QoSProperties & required_qos, + CosNotification::NamedPropertyRangeSeq_out available_qos + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )); + + virtual void subscription_change (const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyComm::InvalidEventType + )); + + virtual CosNotifyFilter::FilterID add_filter (CosNotifyFilter::Filter_ptr new_filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void remove_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyFilter::FilterNotFound + )); + + virtual ::CosNotifyFilter::Filter_ptr get_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyFilter::FilterNotFound + )); + + virtual ::CosNotifyFilter::FilterIDSeq * get_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void remove_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosEventChannelAdmin::ProxyPushSupplier_ptr obtain_push_supplier (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosEventChannelAdmin::ProxyPullSupplier_ptr obtain_pull_supplier (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__ACE_INLINE__) +#include "ConsumerAdmin.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_CONSUMERADMIN_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.inl b/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ConsumerAdmin.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Container.cpp b/TAO/orbsvcs/orbsvcs/Notify/Container.cpp new file mode 100644 index 00000000000..858d38c58da --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Container.cpp @@ -0,0 +1,51 @@ +// $Id$ + +#include "Container.h" +#include "ThreadPool_Task.h" +#include "POA_Helper.h" + +#if ! defined (__ACE_INLINE__) +#include "Container.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Container, "$Id$") + +TAO_NS_Container::TAO_NS_Container (void) + :object_poa_ (0), delete_object_poa_ (0) +{ +} + +TAO_NS_Container::~TAO_NS_Container () +{ +} + +void +TAO_NS_Container::init (TAO_NS_POA_Helper* poa, TAO_NS_Worker_Task* worker_task, TAO_NS_POA_Helper* object_poa, TAO_NS_POA_Helper* proxy_poa) +{ + TAO_NS_Object::init (poa, proxy_poa, worker_task); + + object_poa_ = object_poa; +} + +void +TAO_NS_Container::cleanup (ACE_ENV_SINGLE_ARG_DECL) +{ + if (delete_object_poa_ == 1) + { + object_poa_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + delete object_poa_; + } +} + +void +TAO_NS_Container::object_poa (TAO_NS_POA_Helper* object_poa) +{ + object_poa_ = object_poa; + delete_object_poa_ = 1; +} + +TAO_NS_POA_Helper* +TAO_NS_Container::object_poa (void) +{ + return this->object_poa_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Container.h b/TAO/orbsvcs/orbsvcs/Notify/Container.h new file mode 100644 index 00000000000..4f227303c1b --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Container.h @@ -0,0 +1,71 @@ +/* -*- C++ -*- */ +/** + * @file Container.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_CONTAINER_H +#define TAO_NS_CONTAINER_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/NotifyExtC.h" +#include "Object.h" + +class TAO_NS_POA_Helper; +class TAO_NS_QoSAdmin; + +/** + * @class TAO_NS_Container + * + * @brief A Base class for implementing the Notify participants that behave as Obejct Containers. + * + */ +class TAO_Notify_Export TAO_NS_Container : public virtual TAO_NS_Object +{ +public: + /// Constuctor + TAO_NS_Container (void); + + /// Destructor + virtual ~TAO_NS_Container (); + + /// Init this object. + void init (TAO_NS_POA_Helper* poa, TAO_NS_Worker_Task* worker_task, TAO_NS_POA_Helper* object_poa, TAO_NS_POA_Helper* proxy_poa); + + /// Cleanup + void cleanup (ACE_ENV_SINGLE_ARG_DECL); + + /// Accessor for the object_poa_ + /// Setting the object_poa_ gives ownership to this class. + void object_poa (TAO_NS_POA_Helper* object_poa); + TAO_NS_POA_Helper* object_poa (void); + +protected: + /// = Protected Methods + + /// = Data Members + + /// The POA in which the object's are activated. + TAO_NS_POA_Helper* object_poa_; + + /// Flag that indicates if we own <object_poa_> + int delete_object_poa_; +}; + +#if defined (__ACE_INLINE__) +#include "Container.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_CONTAINER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Container.inl b/TAO/orbsvcs/orbsvcs/Notify/Container.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Container.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Container_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Container_T.cpp new file mode 100644 index 00000000000..b8f86f25e8c --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Container_T.cpp @@ -0,0 +1,78 @@ +// $Id$ + +#ifndef TAO_NS_CONTAINER_T_CPP +#define TAO_NS_CONTAINER_T_CPP + +#include "Container_T.h" + +#include "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "orbsvcs/ESF/ESF_Shutdown_Proxy.h" +#include "Properties.h" +#include "Factory.h" +#include "POA_Helper.h" + +#if ! defined (__ACE_INLINE__) +#include "Container_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Container_T, "$Id$") + +/*************************************************************************************************/ + +template<class OBJECT> +TAO_NS_Object_Find_Worker_T<OBJECT>::TAO_NS_Object_Find_Worker_T (CORBA::Long id) + :id_ (id), result_ (0) +{ +} + +/*************************************************************************************************/ + +template<class TYPE, class OBJECT, class PARENT> +TAO_NS_Container_T<TYPE, OBJECT, PARENT>::TAO_NS_Container_T (void) + : collection_ (0) +{ +} + +template<class TYPE, class OBJECT, class PARENT> +TAO_NS_Container_T<TYPE, OBJECT, PARENT>::~TAO_NS_Container_T () +{ + /// + delete collection_; +} + +template <class TYPE, class OBJECT, class PARENT> void +TAO_NS_Container_T<TYPE, OBJECT, PARENT>::shutdown (ACE_ENV_SINGLE_ARG_DECL) +{ + TAO_NS_Object_T<OBJECT, PARENT>::shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + TAO_ESF_Shutdown_Proxy<TYPE> shutdown_worker; + + this->collection_->for_each (&shutdown_worker ACE_ENV_ARG_PARAMETER); + + /// shutdown Container + this->cleanup (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +template<class TYPE, class OBJECT, class PARENT> void +TAO_NS_Container_T<TYPE, OBJECT, PARENT>::insert (TYPE* type ACE_ENV_ARG_DECL) +{ + this->collection_->connected (type ACE_ENV_ARG_PARAMETER); +} + +template<class TYPE, class OBJECT, class PARENT> void +TAO_NS_Container_T<TYPE, OBJECT, PARENT>::remove (TYPE* type ACE_ENV_ARG_DECL) +{ + this->collection_->disconnected (type ACE_ENV_ARG_PARAMETER); +} + +template<class TYPE, class OBJECT, class PARENT> void +TAO_NS_Container_T<TYPE, OBJECT, PARENT>::init_collection (ACE_ENV_SINGLE_ARG_DECL) +{ + // get the factory + TAO_NS_Factory* factory = TAO_NS_PROPERTIES::instance ()->factory (); + + // Init variables + factory->create (this->collection_ ACE_ENV_ARG_PARAMETER); +} +#endif /* TAO_NS_CONTAINER_T_CPP */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Container_T.h b/TAO/orbsvcs/orbsvcs/Notify/Container_T.h new file mode 100644 index 00000000000..da1855da4c1 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Container_T.h @@ -0,0 +1,109 @@ +/* -*- C++ -*- */ +/** + * @file Container_T.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_CONTAINER_T_H +#define TAO_NS_CONTAINER_T_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Container.h" +#include "Object_T.h" +#include "orbsvcs/ESF/ESF_Worker.h" + +/** + * @class TAO_NS_Container_T + * + * @brief + * + */ +template <class OBJECT> +class TAO_Notify_Export TAO_NS_Object_Find_Worker_T : public TAO_ESF_Worker<OBJECT> +{ + typedef TAO_ESF_Proxy_Collection<OBJECT> COLLECTION; + +public: + /// Constructor + TAO_NS_Object_Find_Worker_T (TAO_NS_Object_Id id); + + /// Find + OBJECT* find (COLLECTION* collection ACE_ENV_ARG_DECL); + +protected: + ///= TAO_ESF_Worker method + void work (OBJECT* object ACE_ENV_ARG_DECL); + + /// The id we're looking for. + TAO_NS_Object_Id id_; + + /// The result + OBJECT* result_; +}; + +/** + * @class TAO_NS_Container_T + * + * @brief A template class that manages a collection. + * TYPE = type of collection, OBJECT = the object, PARENT = parent of object (grandparent of TYPE) + * + */ +template <class TYPE, class OBJECT, class PARENT> +class TAO_Notify_Export TAO_NS_Container_T : public virtual TAO_NS_Object_T<OBJECT, PARENT>, public virtual TAO_NS_Container +{ + typedef TAO_NS_Object_Find_Worker_T<TYPE> FIND_WORKER; + +public: + /// Constuctor + TAO_NS_Container_T (void); + + /// Destructor + virtual ~TAO_NS_Container_T (); + + /// Insert object to this container. + virtual void insert (TYPE* type ACE_ENV_ARG_DECL); + + /// Remove type from container_ + virtual void remove (TYPE* type ACE_ENV_ARG_DECL); + + /// Find the Type. + TYPE* find (TAO_NS_Object_Id id ACE_ENV_ARG_DECL); + + /// Init this object. + void init_collection (ACE_ENV_SINGLE_ARG_DECL); + + /// Shutdown + virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL); + +protected: + typedef TAO_ESF_Proxy_Collection<TYPE> COLLECTION; + + /// The collection data structure that we add objects to. + COLLECTION* collection_; +}; + +#if defined (__ACE_INLINE__) +#include "Container_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Container_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Container_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* TAO_NS_CONTAINER_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Container_T.inl b/TAO/orbsvcs/orbsvcs/Notify/Container_T.inl new file mode 100644 index 00000000000..fa500677454 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Container_T.inl @@ -0,0 +1,27 @@ +// $Id$ + +/*************************************************************************************************/ + +template<class OBJECT> ACE_INLINE OBJECT* +TAO_NS_Object_Find_Worker_T<OBJECT>::find (TAO_NS_Object_Find_Worker_T<OBJECT>::COLLECTION* collection ACE_ENV_ARG_DECL) +{ + collection->for_each (this ACE_ENV_ARG_PARAMETER); + return this->result_; +} + +template<class OBJECT> ACE_INLINE void +TAO_NS_Object_Find_Worker_T<OBJECT>::work (OBJECT* object ACE_ENV_ARG_DECL_NOT_USED) +{ + if (object->id () == this->id_) + this->result_ = object; +} + +/*************************************************************************************************/ + +template<class TYPE, class OBJECT, class PARENT> ACE_INLINE TYPE* +TAO_NS_Container_T<TYPE, OBJECT, PARENT>::find (TAO_NS_Object_Id id ACE_ENV_ARG_DECL) +{ + FIND_WORKER find_worker (id); + + return find_worker.find (this->collection_ ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Destroy_Callback.h b/TAO/orbsvcs/orbsvcs/Notify/Destroy_Callback.h new file mode 100644 index 00000000000..6f8fda43604 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Destroy_Callback.h @@ -0,0 +1,38 @@ +/* -*- C++ -*- */ +/** + * @file Destroy_Callback.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_DESTROY_CALLBACK_H +#define TAO_NS_DESTROY_CALLBACK_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/** + * @class TAO_NS_Destroy_Callback + * + * @brief Interface to be implemented by users of TAO_NS_Refcountable + * + */ +class TAO_Notify_Export TAO_NS_Destroy_Callback +{ +public: + + /// Called when Refcountable count drops to 0 + virtual void release (void) = 0; +}; + + +#include "ace/post.h" +#endif /* TAO_NS_DESTROY_CALLBACK_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Dispatch_Observer_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Dispatch_Observer_T.cpp new file mode 100644 index 00000000000..4ce1b9e34a9 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Dispatch_Observer_T.cpp @@ -0,0 +1,83 @@ +// $Id$ + +#ifndef TAO_NS_DISPACH_OBSERVER_T_CPP +#define TAO_NS_DISPACH_OBSERVER_T_CPP + +#include "Dispatch_Observer_T.h" + +#if ! defined (__ACE_INLINE__) +#include "Dispatch_Observer_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_Dispatch_Observer_T, "$id$") + +#include "tao/debug.h" +#include "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "Peer.h" +#include "Proxy.h" +#include "Properties.h" +#include "Factory.h" + +template <class PEER> +TAO_NS_Dispatch_Observer_T<PEER>::TAO_NS_Dispatch_Observer_T (void) +: max_retry_attempts_ (0) +{ +} + +template <class PEER> +TAO_NS_Dispatch_Observer_T<PEER>::~TAO_NS_Dispatch_Observer_T () +{ + delete this->peer_collection_; +} + +template <class PEER> void +TAO_NS_Dispatch_Observer_T<PEER>::init (ACE_ENV_SINGLE_ARG_DECL) +{ + TAO_NS_Factory* factory = TAO_NS_PROPERTIES::instance ()->factory (); + + factory->create (this->peer_collection_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +template <class PEER> void +TAO_NS_Dispatch_Observer_T<PEER>::enqueue (PEER* peer ACE_ENV_ARG_DECL) +{ + this->peer_collection_->connected (peer ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +template <class PEER> void +TAO_NS_Dispatch_Observer_T<PEER>::dispatch_failure (PEER* peer, int retry_count ACE_ENV_ARG_DECL) +{ + if (retry_count > this->max_retry_attempts_) + { + this->peer_collection_->disconnected (peer ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + ACE_TRY + { + peer->proxy ()->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Dispatch Observer: Exxception in dispatch_failure handling\n")); + } + ACE_ENDTRY; + } + else if (retry_count == 1) // failed for the 1st time. + { + this->peer_collection_->connected (peer ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } +} + +template <class PEER> void +TAO_NS_Dispatch_Observer_T<PEER>::dispatch_success (PEER* peer ACE_ENV_ARG_DECL) +{ + this->peer_collection_->disconnected (peer ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +#endif /* TAO_NS_DISPACH_OBSERVER_T_CPP */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Dispatch_Observer_T.h b/TAO/orbsvcs/orbsvcs/Notify/Dispatch_Observer_T.h new file mode 100644 index 00000000000..84ee9ae6fca --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Dispatch_Observer_T.h @@ -0,0 +1,83 @@ +/* -*- C++ -*- */ +/** + * @file Dispatch_Observer_T.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_DISPATCH_OBSERVER_T_H +#define TAO_NS_DISPATCH_OBSERVER_T_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +//#include "types.h" +#include "orbsvcs/ESF/ESF_Proxy_Collection.h" + +/** + * @class TAO_NS_Dispatch_Observer_T + * + * @brief An observer class that is notified of the success or failure of event/update diapatches. + * If a dispatch fails, the PEER is added to a pending list. This list is obtained by the Pending Worker to retry delivery of + * Events/Updates. When the max_retries are reached, the observer destroys the proxy. + * + */ +template <class PEER> +class TAO_Notify_Export TAO_NS_Dispatch_Observer_T +{ +public: + typedef TAO_ESF_Proxy_Collection<PEER> PEER_COLLECTION; + + /// Constuctor + TAO_NS_Dispatch_Observer_T (void); + + /// Destructor + ~TAO_NS_Dispatch_Observer_T (); + + /// Init + void init (ACE_ENV_SINGLE_ARG_DECL); + + void max_retry_attempts (int max_retry_attempts); + + /// Enqueue this peer. + void enqueue (PEER* peer ACE_ENV_ARG_DECL); + + /// Dispatch failure notice. + void dispatch_failure (PEER* peer, int retry_count ACE_ENV_ARG_DECL); + + /// Dispatch success notice. + void dispatch_success (PEER* peer ACE_ENV_ARG_DECL); + + /// Get peer collection. + PEER_COLLECTION* peer_collection (void); + +protected: + /// Max retry attempts. + int max_retry_attempts_; + + /// Pending list. + PEER_COLLECTION* peer_collection_; +}; + +#if defined (__ACE_INLINE__) +#include "Dispatch_Observer_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Dispatch_Observer_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Dispatch_Observer_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* TAO_NS_DISPATCH_OBSERVER_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Dispatch_Observer_T.inl b/TAO/orbsvcs/orbsvcs/Notify/Dispatch_Observer_T.inl new file mode 100644 index 00000000000..08dc4d37c94 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Dispatch_Observer_T.inl @@ -0,0 +1,13 @@ +// $Id$ + +template <class PEER> ACE_INLINE TAO_NS_Dispatch_Observer_T<PEER>::PEER_COLLECTION* +TAO_NS_Dispatch_Observer_T<PEER>::peer_collection (void) +{ + return this->peer_collection_; +} + +template <class PEER> ACE_INLINE void +TAO_NS_Dispatch_Observer_T<PEER>::max_retry_attempts (int max_retry_attempts) +{ + this->max_retry_attempts_ = max_retry_attempts; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.cpp b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.cpp new file mode 100644 index 00000000000..562a6f9d6a0 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.cpp @@ -0,0 +1,465 @@ +// $Id$ + +#include "ETCL_Filter.h" + +#if ! defined (__ACE_INLINE__) +#include "ETCL_Filter.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_ETCL_Filter, "$id$") + +#include "ace/Auto_Ptr.h" +#include "tao/debug.h" +#include "Constraint_Visitors.h" + +TAO_NS_ETCL_Filter::TAO_NS_ETCL_Filter (void) +{ +} + +TAO_NS_ETCL_Filter::~TAO_NS_ETCL_Filter () +{ + ACE_DECLARE_NEW_CORBA_ENV; + this->remove_all_constraints (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, "Filter Destroyed\n")); + } +} + +char* +TAO_NS_ETCL_Filter::constraint_grammar (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return CORBA::string_dup ("ETCL"); +} + +void +TAO_NS_ETCL_Filter::add_constraints_i (const CosNotifyFilter::ConstraintInfoSeq& constraint_info_seq + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::InvalidConstraint + )) +{ + for (CORBA::ULong index = 0; + index < constraint_info_seq.length (); + ++index) + { + TAO_NS_Constraint_Expr* notify_constr_expr; + + ACE_TRY + { + ACE_NEW_THROW_EX (notify_constr_expr, + TAO_NS_Constraint_Expr (), + CORBA::NO_MEMORY ()); + + const CosNotifyFilter::ConstraintExp& expr = + constraint_info_seq[index].constraint_expression; + + notify_constr_expr->interpreter.build_tree ( + expr.constraint_expr.in () + ACE_ENV_ARG_PARAMETER + ); + ACE_TRY_CHECK; + + notify_constr_expr->constr_expr = expr; + + CosNotifyFilter::ConstraintID cnstr_id = ++constraint_expr_ids_; + + if (this->constraint_expr_list_.bind (cnstr_id, notify_constr_expr) + == -1) + { + ACE_THROW (CORBA::NO_RESOURCES ()); + } + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Added constraint to filter %x\n", this, expr.constraint_expr.in ())); + } + ACE_CATCHANY + { + // Delete the one that failed us. + delete notify_constr_expr; + ACE_RE_THROW; + } + ACE_ENDTRY; + ACE_CHECK; + } +} + +CosNotifyFilter::ConstraintInfoSeq* +TAO_NS_ETCL_Filter::add_constraints (const CosNotifyFilter::ConstraintExpSeq& constraint_list + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::InvalidConstraint + )) +{ + CORBA::ULong constraint_length = constraint_list.length (); + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + "constraint_length = %d\n", + constraint_length)); + } + + // Create the list that goes out. + CosNotifyFilter::ConstraintInfoSeq *infoseq; + ACE_NEW_THROW_EX (infoseq, + CosNotifyFilter::ConstraintInfoSeq (constraint_length), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + infoseq->length (constraint_length); + + auto_ptr<CosNotifyFilter::ConstraintInfoSeq> auto_infoseq (infoseq); + + // Populate infoseq. + for (CORBA::ULong pop_index = 0; pop_index < constraint_length; ++pop_index) + { + (*infoseq)[pop_index].constraint_expression = + constraint_list [pop_index]; + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + "Adding constraint %d, %s\n", + pop_index, + constraint_list [pop_index].constraint_expr.in ())); + } + } + + this->add_constraints_i (*infoseq + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + auto_infoseq.release (); + + return infoseq; +} + +void +TAO_NS_ETCL_Filter::modify_constraints (const CosNotifyFilter::ConstraintIDSeq & del_list, + const CosNotifyFilter::ConstraintInfoSeq & modify_list + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::InvalidConstraint, + CosNotifyFilter::ConstraintNotFound + )) +{ + // First check if all the ids are valid. + u_int index; + + for (index = 0; index < del_list.length (); ++index) + { + if (this->constraint_expr_list_.find (del_list [index]) == -1) + { + ACE_THROW (CosNotifyFilter::ConstraintNotFound (del_list [index])); + } + } + + for (index = 0; index < modify_list.length (); ++index) + { + if (this->constraint_expr_list_.find (modify_list [index].constraint_id) == -1) + { + ACE_THROW (CosNotifyFilter::ConstraintNotFound (modify_list [index].constraint_id)); + } + } + + // Remove previous entries and save them in case we need to reinstate them. + ACE_Array<TAO_NS_Constraint_Expr*> constr_saved (modify_list.length ()); + TAO_NS_Constraint_Expr* constr_expr = 0; + + for (index = 0; index < modify_list.length (); ++index) + { + CosNotifyFilter::ConstraintID cnstr_id = + modify_list [index].constraint_id; + + if (this->constraint_expr_list_.unbind (cnstr_id, constr_expr) != -1) + { + constr_saved[index] = constr_expr; + } + } + + // Now add the new entries. + // Keep a list of ids generated in this session. + ACE_TRY + { + this->add_constraints_i (modify_list + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + // Restore, + for (index = 0; index < modify_list.length (); ++index) + { + CosNotifyFilter::ConstraintID cnstr_id = ++this->constraint_expr_ids_; + + if (constraint_expr_list_.bind (cnstr_id, constr_saved[index]) == -1) + ACE_THROW (CORBA::NO_RESOURCES ()); + } + + ACE_RE_THROW; + } + ACE_ENDTRY; + ACE_CHECK; + + // Now go around deleting... + // for the del_list. + for (index = 0; index < del_list.length (); ++index) + { + if (this->constraint_expr_list_.unbind (del_list [index], constr_expr) != -1) + { + delete constr_expr; + } + } + + // Delete the old constraints. + for (index = 0; index < constr_saved.max_size (); ++index) + { + delete constr_saved[index]; + } +} + +CosNotifyFilter::ConstraintInfoSeq * +TAO_NS_ETCL_Filter::get_constraints (const CosNotifyFilter::ConstraintIDSeq & id_list + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC ((CORBA::SystemException, + CosNotifyFilter::ConstraintNotFound)) +{ + // Create the list that goes out. + CosNotifyFilter::ConstraintInfoSeq *infoseq; + ACE_NEW_THROW_EX (infoseq, + CosNotifyFilter::ConstraintInfoSeq (id_list.length ()), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + auto_ptr<CosNotifyFilter::ConstraintInfoSeq> auto_infoseq (infoseq); + + TAO_NS_Constraint_Expr *notify_constr_expr = 0; + + for (u_int index = 0; index < id_list.length (); ++index) + { + if (this->constraint_expr_list_.find (id_list[index], + notify_constr_expr) == -1) + ACE_THROW_RETURN (CosNotifyFilter::ConstraintNotFound (id_list[index]), + 0); + + (*infoseq)[index].constraint_expression = + notify_constr_expr->constr_expr; + + // Get an id. + (*infoseq)[index].constraint_id = id_list[index]; + } + + auto_infoseq.release (); + return infoseq; +} + +CosNotifyFilter::ConstraintInfoSeq * +TAO_NS_ETCL_Filter::get_all_constraints (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + size_t current_size = this->constraint_expr_list_.current_size (); + + // Create the list that goes out. + CosNotifyFilter::ConstraintInfoSeq *infoseq; + ACE_NEW_THROW_EX (infoseq, + CosNotifyFilter::ConstraintInfoSeq (current_size), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + infoseq->length (current_size); + CONSTRAINT_EXPR_LIST_ITER iter (this->constraint_expr_list_); + CONSTRAINT_EXPR_ENTRY *entry; + + for (u_int index = 0; iter.done () == 0; iter.advance (), ++index) + { + if (iter.next (entry) != 0) + { + // Why do we cast to a const object? + // We want to force the TAO_String_Manager to make a + // copy of the string. It wouldn't unless we coax it to use + // the correct assignment operator. + (*infoseq)[index].constraint_expression = + ACE_static_cast (const CosNotifyFilter::ConstraintExp, + entry->int_id_->constr_expr); + + (*infoseq)[index].constraint_id = entry->ext_id_; + } + } + + return infoseq; +} + +void +TAO_NS_ETCL_Filter::remove_all_constraints (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + CONSTRAINT_EXPR_LIST_ITER iter (this->constraint_expr_list_); + CONSTRAINT_EXPR_ENTRY *entry; + + u_int index; + + for (index = 0; iter.done () == 0; iter.advance (), ++index) + { + if (iter.next (entry) != 0) + { + delete entry->int_id_; + } + } + + this->constraint_expr_list_.unbind_all (); +} + +void +TAO_NS_ETCL_Filter::destroy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->remove_all_constraints (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + PortableServer::POA_var my_POA = _default_POA (); + + PortableServer::ObjectId_var refTemp = my_POA->servant_to_id (this); + + my_POA->deactivate_object (refTemp.in ()); +} + +CORBA::Boolean +TAO_NS_ETCL_Filter::match (const CORBA::Any & /*filterable_data */ + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + CosNotifyFilter::UnsupportedFilterableData)) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), + 0); +} + +CORBA::Boolean +TAO_NS_ETCL_Filter::match_structured (const CosNotification::StructuredEvent & filterable_data + ACE_ENV_ARG_DECL_NOT_USED + ) + ACE_THROW_SPEC ((CORBA::SystemException, + CosNotifyFilter::UnsupportedFilterableData)) +{ + // We want to return true if at least one constraint matches. + CONSTRAINT_EXPR_LIST_ITER iter (this->constraint_expr_list_); + CONSTRAINT_EXPR_ENTRY *entry; + + TAO_NS_Constraint_Visitor visitor; + + if (visitor.bind_structured_event (filterable_data) != 0) + { + // Maybe throw some kind of exception here, or lower down, + return 0; + } + + for (; iter.done () == 0; iter.advance ()) + { + if (iter.next (entry) != 0) + { + if (entry->int_id_->interpreter.evaluate (visitor) == 1) + { + return 1; + } + } + } + + return 0; +} + +CORBA::Boolean +TAO_NS_ETCL_Filter::match_typed ( + const CosNotification::PropertySeq & /* filterable_data */ + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( CORBA::SystemException, + CosNotifyFilter::UnsupportedFilterableData)) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), + 0); +} + +CosNotifyFilter::CallbackID +TAO_NS_ETCL_Filter::attach_callback ( + CosNotifyComm::NotifySubscribe_ptr /* callback */ + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), + 0); +} + +void +TAO_NS_ETCL_Filter::detach_callback ( + CosNotifyFilter::CallbackID /* callback */ + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC ((CORBA::SystemException, + CosNotifyFilter::CallbackNotFound)) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +CosNotifyFilter::CallbackIDSeq * +TAO_NS_ETCL_Filter::get_callbacks (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), + 0); +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +template class ACE_Hash_Map_Entry<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr *>; +template class ACE_Hash_Map_Manager<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Manager_Ex<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,ACE_Hash<CosNotifyFilter::ConstraintID>, ACE_Equal_To<CosNotifyFilter::ConstraintID>,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator_Ex<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,ACE_Hash<CosNotifyFilter::ConstraintID>, ACE_Equal_To<CosNotifyFilter::ConstraintID>,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator_Base_Ex<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,ACE_Hash<CosNotifyFilter::ConstraintID>, ACE_Equal_To<CosNotifyFilter::ConstraintID>,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Reverse_Iterator<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Reverse_Iterator_Ex<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,ACE_Hash<CosNotifyFilter::ConstraintID>, ACE_Equal_To<CosNotifyFilter::ConstraintID>,TAO_SYNCH_MUTEX>; + +#if !defined (ACE_HAS_STD_TEMPLATE_SPECIALIZATION) +template class ACE_Equal_To<CosNotifyFilter::ConstraintID>; +#endif /* ACE_HAS_STD_TEMPLATE_SPECIALIZATION */ + +template class ACE_Array<TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*>; +template class ACE_Array_Base<TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*>; + +template class auto_ptr<CosNotifyFilter::ConstraintInfoSeq>; +template class ACE_Auto_Basic_Ptr<CosNotifyFilter::ConstraintInfoSeq>; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate ACE_Hash_Map_Entry<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*> +#pragma instantiate ACE_Hash_Map_Manager<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Manager_Ex<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,ACE_Hash<CosNotifyFilter::ConstraintID>, ACE_Equal_To<CosNotifyFilter::ConstraintID>,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator_Ex<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,ACE_Hash<CosNotifyFilter::ConstraintID>, ACE_Equal_To<CosNotifyFilter::ConstraintID>,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,ACE_Hash<CosNotifyFilter::ConstraintID>, ACE_Equal_To<CosNotifyFilter::ConstraintID>,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<CosNotifyFilter::ConstraintID,TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*,ACE_Hash<CosNotifyFilter::ConstraintID>, ACE_Equal_To<CosNotifyFilter::ConstraintID>,TAO_SYNCH_MUTEX> + +#if !defined (ACE_HAS_STD_TEMPLATE_SPECIALIZATION) +#pragma instantiate ACE_Equal_To<CosNotifyFilter::ConstraintID> +#endif /* ACE_HAS_STD_TEMPLATE_SPECIALIZATION */ + +#pragma instantiate ACE_Array<TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*> +#pragma instantiate ACE_Array_Base<TAO_NS_ETCL_Filter::TAO_NS_Constraint_Expr*> + +#pragma instantiate auto_ptr<CosNotifyFilter::ConstraintInfoSeq> +#pragma instantiate ACE_Auto_Basic_Ptr<CosNotifyFilter::ConstraintInfoSeq> + +#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.h b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.h new file mode 100644 index 00000000000..853340b2cb9 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.h @@ -0,0 +1,175 @@ +/* -*- C++ -*- */ +/** + * @file ETCL_Filter.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_ETCL_FILTER_H +#define TAO_NS_ETCL_FILTER_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Containers_T.h" +#include "ace/Hash_Map_Manager.h" +#include "ace/Atomic_Op.h" +#include "orbsvcs/CosNotifyFilterS.h" +#include "Constraint_Interpreter.h" + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/** + * @class TAO_ETCL_Filter + * + * @brief + * + */ +class TAO_Notify_Export TAO_NS_ETCL_Filter : public POA_CosNotifyFilter::Filter, public PortableServer::RefCountServantBase +{ +public: + /// Constuctor + TAO_NS_ETCL_Filter (void); + + /// Destructor + ~TAO_NS_ETCL_Filter (); + +protected: + virtual char * constraint_grammar (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual CosNotifyFilter::ConstraintInfoSeq * add_constraints (const CosNotifyFilter::ConstraintExpSeq & constraint_list ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::InvalidConstraint + )); + + virtual void modify_constraints (const CosNotifyFilter::ConstraintIDSeq & del_list, + const CosNotifyFilter::ConstraintInfoSeq & modify_list + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::InvalidConstraint, + CosNotifyFilter::ConstraintNotFound + )); + + virtual CosNotifyFilter::ConstraintInfoSeq * get_constraints (const CosNotifyFilter::ConstraintIDSeq & id_list ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::ConstraintNotFound + )); + + virtual CosNotifyFilter::ConstraintInfoSeq * get_all_constraints (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void remove_all_constraints (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual CORBA::Boolean match (const CORBA::Any & filterable_data ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::UnsupportedFilterableData + )); + + virtual CORBA::Boolean match_structured (const CosNotification::StructuredEvent & filterable_data ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::UnsupportedFilterableData + )); + + virtual CORBA::Boolean match_typed (const CosNotification::PropertySeq & filterable_data ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::UnsupportedFilterableData + )); + + virtual CosNotifyFilter::CallbackID attach_callback (CosNotifyComm::NotifySubscribe_ptr callback ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void detach_callback (CosNotifyFilter::CallbackID callback ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::CallbackNotFound + )); + + virtual CosNotifyFilter::CallbackIDSeq * get_callbacks (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + +private: + void add_constraints_i (const CosNotifyFilter::ConstraintInfoSeq& constraint_info_seq ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::InvalidConstraint + )); + + struct TAO_NS_Constraint_Expr + { + // = DESCRIPTION + // Structure for associating ConstraintInfo with an interpreter. + // + CosNotifyFilter::ConstraintExp constr_expr; + // Constraint Expression. + + TAO_NS_Constraint_Interpreter interpreter; + // Constraint Interpreter. + }; + + /// Id generator for ConstraintInfo's. + ACE_Atomic_Op <TAO_SYNCH_MUTEX, CORBA::Long> constraint_expr_ids_; + + /// A list of the constraints stored in this filter. + ACE_Hash_Map_Manager <CosNotifyFilter::ConstraintID, + ACE_NESTED_CLASS (TAO_NS_ETCL_Filter, TAO_NS_Constraint_Expr*), + TAO_SYNCH_MUTEX> + constraint_expr_list_; + + typedef ACE_Hash_Map_Iterator <CosNotifyFilter::ConstraintID, + ACE_NESTED_CLASS (TAO_NS_ETCL_Filter, TAO_NS_Constraint_Expr*), + TAO_SYNCH_MUTEX> + CONSTRAINT_EXPR_LIST_ITER; + + typedef ACE_Hash_Map_Entry <CosNotifyFilter::ConstraintID, + ACE_NESTED_CLASS (TAO_NS_ETCL_Filter, + TAO_NS_Constraint_Expr*)> + CONSTRAINT_EXPR_ENTRY; +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__ACE_INLINE__) +#include "ETCL_Filter.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_ETCL_FILTER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.inl b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_Filter.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.cpp b/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.cpp new file mode 100644 index 00000000000..5d8ec588c00 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.cpp @@ -0,0 +1,78 @@ +// $Id$ + +#include "ETCL_FilterFactory.h" + +#if ! defined (__ACE_INLINE__) +#include "ETCL_FilterFactory.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_ETCL_FilterFactory, "$id$") + +#include "ETCL_Filter.h" + +TAO_NS_ETCL_FilterFactory::TAO_NS_ETCL_FilterFactory (void) +{ +} + +TAO_NS_ETCL_FilterFactory::~TAO_NS_ETCL_FilterFactory () +{ +} + +CosNotifyFilter::FilterFactory_ptr +TAO_NS_ETCL_FilterFactory::create (ACE_ENV_SINGLE_ARG_DECL) +{ + return _this (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +CosNotifyFilter::Filter_ptr +TAO_NS_ETCL_FilterFactory::create_filter (const char *constraint_grammar ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::InvalidGrammar + )) +{ + // @@: change to "ExTCL" later. + if (ACE_OS::strcmp (constraint_grammar, "TCL") != 0 && + ACE_OS::strcmp (constraint_grammar, "ETCL") != 0) + ACE_THROW_RETURN (CosNotifyFilter::InvalidGrammar (), 0); + + + // Create the RefCounted servant. + TAO_NS_ETCL_Filter* filter = 0; + + ACE_NEW_THROW_EX (filter, + TAO_NS_ETCL_Filter (), + CORBA::NO_MEMORY ()); + + PortableServer::POA_var my_POA = _default_POA (); + + PortableServer::ServantBase_var filter_var (filter); + + PortableServer::ObjectId_var oid = + my_POA->activate_object (filter + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyFilter::Filter::_nil ()); + + CORBA::Object_var obj = + my_POA->id_to_reference (oid.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyFilter::Filter::_nil ()); + + return CosNotifyFilter::Filter::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); +} + +CosNotifyFilter::MappingFilter_ptr +TAO_NS_ETCL_FilterFactory::create_mapping_filter (const char * /*constraint_grammar*/, + const CORBA::Any & /*default_value*/ + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::InvalidGrammar + )) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CosNotifyFilter::MappingFilter::_nil ()); +} + +ACE_FACTORY_DEFINE (TAO_Notify, TAO_NS_ETCL_FilterFactory) diff --git a/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.h b/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.h new file mode 100644 index 00000000000..8db09cbd64b --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.h @@ -0,0 +1,71 @@ +/* -*- C++ -*- */ +/** + * @file ETCL_FilterFactory.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_ETCL_FILTERFACTORY_H +#define TAO_NS_ETCL_FILTERFACTORY_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyFilterS.h" +#include "FilterFactory.h" + +/** + * @class TAO_NS_ETCL_FilterFactory + * + * @brief + * + */ +class TAO_Notify_Export TAO_NS_ETCL_FilterFactory : public POA_CosNotifyFilter::FilterFactory, public TAO_NS_FilterFactory +{ +public: + /// Constuctor + TAO_NS_ETCL_FilterFactory (void); + + /// Destructor + ~TAO_NS_ETCL_FilterFactory (); + + ///= TAO_NS_FilterFactory methods. + + virtual CosNotifyFilter::FilterFactory_ptr create (ACE_ENV_SINGLE_ARG_DECL); + + ///= CosNotifyFilter::FilterFactory methods + + virtual CosNotifyFilter::Filter_ptr create_filter (const char * constraint_grammar + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::InvalidGrammar + )); + + virtual CosNotifyFilter::MappingFilter_ptr create_mapping_filter (const char * constraint_grammar, + const CORBA::Any & default_value + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::InvalidGrammar + )); +}; + +ACE_FACTORY_DECLARE (TAO_Notify, TAO_NS_ETCL_FilterFactory) + +#if defined (__ACE_INLINE__) +#include "ETCL_FilterFactory.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_ETCL_FILTERFACTORY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.inl b/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ETCL_FilterFactory.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event.cpp b/TAO/orbsvcs/orbsvcs/Notify/Event.cpp new file mode 100644 index 00000000000..24d7338a2c3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event.cpp @@ -0,0 +1,40 @@ +// $Id$ + +#include "Event.h" + +#if ! defined (__ACE_INLINE__) +#include "Event.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Event, "$Id$") + +#include "tao/debug.h" +#include "orbsvcs/CosNotificationC.h" + +TAO_NS_Event::TAO_NS_Event (void) + :priority_ (CosNotification::Priority, CosNotification::DefaultPriority), + timeout_ (CosNotification::Timeout) +{ + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG,"event:%x created\n", this )); +} + +TAO_NS_Event::~TAO_NS_Event () +{ + if (TAO_debug_level > 1) + ACE_DEBUG ((LM_DEBUG,"event:%x destroyed\n", this )); +} + +void +TAO_NS_Event::translate (const CORBA::Any& any, CosNotification::StructuredEvent& notification) +{ + notification.remainder_of_body <<= any; + notification.header.fixed_header.event_type.type_name = CORBA::string_dup ("%ANY"); + notification.header.fixed_header.event_type.domain_name = CORBA::string_dup (""); +} + +void +TAO_NS_Event::translate (const CosNotification::StructuredEvent& notification, CORBA::Any& any) +{ + any <<= notification; // is the typecode set by this operation or do we need to set it explicity. +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event.h b/TAO/orbsvcs/orbsvcs/Notify/Event.h new file mode 100644 index 00000000000..2e7b5a9301e --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event.h @@ -0,0 +1,104 @@ +/* -*- C++ -*- */ +/** + * @file Event.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_EVENT_H +#define TAO_NS_EVENT_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Copy_Disabled.h" +#include "orbsvcs/Event_ForwarderS.h" +#include "orbsvcs/CosNotifyFilterC.h" +#include "orbsvcs/CosNotificationC.h" +#include "Property.h" +#include "Property_T.h" + +class TAO_NS_Consumer; +class TAO_NS_EventType; + +/** + * @class TAO_NS_Event + * + * @brief Base class abstraction for Events flowing through the EventChannel. + * + */ +class TAO_Notify_Export TAO_NS_Event : private ACE_Copy_Disabled +{ +public: + /// Constuctor + TAO_NS_Event (void); + + /// Destructor + virtual ~TAO_NS_Event (); + + /// Translate Any to Structured + static void translate (const CORBA::Any& any, CosNotification::StructuredEvent& notification); + + /// Translate Structured to Any + static void translate (const CosNotification::StructuredEvent& notification, CORBA::Any& any); + + /// Get the event type. + virtual const TAO_NS_EventType& type (void) const = 0; + + /// Returns true if the filter matches. + virtual CORBA::Boolean do_match (CosNotifyFilter::Filter_ptr filter ACE_ENV_ARG_DECL) = 0; + + /// Convert to CosNotification::Structured type + virtual void convert (CosNotification::StructuredEvent& notification) = 0; + + /// Push event to consumer + virtual void push (TAO_NS_Consumer* consumer ACE_ENV_ARG_DECL) const = 0; + + /// Push event to the Event_Forwarder interface + virtual void push (Event_Forwarder::StructuredProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) = 0; + + /// Push event to the Event_Forwarder interface + virtual void push_no_filtering (Event_Forwarder::StructuredProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) = 0; + + /// Push event to the Event_Forwarder interface + virtual void push (Event_Forwarder::ProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) = 0; + + /// Push event to the Event_Forwarder interface + virtual void push_no_filtering (Event_Forwarder::ProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) = 0; + + ///= Accessors + /// Priority + TAO_NS_Property_Short& priority (void); + + /// Timeout + TAO_NS_Property_Time& timeout (void); + +protected: + /// = QoS properties + + /// Priority. + TAO_NS_Property_Short priority_; + + /// Timeout. + TAO_NS_Property_Time timeout_; +}; + +template <class EVENT, class SYNCH> class ACE_Refcounted_Auto_Ptr; +template <class T> class ACE_Unbounded_Queue; +typedef ACE_Refcounted_Auto_Ptr<TAO_NS_Event, TAO_SYNCH_MUTEX> TAO_NS_Event_var; +typedef ACE_Unbounded_Queue<TAO_NS_Event_var> TAO_NS_Event_Collection; + +#if defined (__ACE_INLINE__) +#include "Event.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_EVENT_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event.inl b/TAO/orbsvcs/orbsvcs/Notify/Event.inl new file mode 100644 index 00000000000..019194c78aa --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event.inl @@ -0,0 +1,13 @@ +// $Id$ + +ACE_INLINE TAO_NS_Property_Short& +TAO_NS_Event::priority (void) +{ + return this->priority_; +} + +ACE_INLINE TAO_NS_Property_Time& +TAO_NS_Event::timeout (void) +{ + return this->timeout_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannel.cpp b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.cpp new file mode 100644 index 00000000000..9089ae8113d --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.cpp @@ -0,0 +1,362 @@ +// $Id$ + +#include "EventChannel.h" + +#if ! defined (__ACE_INLINE__) +#include "EventChannel.inl" +#endif /* __ACE_INLINE__ */ + +#include "Proxy.h" +#include "Admin.h" +#include "EventChannelFactory.h" +#include "Notify_Service.h" +#include "Event_Manager.h" +#include "Properties.h" +#include "Builder.h" +#include "ThreadPool_Task.h" + +ACE_RCSID(RT_Notify, TAO_NS_EventChannel, "$Id$") + + TAO_NS_EventChannel::TAO_NS_EventChannel (void) +{ +} + +TAO_NS_EventChannel::~TAO_NS_EventChannel () +{ + delete this->event_manager_; + delete this->admin_properties_; +} + +void +TAO_NS_EventChannel::init (ACE_ENV_SINGLE_ARG_DECL) +{ + CosNotifyChannelAdmin::AdminID id; + + this->default_consumer_admin_ = + TAO_NS_PROPERTIES::instance()->builder ()->build_consumer_admin (this, CosNotifyChannelAdmin::OR_OP, id ACE_ENV_ARG_PARAMETER); + + this->default_supplier_admin_ = + TAO_NS_PROPERTIES::instance()->builder ()->build_supplier_admin (this, CosNotifyChannelAdmin::OR_OP, id ACE_ENV_ARG_PARAMETER); +} + +PortableServer::Servant +TAO_NS_EventChannel::servant (void) +{ + return this; +} + +void +TAO_NS_EventChannel::_add_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->_incr_refcnt (); +} + +void +TAO_NS_EventChannel::_remove_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->_decr_refcnt (); +} + +void +TAO_NS_EventChannel::release (void) +{ + delete this; + //@@ inform factory +} + +void +TAO_NS_EventChannel::destroy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + this->inherited::destroy (this ACE_ENV_ARG_PARAMETER); + this->event_manager_->shutdown (); + + /* this->default_consumer_admin_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + this->default_supplier_admin_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);*/ +} + +void +TAO_NS_EventChannel::insert (TAO_NS_Admin* admin ACE_ENV_ARG_DECL) +{ + inherited::insert (admin ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (admin->type () == TAO_NS_Admin::CONSUMER_ADMIN) + this->consumer_admin_id_list_.insert (admin->id ()); + else + this->supplier_admin_id_list_.insert (admin->id ()); +} + +void +TAO_NS_EventChannel::remove (TAO_NS_Admin* admin ACE_ENV_ARG_DECL) +{ + inherited::remove (admin ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (admin->type () == TAO_NS_Admin::CONSUMER_ADMIN) + this->consumer_admin_id_list_.remove (admin->id ()); + else + this->supplier_admin_id_list_.remove (admin->id ()); +} + +void +TAO_NS_EventChannel::set_qos (const CosNotification::QoSProperties & qos ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )) +{ + this->TAO_NS_Object::set_qos (qos ACE_ENV_ARG_PARAMETER); +} + +CosNotification::QoSProperties* +TAO_NS_EventChannel::get_qos (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->TAO_NS_Object::get_qos (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::EventChannelFactory_ptr +TAO_NS_EventChannel::MyFactory (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + CORBA::Object_var object = this->parent_->ref (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::EventChannelFactory::_nil ()); + + CosNotifyChannelAdmin::EventChannelFactory_var ecf_ret; + + ecf_ret = CosNotifyChannelAdmin::EventChannelFactory::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::EventChannelFactory::_nil ()); + + return ecf_ret._retn (); +} + +CosNotifyChannelAdmin::ConsumerAdmin_ptr +TAO_NS_EventChannel::default_consumer_admin (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return CosNotifyChannelAdmin::ConsumerAdmin::_duplicate (this->default_consumer_admin_.in ()); +} + +CosNotifyChannelAdmin::SupplierAdmin_ptr +TAO_NS_EventChannel::default_supplier_admin (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return CosNotifyChannelAdmin::SupplierAdmin::_duplicate (this->default_supplier_admin_.in ()); +} + +::CosNotifyFilter::FilterFactory_ptr TAO_NS_EventChannel::default_filter_factory (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->parent_->get_default_filter_factory (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +::CosNotifyChannelAdmin::ConsumerAdmin_ptr +TAO_NS_EventChannel::new_for_consumers (CosNotifyChannelAdmin::InterFilterGroupOperator op, + CosNotifyChannelAdmin::AdminID_out id ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )) + +{ + /// Builder for ConsumerAdmins + return TAO_NS_PROPERTIES::instance()->builder ()->build_consumer_admin (this, op, id ACE_ENV_ARG_PARAMETER); +} + +::CosNotifyChannelAdmin::SupplierAdmin_ptr +TAO_NS_EventChannel::new_for_suppliers (CosNotifyChannelAdmin::InterFilterGroupOperator op, + CosNotifyChannelAdmin::AdminID_out id + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + /// Builder for SupplierAdmins + return TAO_NS_PROPERTIES::instance()->builder ()->build_supplier_admin (this, op, id ACE_ENV_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::ConsumerAdmin_ptr +TAO_NS_EventChannel::get_consumeradmin (CosNotifyChannelAdmin::AdminID id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminNotFound + )) +{ + TAO_NS_Object* ns_object = this->find (id ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::ConsumerAdmin::_nil ()); + + if (ns_object != 0) + { + CORBA::Object_var object = ns_object->ref (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::ConsumerAdmin::_nil ()); + + CosNotifyChannelAdmin::ConsumerAdmin_var ca_ret; + + ca_ret = CosNotifyChannelAdmin::ConsumerAdmin::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::ConsumerAdmin::_nil ()); + + return ca_ret._retn (); + } + else + ACE_THROW_RETURN (CosNotifyChannelAdmin::AdminNotFound (), CosNotifyChannelAdmin::ConsumerAdmin::_nil ()); +} + +CosNotifyChannelAdmin::SupplierAdmin_ptr +TAO_NS_EventChannel::get_supplieradmin (CosNotifyChannelAdmin::AdminID id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminNotFound + )) +{ + TAO_NS_Object* ns_object = this->find (id ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::SupplierAdmin::_nil ()); + + if (ns_object != 0) + { + CORBA::Object_var object = ns_object->ref (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::SupplierAdmin::_nil ()); + + CosNotifyChannelAdmin::SupplierAdmin_var sa_ret; + + sa_ret = CosNotifyChannelAdmin::SupplierAdmin::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::SupplierAdmin::_nil ()); + + return sa_ret._retn (); + } + else + ACE_THROW_RETURN (CosNotifyChannelAdmin::AdminNotFound (), CosNotifyChannelAdmin::SupplierAdmin::_nil ()); +} + +CosNotifyChannelAdmin::AdminIDSeq* +TAO_NS_EventChannel::get_all_consumeradmins (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + CosNotifyChannelAdmin::AdminIDSeq* seq; + + ACE_NEW_THROW_EX (seq, + CosNotifyChannelAdmin::AdminIDSeq (), + CORBA::NO_MEMORY ()); + + seq->length (this->consumer_admin_id_list_.size ()); + + TAO_NS_Object_Id_Seq::CONST_ITERATOR iter (this->consumer_admin_id_list_); + + TAO_NS_Object_Id* object_id; + + CORBA::ULong i = 0; + for (iter.first (); iter.next (object_id); iter.advance (), ++i) + seq[i] = *object_id; + + return seq; +} + +CosNotifyChannelAdmin::AdminIDSeq* +TAO_NS_EventChannel::get_all_supplieradmins (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + CosNotifyChannelAdmin::AdminIDSeq* seq; + + ACE_NEW_THROW_EX (seq, + CosNotifyChannelAdmin::AdminIDSeq (), + CORBA::NO_MEMORY ()); + + seq->length (this->supplier_admin_id_list_.size ()); + + TAO_NS_Object_Id_Seq::CONST_ITERATOR iter (this->consumer_admin_id_list_); + + TAO_NS_Object_Id* object_id; + + CORBA::ULong i = 0; + for (iter.first (); iter.next (object_id); iter.advance (), ++i) + seq[i] = *object_id; + + return seq; +} + +void +TAO_NS_EventChannel::validate_qos (const CosNotification::QoSProperties & /*required_qos*/, + CosNotification::NamedPropertyRangeSeq_out /*available_qos*/ + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +void +TAO_NS_EventChannel::set_admin (const CosNotification::AdminProperties & admin ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedAdmin + )) +{ + this->admin_properties_->init (admin); +} + +CosNotification::AdminProperties* +TAO_NS_EventChannel::get_admin (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + CosNotification::AdminProperties_var properties; + + ACE_NEW_THROW_EX (properties, + CosNotification::AdminProperties (), + CORBA::NO_MEMORY ()); + + this->admin_properties_->populate (properties); + + return properties._retn (); +} + +CosEventChannelAdmin::ConsumerAdmin_ptr +TAO_NS_EventChannel::for_consumers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + CosEventChannelAdmin::ConsumerAdmin_var ca_ret; + + ca_ret = CosEventChannelAdmin::ConsumerAdmin::_narrow (this->default_consumer_admin_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosEventChannelAdmin::ConsumerAdmin::_nil ()); + + return ca_ret._retn (); + +} + +CosEventChannelAdmin::SupplierAdmin_ptr +TAO_NS_EventChannel::for_suppliers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + CosEventChannelAdmin::SupplierAdmin_var sa_ret = + CosEventChannelAdmin::SupplierAdmin::_narrow (this->default_supplier_admin_.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosEventChannelAdmin::SupplierAdmin::_nil ()); + + return sa_ret._retn (); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannel.h b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.h new file mode 100644 index 00000000000..890acc408fe --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.h @@ -0,0 +1,212 @@ +/* -*- C++ -*- */ +/** + * @file EventChannel.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_EVENTCHANNEL_H +#define TAO_NS_EVENTCHANNEL_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyChannelAdminS.h" +#include "orbsvcs/NotifyExtC.h" +#include "Container_T.h" +#include "Destroy_Callback.h" +#include "AdminProperties.h" + +class TAO_NS_Admin; +class TAO_NS_EventChannelFactory; + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/** + * @class TAO_NS_EventChannel + * + * @brief Implementation of CosNotifyChannelAdmin::EventChannel + * + */ +class TAO_Notify_Export TAO_NS_EventChannel : public POA_CosNotifyChannelAdmin::EventChannel, public virtual TAO_NS_Container_T <TAO_NS_Admin, TAO_NS_EventChannel, TAO_NS_EventChannelFactory>, public TAO_NS_Destroy_Callback +{ + friend class TAO_NS_Builder; + typedef TAO_NS_Container_T <TAO_NS_Admin, TAO_NS_EventChannel, TAO_NS_EventChannelFactory> inherited; + typedef ACE_Unbounded_Set <TAO_NS_Object_Id> TAO_NS_Object_Id_Seq; + +public: + /// Constuctor + TAO_NS_EventChannel (void); + + /// Destructor + ~TAO_NS_EventChannel (); + + /// Init + void init (ACE_ENV_SINGLE_ARG_DECL); + + /// Insert object to this container. + virtual void insert (TAO_NS_Admin* admin ACE_ENV_ARG_DECL); + + /// Remove type from container_ + virtual void remove (TAO_NS_Admin* admin ACE_ENV_ARG_DECL); + + /// Return servant + virtual PortableServer::Servant servant (void); + + /// ServantBase refcount methods. + virtual void _add_ref (ACE_ENV_SINGLE_ARG_DECL); + virtual void _remove_ref (ACE_ENV_SINGLE_ARG_DECL); + + /// TAO_NS_Destroy_Callback methods + virtual void release (void); + +protected: + /// = Data Members + + // Default Consumer Admin + CosNotifyChannelAdmin::ConsumerAdmin_var default_consumer_admin_; + + // Default Supplier Admin + CosNotifyChannelAdmin::SupplierAdmin_var default_supplier_admin_; + + /// List of Consumer Admin ID's + TAO_NS_Object_Id_Seq consumer_admin_id_list_; + + /// List of Supplier Admin ID's + TAO_NS_Object_Id_Seq supplier_admin_id_list_; + + /// =CosNotifyChannelAdmin::EventChannel methods + + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::EventChannelFactory_ptr MyFactory (ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::ConsumerAdmin_ptr default_consumer_admin (ACE_ENV_SINGLE_ARG_DECL + + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::SupplierAdmin_ptr default_supplier_admin (ACE_ENV_SINGLE_ARG_DECL + + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyFilter::FilterFactory_ptr default_filter_factory (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::ConsumerAdmin_ptr new_for_consumers (CosNotifyChannelAdmin::InterFilterGroupOperator op, + CosNotifyChannelAdmin::AdminID_out id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::SupplierAdmin_ptr new_for_suppliers (CosNotifyChannelAdmin::InterFilterGroupOperator op, + CosNotifyChannelAdmin::AdminID_out id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::ConsumerAdmin_ptr get_consumeradmin (CosNotifyChannelAdmin::AdminID id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminNotFound + )); + + virtual ::CosNotifyChannelAdmin::SupplierAdmin_ptr get_supplieradmin (CosNotifyChannelAdmin::AdminID id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminNotFound + )); + + virtual ::CosNotifyChannelAdmin::AdminIDSeq * get_all_consumeradmins (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::AdminIDSeq * get_all_supplieradmins (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotification::QoSProperties * get_qos (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void set_qos (const CosNotification::QoSProperties & qos + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )); + + virtual void validate_qos (const CosNotification::QoSProperties & required_qos, + CosNotification::NamedPropertyRangeSeq_out available_qos + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )); + + virtual ::CosNotification::AdminProperties * get_admin (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void set_admin (const CosNotification::AdminProperties & admin ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedAdmin + )); + + virtual ::CosEventChannelAdmin::ConsumerAdmin_ptr for_consumers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosEventChannelAdmin::SupplierAdmin_ptr for_suppliers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__ACE_INLINE__) +#include "EventChannel.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_EVENTCHANNEL_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannel.inl b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannel.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.cpp b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.cpp new file mode 100644 index 00000000000..a7ca15ded36 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.cpp @@ -0,0 +1,144 @@ +// $Id$ + +#include "EventChannelFactory.h" + +#if ! defined (__ACE_INLINE__) +#include "EventChannelFactory.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_EventChannelFactory, "$Id$") + +#include "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "Properties.h" +#include "Builder.h" +#include "Proxy.h" +#include "Admin.h" +#include "EventChannel.h" +#include "Notify_Service.h" + +TAO_NS_EventChannelFactory::TAO_NS_EventChannelFactory (void) +{ +} + +TAO_NS_EventChannelFactory::~TAO_NS_EventChannelFactory () +{ +} + +void +TAO_NS_EventChannelFactory::init (ACE_ENV_SINGLE_ARG_DECL) +{ + this->default_filter_factory_ = TAO_NS_PROPERTIES::instance()->builder ()->build_filter_factory (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +PortableServer::Servant +TAO_NS_EventChannelFactory::servant (void) +{ + return this; +} + +void +TAO_NS_EventChannelFactory::_add_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->_incr_refcnt (); +} + +void +TAO_NS_EventChannelFactory::_remove_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->_decr_refcnt (); +} + +void +TAO_NS_EventChannelFactory::release (void) +{ + delete this; + //@@ inform factory +} + +CosNotifyFilter::FilterFactory_ptr +TAO_NS_EventChannelFactory::get_default_filter_factory (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + return CosNotifyFilter::FilterFactory::_duplicate (this->default_filter_factory_.in ()); +} + +::CosNotifyChannelAdmin::EventChannel_ptr TAO_NS_EventChannelFactory::create_channel ( + const CosNotification::QoSProperties & initial_qos, + const CosNotification::AdminProperties & initial_admin, + CosNotifyChannelAdmin::ChannelID_out id ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + , CosNotification::UnsupportedAdmin + )) +{ + return TAO_NS_PROPERTIES::instance()->builder ()->build_event_channel (this, initial_qos, initial_admin, id ACE_ENV_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::ChannelIDSeq* +TAO_NS_EventChannelFactory::get_all_channels (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + CosNotifyChannelAdmin::ChannelIDSeq* seq; + + ACE_NEW_THROW_EX (seq, + CosNotifyChannelAdmin::ChannelIDSeq (), + CORBA::NO_MEMORY ()); + + seq->length (this->event_channel_id_list_.size ()); + + TAO_NS_Object_Id_Seq::CONST_ITERATOR iter (this->event_channel_id_list_); + + TAO_NS_Object_Id* object_id; + + CORBA::ULong i = 0; + for (iter.first (); iter.next (object_id); iter.advance (), ++i) + seq[i] = *object_id; + + return seq; +} + +CosNotifyChannelAdmin::EventChannel_ptr +TAO_NS_EventChannelFactory::get_event_channel (CosNotifyChannelAdmin::ChannelID id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::ChannelNotFound + )) +{ + TAO_NS_Object* ns_object = this->find (id ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::EventChannel::_nil ()); + + if (ns_object != 0) + { + CORBA::Object_var object = ns_object->ref (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::EventChannel::_nil ()); + + CosNotifyChannelAdmin::EventChannel_var ec_ret = + CosNotifyChannelAdmin::EventChannel::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::EventChannel::_nil ()); + + return ec_ret._retn (); + } + else + ACE_THROW_RETURN (CosNotifyChannelAdmin::ChannelNotFound (), CosNotifyChannelAdmin::EventChannel::_nil ()); +} + +void +TAO_NS_EventChannelFactory::insert (TAO_NS_EventChannel* event_channel ACE_ENV_ARG_DECL) +{ + inherited::insert (event_channel ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->event_channel_id_list_.insert (event_channel->id ()); +} + +void +TAO_NS_EventChannelFactory::remove (TAO_NS_EventChannel* event_channel ACE_ENV_ARG_DECL) +{ + inherited::remove (event_channel ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->event_channel_id_list_.remove (event_channel->id ()); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.h b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.h new file mode 100644 index 00000000000..34084a7aaee --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.h @@ -0,0 +1,118 @@ +/* -*- C++ -*- */ +/** + * @file EventChannelFactory.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_EVENTCHANNELFACTORY_H +#define TAO_NS_EVENTCHANNELFACTORY_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyChannelAdminS.h" +#include "Container_T.h" +#include "Destroy_Callback.h" + +class TAO_NS_Notify_Service; +class TAO_NS_EventChannel; + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/** + * @class TAO_NS_EventChannelFactory + * + * @brief Implementation of CosNotifyChannelAdmin::EventChannelFactory + * + */ +class TAO_Notify_Export TAO_NS_EventChannelFactory : public virtual POA_CosNotifyChannelAdmin::EventChannelFactory, public TAO_NS_Container_T <TAO_NS_EventChannel, TAO_NS_EventChannelFactory, TAO_NS_Notify_Service>, public TAO_NS_Destroy_Callback +{ + friend class TAO_NS_Builder; + typedef TAO_NS_Container_T <TAO_NS_EventChannel, TAO_NS_EventChannelFactory, TAO_NS_Notify_Service> inherited; + typedef ACE_Unbounded_Set <TAO_NS_Object_Id> TAO_NS_Object_Id_Seq; +public: + /// Constuctor + TAO_NS_EventChannelFactory (void); + + /// Init the factory + void init (ACE_ENV_SINGLE_ARG_DECL); + + /// Destructor + virtual ~TAO_NS_EventChannelFactory (); + + /// Return servant + virtual PortableServer::Servant servant (void); + + /// Insert object to this container. + virtual void insert (TAO_NS_EventChannel* event_channel ACE_ENV_ARG_DECL); + + /// Remove type from container_ + virtual void remove (TAO_NS_EventChannel* event_channel ACE_ENV_ARG_DECL); + + /// = ServantBase Methods + virtual void _add_ref (ACE_ENV_SINGLE_ARG_DECL); + virtual void _remove_ref (ACE_ENV_SINGLE_ARG_DECL); + + /// TAO_NS_Destroy_Callback methods + virtual void release (void); + + /// Accesor for the default filter factory shared by all EC's. + virtual CosNotifyFilter::FilterFactory_ptr get_default_filter_factory (ACE_ENV_SINGLE_ARG_DECL); + + protected: + /// = Data Members + + /// List of Event Channel ID's + TAO_NS_Object_Id_Seq event_channel_id_list_; + + /// The default filter factory. + CosNotifyFilter::FilterFactory_var default_filter_factory_; + + /// = CosNotifyChannelAdmin Methods + + virtual ::CosNotifyChannelAdmin::EventChannel_ptr create_channel (const CosNotification::QoSProperties & initial_qos, + const CosNotification::AdminProperties & initial_admin, + CosNotifyChannelAdmin::ChannelID_out id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + , CosNotification::UnsupportedAdmin + )); + + virtual ::CosNotifyChannelAdmin::ChannelIDSeq * get_all_channels (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::EventChannel_ptr get_event_channel (CosNotifyChannelAdmin::ChannelID id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::ChannelNotFound + )); +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__ACE_INLINE__) +#include "EventChannelFactory.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_EVENTCHANNELFACTORY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.inl b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventChannelFactory.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventType.cpp b/TAO/orbsvcs/orbsvcs/Notify/EventType.cpp new file mode 100644 index 00000000000..ccee7778d4f --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventType.cpp @@ -0,0 +1,123 @@ +// $Id$ + +#include "EventType.h" + +#if ! defined (__ACE_INLINE__) +#include "EventType.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_EventType, "$Id$") + +TAO_NS_EventType +TAO_NS_EventType::special (void) +{ + return TAO_NS_EventType ("*", "%ALL"); +} + +TAO_NS_EventType::TAO_NS_EventType (void) +{ +} + +void +TAO_NS_EventType::init_i (const char* domain_name, const char* type_name) +{ + this->event_type_.domain_name = domain_name; + this->event_type_.type_name = type_name; + + if (this->is_special () == 1) + { + this->event_type_.domain_name = (const char* )"*"; + this->event_type_.type_name = (const char* )"%ALL"; + } + + this->recompute_hash (); +} + +TAO_NS_EventType::TAO_NS_EventType (const char* domain_name, const char* type_name) +{ + this->init_i (domain_name, type_name); +} + +TAO_NS_EventType::TAO_NS_EventType (const CosNotification::EventType& event_type) +{ + this->init_i (event_type.domain_name.in (), event_type.type_name.in ()); +} + +TAO_NS_EventType::~TAO_NS_EventType () +{ +} + +void +TAO_NS_EventType::recompute_hash (void) +{ + // @@ Pradeep: this code is bound to crash someday if the strings + // are too long.... See if the hash_pjw () function can be modified + // to take accumulate multiple strings, as in: + // hash = ACE::hash_pjw_accummulate (0, str1); + // hash = ACE::hash_pjw_accummulate (hash, str2); + // + // @@ Or use grow the buffer when needed, or just add the two hash + // values or something, but fix this code! + // + char buffer[BUFSIZ]; + ACE_OS::strcpy (buffer, this->event_type_.domain_name.in ()); + ACE_OS::strcat (buffer, this->event_type_.type_name.in ()); + + this->hash_value_ = ACE::hash_pjw (buffer); +} + +TAO_NS_EventType& +TAO_NS_EventType::operator=(const CosNotification::EventType& event_type) +{ + this->init_i (event_type.domain_name.in (),event_type.type_name.in ()); + + return *this; +} + +TAO_NS_EventType& +TAO_NS_EventType::operator=(const TAO_NS_EventType& event_type) +{ + if (this == &event_type) + return *this; + + this->init_i (event_type.event_type_.domain_name.in (),event_type.event_type_.type_name.in ()); + + return *this; +} + +int +TAO_NS_EventType::operator==(const TAO_NS_EventType& event_type) const +{ + if (this->hash () != event_type.hash ()) + return 0; + else // compare the strings + return (ACE_OS::strcmp (this->event_type_.type_name, event_type.event_type_.type_name) == 0 && + ACE_OS::strcmp (this->event_type_.domain_name, event_type.event_type_.domain_name) == 0 + ); +} + +int +TAO_NS_EventType::operator!=(const TAO_NS_EventType& event_type) const +{ + if (this->hash () != event_type.hash ()) + return 1; + else // compare the strings + return (ACE_OS::strcmp (this->event_type_.type_name, event_type.event_type_.type_name) != 0 || + ACE_OS::strcmp (this->event_type_.domain_name, event_type.event_type_.domain_name) != 0 + ); +} + +CORBA::Boolean +TAO_NS_EventType::is_special (void) const +{ + if ((this->event_type_.domain_name == 0 || + ACE_OS::strcmp (this->event_type_.domain_name, "") == 0 || + ACE_OS::strcmp (this->event_type_.domain_name, "*") == 0) && + (this->event_type_.type_name == 0 || + ACE_OS::strcmp (this->event_type_.type_name, "") == 0 || + ACE_OS::strcmp (this->event_type_.type_name, "*") == 0 || + ACE_OS::strcmp (this->event_type_.type_name, "%ALL") == 0)) + return 1; + else + return 0; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventType.h b/TAO/orbsvcs/orbsvcs/Notify/EventType.h new file mode 100644 index 00000000000..5bce8b9f532 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventType.h @@ -0,0 +1,89 @@ +/* -*- C++ -*- */ +/** + * @file EventType.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_EVENTTYPE_H +#define TAO_NS_EVENTTYPE_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotificationC.h" + +/** + * @class TAO_NS_EventType + * + * @brief + * + * This type is used to compare different event types. + * It is used by the Event Manager as a key to find subscription lists. + * + */ +class TAO_Notify_Export TAO_NS_EventType +{ +public: + /// Constuctor + TAO_NS_EventType (void); + TAO_NS_EventType (const char* domain_name, const char* type_name); + TAO_NS_EventType (const CosNotification::EventType& event_type); + // Constuctor + + /// Destructor + ~TAO_NS_EventType (); + + /// hash value + u_long hash (void) const; + + /// Assignment from CosNotification::EventType + TAO_NS_EventType& operator=(const CosNotification::EventType& event_type); + + /// Assignment operator. + TAO_NS_EventType& operator=(const TAO_NS_EventType& event_type); + + /// == operator + int operator==(const TAO_NS_EventType& notify_event_type) const; + + /// != operator + int operator!=(const TAO_NS_EventType& notify_event_type) const; + + static TAO_NS_EventType special (void); + // Return the special event type. + + CORBA::Boolean is_special (void) const; + // Is this the special event (accept everything). + + const CosNotification::EventType& native (void) const; + // Get the type underneath us. + +protected: + /// Init this object. + void init_i (const char* domain_name, const char* type_name); + + void recompute_hash (void); + // Recompute the hash value. + + // = Data Members + CosNotification::EventType event_type_; + // The event_type that we're decorating. + + u_long hash_value_; + // The hash value computed. +}; + +#if defined (__ACE_INLINE__) +#include "EventType.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_EVENTTYPE_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventType.inl b/TAO/orbsvcs/orbsvcs/Notify/EventType.inl new file mode 100644 index 00000000000..93af3791bf9 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventType.inl @@ -0,0 +1,13 @@ +// $Id$ + +ACE_INLINE u_long +TAO_NS_EventType::hash (void) const +{ + return this->hash_value_; +} + +ACE_INLINE const CosNotification::EventType& +TAO_NS_EventType::native (void) const +{ + return event_type_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.cpp b/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.cpp new file mode 100644 index 00000000000..750253c0982 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.cpp @@ -0,0 +1,140 @@ +// $Id$ + +#include "EventTypeSeq.h" + +#if ! defined (__ACE_INLINE__) +#include "EventTypeSeq.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_EventTypeSeq, "$Id$") + +TAO_NS_EventTypeSeq::TAO_NS_EventTypeSeq (void) +{ +} + +TAO_NS_EventTypeSeq::TAO_NS_EventTypeSeq (const CosNotification::EventTypeSeq& event_type_seq) +{ + this->insert_seq (event_type_seq); +} + +void +TAO_NS_EventTypeSeq::populate (CosNotification::EventTypeSeq& event_type_seq) const +{ + event_type_seq.length (this->size ()); + + inherited::CONST_ITERATOR iter (*this); + + TAO_NS_EventType* event_type; + + CORBA::ULong i = 0; + for (iter.first (); iter.next (event_type); iter.advance (), ++i) + event_type_seq[i] = event_type->native (); +} + +void +TAO_NS_EventTypeSeq::insert_seq (const CosNotification::EventTypeSeq& event_type_seq) +{ + TAO_NS_EventType event_type; + + for (CORBA::ULong i = 0; i < event_type_seq.length (); ++i) + { + event_type = event_type_seq[i]; + inherited::insert (event_type); + } +} + +void +TAO_NS_EventTypeSeq::remove_seq (const CosNotification::EventTypeSeq& event_type_seq) +{ + TAO_NS_EventType event_type; + + for (CORBA::ULong i = 0; i < event_type_seq.length (); ++i) + { + event_type = event_type_seq[i]; + inherited::remove (event_type); + } +} + +void +TAO_NS_EventTypeSeq::insert_seq (const TAO_NS_EventTypeSeq& event_type_seq) +{ + TAO_NS_EventTypeSeq::CONST_ITERATOR iter (event_type_seq); + + TAO_NS_EventType* event_type; + + for (iter.first (); iter.next (event_type); iter.advance ()) + inherited::insert (*event_type); +} + +void +TAO_NS_EventTypeSeq::remove_seq (const TAO_NS_EventTypeSeq& event_type_seq) +{ + TAO_NS_EventTypeSeq::CONST_ITERATOR iter (event_type_seq); + + TAO_NS_EventType* event_type; + + for (iter.first (); iter.next (event_type); iter.advance ()) + inherited::remove (*event_type); +} + +void +TAO_NS_EventTypeSeq::init (TAO_NS_EventTypeSeq& seq_added, TAO_NS_EventTypeSeq& seq_remove_seq) +{ + const TAO_NS_EventType& special = TAO_NS_EventType::special (); + + if (this->find (special) == 0) + { + if (seq_added.find (special) == 0) + { + seq_added.reset (); + seq_remove_seq.reset (); + } + else + { + this->reset (); + this->insert_seq (seq_added); + + seq_remove_seq.reset (); + seq_remove_seq.insert (special); + } + } + else + { + if (seq_added.find (special) == 0) + { + if (seq_remove_seq.find (special) == 0) + { + seq_added.reset (); + seq_remove_seq.reset (); + } + else + { + seq_remove_seq.reset (); + seq_remove_seq.insert_seq (*this); + + this->reset (); + this->insert (special); + + seq_added.reset (); + seq_added.insert (special); + } + } + else + { + if (seq_remove_seq.find (special) == 0) + { + + seq_remove_seq.reset (); + seq_remove_seq.insert_seq (*this); + + this->reset (); + this->insert_seq (seq_added); + } + else + { + this->insert_seq (seq_added); + this->remove_seq (seq_remove_seq); + } + } + } +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.h b/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.h new file mode 100644 index 00000000000..e4676c70a57 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.h @@ -0,0 +1,65 @@ +/* -*- C++ -*- */ +/** + * @file EventTypeSeq.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_EVENTTYPESEQ_H +#define TAO_NS_EVENTTYPESEQ_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "EventType.h" + +template<class T> class ACE_Unbounded_Set; + +/** + * @class TAO_NS_EventTypeSeq + * + * @brief Allows operations using the CosNotification::EventTypeSeq type. + * + */ +class TAO_Notify_Export TAO_NS_EventTypeSeq : public ACE_Unbounded_Set <TAO_NS_EventType> +{ + typedef ACE_Unbounded_Set <TAO_NS_EventType> inherited; + +public: + /// Constructor + TAO_NS_EventTypeSeq (void); + TAO_NS_EventTypeSeq (const CosNotification::EventTypeSeq& event_type_seq); + + /// Preprocess the types added and removed. + void init (TAO_NS_EventTypeSeq& added, TAO_NS_EventTypeSeq& removed); + + /// insert_seq the contents of <event_type_seq> into this object. + void insert_seq (const CosNotification::EventTypeSeq& event_type_seq); + + /// remove_seq the contents of <event_type_seq> from this object. + void remove_seq (const CosNotification::EventTypeSeq& event_type_seq); + + /// insert_seq the contents of <event_type_seq> into this object. + void insert_seq (const TAO_NS_EventTypeSeq& event_type_seq); + + /// remove_seq the contents of <event_type_seq> from this object. + void remove_seq (const TAO_NS_EventTypeSeq& event_type_seq); + + /// Populate <event_type_seq> with the contents of this object. + void populate (CosNotification::EventTypeSeq& event_type) const; +}; + +#if defined (__ACE_INLINE__) +#include "EventTypeSeq.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_EVENTTYPESEQ_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.inl b/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/EventTypeSeq.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.cpp b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.cpp new file mode 100644 index 00000000000..52d2540d0cc --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.cpp @@ -0,0 +1,358 @@ +// $Id$ + +#include "Event_Manager.h" +#include "tao/debug.h" + +#if ! defined (__ACE_INLINE__) +#include "Event_Manager.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Event_Manager, "$Id$") + +#include "ace/Refcounted_Auto_Ptr.h" +#include "orbsvcs/ESF/ESF_Proxy_Collection.h" + +#include "EventTypeSeq.h" +#include "Event.h" +#include "Peer.h" +#include "Consumer.h" +#include "ProxyConsumer.h" +#include "ProxySupplier.h" +#include "Proxy.h" +#include "Admin.h" +#include "EventChannel.h" +#include "EventChannelFactory.h" +#include "Notify_Service.h" +#include "Pending_Worker_T.h" +#include "Event_Map_Observer_T.h" +#include "Dispatch_Observer_T.h" +#include "Event_Map_T.h" + +TAO_NS_Event_Manager::TAO_NS_Event_Manager (void) + :consumer_map_ (0), supplier_map_ (0), + consumer_map_observer_ (0), supplier_map_observer_ (0), + event_dispatch_observer_(0), updates_dispatch_observer_ (0), + event_pending_worker_ (0), updates_pending_worker_ (0) +{ +} + +TAO_NS_Event_Manager::~TAO_NS_Event_Manager () +{ + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, "destroying consumer/supplier map count = %d/%d, \n", + this->consumer_map_->event_type_count (), this->supplier_map_->event_type_count ())); + } + + delete this->consumer_map_; + delete this->supplier_map_; + delete this->consumer_map_observer_; + delete this->supplier_map_observer_; + delete this->event_dispatch_observer_; + delete this->updates_dispatch_observer_; + delete this->event_pending_worker_; + delete this->updates_pending_worker_; +} + +void +TAO_NS_Event_Manager::init (ACE_ENV_SINGLE_ARG_DECL) +{ + ACE_NEW_THROW_EX (this->consumer_map_, + TAO_NS_Consumer_Map (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + ACE_NEW_THROW_EX (this->supplier_map_, + TAO_NS_Supplier_Map (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + ACE_NEW_THROW_EX (this->consumer_map_observer_, + TAO_NS_Consumer_Map_Observer (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + + ACE_NEW_THROW_EX (this->supplier_map_observer_, + TAO_NS_Supplier_Map_Observer (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + ACE_NEW_THROW_EX (this->event_dispatch_observer_, + TAO_NS_Event_Dispatch_Observer (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + ACE_NEW_THROW_EX (this->updates_dispatch_observer_, + TAO_NS_Updates_Dispatch_Observer (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + ACE_NEW_THROW_EX (this->event_pending_worker_, + TAO_NS_Event_Pending_Worker (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + ACE_NEW_THROW_EX (this->updates_pending_worker_, + TAO_NS_Updates_Pending_Worker (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + this->consumer_map_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->supplier_map_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->event_dispatch_observer_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->updates_dispatch_observer_->init (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->consumer_map_observer_->init (this->supplier_map_, this->updates_dispatch_observer_); + ACE_CHECK; + + this->supplier_map_observer_->init (this->consumer_map_, this->updates_dispatch_observer_); + ACE_CHECK; + + this->consumer_map_->attach_observer (this->consumer_map_observer_); + this->supplier_map_->attach_observer (this->supplier_map_observer_); + + this->event_pending_worker_->init (this->event_dispatch_observer_, TAO_NS_PROPERTIES::instance()->update_period () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (TAO_NS_PROPERTIES::instance()->updates () == 0) + this->updates_pending_worker_->worker_suspend (); + + this->updates_pending_worker_->init (this->updates_dispatch_observer_, TAO_NS_PROPERTIES::instance()->update_period () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_NS_Event_Manager::shutdown (void) +{ + this->event_pending_worker_->shutdown (); + this->updates_pending_worker_->shutdown (); +} + +void +TAO_NS_Event_Manager::subscribe (TAO_NS_ProxySupplier* proxy_supplier, const TAO_NS_EventTypeSeq& seq ACE_ENV_ARG_DECL) +{ + TAO_NS_EventTypeSeq::CONST_ITERATOR iter (seq); + + TAO_NS_EventType* event_type; + + for (iter.first (); iter.next (event_type) != 0; iter.advance ()) + { + consumer_map_->insert (proxy_supplier, *event_type ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } +} + +void +TAO_NS_Event_Manager::un_subscribe (TAO_NS_ProxySupplier* proxy_supplier, const TAO_NS_EventTypeSeq& seq ACE_ENV_ARG_DECL) +{ + TAO_NS_EventTypeSeq::CONST_ITERATOR iter (seq); + + TAO_NS_EventType* event_type = 0; + + for (iter.first (); iter.next (event_type) != 0; iter.advance ()) + { + consumer_map_->remove (proxy_supplier, *event_type ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } +} + +void +TAO_NS_Event_Manager::publish (TAO_NS_ProxyConsumer* proxy_consumer, const TAO_NS_EventTypeSeq& seq ACE_ENV_ARG_DECL) +{ + TAO_NS_EventTypeSeq::CONST_ITERATOR iter (seq); + + TAO_NS_EventType* event_type = 0; + + for (iter.first (); iter.next (event_type) != 0; iter.advance ()) + { + supplier_map_->insert (proxy_consumer, *event_type ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + +} + +void +TAO_NS_Event_Manager::un_publish (TAO_NS_ProxyConsumer* proxy_consumer, const TAO_NS_EventTypeSeq& seq ACE_ENV_ARG_DECL) +{ + TAO_NS_EventTypeSeq::CONST_ITERATOR iter (seq); + + TAO_NS_EventType* event_type = 0; + + for (iter.first (); iter.next (event_type) != 0; iter.advance ()) + { + supplier_map_->remove (proxy_consumer, *event_type ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class TAO_NS_Event_Map_T<TAO_NS_ProxySupplier, TAO_SYNCH_RW_MUTEX>; +template class TAO_NS_Event_Map_T<TAO_NS_ProxyConsumer, TAO_SYNCH_RW_MUTEX>; + +template class TAO_NS_Event_Map_Observer_T<TAO_NS_ProxyConsumer>; +template class TAO_NS_Event_Map_Observer_T<TAO_NS_ProxySupplier>; + +template class TAO_NS_Dispatch_Observer_T<TAO_NS_Peer>; +template class TAO_NS_Dispatch_Observer_T<TAO_NS_Consumer>; + +template class TAO_NS_Pending_Worker_T<TAO_NS_Peer>; +template class TAO_NS_Pending_Worker_T<TAO_NS_Consumer>; + +template class TAO_NS_Dispatch_Pending_Worker_T<TAO_NS_Consumer>; +template class TAO_NS_Dispatch_Pending_Worker_T<TAO_NS_Peer>; + +template class TAO_NS_Update_Removed_Worker<TAO_NS_ProxyConsumer>; +template class TAO_NS_Update_Removed_Worker<TAO_NS_ProxySupplier>; +template class TAO_NS_Update_Added_Worker<TAO_NS_ProxyConsumer>; + +template class ACE_Hash<TAO_NS_EventType>; +template class ACE_Equal_To<TAO_NS_EventType>; + +template class TAO_NS_Event_Map_Entry_T<TAO_NS_ProxyConsumer>; +template class TAO_NS_Event_Map_Entry_T<TAO_NS_ProxySupplier>; + +template class ACE_Hash_Map_Manager_Ex<TAO_NS_EventType, TAO_NS_Event_Map_Entry_T<TAO_NS_ProxyConsumer> *, ACE_Hash<TAO_NS_EventType>, ACE_Equal_To<TAO_NS_EventType>, ACE_Null_Mutex>; +template class ACE_Hash_Map_Manager_Ex<TAO_NS_EventType, TAO_NS_Event_Map_Entry_T<TAO_NS_ProxySupplier> *, ACE_Hash<TAO_NS_EventType>, ACE_Equal_To<TAO_NS_EventType>, ACE_Null_Mutex>; +template class ACE_Hash_Map_Manager<TAO_NS_EventType, TAO_NS_Event_Map_Entry_T<TAO_NS_ProxySupplier> *, ACE_Null_Mutex>; +template class ACE_Hash_Map_Manager<TAO_NS_EventType, TAO_NS_Event_Map_Entry_T<TAO_NS_ProxyConsumer> *, ACE_Null_Mutex>; +template class ACE_Hash_Map_Manager<ACE_CString, CORBA_Any, ACE_Null_Mutex>; + +template class TAO_NS_Object_Find_Worker_T<TAO_NS_Proxy>; +template class TAO_NS_Object_Find_Worker_T<TAO_NS_Admin>; +template class TAO_NS_Object_Find_Worker_T<TAO_NS_EventChannel>; + +template class TAO_NS_Update_Added_Worker<TAO_NS_ProxySupplier>; + +template class ACE_Unbounded_Set<TAO_NS_EventType>; +template class ACE_Unbounded_Set_Const_Iterator<TAO_NS_EventType>; +template class ACE_Unbounded_Queue<ACE_Refcounted_Auto_Ptr<TAO_NS_Event, TAO_SYNCH_MUTEX> >; +template class ACE_Unbounded_Set_Iterator<TAO_NS_EventType>; + +template class TAO_ESF_Worker<TAO_NS_ProxySupplier>; +template class TAO_ESF_Worker<TAO_NS_ProxyConsumer>; +template class TAO_ESF_Worker<TAO_NS_Proxy>; +template class TAO_ESF_Worker<TAO_NS_Consumer>; +template class TAO_ESF_Worker<TAO_NS_Peer>; +template class TAO_ESF_Worker<TAO_NS_Admin>; +template class TAO_ESF_Worker<TAO_NS_EventChannel>; + +template class ACE_Refcounted_Auto_Ptr<TAO_NS_Event, TAO_SYNCH_MUTEX>; +template class ACE_Unbounded_Queue_Iterator<ACE_Refcounted_Auto_Ptr<TAO_NS_Event, TAO_SYNCH_MUTEX> >; + +template class ACE_Node<ACE_Refcounted_Auto_Ptr<TAO_NS_Event, TAO_SYNCH_MUTEX > >; +template class ACE_Node<TAO_NS_Supplier *>; +template class ACE_Node<TAO_NS_Admin *>; +template class ACE_Node<TAO_NS_EventChannel *>; +template class ACE_Node<TAO_NS_ProxyConsumer *>; +template class ACE_Node<TAO_NS_EventType>; +template class ACE_Node<TAO_NS_Peer *>; +template class ACE_Node<TAO_NS_ProxySupplier *>; +template class ACE_Node<TAO_NS_Proxy *>; +template class ACE_Node<TAO_NS_Consumer *>; + +template class ACE_Hash_Map_Entry<TAO_NS_EventType, TAO_NS_Event_Map_Entry_T<TAO_NS_ProxyConsumer> *>; +template class ACE_Hash_Map_Entry<ACE_CString, CORBA_Any>; +template class ACE_Hash_Map_Entry<TAO_NS_EventType, TAO_NS_Event_Map_Entry_T<TAO_NS_ProxySupplier> *>; + +template class ACE_Hash_Map_Iterator_Base_Ex<TAO_NS_EventType, TAO_NS_Event_Map_Entry_T<TAO_NS_ProxySupplier> *, ACE_Hash<TAO_NS_EventType>, ACE_Equal_To<TAO_NS_EventType>, ACE_Null_Mutex>; +template class ACE_Hash_Map_Iterator_Base_Ex<TAO_NS_EventType, TAO_NS_Event_Map_Entry_T<TAO_NS_ProxyConsumer> *, ACE_Hash<TAO_NS_EventType>, ACE_Equal_To<TAO_NS_EventType>, ACE_Null_Mutex>; + +template class ACE_Hash_Map_Manager_Ex<ACE_CString, CORBA_Any, ACE_Hash<ACE_CString >, ACE_Equal_To<ACE_CString >, ACE_Null_Mutex>; + +template class ACE_Hash_Map_Iterator_Base_Ex<ACE_CString, CORBA_Any, ACE_Hash<ACE_CString >, ACE_Equal_To<ACE_CString >, ACE_Null_Mutex>; + +template class TAO_ESF_Shutdown_Proxy<TAO_NS_EventChannel>; +template class TAO_ESF_Shutdown_Proxy<TAO_NS_Admin>; +template class TAO_ESF_Shutdown_Proxy<TAO_NS_Proxy>; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate TAO_NS_Event_Map_T<TAO_NS_ProxySupplier, TAO_SYNCH_RW_MUTEX> +#pragma instantiate TAO_NS_Event_Map_T<TAO_NS_ProxyConsumer, TAO_SYNCH_RW_MUTEX> + +#pragma instantiate TAO_NS_Event_Map_Observer_T<TAO_NS_ProxyConsumer> +#pragma instantiate TAO_NS_Event_Map_Observer_T<TAO_NS_ProxySupplier> + +#pragma instantiate TAO_NS_Dispatch_Observer_T<TAO_NS_Peer> +#pragma instantiate TAO_NS_Dispatch_Observer_T<TAO_NS_Consumer> + +#pragma instantiate TAO_NS_Pending_Worker_T<TAO_NS_Peer> +#pragma instantiate TAO_NS_Pending_Worker_T<TAO_NS_Consumer> + +#pragma instantiate TAO_NS_Dispatch_Pending_Worker_T<TAO_NS_Consumer> +#pragma instantiate TAO_NS_Dispatch_Pending_Worker_T<TAO_NS_Peer> + +#pragma instantiate TAO_NS_Update_Removed_Worker<TAO_NS_ProxyConsumer> +#pragma instantiate TAO_NS_Update_Removed_Worker<TAO_NS_ProxySupplier> +#pragma instantiate TAO_NS_Update_Added_Worker<TAO_NS_ProxyConsumer> + +#pragma instantiate ACE_Hash<TAO_NS_EventType> +#pragma instantiate ACE_Equal_To<TAO_NS_EventType> + +#pragma instantiate TAO_NS_Event_Map_Entry_T<TAO_NS_ProxyConsumer> +#pragma instantiate TAO_NS_Event_Map_Entry_T<TAO_NS_ProxySupplier> + +#pragma instantiate ACE_Hash_Map_Manager_Ex<TAO_NS_EventType, TAO_NS_Event_Map_Entry_T<TAO_NS_ProxyConsumer> *, ACE_Hash<TAO_NS_EventType>, ACE_Equal_To<TAO_NS_EventType>, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Manager_Ex<TAO_NS_EventType, TAO_NS_Event_Map_Entry_T<TAO_NS_ProxySupplier> *, ACE_Hash<TAO_NS_EventType>, ACE_Equal_To<TAO_NS_EventType>, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Manager<TAO_NS_EventType, TAO_NS_Event_Map_Entry_T<TAO_NS_ProxySupplier> *, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Manager<TAO_NS_EventType, TAO_NS_Event_Map_Entry_T<TAO_NS_ProxyConsumer> *, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Manager<ACE_CString, CORBA_Any, ACE_Null_Mutex> + +#pragma instantiate TAO_NS_Object_Find_Worker_T<TAO_NS_Proxy> +#pragma instantiate TAO_NS_Object_Find_Worker_T<TAO_NS_Admin> +#pragma instantiate TAO_NS_Object_Find_Worker_T<TAO_NS_EventChannel> + +#pragma instantiate TAO_NS_Update_Added_Worker<TAO_NS_ProxySupplier> + +#pragma instantiate ACE_Unbounded_Set<TAO_NS_EventType> +#pragma instantiate ACE_Unbounded_Set_Const_Iterator<TAO_NS_EventType> +#pragma instantiate ACE_Unbounded_Queue<ACE_Refcounted_Auto_Ptr<TAO_NS_Event, TAO_SYNCH_MUTEX> > +#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_NS_EventType> + +#pragma instantiate TAO_ESF_Worker<TAO_NS_ProxySupplier> +#pragma instantiate TAO_ESF_Worker<TAO_NS_ProxyConsumer> +#pragma instantiate TAO_ESF_Worker<TAO_NS_Proxy> +#pragma instantiate TAO_ESF_Worker<TAO_NS_Consumer> +#pragma instantiate TAO_ESF_Worker<TAO_NS_Peer> +#pragma instantiate TAO_ESF_Worker<TAO_NS_Admin> +#pragma instantiate TAO_ESF_Worker<TAO_NS_EventChannel> + +#pragma instantiate ACE_Refcounted_Auto_Ptr<TAO_NS_Event, TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Unbounded_Queue_Iterator<ACE_Refcounted_Auto_Ptr<TAO_NS_Event, TAO_SYNCH_MUTEX> > + +#pragma instantiate ACE_Node<ACE_Refcounted_Auto_Ptr<TAO_NS_Event, TAO_SYNCH_MUTEX > > +#pragma instantiate ACE_Node<TAO_NS_Supplier *> +#pragma instantiate ACE_Node<TAO_NS_Admin *> +#pragma instantiate ACE_Node<TAO_NS_EventChannel *> +#pragma instantiate ACE_Node<TAO_NS_ProxyConsumer *> +#pragma instantiate ACE_Node<TAO_NS_EventType> +#pragma instantiate ACE_Node<TAO_NS_Peer *> +#pragma instantiate ACE_Node<TAO_NS_ProxySupplier *> +#pragma instantiate ACE_Node<TAO_NS_Proxy *> +#pragma instantiate ACE_Node<TAO_NS_Consumer *> + +#pragma instantiate ACE_Hash_Map_Entry<TAO_NS_EventType, TAO_NS_Event_Map_Entry_T<TAO_NS_ProxyConsumer> *> +#pragma instantiate ACE_Hash_Map_Entry<ACE_CString, CORBA_Any> +#pragma instantiate ACE_Hash_Map_Entry<TAO_NS_EventType, TAO_NS_Event_Map_Entry_T<TAO_NS_ProxySupplier> *> + +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<TAO_NS_EventType, TAO_NS_Event_Map_Entry_T<TAO_NS_ProxySupplier> *, ACE_Hash<TAO_NS_EventType>, ACE_Equal_To<TAO_NS_EventType>, ACE_Null_Mutex> +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<TAO_NS_EventType, TAO_NS_Event_Map_Entry_T<TAO_NS_ProxyConsumer> *, ACE_Hash<TAO_NS_EventType>, ACE_Equal_To<TAO_NS_EventType>, ACE_Null_Mutex> + +#pragma instantiate ACE_Hash_Map_Manager_Ex<ACE_CString, CORBA_Any, ACE_Hash<ACE_CString >, ACE_Equal_To<ACE_CString >, ACE_Null_Mutex> + +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<ACE_CString, CORBA_Any, ACE_Hash<ACE_CString >, ACE_Equal_To<ACE_CString >, ACE_Null_Mutex> + +#pragma instantiate TAO_ESF_Shutdown_Proxy<TAO_NS_EventChannel> +#pragma instantiate TAO_ESF_Shutdown_Proxy<TAO_NS_Admin> +#pragma instantiate TAO_ESF_Shutdown_Proxy<TAO_NS_Proxy> + +#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.h b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.h new file mode 100644 index 00000000000..eddef6ed5b6 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.h @@ -0,0 +1,99 @@ +/* -*- C++ -*- */ +/** + * @file Event_Manager.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_EVENT_MANAGER_H +#define TAO_NS_EVENT_MANAGER_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Types.h" + + +/** + * @class TAO_NS_Event_Manager + * + * @brief A class that manages the Consumer and Supplier maps. + * + */ +class TAO_Notify_Export TAO_NS_Event_Manager +{ +public: + /// Constuctor + TAO_NS_Event_Manager (void); + + /// Destructor + ~TAO_NS_Event_Manager (); + + /// Init + void init (ACE_ENV_SINGLE_ARG_DECL); + + /// Init + void shutdown (void); + + /// Subscribe <proxy_supplier> to the event type sequence list <seq>. + void subscribe (TAO_NS_ProxySupplier* proxy_supplier, const TAO_NS_EventTypeSeq& seq ACE_ENV_ARG_DECL); + + /// Unsubscribe <proxy_supplier> to the event type sequence list <seq>. + void un_subscribe (TAO_NS_ProxySupplier* proxy_supplier, const TAO_NS_EventTypeSeq& seq ACE_ENV_ARG_DECL); + + /// Subscribe <proxy_consumer> to the event type sequence list <seq>. + void publish (TAO_NS_ProxyConsumer* proxy_consumer, const TAO_NS_EventTypeSeq& seq ACE_ENV_ARG_DECL); + + /// Subscribe <proxy_consumer> to the event type sequence list <seq>. + void un_publish (TAO_NS_ProxyConsumer* proxy_consumer, const TAO_NS_EventTypeSeq& seq ACE_ENV_ARG_DECL); + + /// Map accessors. + TAO_NS_Consumer_Map* consumer_map (void); + TAO_NS_Supplier_Map* supplier_map (void); + + /// Event Dispatch Observer + TAO_NS_Event_Dispatch_Observer* event_dispatch_observer (void); + + /// Update dispatch observer. + TAO_NS_Updates_Dispatch_Observer* updates_dispatch_observer (void); + +protected: + /// Consumer Map + TAO_NS_Consumer_Map* consumer_map_; + + /// Supplier Map + TAO_NS_Supplier_Map* supplier_map_; + + /// Consumer Map Observer + TAO_NS_Consumer_Map_Observer* consumer_map_observer_; + + /// Supplier Map Observer + TAO_NS_Supplier_Map_Observer* supplier_map_observer_; + + /// Event Dispatch Observer. + TAO_NS_Event_Dispatch_Observer* event_dispatch_observer_; + + /// Update dispatch observer. + TAO_NS_Updates_Dispatch_Observer* updates_dispatch_observer_; + + /// Worker task that dispatches pending events. + TAO_NS_Event_Pending_Worker* event_pending_worker_; + + /// Worker task that dispatches pending update messges. + TAO_NS_Updates_Pending_Worker* updates_pending_worker_; +}; + +#if defined (__ACE_INLINE__) +#include "Event_Manager.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_EVENT_MANAGER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.inl b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.inl new file mode 100644 index 00000000000..f988e9d2914 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Manager.inl @@ -0,0 +1,25 @@ +// $Id$ + +ACE_INLINE TAO_NS_Consumer_Map* +TAO_NS_Event_Manager::consumer_map (void) +{ + return consumer_map_; +} + +ACE_INLINE TAO_NS_Supplier_Map* +TAO_NS_Event_Manager::supplier_map (void) +{ + return supplier_map_; +} + +ACE_INLINE TAO_NS_Event_Dispatch_Observer* +TAO_NS_Event_Manager::event_dispatch_observer (void) +{ + return this->event_dispatch_observer_; +} + +ACE_INLINE TAO_NS_Updates_Dispatch_Observer* +TAO_NS_Event_Manager::updates_dispatch_observer (void) +{ + return this->updates_dispatch_observer_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.cpp new file mode 100644 index 00000000000..625a64f82bb --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.cpp @@ -0,0 +1,52 @@ +// $Id$ + +#ifndef TAO_NS_EVENT_MAP_ENTRY_CPP +#define TAO_NS_EVENT_MAP_ENTRY_CPP + +#include "Event_Map_Entry_T.h" + +#if ! defined (__ACE_INLINE__) +#include "Event_Map_Entry_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_Event_Map_Entry_T, "$id$") + +#include "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "Properties.h" +#include "Factory.h" + +template <class PROXY> +TAO_NS_Event_Map_Entry_T<PROXY>::TAO_NS_Event_Map_Entry_T (void) + : collection_ (0), count_ (0) +{ +} + +template <class PROXY> +TAO_NS_Event_Map_Entry_T<PROXY>::~TAO_NS_Event_Map_Entry_T () +{ + delete collection_; +} + +template <class PROXY> void +TAO_NS_Event_Map_Entry_T<PROXY>::init (ACE_ENV_SINGLE_ARG_DECL) +{ + TAO_NS_Factory* factory = TAO_NS_PROPERTIES::instance ()->factory (); + + factory->create (collection_ ACE_ENV_ARG_PARAMETER); +} + +template <class PROXY> void +TAO_NS_Event_Map_Entry_T<PROXY>::connected (PROXY* proxy ACE_ENV_ARG_DECL) +{ + this->collection_->connected (proxy ACE_ENV_ARG_PARAMETER); + ++count_; +} + +template <class PROXY> void +TAO_NS_Event_Map_Entry_T<PROXY>::disconnected (PROXY* proxy ACE_ENV_ARG_DECL) +{ + this->collection_->disconnected (proxy ACE_ENV_ARG_PARAMETER); + --count_; +} + +#endif /* TAO_NS_EVENT_MAP_ENTRY_CPP */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.h b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.h new file mode 100644 index 00000000000..566f8b4894d --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.h @@ -0,0 +1,81 @@ +/* -*- C++ -*- */ +/** + * @file Event_Map_Entry_T.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_EVENT_MAP_ENTRY_T_H +#define TAO_NS_EVENT_MAP_ENTRY_T_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Copy_Disabled.h" +#include "Types.h" + +template <class PROXY, class ACE_LOCK> class TAO_NS_Event_Map_T; + +/** + * @class TAO_NS_Event_Map_Entry_T + * + * @brief The entry stored in the event map. + * + */ +template <class PROXY> +class TAO_NS_Event_Map_Entry_T : private ACE_Copy_Disabled +{ +public: + typedef TAO_ESF_Proxy_Collection<PROXY> COLLECTION; + + /// Constructor + TAO_NS_Event_Map_Entry_T (void); + + /// Destructor + ~TAO_NS_Event_Map_Entry_T (void); + + /// Init - Allocates collection + void init (ACE_ENV_SINGLE_ARG_DECL); + + /// Connect + void connected (PROXY* proxy ACE_ENV_ARG_DECL); + + /// Disconnect + void disconnected (PROXY* proxy ACE_ENV_ARG_DECL); + + /// Collection accessor + COLLECTION* collection (void); + + /// Count accessor + int count (void); + +protected: + /// The Collection + COLLECTION* collection_; + + /// Count of PROXY's connected in the collection; + int count_; +}; + +#if defined (__ACE_INLINE__) +#include "Event_Map_Entry_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Event_Map_Entry_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Event_Map_Entry_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* TAO_NS_EVENT_MAP_ENTRY_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.inl b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.inl new file mode 100644 index 00000000000..8a6e21871a8 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Entry_T.inl @@ -0,0 +1,13 @@ +// $Id$ + +template <class PROXY> ACE_INLINE TAO_NS_Event_Map_Entry_T<PROXY>::COLLECTION* +TAO_NS_Event_Map_Entry_T<PROXY>::collection (void) +{ + return collection_; +} + +template <class PROXY> ACE_INLINE int +TAO_NS_Event_Map_Entry_T<PROXY>::count (void) +{ + return this->count_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer.h b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer.h new file mode 100644 index 00000000000..06ef8e3ecce --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer.h @@ -0,0 +1,39 @@ +/* -*- C++ -*- */ +/** + * @file Event_Map_Observer.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_EVENT_MAP_OBSERVER_H +#define TAO_NS_EVENT_MAP_OBSERVER_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +/** + * @class TAO_NS_Event_Map_Observer + * + * @brief + * + */ +class TAO_Notify_Export TAO_NS_Event_Map_Observer +{ +public: + /// <event_type> was seen for the first time in the event map. + virtual void type_added (const TAO_NS_EventType& event_type ACE_ENV_ARG_DECL) = 0; + + /// <event_type> does not have any proxy interested in it. + virtual void type_removed (const TAO_NS_EventType& event_type ACE_ENV_ARG_DECL) = 0; +}; + +#include "ace/post.h" +#endif /* TAO_NS_EVENT_MAP_OBSERVER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer_T.cpp new file mode 100644 index 00000000000..a055fc7c666 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer_T.cpp @@ -0,0 +1,111 @@ +// $Id$ + +#ifndef TAO_NS_EVENT_MAP_ENTRY_OBSERVER_T_CPP +#define TAO_NS_EVENT_MAP_ENTRY_OBSERVER_T_CPP + +#include "Event_Map_Observer_T.h" + +#if ! defined (__ACE_INLINE__) +#include "Event_Map_Observer_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_Event_Map_Observer_T, "$id$") + +#include "Proxy.h" +#include "Peer.h" +#include "Dispatch_Observer_T.h" +#include "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "Event_Map_T.h" + +/******************************************************************************************/ + +template <class PROXY> +TAO_NS_Update_Added_Worker<PROXY>::TAO_NS_Update_Added_Worker (const TAO_NS_EventType& event_type, TAO_NS_Updates_Dispatch_Observer* dispatch_observer) + :event_type_ (event_type), dispatch_observer_ (dispatch_observer) +{ +} + +template <class PROXY> void +TAO_NS_Update_Added_Worker<PROXY>::work (PROXY* proxy ACE_ENV_ARG_DECL) +{ + proxy->type_added (this->event_type_); + + if (proxy->updates_off () == 0) + { + this->dispatch_observer_->enqueue (proxy->peer () ACE_ENV_ARG_PARAMETER); // Tell the observer that this peer has a update pending. + } +} + +/******************************************************************************************/ + +template <class PROXY> +TAO_NS_Update_Removed_Worker<PROXY>::TAO_NS_Update_Removed_Worker (const TAO_NS_EventType& event_type, TAO_NS_Updates_Dispatch_Observer* dispatch_observer) + :event_type_ (event_type), dispatch_observer_ (dispatch_observer) +{ +} + +template <class PROXY> void +TAO_NS_Update_Removed_Worker<PROXY>::work (PROXY* proxy ACE_ENV_ARG_DECL) +{ + if (proxy->updates_off () == 0) + { + proxy->type_removed (this->event_type_); + this->dispatch_observer_->enqueue (proxy->peer () ACE_ENV_ARG_PARAMETER); // Tell the observer that this peer has a update pending. + } +} + +/******************************************************************************************/ + +template <class PROXY> +TAO_NS_Event_Map_Observer_T<PROXY>::TAO_NS_Event_Map_Observer_T (void) + :event_map_ (0), dispatch_observer_ (0) +{ +} + +template <class PROXY> +TAO_NS_Event_Map_Observer_T<PROXY>::~TAO_NS_Event_Map_Observer_T () +{ +} + +template <class PROXY> void +TAO_NS_Event_Map_Observer_T<PROXY>::init (EVENT_MAP* event_map, TAO_NS_Updates_Dispatch_Observer* dispatch_observer) +{ + this->event_map_ = event_map; + this->dispatch_observer_ = dispatch_observer; +} + +template <class PROXY> void +TAO_NS_Event_Map_Observer_T<PROXY>::type_added (const TAO_NS_EventType& event_type ACE_ENV_ARG_DECL) +{ + UPDATE_ADDED_WORKER worker (event_type, this->dispatch_observer_); + + PROXY_COLLECTION* proxys = this->event_map_->find (event_type ACE_ENV_ARG_PARAMETER); + + if (proxys != 0) + proxys->for_each (&worker ACE_ENV_ARG_PARAMETER); + + // Get the default broadcast collection. + proxys = this->event_map_->broadcast_collection (); + + if (proxys != 0) + proxys->for_each (&worker ACE_ENV_ARG_PARAMETER); +} + +template <class PROXY> void +TAO_NS_Event_Map_Observer_T<PROXY>::type_removed (const TAO_NS_EventType& event_type ACE_ENV_ARG_DECL) +{ + UPDATE_REMOVED_WORKER worker (event_type, this->dispatch_observer_); + + PROXY_COLLECTION* proxys = this->event_map_->find (event_type ACE_ENV_ARG_PARAMETER); + + if (proxys != 0) + proxys->for_each (&worker ACE_ENV_ARG_PARAMETER); + + // Get the default broadcast collection. + proxys = this->event_map_->broadcast_collection (); + + if (proxys != 0) + proxys->for_each (&worker ACE_ENV_ARG_PARAMETER); +} + +#endif /* TAO_NS_EVENT_MAP_ENTRY_OBSERVER_T_CPP */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer_T.h b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer_T.h new file mode 100644 index 00000000000..6ff8659746c --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer_T.h @@ -0,0 +1,126 @@ +/* -*- C++ -*- */ +/** + * @file Event_Map_Observer_T.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_EVENT_MAP_OBSERVER_T_H +#define TAO_EVENT_MAP_OBSERVER_T_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Types.h" +#include "Event_Map_Observer.h" +#include "orbsvcs/ESF/ESF_Worker.h" + +/** + * @class TAO_NS_Update_Added_Worker_T + * + * @brief Inform Peers of new offered type. + * + */ +template <class PROXY> +class TAO_Notify_Export TAO_NS_Update_Added_Worker : public TAO_ESF_Worker<PROXY> +{ +public: + TAO_NS_Update_Added_Worker (const TAO_NS_EventType& event_type, TAO_NS_Updates_Dispatch_Observer* dispatch_observer); + +protected: + ///= TAO_ESF_Worker method + void work (PROXY* proxy ACE_ENV_ARG_DECL); + + const TAO_NS_EventType& event_type_; + + /// Updates Observer. + TAO_NS_Updates_Dispatch_Observer* dispatch_observer_; +}; + +/*******************************************************************************************/ + + +/** + * @class TAO_NS_Update_Removed_Worker_T + * + * @brief Inform Peers of offered type removed. + * + */ +template <class PROXY> +class TAO_Notify_Export TAO_NS_Update_Removed_Worker : public TAO_ESF_Worker<PROXY> +{ +public: + TAO_NS_Update_Removed_Worker (const TAO_NS_EventType& event_type, TAO_NS_Updates_Dispatch_Observer* dispatch_observer); + +protected: + ///= TAO_ESF_Worker method + void work (PROXY* proxy ACE_ENV_ARG_DECL); + + const TAO_NS_EventType& event_type_; + + /// Updates Observer. + TAO_NS_Updates_Dispatch_Observer* dispatch_observer_; +}; + +/*******************************************************************************************/ + +/** + * @class TAO_Event_Map_Observer_T + * + * @brief Observe significant changes to the Event Map. + * + */ +template <class PROXY> +class TAO_Notify_Export TAO_NS_Event_Map_Observer_T : public TAO_NS_Event_Map_Observer +{ + typedef TAO_NS_Event_Map_T<PROXY, TAO_SYNCH_RW_MUTEX> EVENT_MAP; + typedef TAO_NS_Update_Added_Worker<PROXY> UPDATE_ADDED_WORKER; + typedef TAO_NS_Update_Removed_Worker<PROXY> UPDATE_REMOVED_WORKER; + typedef TAO_ESF_Proxy_Collection<PROXY> PROXY_COLLECTION; + +public: + /// Constructor + TAO_NS_Event_Map_Observer_T (void); + + /// Destructor + virtual ~TAO_NS_Event_Map_Observer_T (); + + /// Set the inverse event map and the updates dispatch observer. + void init (EVENT_MAP* event_map, TAO_NS_Updates_Dispatch_Observer* dispatch_observer); + + /// <event_type> was seen for the first time in the event map. + virtual void type_added (const TAO_NS_EventType& event_type ACE_ENV_ARG_DECL); + + /// <event_type> does not have any proxy interested in it. + virtual void type_removed (const TAO_NS_EventType& event_type ACE_ENV_ARG_DECL); + +protected: + /// Event Map + EVENT_MAP* event_map_; + + /// Updates Observer. + TAO_NS_Updates_Dispatch_Observer* dispatch_observer_; +}; + +#if defined (__ACE_INLINE__) +#include "Event_Map_Observer_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Event_Map_Observer_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Event_Map_Observer_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* TAO_EVENT_MAP_OBSERVER_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer_T.inl b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer_T.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer_T.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.cpp new file mode 100644 index 00000000000..bf88e776c36 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.cpp @@ -0,0 +1,132 @@ +// $Id$ + +#ifndef TAO_NS_EVENT_MAP_T_C +#define TAO_NS_EVENT_MAP_T_C + +#include "Event_Map_T.h" +#include "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "Event_Map_Entry_T.h" +#include "Properties.h" +#include "Factory.h" +#include "Event_Map_Observer.h" + +#if ! defined (__ACE_INLINE__) +#include "Event_Map_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Event_Map_T, "$Id$") + +template <class PROXY, class ACE_LOCK> +TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::TAO_NS_Event_Map_T (void) + :event_type_count_ (0), observer_ (0) +{ + +} + +template <class PROXY, class ACE_LOCK> +TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::~TAO_NS_Event_Map_T () +{ +} + +template <class PROXY, class ACE_LOCK> void +TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::init (ACE_ENV_SINGLE_ARG_DECL) +{ + this->broadcast_entry_.init (ACE_ENV_SINGLE_ARG_PARAMETER); +} + + +template <class PROXY, class ACE_LOCK> int +TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::insert (PROXY* proxy, const TAO_NS_EventType& event_type ACE_ENV_ARG_DECL) +{ + ENTRY* entry; + + int result = -1; + + if (event_type.is_special () == 1) + { + entry = &this->broadcast_entry_; + result = 0; + } + else + { + ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); + + result = this->map_.find (event_type, entry); + } + + if (result == -1) + { + ACE_NEW_THROW_EX (entry, + ENTRY (), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (-1); + + entry->init (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + entry->connected (proxy ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); + + if (map_.bind (event_type, entry) == -1) + ACE_THROW_RETURN (CORBA::NO_MEMORY (), -1); + + if (this->observer_ != 0) + this->observer_->type_added (event_type ACE_ENV_ARG_PARAMETER); + + return ++event_type_count_; + } + else + { + entry->connected (proxy ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); + return ++event_type_count_; + } +} + +template <class PROXY, class ACE_LOCK> int +TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::remove (PROXY* proxy, const TAO_NS_EventType& event_type ACE_ENV_ARG_DECL) +{ + ENTRY* entry; + + int result = -1; + + if (event_type.is_special () == 1) + { + entry = &this->broadcast_entry_; + result = 0; + } + else + { + ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); + + result = this->map_.find (event_type, entry); + } + + if (result == 0) + { + entry->disconnected (proxy ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + ACE_WRITE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1); + return --event_type_count_; + + if (entry->count () == 0) + { + if (this->observer_ != 0) + this->observer_->type_removed (event_type ACE_ENV_ARG_PARAMETER); + + /// @@TODO: Exec a strategy for removing entries. + /// Strategy 1: remove_immediately + /// Strategy 2: remove_bunch_after_threshold + /// Strategy 3: use cached allocator and 1 + } + } + + return -1; +} + +#endif /* TAO_NS_EVENT_MAP_T_C */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.h b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.h new file mode 100644 index 00000000000..e09bced4a0d --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.h @@ -0,0 +1,98 @@ +/* -*- C++ -*- */ +/** + * @file Event_Map_T.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_EVENT_MAP_T_H +#define TAO_NS_EVENT_MAP_T_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Hash_Map_Manager.h" +#include "Types.h" +#include "EventType.h" +#include "Event_Map_Entry_T.h" + +class TAO_NS_Event_Map_Observer; + +/** + * @class TAO_NS_Event_Map_T + * + * @brief Template class for storing the collection of Proxys. + * + */ +template <class PROXY, class ACE_LOCK> +class TAO_NS_Event_Map_T +{ + typedef TAO_NS_Event_Map_Entry_T<PROXY> ENTRY; + +public: + /// Constuctor + TAO_NS_Event_Map_T (void); + + /// Destructor + ~TAO_NS_Event_Map_T (); + + /// Init + void init (ACE_ENV_SINGLE_ARG_DECL); + + /// Attach an Observer. + void attach_observer (TAO_NS_Event_Map_Observer* observer); + + /// Associate PROXY and event_type. returns count of PROXYs. + int insert (PROXY* proxy, const TAO_NS_EventType& event_type ACE_ENV_ARG_DECL); + + /// Remove association of PROXY and event_type. returns count of PROXYs. + int remove (PROXY* proxy, const TAO_NS_EventType& event_type ACE_ENV_ARG_DECL); + + /// Find the collection mapped to the <event_type> + ENTRY::COLLECTION* find (const TAO_NS_EventType& event_type ACE_ENV_ARG_DECL); + + /// Find the default broadcast list. + ENTRY::COLLECTION* broadcast_collection (void); + + /// Access count, number of different event types in the map. + int event_type_count (void); + +protected: + /// The Map that stores eventtype to entry mapping. + ACE_Hash_Map_Manager <TAO_NS_EventType, ENTRY*, ACE_SYNCH_NULL_MUTEX> map_; + + /// The lock to use. + ACE_LOCK lock_; + + /// Count of items entered in the map. + int event_type_count_; + + /// The default broadcast list for EventType::special. + ENTRY broadcast_entry_; + + /// Observer attached to us. + TAO_NS_Event_Map_Observer* observer_; +}; + +#if defined (__ACE_INLINE__) +#include "Event_Map_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Event_Map_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Event_Map_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* TAO_NS_EVENT_MAP_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.inl b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.inl new file mode 100644 index 00000000000..57684f896bd --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Event_Map_T.inl @@ -0,0 +1,32 @@ +// $Id$ + +template <class PROXY, class ACE_LOCK> ACE_INLINE TAO_NS_Event_Map_Entry_T<PROXY>::COLLECTION* +TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::find (const TAO_NS_EventType& event_type ACE_ENV_ARG_DECL_NOT_USED) +{ + TAO_NS_Event_Map_Entry_T<PROXY>* entry; + + ACE_READ_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, 0); + + if (map_.find (event_type, entry) == 0) + return entry->collection (); + else + return 0; +} + +template <class PROXY, class ACE_LOCK> ACE_INLINE TAO_NS_Event_Map_Entry_T<PROXY>::COLLECTION* +TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::broadcast_collection (void) +{ + return this->broadcast_entry_.collection (); +} + +template <class PROXY, class ACE_LOCK> ACE_INLINE void +TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::attach_observer (TAO_NS_Event_Map_Observer* observer) +{ + this->observer_ = observer; +} + +template <class PROXY, class ACE_LOCK> ACE_INLINE int +TAO_NS_Event_Map_T<PROXY, ACE_LOCK>::event_type_count (void) +{ + return this->event_type_count_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Factory.cpp b/TAO/orbsvcs/orbsvcs/Notify/Factory.cpp new file mode 100644 index 00000000000..b56200c5ed7 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Factory.cpp @@ -0,0 +1,428 @@ +// $Id$ + +#include "Factory.h" + +#if ! defined (__ACE_INLINE__) +#include "Factory.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RN_Notify, TAO_NS_Factory, "$Id$") + +#include "orbsvcs/ESF/ESF_Proxy_List.h" +#include "orbsvcs/ESF/ESF_Copy_On_Write.h" + +#include "Notify_Service.h" +#include "EventChannelFactory.h" +#include "EventChannel.h" +#include "Admin.h" +#include "Proxy.h" +#include "SupplierAdmin.h" +#include "ConsumerAdmin.h" +#include "Structured/StructuredProxyPushConsumer.h" +#include "Structured/StructuredProxyPushSupplier.h" +#include "Any/ProxyPushConsumer.h" +#include "Any/ProxyPushSupplier.h" +#include "Any/CosEC_ProxyPushConsumer.h" +#include "Any/CosEC_ProxyPushSupplier.h" +#include "Sequence/SequenceProxyPushConsumer.h" +#include "Sequence/SequenceProxyPushSupplier.h" + +TAO_NS_Factory::TAO_NS_Factory (void) +{ +} + +TAO_NS_Factory::~TAO_NS_Factory () +{ +} + +ACE_Lock* +TAO_NS_Factory::create_object_lock (ACE_ENV_SINGLE_ARG_DECL) +{ + ACE_Lock* lock; + ACE_NEW_THROW_EX (lock, + ACE_Lock_Adapter<TAO_SYNCH_MUTEX> (), + CORBA::NO_MEMORY ()); + return lock; +} + +void +TAO_NS_Factory::create (TAO_NS_Peer_Collection*& collection ACE_ENV_ARG_DECL) +{ + typedef TAO_ESF_Proxy_List<TAO_NS_Peer>::Iterator ProxyIterator; + typedef TAO_ESF_Copy_On_Write<TAO_NS_Peer, TAO_ESF_Proxy_List<TAO_NS_Peer>,ProxyIterator, ACE_SYNCH> ProxyType; + + ACE_NEW_THROW_EX (collection, + ProxyType (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Factory::create (TAO_NS_ProxyConsumer_Collection*& collection ACE_ENV_ARG_DECL) +{ + typedef TAO_ESF_Proxy_List<TAO_NS_ProxyConsumer>::Iterator ProxyIterator; + typedef TAO_ESF_Copy_On_Write<TAO_NS_ProxyConsumer, TAO_ESF_Proxy_List<TAO_NS_ProxyConsumer>,ProxyIterator, ACE_SYNCH> ProxyType; + + ACE_NEW_THROW_EX (collection, + ProxyType (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Factory::create (TAO_NS_ProxySupplier_Collection*& collection ACE_ENV_ARG_DECL) +{ + typedef TAO_ESF_Proxy_List<TAO_NS_ProxySupplier>::Iterator ProxyIterator; + typedef TAO_ESF_Copy_On_Write<TAO_NS_ProxySupplier, TAO_ESF_Proxy_List<TAO_NS_ProxySupplier>,ProxyIterator, ACE_SYNCH> ProxyType; + + ACE_NEW_THROW_EX (collection, + ProxyType (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Factory::create (TAO_NS_Consumer_Collection*& collection ACE_ENV_ARG_DECL) +{ + typedef TAO_ESF_Proxy_List<TAO_NS_Consumer>::Iterator ProxyIterator; + typedef TAO_ESF_Copy_On_Write<TAO_NS_Consumer, TAO_ESF_Proxy_List<TAO_NS_Consumer>,ProxyIterator, ACE_SYNCH> ProxyType; + + ACE_NEW_THROW_EX (collection, + ProxyType (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Factory::create (TAO_NS_Supplier_Collection*& collection ACE_ENV_ARG_DECL) +{ + typedef TAO_ESF_Proxy_List<TAO_NS_Supplier>::Iterator ProxyIterator; + typedef TAO_ESF_Copy_On_Write<TAO_NS_Supplier, TAO_ESF_Proxy_List<TAO_NS_Supplier>,ProxyIterator, ACE_SYNCH> ProxyType; + + ACE_NEW_THROW_EX (collection, + ProxyType (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Factory::create (TAO_NS_EventChannel_Collection*& collection ACE_ENV_ARG_DECL) +{ + typedef TAO_ESF_Proxy_List<TAO_NS_EventChannel>::Iterator ProxyIterator; + typedef TAO_ESF_Copy_On_Write<TAO_NS_EventChannel, TAO_ESF_Proxy_List<TAO_NS_EventChannel>,ProxyIterator, ACE_SYNCH> ProxyType; + + ACE_NEW_THROW_EX (collection, + ProxyType (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Factory::create (TAO_NS_Admin_Collection*& collection ACE_ENV_ARG_DECL) +{ + typedef TAO_ESF_Proxy_List<TAO_NS_Admin>::Iterator ProxyIterator; + typedef TAO_ESF_Copy_On_Write<TAO_NS_Admin, TAO_ESF_Proxy_List<TAO_NS_Admin>,ProxyIterator, ACE_SYNCH> ProxyType; + + ACE_NEW_THROW_EX (collection, + ProxyType (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Factory::create (TAO_NS_Proxy_Collection*& collection ACE_ENV_ARG_DECL) +{ + typedef TAO_ESF_Proxy_List<TAO_NS_Proxy>::Iterator ProxyIterator; + typedef TAO_ESF_Copy_On_Write<TAO_NS_Proxy,TAO_ESF_Proxy_List<TAO_NS_Proxy>,ProxyIterator,ACE_SYNCH> ProxyType; + + ACE_NEW_THROW_EX (collection, + ProxyType (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Factory::create (TAO_NS_EventChannelFactory*& factory ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (factory, + TAO_NS_EventChannelFactory (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Factory::create (TAO_NS_EventChannel*& channel ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (channel, + TAO_NS_EventChannel (), + CORBA::NO_MEMORY ()); +} + + +void +TAO_NS_Factory::create (TAO_NS_SupplierAdmin*& admin ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (admin, + TAO_NS_SupplierAdmin (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Factory::create (TAO_NS_ConsumerAdmin*& admin ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (admin, + TAO_NS_ConsumerAdmin (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Factory::create (TAO_NS_StructuredProxyPushConsumer*& proxy ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (proxy, + TAO_NS_StructuredProxyPushConsumer (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Factory::create (TAO_NS_StructuredProxyPushSupplier*& proxy ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (proxy, + TAO_NS_StructuredProxyPushSupplier (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Factory::create (TAO_NS_ProxyPushConsumer*& proxy ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (proxy, + TAO_NS_ProxyPushConsumer (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Factory::create (TAO_NS_ProxyPushSupplier*& proxy ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (proxy, + TAO_NS_ProxyPushSupplier (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Factory::create (TAO_NS_CosEC_ProxyPushConsumer*& proxy ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (proxy, + TAO_NS_CosEC_ProxyPushConsumer (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Factory::create (TAO_NS_CosEC_ProxyPushSupplier*& proxy ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (proxy, + TAO_NS_CosEC_ProxyPushSupplier (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Factory::create (TAO_NS_SequenceProxyPushConsumer*& proxy ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (proxy, + TAO_NS_SequenceProxyPushConsumer (), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_Factory::create (TAO_NS_SequenceProxyPushSupplier*& proxy ACE_ENV_ARG_DECL) +{ + ACE_NEW_THROW_EX (proxy, + TAO_NS_SequenceProxyPushSupplier (), + CORBA::NO_MEMORY ()); +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +template class TAO_NS_Container_T <TAO_NS_EventChannel,TAO_NS_EventChannelFactory, TAO_NS_Notify_Service>; +template class TAO_NS_Container_T <TAO_NS_Admin, TAO_NS_EventChannel, TAO_NS_EventChannelFactory>; +template class TAO_NS_Container_T <TAO_NS_Proxy, TAO_NS_Admin, TAO_NS_EventChannel>; + +template class TAO_NS_Object_T<TAO_NS_EventChannelFactory, TAO_NS_Notify_Service>; +template class TAO_NS_Object_T <TAO_NS_EventChannel, TAO_NS_EventChannelFactory>; +template class TAO_NS_Object_T <TAO_NS_Admin, TAO_NS_EventChannel>; +template class TAO_NS_Object_T <TAO_NS_Proxy, TAO_NS_Admin>; + +template class TAO_NS_ProxySupplier_T <POA_Event_Forwarder::StructuredProxyPushSupplier>; +template class TAO_NS_Proxy_T <POA_Event_Forwarder::StructuredProxyPushSupplier>; +template class TAO_NS_ProxySupplier_T <POA_CosNotifyChannelAdmin::SequenceProxyPushSupplier>; +template class TAO_NS_Proxy_T <POA_CosNotifyChannelAdmin::SequenceProxyPushSupplier>; +template class TAO_NS_ProxySupplier_T <POA_Event_Forwarder::ProxyPushSupplier>; +template class TAO_NS_Proxy_T <POA_Event_Forwarder::ProxyPushSupplier>; +template class TAO_NS_ProxySupplier_T <POA_CosEventChannelAdmin::ProxyPushSupplier>; +template class TAO_NS_Proxy_T <POA_CosEventChannelAdmin::ProxyPushSupplier>; + +template class TAO_NS_ProxyConsumer_T <POA_CosNotifyChannelAdmin::StructuredProxyPushConsumer>; +template class TAO_NS_Proxy_T <POA_CosNotifyChannelAdmin::StructuredProxyPushConsumer>; +template class TAO_NS_ProxyConsumer_T <POA_CosNotifyChannelAdmin::SequenceProxyPushConsumer>; +template class TAO_NS_Proxy_T <POA_CosNotifyChannelAdmin::SequenceProxyPushConsumer>; +template class TAO_NS_ProxyConsumer_T <POA_CosNotifyChannelAdmin::ProxyPushConsumer>; +template class TAO_NS_Proxy_T <POA_CosNotifyChannelAdmin::ProxyPushConsumer>; +template class TAO_NS_ProxyConsumer_T <POA_CosEventChannelAdmin::ProxyPushConsumer>; +template class TAO_NS_Proxy_T <POA_CosEventChannelAdmin::ProxyPushConsumer>; + +template class TAO_ESF_Proxy_Collection<TAO_NS_ProxyConsumer>; +template class TAO_ESF_Proxy_Collection<TAO_NS_ProxySupplier>; +template class TAO_ESF_Proxy_Collection<TAO_NS_EventChannel>; +template class TAO_ESF_Proxy_Collection<TAO_NS_Admin>; +template class TAO_ESF_Proxy_Collection<TAO_NS_Proxy>; +template class TAO_ESF_Proxy_Collection<TAO_NS_Consumer>; +template class TAO_ESF_Proxy_Collection<TAO_NS_Supplier>; +template class TAO_ESF_Proxy_Collection<TAO_NS_Peer>; + +template class ACE_Unbounded_Set<int>; +template class ACE_Unbounded_Set<TAO_NS_EventType>; +template class ACE_Unbounded_Set<TAO_NS_ProxySupplier *>; + +template class ACE_Unbounded_Set_Const_Iterator<int>; +template class ACE_Unbounded_Set_Iterator<TAO_NS_Proxy *>; + +template class TAO_ESF_Copy_On_Write<TAO_NS_Proxy, TAO_ESF_Proxy_List<TAO_NS_Proxy>, ACE_Unbounded_Set_Iterator<TAO_NS_Proxy *>, ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write<TAO_NS_Peer, TAO_ESF_Proxy_List<TAO_NS_Peer>, ACE_Unbounded_Set_Iterator<TAO_NS_Peer *>, ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write<TAO_NS_Consumer, TAO_ESF_Proxy_List<TAO_NS_Consumer>, ACE_Unbounded_Set_Iterator<TAO_NS_Consumer *>, ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write<TAO_NS_Supplier, TAO_ESF_Proxy_List<TAO_NS_Supplier>, ACE_Unbounded_Set_Iterator<TAO_NS_Supplier *>, ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write<TAO_NS_EventChannel, TAO_ESF_Proxy_List<TAO_NS_EventChannel>, ACE_Unbounded_Set_Iterator<TAO_NS_EventChannel *>, ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write<TAO_NS_ProxyConsumer, TAO_ESF_Proxy_List<TAO_NS_ProxyConsumer>, ACE_Unbounded_Set_Iterator<TAO_NS_ProxyConsumer *>, ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write<TAO_NS_ProxySupplier, TAO_ESF_Proxy_List<TAO_NS_ProxySupplier>, ACE_Unbounded_Set_Iterator<TAO_NS_ProxySupplier *>, ACE_SYNCH>; +template class TAO_ESF_Copy_On_Write<TAO_NS_Admin, TAO_ESF_Proxy_List<TAO_NS_Admin>, ACE_Unbounded_Set_Iterator<TAO_NS_Admin *>, ACE_SYNCH>; + +template class TAO_ESF_Proxy_List<TAO_NS_Admin>; +template class TAO_ESF_Proxy_List<TAO_NS_Consumer>; +template class TAO_ESF_Proxy_List<TAO_NS_Supplier>; +template class TAO_ESF_Proxy_List<TAO_NS_ProxyConsumer>; +template class TAO_ESF_Proxy_List<TAO_NS_Proxy>; +template class TAO_ESF_Proxy_List<TAO_NS_EventChannel>; +template class TAO_ESF_Proxy_List<TAO_NS_Peer>; +template class TAO_ESF_Proxy_List<TAO_NS_ProxySupplier>; + +template class ACE_Unbounded_Set<TAO_NS_Peer *>; +template class ACE_Unbounded_Set<TAO_NS_Supplier *>; +template class ACE_Unbounded_Set<TAO_NS_Consumer *>; +template class ACE_Unbounded_Set<TAO_NS_ProxyConsumer *>; +template class ACE_Unbounded_Set<TAO_NS_Admin *>; +template class ACE_Unbounded_Set<TAO_NS_EventChannel *>; +template class ACE_Unbounded_Set<TAO_NS_Proxy *>; + +template class ACE_Unbounded_Set_Iterator<TAO_NS_Peer *>; +template class ACE_Unbounded_Set_Iterator<TAO_NS_Supplier *>; +template class ACE_Unbounded_Set_Iterator<TAO_NS_Consumer *>; +template class ACE_Unbounded_Set_Iterator<TAO_NS_ProxyConsumer *>; +template class ACE_Unbounded_Set_Iterator<TAO_NS_ProxySupplier *>; +template class ACE_Unbounded_Set_Iterator<TAO_NS_Admin *>; +template class ACE_Unbounded_Set_Iterator<TAO_NS_EventChannel *>; +template class ACE_Unbounded_Set_Iterator<int>; + +template class TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_NS_Proxy>, ACE_Unbounded_Set_Iterator<TAO_NS_Proxy *>, ACE_MT_SYNCH>; +template class TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_NS_Peer>, ACE_Unbounded_Set_Iterator<TAO_NS_Peer *>, ACE_MT_SYNCH>; +template class TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_NS_Admin>, ACE_Unbounded_Set_Iterator<TAO_NS_Admin *>, ACE_MT_SYNCH>; +template class TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_NS_Consumer>, ACE_Unbounded_Set_Iterator<TAO_NS_Consumer *>, ACE_MT_SYNCH>; +template class TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_NS_ProxyConsumer>, ACE_Unbounded_Set_Iterator<TAO_NS_ProxyConsumer *>, ACE_MT_SYNCH>; +template class TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_NS_EventChannel>, ACE_Unbounded_Set_Iterator<TAO_NS_EventChannel *>, ACE_MT_SYNCH>; +template class TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_NS_ProxySupplier>, ACE_Unbounded_Set_Iterator<TAO_NS_ProxySupplier *>, ACE_MT_SYNCH>; +template class TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_NS_Supplier>, ACE_Unbounded_Set_Iterator<TAO_NS_Supplier *>, ACE_MT_SYNCH>; + +template class TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_NS_ProxyConsumer>, ACE_Unbounded_Set_Iterator<TAO_NS_ProxyConsumer *> >; +template class TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_NS_Supplier>, ACE_Unbounded_Set_Iterator<TAO_NS_Supplier *> >; +template class TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_NS_Admin>, ACE_Unbounded_Set_Iterator<TAO_NS_Admin *> >; +template class TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_NS_EventChannel>, ACE_Unbounded_Set_Iterator<TAO_NS_EventChannel *> >; +template class TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_NS_Consumer>, ACE_Unbounded_Set_Iterator<TAO_NS_Consumer *> >; +template class TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_NS_Peer>, ACE_Unbounded_Set_Iterator<TAO_NS_Peer *> >; +template class TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_NS_ProxySupplier>, ACE_Unbounded_Set_Iterator<TAO_NS_ProxySupplier *> >; +template class TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_NS_Proxy>, ACE_Unbounded_Set_Iterator<TAO_NS_Proxy *> >; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate TAO_NS_Container_T <TAO_NS_EventChannel,TAO_NS_EventChannelFactory, TAO_NS_Notify_Service> +#pragma instantiate TAO_NS_Container_T <TAO_NS_Admin, TAO_NS_EventChannel, TAO_NS_EventChannelFactory> +#pragma instantiate TAO_NS_Container_T <TAO_NS_Proxy, TAO_NS_Admin, TAO_NS_EventChannel> + +#pragma instantiate TAO_NS_Object_T<TAO_NS_EventChannelFactory, TAO_NS_Notify_Service> +#pragma instantiate TAO_NS_Object_T <TAO_NS_EventChannel, TAO_NS_EventChannelFactory> +#pragma instantiate TAO_NS_Object_T <TAO_NS_Admin, TAO_NS_EventChannel> +#pragma instantiate TAO_NS_Object_T <TAO_NS_Proxy, TAO_NS_Admin> + +#pragma instantiate TAO_NS_ProxySupplier_T <POA_Event_Forwarder::StructuredProxyPushSupplier> +#pragma instantiate TAO_NS_Proxy_T <POA_Event_Forwarder::StructuredProxyPushSupplier> +#pragma instantiate TAO_NS_ProxySupplier_T <POA_CosNotifyChannelAdmin::SequenceProxyPushSupplier> +#pragma instantiate TAO_NS_Proxy_T <POA_CosNotifyChannelAdmin::SequenceProxyPushSupplier> +#pragma instantiate TAO_NS_ProxySupplier_T <POA_Event_Forwarder::ProxyPushSupplier> +#pragma instantiate TAO_NS_Proxy_T <POA_Event_Forwarder::ProxyPushSupplier> +#pragma instantiate TAO_NS_ProxySupplier_T <POA_CosEventChannelAdmin::ProxyPushSupplier> +#pragma instantiate TAO_NS_Proxy_T <POA_CosEventChannelAdmin::ProxyPushSupplier> + +#pragma instantiate TAO_NS_ProxyConsumer_T <POA_CosNotifyChannelAdmin::StructuredProxyPushConsumer> +#pragma instantiate TAO_NS_Proxy_T <POA_CosNotifyChannelAdmin::StructuredProxyPushConsumer> +#pragma instantiate TAO_NS_ProxyConsumer_T <POA_CosNotifyChannelAdmin::SequenceProxyPushConsumer> +#pragma instantiate TAO_NS_Proxy_T <POA_CosNotifyChannelAdmin::SequenceProxyPushConsumer> +#pragma instantiate TAO_NS_ProxyConsumer_T <POA_CosNotifyChannelAdmin::ProxyPushConsumer> +#pragma instantiate TAO_NS_Proxy_T <POA_CosNotifyChannelAdmin::ProxyPushConsumer> +#pragma instantiate TAO_NS_ProxyConsumer_T <POA_CosEventChannelAdmin::ProxyPushConsumer> +#pragma instantiate TAO_NS_Proxy_T <POA_CosEventChannelAdmin::ProxyPushConsumer> + +#pragma instantiate TAO_ESF_Proxy_Collection<TAO_NS_ProxyConsumer> +#pragma instantiate TAO_ESF_Proxy_Collection<TAO_NS_ProxySupplier> +#pragma instantiate TAO_ESF_Proxy_Collection<TAO_NS_EventChannel> +#pragma instantiate TAO_ESF_Proxy_Collection<TAO_NS_Admin> +#pragma instantiate TAO_ESF_Proxy_Collection<TAO_NS_Proxy> +#pragma instantiate TAO_ESF_Proxy_Collection<TAO_NS_Consumer> +#pragma instantiate TAO_ESF_Proxy_Collection<TAO_NS_Supplier> +#pragma instantiate TAO_ESF_Proxy_Collection<TAO_NS_Peer> + +#pragma instantiate ACE_Unbounded_Set<int> +#pragma instantiate ACE_Unbounded_Set<TAO_NS_EventType> +#pragma instantiate ACE_Unbounded_Set<TAO_NS_ProxySupplier *> + +#pragma instantiate ACE_Unbounded_Set_Const_Iterator<int> +#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_NS_Proxy *> + +#pragma instantiate TAO_ESF_Copy_On_Write<TAO_NS_Proxy, TAO_ESF_Proxy_List<TAO_NS_Proxy>, ACE_Unbounded_Set_Iterator<TAO_NS_Proxy *>, ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write<TAO_NS_Peer, TAO_ESF_Proxy_List<TAO_NS_Peer>, ACE_Unbounded_Set_Iterator<TAO_NS_Peer *>, ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write<TAO_NS_Consumer, TAO_ESF_Proxy_List<TAO_NS_Consumer>, ACE_Unbounded_Set_Iterator<TAO_NS_Consumer *>, ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write<TAO_NS_Supplier, TAO_ESF_Proxy_List<TAO_NS_Supplier>, ACE_Unbounded_Set_Iterator<TAO_NS_Supplier *>, ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write<TAO_NS_EventChannel, TAO_ESF_Proxy_List<TAO_NS_EventChannel>, ACE_Unbounded_Set_Iterator<TAO_NS_EventChannel *>, ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write<TAO_NS_ProxyConsumer, TAO_ESF_Proxy_List<TAO_NS_ProxyConsumer>, ACE_Unbounded_Set_Iterator<TAO_NS_ProxyConsumer *>, ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write<TAO_NS_ProxySupplier, TAO_ESF_Proxy_List<TAO_NS_ProxySupplier>, ACE_Unbounded_Set_Iterator<TAO_NS_ProxySupplier *>, ACE_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write<TAO_NS_Admin, TAO_ESF_Proxy_List<TAO_NS_Admin>, ACE_Unbounded_Set_Iterator<TAO_NS_Admin *>, ACE_SYNCH> + +#pragma instantiate TAO_ESF_Proxy_List<TAO_NS_Admin> +#pragma instantiate TAO_ESF_Proxy_List<TAO_NS_Consumer> +#pragma instantiate TAO_ESF_Proxy_List<TAO_NS_Supplier> +#pragma instantiate TAO_ESF_Proxy_List<TAO_NS_ProxyConsumer> +#pragma instantiate TAO_ESF_Proxy_List<TAO_NS_Proxy> +#pragma instantiate TAO_ESF_Proxy_List<TAO_NS_EventChannel> +#pragma instantiate TAO_ESF_Proxy_List<TAO_NS_Peer> +#pragma instantiate TAO_ESF_Proxy_List<TAO_NS_ProxySupplier> + +#pragma instantiate ACE_Unbounded_Set<TAO_NS_Peer *> +#pragma instantiate ACE_Unbounded_Set<TAO_NS_Supplier *> +#pragma instantiate ACE_Unbounded_Set<TAO_NS_Consumer *> +#pragma instantiate ACE_Unbounded_Set<TAO_NS_ProxyConsumer *> +#pragma instantiate ACE_Unbounded_Set<TAO_NS_Admin *> +#pragma instantiate ACE_Unbounded_Set<TAO_NS_EventChannel *> +#pragma instantiate ACE_Unbounded_Set<TAO_NS_Proxy *> + +#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_NS_Peer *> +#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_NS_Supplier *> +#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_NS_Consumer *> +#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_NS_ProxyConsumer *> +#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_NS_ProxySupplier *> +#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_NS_Admin *> +#pragma instantiate ACE_Unbounded_Set_Iterator<TAO_NS_EventChannel *> +#pragma instantiate ACE_Unbounded_Set_Iterator<int> + +#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_NS_Proxy>, ACE_Unbounded_Set_Iterator<TAO_NS_Proxy *>, ACE_MT_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_NS_Peer>, ACE_Unbounded_Set_Iterator<TAO_NS_Peer *>, ACE_MT_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_NS_Admin>, ACE_Unbounded_Set_Iterator<TAO_NS_Admin *>, ACE_MT_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_NS_Consumer>, ACE_Unbounded_Set_Iterator<TAO_NS_Consumer *>, ACE_MT_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_NS_ProxyConsumer>, ACE_Unbounded_Set_Iterator<TAO_NS_ProxyConsumer *>, ACE_MT_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_NS_EventChannel>, ACE_Unbounded_Set_Iterator<TAO_NS_EventChannel *>, ACE_MT_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_NS_ProxySupplier>, ACE_Unbounded_Set_Iterator<TAO_NS_ProxySupplier *>, ACE_MT_SYNCH> +#pragma instantiate TAO_ESF_Copy_On_Write_Write_Guard<TAO_ESF_Proxy_List<TAO_NS_Supplier>, ACE_Unbounded_Set_Iterator<TAO_NS_Supplier *>, ACE_MT_SYNCH> + +#pragma instantiate TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_NS_ProxyConsumer>, ACE_Unbounded_Set_Iterator<TAO_NS_ProxyConsumer *> > +#pragma instantiate TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_NS_Supplier>, ACE_Unbounded_Set_Iterator<TAO_NS_Supplier *> > +#pragma instantiate TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_NS_Admin>, ACE_Unbounded_Set_Iterator<TAO_NS_Admin *> > +#pragma instantiate TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_NS_EventChannel>, ACE_Unbounded_Set_Iterator<TAO_NS_EventChannel *> > +#pragma instantiate TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_NS_Consumer>, ACE_Unbounded_Set_Iterator<TAO_NS_Consumer *> > +#pragma instantiate TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_NS_Peer>, ACE_Unbounded_Set_Iterator<TAO_NS_Peer *> > +#pragma instantiate TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_NS_ProxySupplier>, ACE_Unbounded_Set_Iterator<TAO_NS_ProxySupplier *> > +#pragma instantiate TAO_ESF_Copy_On_Write_Collection<TAO_ESF_Proxy_List<TAO_NS_Proxy>, ACE_Unbounded_Set_Iterator<TAO_NS_Proxy *> > + +#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Factory.h b/TAO/orbsvcs/orbsvcs/Notify/Factory.h new file mode 100644 index 00000000000..82ee2e282e3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Factory.h @@ -0,0 +1,113 @@ +/* -*- C++ -*- */ +/** + * @file Factory.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_FACTORY_H +#define TAO_NS_FACTORY_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/CORBA_macros.h" + +#include "Types.h" + +class ACE_Lock; +class TAO_NS_Object; +class TAO_NS_EventChannelFactory; +class TAO_NS_EventChannel; +class TAO_NS_SupplierAdmin; +class TAO_NS_ConsumerAdmin; +class TAO_NS_ProxyPushConsumer; +class TAO_NS_CosEC_ProxyPushSupplier; +class TAO_NS_CosEC_ProxyPushConsumer; +class TAO_NS_ProxyPushSupplier; +class TAO_NS_StructuredProxyPushConsumer; +class TAO_NS_StructuredProxyPushSupplier; +class TAO_NS_SequenceProxyPushConsumer; +class TAO_NS_SequenceProxyPushSupplier; + +/** + * @class TAO_NS_Factory + * + * @brief Factory interface for creating Notify Objects. + * + */ +class TAO_Notify_Export TAO_NS_Factory +{ +public: + /// Constuctor + TAO_NS_Factory (void); + + /// Destructor + virtual ~TAO_NS_Factory (); + + /// Create Object Lock. + virtual ACE_Lock* create_object_lock (ACE_ENV_SINGLE_ARG_DECL); + + /// Create Collection + virtual void create (TAO_NS_ProxySupplier_Collection*& collection ACE_ENV_ARG_DECL); + virtual void create (TAO_NS_ProxyConsumer_Collection*& collection ACE_ENV_ARG_DECL); + + virtual void create (TAO_NS_EventChannel_Collection*& collection ACE_ENV_ARG_DECL); + virtual void create (TAO_NS_Admin_Collection*& collection ACE_ENV_ARG_DECL); + virtual void create (TAO_NS_Proxy_Collection*& collection ACE_ENV_ARG_DECL); + + virtual void create (TAO_NS_Peer_Collection*& collection ACE_ENV_ARG_DECL); + virtual void create (TAO_NS_Consumer_Collection*& collection ACE_ENV_ARG_DECL); + virtual void create (TAO_NS_Supplier_Collection*& collection ACE_ENV_ARG_DECL); + + /// Create EventChannelFactory + virtual void create (TAO_NS_EventChannelFactory*& channel_factory ACE_ENV_ARG_DECL); + + /// Create EventChannel + virtual void create (TAO_NS_EventChannel*& channel ACE_ENV_ARG_DECL); + + /// Create SupplierAdmin + virtual void create (TAO_NS_SupplierAdmin*& admin ACE_ENV_ARG_DECL); + + /// Create ConsumerAdmin + virtual void create (TAO_NS_ConsumerAdmin*& admin ACE_ENV_ARG_DECL); + + /// Create ProxyPushConsumer + virtual void create (TAO_NS_ProxyPushConsumer*& proxy ACE_ENV_ARG_DECL); + + /// Create ProxyPushSupplier + virtual void create (TAO_NS_ProxyPushSupplier*& proxy ACE_ENV_ARG_DECL); + + /// Create CosEC_ProxyPushConsumer + virtual void create (TAO_NS_CosEC_ProxyPushConsumer*& proxy ACE_ENV_ARG_DECL); + + /// Create CosEC_ProxyPushSupplier + virtual void create (TAO_NS_CosEC_ProxyPushSupplier*& proxy ACE_ENV_ARG_DECL); + + /// Create StructuredProxyPushConsumer + virtual void create (TAO_NS_StructuredProxyPushConsumer*& proxy ACE_ENV_ARG_DECL); + + /// Create StructuredProxyPushSupplier + virtual void create (TAO_NS_StructuredProxyPushSupplier*& proxy ACE_ENV_ARG_DECL); + + /// Create SequenceProxyPushConsumer + virtual void create (TAO_NS_SequenceProxyPushConsumer*& proxy ACE_ENV_ARG_DECL); + + /// Create SequenceProxyPushSupplier + virtual void create (TAO_NS_SequenceProxyPushSupplier*& proxy ACE_ENV_ARG_DECL); +}; + +#if defined (__ACE_INLINE__) +#include "Factory.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_FACTORY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Factory.inl b/TAO/orbsvcs/orbsvcs/Notify/Factory.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Factory.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.cpp b/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.cpp new file mode 100644 index 00000000000..af178867f15 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.cpp @@ -0,0 +1,156 @@ +/* -*- C++ -*- $Id$ */ +#include "FilterAdmin.h" +#include "ace/Refcounted_Auto_Ptr.h" + +ACE_RCSID(Notify, FilterAdmin, "$Id$") + +// Implementation skeleton constructor +TAO_NS_FilterAdmin::TAO_NS_FilterAdmin (void) +{ +} + +// Implementation skeleton destructor +TAO_NS_FilterAdmin::~TAO_NS_FilterAdmin (void) +{ +} + +CORBA::Boolean +TAO_NS_FilterAdmin::match (TAO_NS_Event_var &event ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::UnsupportedFilterableData + )) +{ + // If no filter is active, treat it as a '*' i.e, let all events pass. + // or if its the special type, let it pass. + if (this->filter_list_.current_size () == 0) // || event.is_special_event_type ()) + return 1; + + // We want to return true if atleast one constraint matches. + FILTER_LIST::ITERATOR iter (this->filter_list_); + FILTER_LIST::ENTRY *entry; + CORBA::Boolean ret_val = 0; + + for (; iter.next (entry); iter.advance ()) + { + ret_val = event->do_match (entry->int_id_.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + if (ret_val == 1) + return 1; + } + + return 0; +} + +CosNotifyFilter::FilterID +TAO_NS_FilterAdmin::add_filter (CosNotifyFilter::Filter_ptr new_filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (CORBA::is_nil (new_filter)) + ACE_THROW_RETURN (CORBA::BAD_PARAM (), 0); + + CosNotifyFilter::FilterID new_id = this->filter_ids_.id (); + + CosNotifyFilter::Filter_var new_filter_var = + CosNotifyFilter::Filter::_duplicate (new_filter); + + if (this->filter_list_.bind (new_id, new_filter_var) == -1) + ACE_THROW_RETURN (CORBA::INTERNAL (), + 0); + else + { + return new_id; + } +} + +void TAO_NS_FilterAdmin::remove_filter (CosNotifyFilter::FilterID filter_id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::FilterNotFound + )) +{ + if (this->filter_list_.unbind (filter_id) == -1) + ACE_THROW (CosNotifyFilter::FilterNotFound ()); +} + +CosNotifyFilter::Filter_ptr +TAO_NS_FilterAdmin::get_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::FilterNotFound + )) +{ + CosNotifyFilter::Filter_var filter_var; + + if (this->filter_list_.find (filter, + filter_var) == -1) + ACE_THROW_RETURN (CosNotifyFilter::FilterNotFound (), + 0); + + return CosNotifyFilter::Filter::_duplicate (filter_var.in ()); +} + +CosNotifyFilter::FilterIDSeq* +TAO_NS_FilterAdmin::get_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + // Figure out the length of the list. + size_t len = this->filter_list_.current_size (); + + CosNotifyFilter::FilterIDSeq* list = 0; + + // Allocate the list of <len> length. + ACE_NEW_THROW_EX (list, + CosNotifyFilter::FilterIDSeq (len), + CORBA::NO_MEMORY ()); + ACE_CHECK_RETURN (0); + + list->length (len); + + FILTER_LIST_ITER iter (this->filter_list_); + FILTER_LIST_ENTRY *entry; + + u_int index; + + for (index = 0; iter.done () == 0; iter.advance (), ++index) + { + if (iter.next (entry) != 0) + { + list[index] = entry->ext_id_; + } + } + + return list; +} + +void +TAO_NS_FilterAdmin::remove_all_filters (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->filter_list_.unbind_all (); +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +template class ACE_Hash_Map_Entry<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var>; +template class ACE_Hash_Map_Manager<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Manager_Ex<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,ACE_Hash<CosNotifyFilter::FilterID>, ACE_Equal_To<CosNotifyFilter::FilterID>,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator_Ex<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,ACE_Hash<CosNotifyFilter::FilterID>, ACE_Equal_To<CosNotifyFilter::FilterID>,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Iterator_Base_Ex<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,ACE_Hash<CosNotifyFilter::FilterID>, ACE_Equal_To<CosNotifyFilter::FilterID>,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Reverse_Iterator<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,TAO_SYNCH_MUTEX>; +template class ACE_Hash_Map_Reverse_Iterator_Ex<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,ACE_Hash<CosNotifyFilter::FilterID>, ACE_Equal_To<CosNotifyFilter::FilterID>,TAO_SYNCH_MUTEX>; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Hash_Map_Entry<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var> +#pragma instantiate ACE_Hash_Map_Manager<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Manager_Ex<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,ACE_Hash<CosNotifyFilter::FilterID>, ACE_Equal_To<CosNotifyFilter::FilterID>,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator_Ex<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,ACE_Hash<CosNotifyFilter::FilterID>, ACE_Equal_To<CosNotifyFilter::FilterID>,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Iterator_Base_Ex<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,ACE_Hash<CosNotifyFilter::FilterID>, ACE_Equal_To<CosNotifyFilter::FilterID>,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,TAO_SYNCH_MUTEX> +#pragma instantiate ACE_Hash_Map_Reverse_Iterator_Ex<CosNotifyFilter::FilterID,CosNotifyFilter::Filter_var,ACE_Hash<CosNotifyFilter::FilterID>, ACE_Equal_To<CosNotifyFilter::FilterID>,TAO_SYNCH_MUTEX> + +#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.h b/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.h new file mode 100644 index 00000000000..0f56bea1704 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/FilterAdmin.h @@ -0,0 +1,88 @@ +//============================================================================= +/** + * @file FilterAdmin.h + * + * $Id$ + * + * + * + * + * @author Pradeep Gore <pradeep@cs.wustl.edu> + */ +//============================================================================= + + +#ifndef NOTIFY_FILTERADMIN_H +#define NOTIFY_FILTERADMIN_H +#include "ace/pre.h" + +#include "orbsvcs/CosNotifyFilterS.h" +#include "ace/Hash_Map_Manager.h" +#include "ID_Factory.h" +#include "Event.h" +#include "notify_export.h" +#include "Types.h" + +/** + * @class TAO_NS_FilterAdmin + * + * @brief FilterAdmin interface methods implementation. + * + */ +class TAO_Notify_Export TAO_NS_FilterAdmin +{ + + public: + /// Constructor + TAO_NS_FilterAdmin (void); + + /// Destructor + virtual ~TAO_NS_FilterAdmin (void); + + // = match operation on all the filters + /// See if any of the filters match. + CORBA::Boolean match (TAO_NS_Event_var &event ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::UnsupportedFilterableData + )); + + virtual CosNotifyFilter::FilterID add_filter (CosNotifyFilter::Filter_ptr new_filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void remove_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::FilterNotFound + )); + + virtual CosNotifyFilter::Filter_ptr get_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::FilterNotFound + )); + + virtual CosNotifyFilter::FilterIDSeq * get_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void remove_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + private: + typedef ACE_Hash_Map_Manager <CosNotifyFilter::FilterID, CosNotifyFilter::Filter_var, TAO_SYNCH_MUTEX> FILTER_LIST; + typedef ACE_Hash_Map_Iterator <CosNotifyFilter::FilterID, CosNotifyFilter::Filter_var, TAO_SYNCH_MUTEX> FILTER_LIST_ITER; + typedef ACE_Hash_Map_Entry <CosNotifyFilter::FilterID, CosNotifyFilter::Filter_var> FILTER_LIST_ENTRY; + + /// List of filters + FILTER_LIST filter_list_; + + /// Id generator for proxy suppliers + TAO_NS_ID_Factory filter_ids_; +}; + +#include "ace/post.h" +#endif /* NOTIFY_FILTERADMIN_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/FilterFactory.h b/TAO/orbsvcs/orbsvcs/Notify/FilterFactory.h new file mode 100644 index 00000000000..0f6b520589b --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/FilterFactory.h @@ -0,0 +1,39 @@ +/* -*- C++ -*- */ +/** + * @file FilterFactory.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_FILTERFACTORY_H +#define TAO_NS_FILTERFACTORY_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Service_Object.h" + +/** + * @class TAO_NS_FilterFactory + * + * @brief Service Object to obtain a CosNotifyFilter::FilterFactory reference. + * + */ +class /*TAO_Notify_Export*/ TAO_NS_FilterFactory : public ACE_Service_Object +{ +public: + /// Factory method to create a FilterFactory reference + /// The Factory is activated in the default POA. + virtual CosNotifyFilter::FilterFactory_ptr create (ACE_ENV_SINGLE_ARG_DECL) = 0; +}; + +#include "ace/post.h" +#endif /* TAO_NS_FILTERFACTORY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ID_Factory.cpp b/TAO/orbsvcs/orbsvcs/Notify/ID_Factory.cpp new file mode 100644 index 00000000000..466a2ea8fb4 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ID_Factory.cpp @@ -0,0 +1,17 @@ +// $Id$ + +#include "ID_Factory.h" + +#if ! defined (__ACE_INLINE__) +#include "ID_Factory.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_ID_Factory, "$Id$") + +TAO_NS_ID_Factory::TAO_NS_ID_Factory (void) +{ +} + +TAO_NS_ID_Factory::~TAO_NS_ID_Factory () +{ +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ID_Factory.h b/TAO/orbsvcs/orbsvcs/Notify/ID_Factory.h new file mode 100644 index 00000000000..014516164e2 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ID_Factory.h @@ -0,0 +1,52 @@ +/* -*- C++ -*- */ +/** + * @file ID_Factory.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_ID_FACTORY_H +#define TAO_NS_ID_FACTORY_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Types.h" +#include "ace/Atomic_Op.h" + +/** + * @class TAO_NS_ID_Factory + * + * @brief A simple factory for generating ID's for objects created by Notify. + * + */ +class TAO_Notify_Export TAO_NS_ID_Factory +{ +public: + /// Constuctor + TAO_NS_ID_Factory (void); + + /// Destructor + ~TAO_NS_ID_Factory (); + + TAO_NS_Object_Id id (void); + +private: + ACE_Atomic_Op<TAO_SYNCH_MUTEX, TAO_NS_Object_Id> seed_; +}; + + +#if defined (__ACE_INLINE__) +#include "ID_Factory.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_ID_FACTORY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ID_Factory.inl b/TAO/orbsvcs/orbsvcs/Notify/ID_Factory.inl new file mode 100644 index 00000000000..5756b006767 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ID_Factory.inl @@ -0,0 +1,7 @@ +// $Id$ + +ACE_INLINE TAO_NS_Object_Id +TAO_NS_ID_Factory::id (void) +{ + return ++seed_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request.cpp b/TAO/orbsvcs/orbsvcs/Notify/Method_Request.cpp new file mode 100644 index 00000000000..c47f0fc06a1 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request.cpp @@ -0,0 +1,52 @@ +// $Id$ + +#include "Method_Request.h" + +#if ! defined (__ACE_INLINE__) +#include "Method_Request.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Method_Request, "$Id$") + +TAO_NS_Method_Request_Event::TAO_NS_Method_Request_Event (TAO_NS_Event_var& event) + :event_ (event) +{ + // Set the parameters that affect queuing in the message queue. + // The ACE_Message_Block priorities go from 0 (lowest) to ULONG_MAX + // (highest), while the Notification Events go from -32767 (lowest, + // even though CORBA::Short goes to -32768) to 32767 (highest). + + // Convert to CORBA::Long to preserve the sign. Conversion to + // unsigned long will happen automatically and we do not have to worry + // about losing the number in the addition since priority () returns a + // CORBA::Short. + this->msg_priority ((CORBA::Long)this->event_->priority ().value () + + PRIORITY_BASE); + + // The deadline time for the message block is absolute, while the + // timeout for the event is relative to the time it was received. + // So, we do a little conversion and set it on the message block (us) + + TAO_NS_Property_Time& timeout = this->event_->timeout (); + + if (timeout.is_valid () && timeout != 0) + { + // I am multiplying timeout () by 1 because it returns a + // CORBA::ULongLong, which on some platforms doesn't automatically + // convert to the long that the ACE_Time_Value expects. The / + // operator returns a 32-bit integer. + ACE_Time_Value current = ACE_OS::gettimeofday () + +# if defined (ACE_CONFIG_WIN32_H) + ACE_Time_Value ( + ACE_static_cast (long, + timeout.value ())); +# else + ACE_Time_Value (timeout.value () / 1); +# endif /* ACE_CONFIG_WIN32_H */ + this->msg_deadline_time (current); + } +} + +TAO_NS_Method_Request_Event::~TAO_NS_Method_Request_Event () +{ +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request.h b/TAO/orbsvcs/orbsvcs/Notify/Method_Request.h new file mode 100644 index 00000000000..c875b498dd8 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request.h @@ -0,0 +1,91 @@ +/* -*- C++ -*- */ +/** + * @file Method_Request.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_METHOD_REQUEST_H +#define TAO_NS_METHOD_REQUEST_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Message_Block.h" +#include "ace/Refcounted_Auto_Ptr.h" +#include "Event.h" +#include "Types.h" +#include "Refcountable.h" + +/** + * @class TAO_NS_Method_Request + * + * @brief Interface for NS method Requests + * + */ +class TAO_Notify_Export TAO_NS_Method_Request : public ACE_Message_Block +{ +public: + enum {PRIORITY_BASE = 32768}; + + /// Execute the Request + virtual int execute (ACE_ENV_SINGLE_ARG_DECL) = 0; + + /// Create a copy of this object. + virtual TAO_NS_Method_Request* copy (void) = 0; +}; + +/***********************************************************************/ + +/** + * @class TAO_NS_Method_Request_Event + * + * @brief Base class for NS method Requests on Events. + * + */ +class TAO_Notify_Export TAO_NS_Method_Request_Event : public TAO_NS_Method_Request +{ +public: + /// Constuctor + TAO_NS_Method_Request_Event (TAO_NS_Event_var& event); + + /// Destructor + virtual ~TAO_NS_Method_Request_Event (); + +protected: + TAO_NS_Event_var event_; +}; + +/***********************************************************************/ + +/** + * @class TAO_NS_Refcountable_Guard + * + * @brief Ref. Count Guard + * + */ +class TAO_Notify_Export TAO_NS_Refcountable_Guard +{ +public: + TAO_NS_Refcountable_Guard (TAO_NS_Refcountable& refcountable); + + ~TAO_NS_Refcountable_Guard (); + +protected: + TAO_NS_Refcountable& refcountable_; +}; + +#if defined (__ACE_INLINE__) +#include "Method_Request.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_METHOD_REQUEST_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request.inl b/TAO/orbsvcs/orbsvcs/Notify/Method_Request.inl new file mode 100644 index 00000000000..be75f075cd8 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request.inl @@ -0,0 +1,14 @@ +// $Id$ + +ACE_INLINE +TAO_NS_Refcountable_Guard::TAO_NS_Refcountable_Guard (TAO_NS_Refcountable& refcountable) + :refcountable_ (refcountable) +{ + this->refcountable_._incr_refcnt (); +} + +ACE_INLINE +TAO_NS_Refcountable_Guard::~TAO_NS_Refcountable_Guard () +{ + this->refcountable_._decr_refcnt (); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.cpp b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.cpp new file mode 100644 index 00000000000..b1178ba0030 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.cpp @@ -0,0 +1,71 @@ +// $Id$ + +#include "Method_Request_Dispatch.h" + +#if ! defined (__ACE_INLINE__) +#include "Method_Request_Dispatch.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Method_Request_Dispatch, "$Id$") + +#include "tao/debug.h" +#include "ProxySupplier.h" +#include "Consumer.h" +#include "Proxy.h" +#include "Admin.h" +#include "EventChannel.h" +#include "EventChannelFactory.h" +#include "Notify_Service.h" + +TAO_NS_Method_Request_Dispatch::TAO_NS_Method_Request_Dispatch (TAO_NS_Event_var& event, TAO_NS_ProxySupplier* proxy_supplier) + : TAO_NS_Method_Request_Event (event), proxy_supplier_ (proxy_supplier), refcountable_guard_ (*proxy_supplier) +{ +} + +TAO_NS_Method_Request_Dispatch::~TAO_NS_Method_Request_Dispatch () +{ +} + +TAO_NS_Method_Request* +TAO_NS_Method_Request_Dispatch::copy (void) +{ + /// @@use factory + return new TAO_NS_Method_Request_Dispatch (this->event_, this->proxy_supplier_); +} + +int +TAO_NS_Method_Request_Dispatch::execute (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->proxy_supplier_->has_shutdown ()) + return 0; // If we were shutdown while waiting in the queue, return with no action. + + CORBA::Boolean val = this->proxy_supplier_->check_filters (this->event_ ACE_ENV_ARG_PARAMETER); + + if (TAO_debug_level > 1) + ACE_DEBUG ((LM_DEBUG, "Proxysupplier %x filter eval result = %d",this->proxy_supplier_ , val)); + + // Filter failed - do nothing. + if (val == 0) + return 0; + + ACE_TRY + { + this->proxy_supplier_->consumer ()->push (this->event_ ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::UserException, ue) + { + ACE_PRINT_EXCEPTION (ue, + "TAO_NS_Method_Request_Dispatch::: error sending event. "); + //ACE_RE_THROW; + } + ACE_CATCH (CORBA::SystemException, se) + { + ACE_PRINT_EXCEPTION (se, + "TAO_NS_Method_Request_Dispatch::: error sending event. "); + //ACE_RE_THROW; + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.h b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.h new file mode 100644 index 00000000000..2e13ce6aa09 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.h @@ -0,0 +1,59 @@ +/* -*- C++ -*- */ +/** + * @file Method_Request_Dispatch.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_DISPATCH_METHOD_REQUEST_H +#define TAO_NS_DISPATCH_METHOD_REQUEST_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Method_Request.h" +#include "Types.h" + +/** + * @class TAO_NS_Method_Request_Dispatch + * + * @brief Dispatchs an event to a proxy supplier. + * + */ +class TAO_Notify_Export TAO_NS_Method_Request_Dispatch : public TAO_NS_Method_Request_Event +{ +public: + /// Constuctor + TAO_NS_Method_Request_Dispatch (TAO_NS_Event_var& event, TAO_NS_ProxySupplier* proxy_supplier); + + /// Destructor + ~TAO_NS_Method_Request_Dispatch (); + + /// Create a copy of this object. + TAO_NS_Method_Request* copy (void); + + /// Execute the Request + virtual int execute (ACE_ENV_SINGLE_ARG_DECL); + +private: + /// Proxy Supplier that we use. + TAO_NS_ProxySupplier* proxy_supplier_; + + /// Guard to automatically inc/decr ref count on the proxy. + TAO_NS_Refcountable_Guard refcountable_guard_; +}; + +#if defined (__ACE_INLINE__) +#include "Method_Request_Dispatch.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_DISPATCH_METHOD_REQUEST_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.inl b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.cpp b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.cpp new file mode 100644 index 00000000000..5c64f039fcf --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.cpp @@ -0,0 +1,62 @@ +// $Id$ + +#include "Method_Request_Dispatch_No_Filtering.h" + +#if ! defined (__ACE_INLINE__) +#include "Method_Request_Dispatch_No_Filtering.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Method_Request_Dispatch_No_Filtering, "$Id$") + +#include "tao/debug.h" +#include "ProxySupplier.h" +#include "Consumer.h" +#include "Proxy.h" +#include "Admin.h" +#include "EventChannel.h" +#include "EventChannelFactory.h" +#include "Notify_Service.h" + +TAO_NS_Method_Request_Dispatch_No_Filtering::TAO_NS_Method_Request_Dispatch_No_Filtering (TAO_NS_Event_var& event, TAO_NS_ProxySupplier* proxy_supplier) + : TAO_NS_Method_Request_Event (event), proxy_supplier_ (proxy_supplier), refcountable_guard_ (*proxy_supplier) +{ +} + +TAO_NS_Method_Request_Dispatch_No_Filtering::~TAO_NS_Method_Request_Dispatch_No_Filtering () +{ +} + +TAO_NS_Method_Request* +TAO_NS_Method_Request_Dispatch_No_Filtering::copy (void) +{ + /// @@use factory + return new TAO_NS_Method_Request_Dispatch_No_Filtering (this->event_, this->proxy_supplier_); +} + +int +TAO_NS_Method_Request_Dispatch_No_Filtering::execute (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->proxy_supplier_->has_shutdown ()) + return 0; // If we were shutdown while waiting in the queue, return with no action. + + ACE_TRY + { + this->proxy_supplier_->consumer ()->push (this->event_ ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::UserException, ue) + { + ACE_PRINT_EXCEPTION (ue, + "TAO_NS_Method_Request_Dispatch_No_Filtering::: error sending event. "); + //ACE_RE_THROW; + } + ACE_CATCH (CORBA::SystemException, se) + { + ACE_PRINT_EXCEPTION (se, + "TAO_NS_Method_Request_Dispatch_No_Filtering::: error sending event. "); + //ACE_RE_THROW; + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.h b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.h new file mode 100644 index 00000000000..53a74f93fc9 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.h @@ -0,0 +1,59 @@ +/* -*- C++ -*- */ +/** + * @file Method_Request_Dispatch_No_Filtering.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_DISPATCH_METHOD_REQUEST_NO_FILTERING_H +#define TAO_NS_DISPATCH_METHOD_REQUEST_NO_FILTERING_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Method_Request.h" +#include "Types.h" + +/** + * @class TAO_NS_Method_Request_Dispatch_No_Filtering + * + * @brief Dispatchs an event to a proxy supplier but does NOT perform filtering. + * + */ +class TAO_Notify_Export TAO_NS_Method_Request_Dispatch_No_Filtering : public TAO_NS_Method_Request_Event +{ +public: + /// Constuctor + TAO_NS_Method_Request_Dispatch_No_Filtering (TAO_NS_Event_var& event, TAO_NS_ProxySupplier* proxy_supplier); + + /// Destructor + ~TAO_NS_Method_Request_Dispatch_No_Filtering (); + + /// Create a copy of this object. + TAO_NS_Method_Request* copy (void); + + /// Execute the Request + virtual int execute (ACE_ENV_SINGLE_ARG_DECL); + +private: + /// Proxy Supplier that we use. + TAO_NS_ProxySupplier* proxy_supplier_; + + /// Guard to automatically inc/decr ref count on the proxy. + TAO_NS_Refcountable_Guard refcountable_guard_; +}; + +#if defined (__ACE_INLINE__) +#include "Method_Request_Dispatch_No_Filtering.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_DISPATCH_METHOD_REQUEST_NO_FILTERING_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.inl b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Dispatch_No_Filtering.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.cpp b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.cpp new file mode 100644 index 00000000000..e03c1e3148a --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.cpp @@ -0,0 +1,72 @@ +// $Id$ + +#include "Method_Request_Lookup.h" + +#if ! defined (__ACE_INLINE__) +#include "Method_Request_Lookup.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Method_Request_Lookup, "$Id$") + +#include "tao/debug.h" +#include "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "Event_Map_T.h" +#include "ProxySupplier.h" +#include "ProxyConsumer.h" +#include "Proxy.h" +#include "Admin.h" +#include "EventChannel.h" +#include "EventChannelFactory.h" +#include "Notify_Service.h" + +TAO_NS_Method_Request_Lookup::TAO_NS_Method_Request_Lookup (TAO_NS_Event_var& event, TAO_NS_ProxyConsumer* proxy_consumer, TAO_NS_Consumer_Map* map) + : TAO_NS_Method_Request_Event (event), proxy_consumer_ (proxy_consumer), map_ (map), + refcountable_guard_ (*proxy_consumer) +{ +} + +TAO_NS_Method_Request_Lookup::~TAO_NS_Method_Request_Lookup () +{ +} + +TAO_NS_Method_Request* +TAO_NS_Method_Request_Lookup::copy (void) +{ + /// @@use factory + return new TAO_NS_Method_Request_Lookup (this->event_, this->proxy_consumer_, this->map_); +} + +int +TAO_NS_Method_Request_Lookup::execute (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->proxy_consumer_->has_shutdown ()) + return 0; // If we were shutdown while waiting in the queue, return with no action. + + CORBA::Boolean val = this->proxy_consumer_->check_filters (this->event_ ACE_ENV_ARG_PARAMETER); + + if (TAO_debug_level > 1) + ACE_DEBUG ((LM_DEBUG, "Proxyconsumer %x filter eval result = %d",this->proxy_consumer_ , val)); + + // Filter failed - do nothing. + if (val == 0) + return 0; + + TAO_NS_ProxySupplier_Collection* consumers = map_->find (this->event_->type () ACE_ENV_ARG_PARAMETER); + + if (consumers != 0) + consumers->for_each (this ACE_ENV_ARG_PARAMETER); + + // Get the default consumers + consumers = map_->broadcast_collection (); + + if (consumers != 0) + consumers->for_each (this ACE_ENV_ARG_PARAMETER); + + return 0; +} + +void +TAO_NS_Method_Request_Lookup::work (TAO_NS_ProxySupplier* proxy_supplier ACE_ENV_ARG_DECL_NOT_USED) +{ + proxy_supplier->push (this->event_); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.h b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.h new file mode 100644 index 00000000000..f56f6605177 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.h @@ -0,0 +1,66 @@ +/* -*- C++ -*- */ +/** + * @file Method_Request_Lookup.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_LOOKUP_METHOD_REQUEST_H +#define TAO_NS_LOOKUP_METHOD_REQUEST_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/ESF/ESF_Worker.h" +#include "Method_Request.h" +#include "Types.h" + +/** + * @class TAO_NS_Method_Request_Lookup + * + * @brief Lookup command object looks up the event type of the given event in the consumer map and send the event to each proxysupplier. + * + */ +class TAO_Notify_Export TAO_NS_Method_Request_Lookup : public TAO_NS_Method_Request_Event, public TAO_ESF_Worker<TAO_NS_ProxySupplier> +{ +public: + /// Constuctor + TAO_NS_Method_Request_Lookup (TAO_NS_Event_var& event, TAO_NS_ProxyConsumer* proxy_consumer, TAO_NS_Consumer_Map* map); + + /// Destructor + ~TAO_NS_Method_Request_Lookup (); + + /// Create a copy of this object. + TAO_NS_Method_Request* copy (void); + + /// Execute the Request + virtual int execute (ACE_ENV_SINGLE_ARG_DECL); + + ///= TAO_ESF_Worker method + void work (TAO_NS_ProxySupplier* proxy_supplier ACE_ENV_ARG_DECL); + +private: + /// ProxyConsumer supplying event. + TAO_NS_ProxyConsumer* proxy_consumer_; + + /// The map of subscriptions. + TAO_NS_Consumer_Map* map_; + + /// Guard to automatically inc/decr ref count on the proxy. + TAO_NS_Refcountable_Guard refcountable_guard_; +}; + +#if defined (__ACE_INLINE__) +#include "Method_Request_Lookup.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_LOOKUP_METHOD_REQUEST_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.inl b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Lookup.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.cpp b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.cpp new file mode 100644 index 00000000000..434179006e7 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.cpp @@ -0,0 +1,35 @@ +// $Id$ + +#include "Method_Request_Shutdown.h" +#include "ThreadPool_Task.h" + +#if ! defined (__ACE_INLINE__) +#include "Method_Request_Shutdown.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Method_Request_Shutdown, "$Id$") + +TAO_NS_Method_Request_Shutdown::TAO_NS_Method_Request_Shutdown (TAO_NS_ThreadPool_Task* task) + : task_ (task) +{ +} + +TAO_NS_Method_Request_Shutdown::~TAO_NS_Method_Request_Shutdown () +{ +} + +TAO_NS_Method_Request* +TAO_NS_Method_Request_Shutdown::copy (void) +{ + return new TAO_NS_Method_Request_Shutdown (this->task_); +} + +int +TAO_NS_Method_Request_Shutdown::execute (ACE_ENV_SINGLE_ARG_DECL) +{ + // Shut down the scheduler by deactivating the activation queue's + // underlying message queue - should pop all worker threads off their + // wait and they'll exit. + this->task_->msg_queue ()->deactivate (); + return -1; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.h b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.h new file mode 100644 index 00000000000..433dea36e51 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.h @@ -0,0 +1,57 @@ +/* -*- C++ -*- */ +/** + * @file Method_Request_Shutdown.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_METHOD_REQUEST_SHUTDOWN_H +#define TAO_NS_METHOD_REQUEST_SHUTDOWN_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Method_Request.h" + +class TAO_NS_ThreadPool_Task; + +/** + * @class TAO_NS_Method_Request_Shutdown + * + * @brief Shutdown message for the ThreadPool_Task + * + */ +class TAO_Notify_Export TAO_NS_Method_Request_Shutdown : public TAO_NS_Method_Request +{ +public: + /// Constuctor + TAO_NS_Method_Request_Shutdown (TAO_NS_ThreadPool_Task* task); + + /// Destructor + ~TAO_NS_Method_Request_Shutdown (); + + /// Create a copy of this object. + TAO_NS_Method_Request* copy (void); + + /// Execute the Request + virtual int execute (ACE_ENV_SINGLE_ARG_DECL); + +private: + // Task to shutdown + TAO_NS_ThreadPool_Task* task_; +}; + +#if defined (__ACE_INLINE__) +#include "Method_Request_Shutdown.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_METHOD_REQUEST_SHUTDOWN_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.inl b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Method_Request_Shutdown.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_Service.cpp b/TAO/orbsvcs/orbsvcs/Notify/Notify_Service.cpp new file mode 100644 index 00000000000..88ec5b92490 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_Service.cpp @@ -0,0 +1,226 @@ +// $Id$ + +#include "Notify_Service.h" + +#include "ace/Sched_Params.h" +#include "ace/Arg_Shifter.h" +#include "tao/ORB_Core.h" +#include "Builder.h" +#include "Properties.h" +#include "Factory.h" + +ACE_RCSID(RT_Notify, TAO_NS_Notify_Service, "$Id$") + +TAO_NS_Notify_Service::TAO_NS_Notify_Service (void) +:factory_ (0), builder_ (0) +{ +} + +TAO_NS_Notify_Service::~TAO_NS_Notify_Service () +{ + delete factory_; + delete builder_; +} + +int +TAO_NS_Notify_Service::init (int argc, char *argv[]) +{ + ACE_Arg_Shifter arg_shifter (argc, argv); + + const ACE_TCHAR *current_arg = 0; + + while (arg_shifter.is_anything_left ()) + { + if (arg_shifter.cur_arg_strncasecmp (ACE_LIB_TEXT("-Updates")) == 0) // -Updates update_period_uS + { + arg_shifter.consume_arg (); + + current_arg = arg_shifter.get_current (); + + if (current_arg != 0) + { + ACE_Time_Value update_period (0, ACE_OS::atoi (current_arg)); + + TAO_NS_PROPERTIES::instance()->updates (1); + TAO_NS_PROPERTIES::instance()->update_period (update_period); + } + } + else if (arg_shifter.cur_arg_strncasecmp (ACE_LIB_TEXT("-NoUpdates")) == 0) // No Updates + { + arg_shifter.consume_arg (); + + TAO_NS_PROPERTIES::instance()->updates (0); + } + else if ((current_arg = arg_shifter.get_the_parameter (ACE_LIB_TEXT("-DispatchingThreads")))) + { + int dispatching_threads = ACE_OS::atoi (current_arg); + + arg_shifter.consume_arg (); + + if (dispatching_threads > 0) + { + NotifyExt::ThreadPoolParams tp_params = {0, dispatching_threads, 0, ACE_DEFAULT_THREAD_PRIORITY, 0, 0, 0 }; + CosNotification::QoSProperties ec_qos; + + ec_qos.length (1); + ec_qos[0].name = CORBA::string_dup (NotifyExt::ThreadPool); + ec_qos[0].value <<= tp_params; + + TAO_NS_PROPERTIES::instance()->default_event_channel_qos_properties (ec_qos); + } + } + } + + return 0; +} + +int +TAO_NS_Notify_Service::fini (void) +{ + return 0; +} + +void +TAO_NS_Notify_Service::init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) +{ + ACE_DEBUG ((LM_DEBUG, "Loading the Cos Notification Service...\n")); + + this->init_i (orb ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_NS_Notify_Service::init_i (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) +{ + /// first, init the main thread. + //this->init_main_thread (orb ACE_ENV_ARG_PARAMETER); + //ACE_CHECK; + + // Obtain the Root POA + CORBA::Object_var object = + orb->resolve_initial_references("RootPOA" ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (object.in ())) + ACE_ERROR ((LM_ERROR, + " (%P|%t) Unable to resolve the RootPOA.\n")); + + PortableServer::POA_var default_poa = PortableServer::POA::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + /// Set the properties + TAO_NS_Properties* properties = TAO_NS_PROPERTIES::instance(); + + properties->orb (orb); + properties->default_poa (default_poa.in ()); + properties->sched_policy (orb->orb_core ()->orb_params ()->sched_policy ()); + properties->scope_policy (orb->orb_core ()->orb_params ()->scope_policy ()); + + // Init the factory and builder + + this->init_factory (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->init_builder (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_NS_Notify_Service::init_main_thread (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) +{ + ACE_Sched_Params::Policy sched_policy; + long thr_sched_policy = orb->orb_core ()->orb_params ()->sched_policy (); + + long thr_scope_policy = orb->orb_core ()->orb_params ()->scope_policy (); + + if (thr_sched_policy == THR_SCHED_FIFO) + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Sched policy = THR_SCHED_FIFO\n")); + + sched_policy = ACE_SCHED_FIFO; + } + else if (thr_sched_policy == THR_SCHED_RR) + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Sched policy = THR_SCHED_RR\n")); + + sched_policy = ACE_SCHED_RR; + } + else + { + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Sched policy = THR_SCHED_OTHER\n")); + + sched_policy = ACE_SCHED_OTHER; + } + + /// Check sched. + int min_priority = ACE_Sched_Params::priority_min (sched_policy); + int max_priority = ACE_Sched_Params::priority_max (sched_policy); + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, "max_priority = %d, min_priority = %d\n", + max_priority, min_priority)); + + if (max_priority == min_priority) + { + ACE_DEBUG ((LM_DEBUG,"Detected max_priority == min_priority\n")); + } + } + + // Set the main thread to min priority... + int priority = min_priority; + + if (ACE_OS::sched_params (ACE_Sched_Params (sched_policy , + priority, + ACE_SCOPE_PROCESS)) != 0) + { + if (ACE_OS::last_error () == EPERM) + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t): user is not superuser, " + "test runs in time-shared class\n")); + } + else + ACE_ERROR ((LM_ERROR, + "(%P|%t): sched_params failed\n")); + } +} + +void +TAO_NS_Notify_Service::init_factory (ACE_ENV_SINGLE_ARG_DECL) +{ + ACE_NEW_THROW_EX (this->factory_, + TAO_NS_Factory (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + TAO_NS_PROPERTIES::instance()->factory (this->factory_); +} + +void +TAO_NS_Notify_Service::init_builder (ACE_ENV_SINGLE_ARG_DECL) +{ + ACE_NEW_THROW_EX (this->builder_, + TAO_NS_Builder (), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + TAO_NS_PROPERTIES::instance()->builder (this->builder_); +} + +CosNotifyChannelAdmin::EventChannelFactory_ptr +TAO_NS_Notify_Service::create (PortableServer::POA_ptr poa ACE_ENV_ARG_DECL) +{ + return this->builder_->build_event_channel_factory (poa ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_Notify_Service::remove (TAO_NS_EventChannelFactory* /*ecf*/ ACE_ENV_ARG_DECL_NOT_USED) +{ + // NOP. +} + +ACE_FACTORY_DEFINE (TAO_Notify, TAO_NS_Notify_Service) diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_Service.h b/TAO/orbsvcs/orbsvcs/Notify/Notify_Service.h new file mode 100644 index 00000000000..37d771cda83 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_Service.h @@ -0,0 +1,84 @@ +/* -*- C++ -*- */ +/** + * @file Notify_Service.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_COSNOTIFY_SERVICE_H +#define TAO_NS_COSNOTIFY_SERVICE_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Service.h" + +class TAO_NS_Factory; +class TAO_NS_Builder; +class TAO_NS_Properties; +class TAO_NS_EventChannelFactory; + +/** + * @class TAO_NS_Notify_Service + * + * @brief A service object for creating the Notify Service Factory. + * + */ +class TAO_Notify_Export TAO_NS_Notify_Service : public TAO_NS_Service +{ +public: + /// Constuctor + TAO_NS_Notify_Service (void); + + /// Destructor + virtual ~TAO_NS_Notify_Service (); + + /// = Service_Object virtual method overloads. + virtual int init (int argc, char *argv[]); + virtual int fini (void); + + /// Init + virtual void init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL); + + /// Create the Channel Factory. + virtual CosNotifyChannelAdmin::EventChannelFactory_ptr create (PortableServer::POA_ptr default_POA ACE_ENV_ARG_DECL); + + /// Called by the factory when it is destroyed. + virtual void remove (TAO_NS_EventChannelFactory* ecf ACE_ENV_ARG_DECL); + +protected: + /// Init the data members + virtual void init_i (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL); + + /// Create the Factory for RT Notify objects. + virtual void init_factory (ACE_ENV_SINGLE_ARG_DECL); + + /// Creates the Builder for RT Notify objects. + virtual void init_builder (ACE_ENV_SINGLE_ARG_DECL); + + /// Apply ORB Scheduling policy to main thread and set its priority to the lowest available. + void init_main_thread (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL); + + /// Service component for object factory operations. + TAO_NS_Factory* factory_; + + /// Service component for building NS participants. + TAO_NS_Builder* builder_; +}; + +ACE_FACTORY_DECLARE (TAO_Notify, TAO_NS_Notify_Service) + +#if defined (__ACE_INLINE__) +#include "Notify_Service.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_COSNOTIFY_SERVICE_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_Service.inl b/TAO/orbsvcs/orbsvcs/Notify/Notify_Service.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_Service.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Object.cpp b/TAO/orbsvcs/orbsvcs/Notify/Object.cpp new file mode 100644 index 00000000000..a2377e06676 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Object.cpp @@ -0,0 +1,169 @@ +// $Id$ + +#include "Object.h" +#include "POA_Helper.h" +#include "Worker_Task.h" +#include "Properties.h" +#include "Builder.h" +#include "tao/debug.h" + +#if ! defined (__ACE_INLINE__) +#include "Object.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Object, "$Id$") + +TAO_NS_Object::TAO_NS_Object (void) + :event_manager_ (0), admin_properties_ (0), id_ (0), poa_ (0), worker_task_ (0), delete_worker_task_ (0), proxy_poa_ (0), delete_proxy_poa_ (0), shutdown_ (0) +{ + if (TAO_debug_level > 1 ) + ACE_DEBUG ((LM_DEBUG,"object:%x created\n", this )); +} + +TAO_NS_Object::~TAO_NS_Object () +{ + if (TAO_debug_level > 1 ) + ACE_DEBUG ((LM_DEBUG,"object:%x destroyed\n", this )); + + this->shutdown_worker_task (); +} + +void +TAO_NS_Object::init (TAO_NS_POA_Helper* poa, TAO_NS_POA_Helper* proxy_poa, TAO_NS_Worker_Task* worker_task) +{ + poa_ = poa; + proxy_poa_ = proxy_poa; + worker_task_ = worker_task; +} + +CORBA::Object_ptr +TAO_NS_Object::activate (ACE_ENV_SINGLE_ARG_DECL) +{ + return poa_->activate (this->servant (), id_ ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_Object::deactivate (ACE_ENV_SINGLE_ARG_DECL) +{ + poa_->deactivate (id_ ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_Object::shutdown (ACE_ENV_SINGLE_ARG_DECL) +{ + this->shutdown_ = 1; + this->deactivate (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +CORBA::Object_ptr +TAO_NS_Object::ref (ACE_ENV_SINGLE_ARG_DECL) +{ + return poa_->id_to_reference (id_ ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_Object::shutdown_worker_task (void) +{ + ACE_DECLARE_NEW_CORBA_ENV; + + /// Only do this if we are the owner. + if (delete_worker_task_ == 1) + { + this->worker_task_->shutdown (); + delete this->worker_task_; + } + + if (delete_proxy_poa_ == 1) + { + proxy_poa_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + delete proxy_poa_; + } +} + +void +TAO_NS_Object::worker_task_own (TAO_NS_Worker_Task* worker_task) +{ + this->worker_task (worker_task); + + /// claim ownership. + delete_worker_task_ = 1; +} + +void +TAO_NS_Object::worker_task (TAO_NS_Worker_Task* worker_task) +{ + /// shutdown the current worker. + this->shutdown_worker_task (); + + this->worker_task_ = worker_task; + + delete_worker_task_ = 0; +} + + +void +TAO_NS_Object::proxy_poa (TAO_NS_POA_Helper* proxy_poa) +{ + proxy_poa_ = proxy_poa; + delete_proxy_poa_ = 1; +} + +TAO_NS_POA_Helper* +TAO_NS_Object::proxy_poa (void) +{ + return this->proxy_poa_; +} + +void +TAO_NS_Object::set_qos (const CosNotification::QoSProperties & qos ACE_ENV_ARG_DECL) +{ + CosNotification::PropertyErrorSeq err_seq; + + // Init the standard QoS + int ret_val = this->qos_properties_.init (qos, err_seq); + + // Init the Worker Task QoS + if (this->qos_properties_.thread_pool ().is_valid ()) + { + TAO_NS_PROPERTIES::instance()->builder ()->apply_threadpool_qos (*this, + this->qos_properties_.thread_pool ().value (), + *this->admin_properties_ + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + else if (this->qos_properties_.thread_pool_lane ().is_valid ()) + { + TAO_NS_PROPERTIES::instance()->builder ()-> + apply_threadpool_lane_qos (*this, + this->qos_properties_.thread_pool_lane ().value (), + *this->admin_properties_ + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + + // Inform subclasses of QoS changed. + this->qos_changed (); + + if (ret_val == 1) // Unsupported Property + ACE_THROW (CosNotification::UnsupportedQoS (err_seq)); +} + +CosNotification::QoSProperties* +TAO_NS_Object::get_qos (ACE_ENV_SINGLE_ARG_DECL) +{ + CosNotification::QoSProperties_var properties; + + ACE_NEW_THROW_EX (properties, + CosNotification::QoSProperties (), + CORBA::NO_MEMORY ()); + + this->qos_properties_.populate (properties); + + return properties._retn (); +} + +void +TAO_NS_Object::qos_changed (void) +{ + // NOP. +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Object.h b/TAO/orbsvcs/orbsvcs/Notify/Object.h new file mode 100644 index 00000000000..79dee8b0845 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Object.h @@ -0,0 +1,150 @@ +/* -*- C++ -*- */ +/** + * @file Object.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_OBJECT_H +#define TAO_NS_OBJECT_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/corba.h" +#include "tao/PortableServer/Servant_Base.h" +#include "Types.h" +#include "QoSProperties.h" + +class TAO_NS_POA_Helper; +class TAO_NS_Worker_Task; +class TAO_NS_Event_Manager; +class TAO_NS_AdminProperties; + +/** + * @class TAO_NS_Object_Id + * + * @brief Id for Objects. + * + */ +typedef CORBA::Long TAO_NS_Object_Id; + +/** + * @class TAO_NS_Object + * + * @brief Base Object for RT_Notify's CORBA Objects. + * + */ +class TAO_Notify_Export TAO_NS_Object +{ +public: + /// Constuctor + TAO_NS_Object (void); + + /// Destructor + virtual ~TAO_NS_Object (void); + + /// Init. + void init (TAO_NS_POA_Helper* poa, TAO_NS_POA_Helper* proxy_poa, TAO_NS_Worker_Task* worker_task); + + /// This Object's ID + CORBA::Long id (void); + + /// Activate + CORBA::Object_ptr activate (ACE_ENV_SINGLE_ARG_DECL); + + /// Deactivate + void deactivate (ACE_ENV_SINGLE_ARG_DECL); + + /// shutdown + virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL); + + /// Have we been shutdown. returns 1 if shutdown. + int has_shutdown (void); + + /// Get CORBA Ref. + CORBA::Object_ptr ref (ACE_ENV_SINGLE_ARG_DECL); + + /// Get Worker Task. + TAO_NS_Worker_Task* worker_task (void); + + /// Get the POA assigned to us. + TAO_NS_POA_Helper* poa (void); + + /// Setting the proxy_poa_ gives ownership to this class. + void proxy_poa (TAO_NS_POA_Helper* proxy_poa); + + /// Accessor for the proxy_poa_ + TAO_NS_POA_Helper* proxy_poa (void); + + /// Set Worker Task. This object assume ownership of the set object. + void worker_task_own (TAO_NS_Worker_Task* worker_task); + + /// Set Worker Task. Does not assume ownership. + void worker_task (TAO_NS_Worker_Task* worker_task); + + /// Set the QoS Properties. + virtual void set_qos (const CosNotification::QoSProperties & qos ACE_ENV_ARG_DECL); + + /// Get the QoS Properties. + CosNotification::QoSProperties* get_qos (ACE_ENV_SINGLE_ARG_DECL); + +protected: + /// Servant which we use. + virtual PortableServer::Servant servant (void) = 0; + + /// Shutdown the current worker task and delete it if we own it. + void shutdown_worker_task (void); + + /// Notification that can be overridden by subclasses to be informed that <qos_properties_> have been modified. + virtual void qos_changed (void); + + ///= Protected data members. + + /// The event manager. + TAO_NS_Event_Manager* event_manager_; + + ///=Attributes + + /// Admin Properties. + TAO_NS_AdminProperties* admin_properties_; + + /// QoS Properties. + TAO_NS_QoSProperties qos_properties_; + + /// Id assigned to this object + TAO_NS_Object_Id id_; + + /// The POA in which the object is activated. + TAO_NS_POA_Helper* poa_; + + /// Worker Task. + TAO_NS_Worker_Task* worker_task_; + + /// Ownership flag + int delete_worker_task_; + + /// The POA in which the proxys are activated. + TAO_NS_POA_Helper* proxy_poa_; + + /// Flag that indicates if we own <proxy_poa_> + int delete_proxy_poa_; + + /// Are we shutdown (i,e. scheduled for destroy). + int shutdown_; +}; + +#if defined (__ACE_INLINE__) +#include "Object.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_OBJECT_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Object.inl b/TAO/orbsvcs/orbsvcs/Notify/Object.inl new file mode 100644 index 00000000000..7537377ec91 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Object.inl @@ -0,0 +1,25 @@ +// $Id$ + +ACE_INLINE CORBA::Long +TAO_NS_Object::id (void) +{ + return id_; +} + +ACE_INLINE TAO_NS_Worker_Task* +TAO_NS_Object::worker_task (void) +{ + return this->worker_task_; +} + +ACE_INLINE TAO_NS_POA_Helper* +TAO_NS_Object::poa (void) +{ + return this->poa_; +} + +ACE_INLINE int +TAO_NS_Object::has_shutdown (void) +{ + return this->shutdown_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Object_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Object_T.cpp new file mode 100644 index 00000000000..372773f3af6 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Object_T.cpp @@ -0,0 +1,38 @@ +// $Id$ + +#ifndef TAO_NS_OBJECT_T_CPP +#define TAO_NS_OBJECT_T_CPP + +#include "Object_T.h" +#include "orbsvcs/ESF/ESF_RefCount_Guard.h" + +#if ! defined (__ACE_INLINE__) +#include "Object_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Object, "$Id$") + +template <class TYPE, class PARENT> +TAO_NS_Object_T<TYPE, PARENT>::TAO_NS_Object_T (void) + :parent_ (0) +{ +} + +template <class TYPE, class PARENT> +TAO_NS_Object_T<TYPE, PARENT>::~TAO_NS_Object_T () +{ +} + +template <class TYPE, class PARENT> void +TAO_NS_Object_T<TYPE, PARENT>::destroy (TYPE *type ACE_ENV_ARG_DECL) +{ + TAO_NS_Object_RefCount_Guard guard (this->refcount_); + + this->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (parent_) + parent_->remove (type ACE_ENV_ARG_PARAMETER); +} + +#endif /* TAO_NS_OBJECT_T_CPP */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Object_T.h b/TAO/orbsvcs/orbsvcs/Notify/Object_T.h new file mode 100644 index 00000000000..a85d95531ff --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Object_T.h @@ -0,0 +1,64 @@ +/* -*- C++ -*- */ +/** + * @file Object_T.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_OBJECT_T_H +#define TAO_NS_OBJECT_T_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Object.h" +#include "Refcountable.h" + +/** + * @class TAO_NS_Object_T + * + * @brief Base attributes of all EC participants. + * + */ +template <class TYPE, class PARENT> +class TAO_NS_Object_T : public virtual TAO_NS_Object, public TAO_NS_Refcountable +{ +public: + /// Constuctor + TAO_NS_Object_T (void); + + /// Destructor + virtual ~TAO_NS_Object_T (); + + /// destroy <type> + void destroy (TYPE* type ACE_ENV_ARG_DECL); + +protected: + /// = Data Members + + /// Parent + PARENT* parent_; +}; + +#if defined (__ACE_INLINE__) +#include "Object_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Object_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Object_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* TAO_NS_OBJECT_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Object_T.inl b/TAO/orbsvcs/orbsvcs/Notify/Object_T.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Object_T.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.cpp b/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.cpp new file mode 100644 index 00000000000..34a959d79fc --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.cpp @@ -0,0 +1,166 @@ +// $Id$ + +#include "POA_Helper.h" + +#if ! defined (__ACE_INLINE__) +#include "POA_Helper.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_POA_Helper, "$Id$") + +#include "tao/debug.h" + +TAO_NS_POA_Helper::TAO_NS_POA_Helper (void) +{ +} + +TAO_NS_POA_Helper::~TAO_NS_POA_Helper () +{ + +} + +void +TAO_NS_POA_Helper::init (PortableServer::POA_ptr parent_poa, const char* poa_name ACE_ENV_ARG_DECL) +{ + CORBA::PolicyList policy_list (2); + + this->set_policy (parent_poa, policy_list ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->create_i (parent_poa, poa_name, policy_list ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_POA_Helper::init (PortableServer::POA_ptr parent_poa ACE_ENV_ARG_DECL) +{ + char child_poa_name[32]; + ACE_OS_String::itoa (ACE_OS::rand (), child_poa_name, 10); + + this->init (parent_poa, child_poa_name ACE_ENV_ARG_PARAMETER); +} + + +void +TAO_NS_POA_Helper::set_policy (PortableServer::POA_ptr parent_poa, CORBA::PolicyList &policy_list ACE_ENV_ARG_DECL) +{ + policy_list.length (2); + + policy_list[0] = + parent_poa->create_id_uniqueness_policy (PortableServer::UNIQUE_ID + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + policy_list[1] = + parent_poa->create_id_assignment_policy (PortableServer::USER_ID + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + + +void +TAO_NS_POA_Helper::create_i (PortableServer::POA_ptr parent_poa, const char* poa_name, CORBA::PolicyList &policy_list ACE_ENV_ARG_DECL) +{ + PortableServer::POAManager_var manager = + parent_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + // Create the child POA. + this->poa_ = parent_poa->create_POA (poa_name, + manager.in (), + policy_list + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Created POA : %s\n", this->poa_->the_name ())); + /* + // Destroy the policies + for (CORBA::ULong index = 0; index < policy_list.length (); ++index) + { + policy_list[index]->destroy (); + } + */ +} + +PortableServer::ObjectId * +TAO_NS_POA_Helper::long_to_ObjectId (CORBA::Long id ACE_ENV_ARG_DECL) const +{ + // Modified code from string_to_ObjectId .. + // + + CORBA::ULong buffer_size = 4; + + // Create the buffer for the Id + CORBA::Octet *buffer = PortableServer::ObjectId::allocbuf (buffer_size); + + // Copy the contents + ACE_OS::memcpy (buffer, (char*)&id, buffer_size); + + // @@ Pradeep: TAO guarantees that Long is 4 bytes wide, but the + // standard only guarantees that it is at least 4 bytes wide. You + // may want to think about that.... + + // Create and return a new ID + PortableServer::ObjectId *obj_id = 0; + ACE_NEW_THROW_EX (obj_id, + PortableServer::ObjectId (buffer_size, + buffer_size, + buffer, + 1), + CORBA::NO_MEMORY ()); + + return obj_id; +} + +CORBA::Object_ptr +TAO_NS_POA_Helper::activate (PortableServer::Servant servant, CORBA::Long& id ACE_ENV_ARG_DECL) +{ + // Generate a new ID. + id = this->id_factory_.id (); + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Activating object with id = %d in POA : %s\n", id, this->poa_->the_name ())); + + // Convert CORBA::Long to ObjectId + PortableServer::ObjectId_var oid = + this->long_to_ObjectId (id ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + + poa_->activate_object_with_id (oid.in (), + servant + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + + return poa_->id_to_reference (oid.in () + ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_POA_Helper::deactivate (CORBA::Long id ACE_ENV_ARG_DECL) const +{ + // Convert CORBA::Long to ObjectId + PortableServer::ObjectId_var oid = + this->long_to_ObjectId (id ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + poa_->deactivate_object (oid.in () ACE_ENV_ARG_PARAMETER); +} + +CORBA::Object_ptr +TAO_NS_POA_Helper::id_to_reference (CORBA::Long id ACE_ENV_ARG_DECL) const +{ + // Convert CORBA::Long to ObjectId + PortableServer::ObjectId_var oid = + this->long_to_ObjectId (id ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CORBA::Object::_nil ()); + + return poa_->id_to_reference (oid.in () + ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_POA_Helper::destroy (ACE_ENV_SINGLE_ARG_DECL) +{ + poa_->destroy (1,0 ACE_ENV_ARG_PARAMETER); + // The <wait_for_completion> flag = 0 +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.h b/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.h new file mode 100644 index 00000000000..cc587914671 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.h @@ -0,0 +1,84 @@ +/* -*- C++ -*- */ +/** + * @file POA.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_POA_Helper_H +#define TAO_NS_POA_Helper_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Copy_Disabled.h" +#include "tao/PortableServer/PortableServer.h" +#include "ID_Factory.h" + +/** + * @class TAO_NS_POA_Helper + * + * @brief POA Abstraction. + * + */ +class TAO_Notify_Export TAO_NS_POA_Helper : private ACE_Copy_Disabled +{ +public: + /// Default Constructor + TAO_NS_POA_Helper (void); + + /// Create a new PortableServer::POA. + void init (PortableServer::POA_ptr parent_poa, const char* poa_name ACE_ENV_ARG_DECL); + + /// Create a new PortableServer::POA. The name is chosen at random. + void init (PortableServer::POA_ptr parent_poa ACE_ENV_ARG_DECL); + + /// Destructor + virtual ~TAO_NS_POA_Helper (); + + /// Get underlying POA + PortableServer::POA_ptr poa (void); + + /// Destroy underlying POA. + void destroy (ACE_ENV_SINGLE_ARG_DECL); + + /// Activate Object, the POA will assign an ID and return its value. + CORBA::Object_ptr activate (PortableServer::Servant servant, CORBA::Long& id ACE_ENV_ARG_DECL); + + /// Deactivate Object with ID + void deactivate (CORBA::Long id ACE_ENV_ARG_DECL) const; + + /// Convert ID to reference. + CORBA::Object_ptr id_to_reference (CORBA::Long id ACE_ENV_ARG_DECL) const; + +protected: + /// Set default POA policies. + virtual void set_policy (PortableServer::POA_ptr parent_poa, CORBA::PolicyList &policy_list ACE_ENV_ARG_DECL); + + /// Apply the polices and create child POA. + void create_i (PortableServer::POA_ptr parent_poa, const char* poa_name, CORBA::PolicyList &policy_list ACE_ENV_ARG_DECL); + + /// POA + PortableServer::POA_var poa_; + + /// ID Factory + TAO_NS_ID_Factory id_factory_; + + /// Convert id to ObjectID + PortableServer::ObjectId* long_to_ObjectId (CORBA::Long id ACE_ENV_ARG_DECL) const; +}; + +#if defined (__ACE_INLINE__) +#include "POA_Helper.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_POA_Helper_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.inl b/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.inl new file mode 100644 index 00000000000..3fc996c803c --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/POA_Helper.inl @@ -0,0 +1,7 @@ +// $Id$ + +ACE_INLINE PortableServer::POA_ptr +TAO_NS_POA_Helper::poa (void) +{ + return this->poa_.in (); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Peer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Peer.cpp new file mode 100644 index 00000000000..57a8ac2cbaa --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Peer.cpp @@ -0,0 +1,99 @@ +// $Id$ + +#include "Peer.h" + +#if ! defined (__ACE_INLINE__) +#include "Peer.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_Peer, "$id$") + +#include "tao/debug.h" +#include "Dispatch_Observer_T.h" +#include "Proxy.h" +#include "Proxy.h" +#include "Admin.h" +#include "EventChannel.h" +#include "EventChannelFactory.h" +#include "Notify_Service.h" + +TAO_NS_Peer::TAO_NS_Peer (void) + :updates_dispatch_observer_ (0), retry_count_ (1) +{ +} + +TAO_NS_Peer::~TAO_NS_Peer () +{ +} + +void +TAO_NS_Peer::qos_changed (TAO_NS_QoSProperties& /*qos_properties*/) +{ + // NOP. +} + +void +TAO_NS_Peer::shutdown (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + // NOP. +} + +void +TAO_NS_Peer::dispatch_pending (ACE_ENV_SINGLE_ARG_DECL) +{ + TAO_NS_Proxy* proxy = this->proxy (); + TAO_NS_EventTypeSeq& added = proxy->added_; + TAO_NS_EventTypeSeq& removed = proxy->removed_; + + if (added.size () == 0 && removed.size () == 0) + return; // Return if nothing to send. + + TAO_NS_EventTypeSeq added_copy; + TAO_NS_EventTypeSeq removed_copy; + TAO_NS_Reverse_Lock unlock (proxy->lock_); + + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, proxy->lock_); + + added_copy = added; + removed_copy = removed; + added.reset (); + removed.reset (); + + ACE_TRY + { + { + ACE_GUARD (TAO_NS_Reverse_Lock, ace_mon, unlock); + + this->dispatch_updates_i (added_copy, removed_copy ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (this->updates_dispatch_observer_ != 0) + this->updates_dispatch_observer_->dispatch_success (this ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + + this->retry_count_ = 0; + } + ACE_CATCHANY + { + if (TAO_debug_level > 0) + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Peer:dispatch_pending serror sending updates\n "); + } + //ACE_RE_THROW; + + ++this->retry_count_; + + if (this->updates_dispatch_observer_ != 0) + { + /// Restore the lists. + added.insert_seq (added_copy); + removed.insert_seq (removed_copy); + + ACE_GUARD (TAO_NS_Reverse_Lock, ace_mon, unlock); + + this->updates_dispatch_observer_->dispatch_failure (this, this->retry_count_ ACE_ENV_ARG_PARAMETER); + } + } + ACE_ENDTRY; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Peer.h b/TAO/orbsvcs/orbsvcs/Notify/Peer.h new file mode 100644 index 00000000000..2d827073fda --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Peer.h @@ -0,0 +1,89 @@ +/* -*- C++ -*- */ +/** + * @file Peer.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_PEER_H +#define TAO_NS_PEER_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotificationC.h" +#include "Destroy_Callback.h" +#include "EventTypeSeq.h" +//#include "Types.h" + +class TAO_NS_Proxy; +class TAO_NS_QoSProperties; +class TAO_NS_Peer; + +template <class PEER> class TAO_NS_Dispatch_Observer_T; +typedef TAO_NS_Dispatch_Observer_T<TAO_NS_Peer> TAO_NS_Updates_Dispatch_Observer; + +/** + * @class TAO_NS_Peer + * + * @brief Base class for Supplier and Consumer classes. + * This object delegates its reference count to its creator proxy object. + * + */ +class TAO_Notify_Export TAO_NS_Peer : public TAO_NS_Destroy_Callback +{ +public: + /// Constuctor + TAO_NS_Peer (void); + + /// Destructor + virtual ~TAO_NS_Peer (); + + /// Shutdown the peer. + virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL); + + /// Install the updates observer. + void updates_dispatch_observer (TAO_NS_Updates_Dispatch_Observer* updates_dispatch_observer); + + /// Access Proxy. + virtual TAO_NS_Proxy* proxy (void) = 0; + + /// This method sigantures deliberately match the RefCounting methods required for ESF Proxy + CORBA::ULong _incr_refcnt (void); + CORBA::ULong _decr_refcnt (void); + + /// Dispatch Pending. + void dispatch_pending (ACE_ENV_SINGLE_ARG_DECL); + + /// QoS changed notification from the Peer. + virtual void qos_changed (TAO_NS_QoSProperties& qos_properties); + +protected: + // Dispatch updates implementation. + virtual void dispatch_updates_i (const TAO_NS_EventTypeSeq & added, + const TAO_NS_EventTypeSeq & removed + ACE_ENV_ARG_DECL) = 0; + + ///= Data Members + + // Updates Dispatch Observer + TAO_NS_Updates_Dispatch_Observer* updates_dispatch_observer_; + + /// Retry count. How many times have we failed to contact the remote peer? + int retry_count_; +}; + +#if defined (__ACE_INLINE__) +#include "Peer.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_PEER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Peer.inl b/TAO/orbsvcs/orbsvcs/Notify/Peer.inl new file mode 100644 index 00000000000..e466a588442 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Peer.inl @@ -0,0 +1,21 @@ +// $Id$ + +#include "Proxy.h" + +ACE_INLINE CORBA::ULong +TAO_NS_Peer::_incr_refcnt (void) +{ + return this->proxy ()->_incr_refcnt (); +} + +ACE_INLINE CORBA::ULong +TAO_NS_Peer::_decr_refcnt (void) +{ + return this->proxy ()->_decr_refcnt (); +} + +ACE_INLINE void +TAO_NS_Peer::updates_dispatch_observer (TAO_NS_Updates_Dispatch_Observer* updates_dispatch_observer) +{ + this->updates_dispatch_observer_ = updates_dispatch_observer; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Pending_Worker_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Pending_Worker_T.cpp new file mode 100644 index 00000000000..b70ce05d6e7 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Pending_Worker_T.cpp @@ -0,0 +1,100 @@ +// $Id$ + +#ifndef TAO_NS_PENDING_WORKER_T_CPP +#define TAO_NS_PENDING_WORKER_T_CPP + +#include "Pending_Worker_T.h" + +#if ! defined (__ACE_INLINE__) +#include "Pending_Worker_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_Pending_Worker_T, "$id$") + +#include "tao/debug.h" +#include "Properties.h" +#include "Dispatch_Observer_T.h" + +/*****************************************************************************************/ + +template <class PEER> void +TAO_NS_Dispatch_Pending_Worker_T<PEER>::work (PEER* peer ACE_ENV_ARG_DECL) +{ + peer->dispatch_pending (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +/*****************************************************************************************/ + +template <class PEER> +TAO_NS_Pending_Worker_T<PEER>::TAO_NS_Pending_Worker_T (void) + :dispatch_observer_ (0), done_ (0), suspended_ (0) +{ +} + +template <class PEER> +TAO_NS_Pending_Worker_T<PEER>::~TAO_NS_Pending_Worker_T () +{ +} + +template <class PEER> void +TAO_NS_Pending_Worker_T<PEER>::init (TAO_NS_Dispatch_Observer_T<PEER>* dispatch_observer, ACE_Time_Value& update_period ACE_ENV_ARG_DECL) +{ + this->dispatch_observer_ = dispatch_observer; + this->update_period_ = update_period; + + long flags = THR_NEW_LWP | THR_JOINABLE; + + flags |= + TAO_NS_PROPERTIES::instance()->scope_policy () | + TAO_NS_PROPERTIES::instance()->sched_policy (); + + // Become an active object. + if (this->ACE_Task <ACE_SYNCH>::activate (flags, + 1, + 0, + ACE_DEFAULT_THREAD_PRIORITY) == -1) + { + if (TAO_debug_level > 0) + { + if (ACE_OS::last_error () == EPERM) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Insufficient privilege.\n"))); + else + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("(%t) task activation at priority %d failed\n") + ACE_TEXT ("exiting!\n%a"), + ACE_DEFAULT_THREAD_PRIORITY)); + } + + ACE_THROW (CORBA::BAD_PARAM ()); + } +} + +template <class PEER> int +TAO_NS_Pending_Worker_T<PEER>::svc (void) +{ + ACE_DECLARE_NEW_CORBA_ENV; + + while (!this->done_) + { + ACE_OS::sleep (this->update_period_); + + if (this->suspended_ == 1) + continue; + + TAO_NS_Dispatch_Pending_Worker_T<PEER> worker; + + TAO_NS_Dispatch_Observer_T<PEER>::PEER_COLLECTION* peer_collection + = this->dispatch_observer_->peer_collection (); + + if (peer_collection != 0) + peer_collection->for_each (&worker ACE_ENV_ARG_PARAMETER); + } + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, "Exiting TAO_NS_Pending_Worker_T<PEER>::svc \n")); + } + return 0; +} + +#endif /* TAO_NS_PENDING_WORKER_T_CPP */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Pending_Worker_T.h b/TAO/orbsvcs/orbsvcs/Notify/Pending_Worker_T.h new file mode 100644 index 00000000000..365b66c0b27 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Pending_Worker_T.h @@ -0,0 +1,102 @@ +/* -*- C++ -*- */ +/** + * @file Pending_Worker_T.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_PENDING_WORKER_T_H +#define TAO_NS_PENDING_WORKER_T_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Types.h" +#include "ace/Task.h" +#include "orbsvcs/ESF/ESF_Worker.h" + +template <class PEER> class TAO_NS_Dispatch_Observer_T; + +/** + * @class TAO_NS_Dispatch_Pending_Worker_T + * + * @brief Ask each PEER to dispatch pending updates. + * + */ +template <class PEER> +class TAO_Notify_Export TAO_NS_Dispatch_Pending_Worker_T : public TAO_ESF_Worker<PEER> +{ +protected: + ///= TAO_ESF_Worker method + void work (PEER* peer ACE_ENV_ARG_DECL); +}; + +/*******************************************************************************************/ + +/** + * @class TAO_NS_Pending_Worker_T + * + * @brief Periodic Task that obtains the list of pending PEER's from the dispatch_observer and dispatches pending events/updates. + * + */ +template <class PEER> +class TAO_Notify_Export TAO_NS_Pending_Worker_T : public ACE_Task<ACE_SYNCH> +{ +public: + /// Constuctor + TAO_NS_Pending_Worker_T (void); + + /// Destructor + ~TAO_NS_Pending_Worker_T (); + + /// Init + void init (TAO_NS_Dispatch_Observer_T<PEER>* dispatch_observer, ACE_Time_Value& update_period ACE_ENV_ARG_DECL); + + /// Shutdown + void shutdown (void); + + /// Suspend + void worker_suspend (void); + + /// Resume + void worker_resume (void); + +protected: + /// task svc + virtual int svc (void); + + /// The observer that logs PEERs that need updates. + TAO_NS_Dispatch_Observer_T<PEER>* dispatch_observer_; + + /// The period at which updates are send. + ACE_Time_Value update_period_; + + /// Flag that we should shutdown. + CORBA::Boolean done_; + + /// Flag that we are suspended. + CORBA::Boolean suspended_; +}; + +#if defined (__ACE_INLINE__) +#include "Pending_Worker_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Pending_Worker_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Pending_Worker_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* TAO_NS_PENDING_WORKER_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Pending_Worker_T.inl b/TAO/orbsvcs/orbsvcs/Notify/Pending_Worker_T.inl new file mode 100644 index 00000000000..732372f1066 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Pending_Worker_T.inl @@ -0,0 +1,20 @@ +// $Id$ + +template <class PEER> ACE_INLINE void +TAO_NS_Pending_Worker_T<PEER>::shutdown (void) +{ + this->done_ = 1; + this->wait (); +} + +template <class PEER> ACE_INLINE void +TAO_NS_Pending_Worker_T<PEER>::worker_suspend (void) +{ + this->suspended_ = 1; +} + +template <class PEER> ACE_INLINE void +TAO_NS_Pending_Worker_T<PEER>::worker_resume (void) +{ + this->suspended_ = 0; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Properties.cpp b/TAO/orbsvcs/orbsvcs/Notify/Properties.cpp new file mode 100644 index 00000000000..3779ea8e2a3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Properties.cpp @@ -0,0 +1,31 @@ +// $Id$ + +#include "Properties.h" +#include "tao/debug.h" + +#if ! defined (__ACE_INLINE__) +#include "Properties.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Properties, "$Id$") + +TAO_NS_Properties::TAO_NS_Properties (void) + :updates_ (1), update_period_ (0, 10000) +{ + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "in TAO_Properties ctos %x\n", this)); +} + +TAO_NS_Properties::~TAO_NS_Properties () +{ +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class ACE_Singleton<TAO_NS_Properties, TAO_SYNCH_MUTEX>; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate ACE_Singleton<TAO_NS_Properties, TAO_SYNCH_MUTEX> + +#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Properties.h b/TAO/orbsvcs/orbsvcs/Notify/Properties.h new file mode 100644 index 00000000000..06090bc0291 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Properties.h @@ -0,0 +1,116 @@ +/* -*- C++ -*- */ +/** + * @file Properties.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_PROPERTIES_H +#define TAO_NS_PROPERTIES_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Singleton.h" +#include "tao/ORB.h" +#include "tao/PortableServer/PortableServer.h" +#include "orbsvcs/CosNotificationC.h" + +class TAO_NS_Factory; +class TAO_NS_Builder; + +/** + * @class TAO_NS_Properties + * + * @brief Global properties that strategize RT Notify's run-time behaviour. + * + */ +class TAO_Notify_Export TAO_NS_Properties +{ + friend class ACE_Singleton<TAO_NS_Properties, TAO_SYNCH_MUTEX>; + +public: + /// Constuctor + TAO_NS_Properties (void); + + /// Destructor + ~TAO_NS_Properties (); + + // = Property Accessors + TAO_NS_Factory* factory (void); + void factory (TAO_NS_Factory* factory); + + TAO_NS_Builder* builder (void); + void builder (TAO_NS_Builder* builder); + + CORBA::ORB_ptr orb (void); + void orb (CORBA::ORB_ptr orb); + + PortableServer::POA_ptr default_poa (void); + void default_poa (PortableServer::POA_ptr default_poa); + + long scope_policy (void); + void scope_policy (long scope_policy); + + long sched_policy (void); + void sched_policy (long sched_policy); + + CORBA::Boolean updates (void); + void updates (CORBA::Boolean updates); + + ACE_Time_Value& update_period (void); + void update_period (ACE_Time_Value& time_value); + + // The QoS Property that must be applied to each newly created Event Channel + const CosNotification::QoSProperties& default_event_channel_qos_properties (void); + + // Set the default EC QoS Property. + void default_event_channel_qos_properties (const CosNotification::QoSProperties &ec_qos); + +protected: + /// Object Factory + TAO_NS_Factory* factory_; + + /// Object Builder + TAO_NS_Builder* builder_; + + /// ORB + CORBA::ORB_var orb_; + + // POA + PortableServer::POA_var default_poa_; + + /// Sched policy + long thr_sched_policy_; + + /// Scope policy + long thr_scope_policy_; + + /// True if updates are sent. + CORBA::Boolean updates_; + + /// The Update period for updates. + ACE_Time_Value update_period_; + + /// The default EC QoS Properties. + CosNotification::QoSProperties ec_qos_; +}; + +typedef ACE_Singleton<TAO_NS_Properties, TAO_SYNCH_MUTEX> TAO_NS_PROPERTIES; + +TAO_NOTIFY_SINGLETON_DECLARE (ACE_Singleton, TAO_NS_Properties, TAO_SYNCH_MUTEX); + +#if defined (__ACE_INLINE__) +#include "Properties.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_PROPERTIES_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Properties.inl b/TAO/orbsvcs/orbsvcs/Notify/Properties.inl new file mode 100644 index 00000000000..e838bba9f92 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Properties.inl @@ -0,0 +1,109 @@ +// $Id$ + +ACE_INLINE TAO_NS_Factory* +TAO_NS_Properties::factory (void) +{ + return this->factory_; +} + +ACE_INLINE void +TAO_NS_Properties::factory (TAO_NS_Factory* factory) +{ + this->factory_ = factory; +} + +ACE_INLINE TAO_NS_Builder* +TAO_NS_Properties::builder (void) +{ + return this->builder_; +} + +ACE_INLINE void +TAO_NS_Properties::builder (TAO_NS_Builder* builder) +{ + this->builder_ = builder; +} + +ACE_INLINE CORBA::ORB_ptr +TAO_NS_Properties::orb (void) +{ + return CORBA::ORB::_duplicate (orb_.in ()); +} + +ACE_INLINE void +TAO_NS_Properties::orb (CORBA::ORB_ptr orb) +{ + orb_ = CORBA::ORB::_duplicate (orb); +} + +ACE_INLINE PortableServer::POA_ptr +TAO_NS_Properties::default_poa (void) +{ + return PortableServer::POA::_duplicate (this->default_poa_.in ()); +} + +ACE_INLINE void +TAO_NS_Properties::default_poa (PortableServer::POA_ptr default_poa) +{ + this->default_poa_ = PortableServer::POA::_duplicate (default_poa); +} + +ACE_INLINE long +TAO_NS_Properties::scope_policy (void) +{ + return thr_scope_policy_; +} + +ACE_INLINE void +TAO_NS_Properties::scope_policy (long scope_policy) +{ + thr_scope_policy_ = scope_policy; +} + +ACE_INLINE long +TAO_NS_Properties::sched_policy (void) +{ + return thr_sched_policy_; +} + +ACE_INLINE void +TAO_NS_Properties::sched_policy (long sched_policy) +{ + thr_sched_policy_ = sched_policy; +} + +ACE_INLINE CORBA::Boolean +TAO_NS_Properties::updates (void) +{ + return this->updates_; +} + +ACE_INLINE void +TAO_NS_Properties::updates (CORBA::Boolean synchronous_updates) +{ + this->updates_ = synchronous_updates; +} + +ACE_INLINE ACE_Time_Value& +TAO_NS_Properties::update_period (void) +{ + return this->update_period_; +} + +ACE_INLINE void +TAO_NS_Properties::update_period (ACE_Time_Value& time_value) +{ + this->update_period_ = time_value; +} + +ACE_INLINE const CosNotification::QoSProperties& +TAO_NS_Properties::default_event_channel_qos_properties (void) +{ + return this->ec_qos_; +} + +ACE_INLINE void +TAO_NS_Properties::default_event_channel_qos_properties (const CosNotification::QoSProperties &ec_qos) +{ + this->ec_qos_ = ec_qos; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Property.h b/TAO/orbsvcs/orbsvcs/Notify/Property.h new file mode 100644 index 00000000000..80565568c59 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Property.h @@ -0,0 +1,42 @@ +/* -*- C++ -*- */ +/** + * @file Property.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_PROPERTY_H +#define TAO_NS_PROPERTY_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/corba.h" +#include "tao/orbconf.h" +#include "tao/TimeBaseC.h" +#include "orbsvcs/NotifyExtC.h" + +template <class LOCK, class TYPE> class ACE_Atomic_Op; +template <class LOCK, class TYPE> class TAO_Notify_Signal_Property; + +template <class TYPE> class TAO_NS_Property_T; +template <class TYPE> class TAO_NS_StructProperty_T; + +typedef ACE_Atomic_Op <TAO_SYNCH_MUTEX,CORBA::Long> TAO_NS_Atomic_Property_Long; +typedef TAO_Notify_Signal_Property <TAO_SYNCH_MUTEX,CORBA::Long> TAO_NS_Signal_Property_Long; + +typedef TAO_NS_Property_T<CORBA::Long> TAO_NS_Property_Long; +typedef TAO_NS_Property_T<CORBA::Short> TAO_NS_Property_Short; +typedef TAO_NS_Property_T<TimeBase::TimeT> TAO_NS_Property_Time; +typedef TAO_NS_StructProperty_T<NotifyExt::ThreadPoolParams> TAO_NS_Property_ThreadPool; +typedef TAO_NS_StructProperty_T<NotifyExt::ThreadPoolLanesParams> TAO_NS_Property_ThreadPoolLanes; + +#endif /* TAO_NS_PROPERTY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/PropertySeq.cpp b/TAO/orbsvcs/orbsvcs/Notify/PropertySeq.cpp new file mode 100644 index 00000000000..ad5042b9e87 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/PropertySeq.cpp @@ -0,0 +1,53 @@ +// $Id$ + +#include "PropertySeq.h" + +#if ! defined (__ACE_INLINE__) +#include "PropertySeq.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_PropertySeq, "$id$") + +TAO_NS_PropertySeq::TAO_NS_PropertySeq (void) +{ +} + +TAO_NS_PropertySeq::~TAO_NS_PropertySeq () +{ +} + +int +TAO_NS_PropertySeq::init (const CosNotification::PropertySeq& prop_seq) +{ + ACE_CString name; + + for (CORBA::ULong i = 0; i < prop_seq.length (); ++i) + { + name = prop_seq[i].name.in (); + + if (this->property_map_.rebind (name, prop_seq[i].value) == -1) + return -1; + } + // Note call to rebind. This allows to call <init> to set updates. + + return 0; +} + +int +TAO_NS_PropertySeq::populate (CosNotification::PropertySeq_var& prop_seq) +{ + PROPERTY_MAP::ITERATOR iterator (this->property_map_); + + int index = prop_seq->length (); + prop_seq->length (index + this->property_map_.current_size ()); + + for (PROPERTY_MAP::ENTRY *entry = 0; + iterator.next (entry) != 0; + iterator.advance (), ++index) + { + (*prop_seq)[index].name = CORBA::string_dup (entry->ext_id_.c_str ()); + (*prop_seq)[index].value = entry->int_id_; + } + + return 0; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/PropertySeq.h b/TAO/orbsvcs/orbsvcs/Notify/PropertySeq.h new file mode 100644 index 00000000000..4371aea34f9 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/PropertySeq.h @@ -0,0 +1,62 @@ +/* -*- C++ -*- */ +/** + * @file PropertySeq.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_PROPERTYSEQ_H +#define TAO_NS_PROPERTYSEQ_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotificationC.h" +#include "ace/Hash_Map_Manager.h" +#include "ace/SString.h" + +/** + * @class TAO_NS_PropertySeq + * + * @brief + * + */ +class TAO_Notify_Export TAO_NS_PropertySeq +{ +public: + /// Constuctor + TAO_NS_PropertySeq (void); + + /// Destructor + ~TAO_NS_PropertySeq (); + + /// Return 0 on success, -1 on error. + int init (const CosNotification::PropertySeq& prop_seq); + + /// Find the <value> for property <name>. Returns 0 on success. + int find (const ACE_CString& name, CosNotification::PropertyValue& value) const; + + /// Return -1 on error. + int populate (CosNotification::PropertySeq_var& prop_seq); + +protected: + /// Property Map. + typedef ACE_Hash_Map_Manager <ACE_CString, CosNotification::PropertyValue, ACE_SYNCH_NULL_MUTEX> PROPERTY_MAP; + + PROPERTY_MAP property_map_; +}; + +#if defined (__ACE_INLINE__) +#include "PropertySeq.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_PROPERTYSEQ_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/PropertySeq.inl b/TAO/orbsvcs/orbsvcs/Notify/PropertySeq.inl new file mode 100644 index 00000000000..271543a2f82 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/PropertySeq.inl @@ -0,0 +1,7 @@ +// $Id$ + +ACE_INLINE int +TAO_NS_PropertySeq::find (const ACE_CString& name, CosNotification::PropertyValue& value) const +{ + return this->property_map_.find (name, value); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.cpp b/TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.cpp new file mode 100644 index 00000000000..4c240b12bd9 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.cpp @@ -0,0 +1,43 @@ +// $Id$ + +#include "Property_Boolean.h" + +#if ! defined (__ACE_INLINE__) +#include "Property_Boolean.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_Property_Boolean, "$id$") + +#include "PropertySeq.h" + +TAO_NS_Property_Boolean::TAO_NS_Property_Boolean (const ACE_CString& name) + :name_ (name), valid_(0) +{ +} + +TAO_NS_Property_Boolean::TAO_NS_Property_Boolean (const ACE_CString& name, CORBA::Boolean initial) + :name_ (name), value_ (initial), valid_ (1) +{ +} + +int +TAO_NS_Property_Boolean::set (const TAO_NS_PropertySeq& property_seq) +{ + CosNotification::PropertyValue value; + + if (property_seq.find (this->name_, value) == -1) + return -1; + + value >>= CORBA::Any::to_boolean (this->value_); + + return 0; +} + +void +TAO_NS_Property_Boolean::get (CosNotification::PropertySeq& prop_seq) +{ + /// Make space + prop_seq.length (prop_seq.length () + 1); + + prop_seq[prop_seq.length () - 1].value <<= CORBA::Any::from_boolean (this->value_); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.h b/TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.h new file mode 100644 index 00000000000..1ddb447f418 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.h @@ -0,0 +1,81 @@ +/* -*- C++ -*- */ +/** + * @file Property_Boolean.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_PROPERTY_BOOLEAN_H +#define TAO_NS_PROPERTY_BOOLEAN_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotificationC.h" + +class TAO_NS_PropertySeq; + +/** + * @class TAO_NS_Property_Boolean + * + * @brief Boolean Property. + * + */ +/*******************************************************************************/ + +class TAO_Notify_Export TAO_NS_Property_Boolean +{ +public: + /// Constuctor + TAO_NS_Property_Boolean (const ACE_CString& name, CORBA::Boolean initial); + + /// Constuctor + TAO_NS_Property_Boolean (const ACE_CString& name); + + /// Assignment from TAO_NS_Property_Boolean + TAO_NS_Property_Boolean& operator= (const TAO_NS_Property_Boolean& rhs); + + /// Assignment from CORBA::Boolean + TAO_NS_Property_Boolean& operator= (const CORBA::Boolean& rhs); + + /// Equality comparison operator. + int operator== (const CORBA::Boolean &rhs) const; + + /// Inequality comparison operator. + int operator!= (const CORBA::Boolean &rhs) const; + + int set (const TAO_NS_PropertySeq& property_seq); + + void get (CosNotification::PropertySeq& prop_seq); + + /// Return the value. + CORBA::Boolean value (void) const; + + /// Is the current value valid + CORBA::Boolean is_valid (void) const; + +protected: + /// The Property name. + ACE_CString name_; + + /// The value + CORBA::Boolean value_; + + /// Is the value valid + CORBA::Boolean valid_; +}; + +#if defined (__ACE_INLINE__) +#include "Property_Boolean.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_PROPERTY_BOOLEAN_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.inl b/TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.inl new file mode 100644 index 00000000000..d30cabb4e39 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Property_Boolean.inl @@ -0,0 +1,49 @@ +// $Id$ + +ACE_INLINE TAO_NS_Property_Boolean& +TAO_NS_Property_Boolean::operator= (const TAO_NS_Property_Boolean& rhs) +{ + if (this == &rhs) + return *this; + + if (rhs.is_valid ()) + { + this->name_ = rhs.name_; + this->value_ = rhs.value_; + this->valid_ = rhs.valid_; + } + + return *this; +} + +ACE_INLINE TAO_NS_Property_Boolean& +TAO_NS_Property_Boolean::operator= (const CORBA::Boolean& value) +{ + this->value_ = value; + + return *this; +} + +ACE_INLINE int +TAO_NS_Property_Boolean::operator== (const CORBA::Boolean &rhs) const +{ + return (this->value_ == rhs); +} + +ACE_INLINE int +TAO_NS_Property_Boolean::operator!= (const CORBA::Boolean &rhs) const +{ + return (this->value_ != rhs); +} + +ACE_INLINE CORBA::Boolean +TAO_NS_Property_Boolean::value (void) const +{ + return this->value_; +} + +ACE_INLINE CORBA::Boolean +TAO_NS_Property_Boolean::is_valid (void) const +{ + return this->valid_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Property_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Property_T.cpp new file mode 100644 index 00000000000..051345844c1 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Property_T.cpp @@ -0,0 +1,119 @@ +// $Id$ + +#ifndef TAO_NS_PROPERTY_T_CPP +#define TAO_NS_PROPERTY_T_CPP + +#include "Property_T.h" + +#if ! defined (__ACE_INLINE__) +#include "Property_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_Property_T, "$id$") + +#include "PropertySeq.h" + +/*******************************************************************************/ + +template <class TYPE> +TAO_NS_PropertyBase_T<TYPE>::TAO_NS_PropertyBase_T (const ACE_CString& name) + :name_ (name), valid_(0) +{ +} + +template <class TYPE> +TAO_NS_PropertyBase_T<TYPE>::TAO_NS_PropertyBase_T (const ACE_CString& name, const TYPE& initial) + :name_ (name), value_ (initial), valid_ (1) +{ +} + +template <class TYPE> +TAO_NS_PropertyBase_T<TYPE>::TAO_NS_PropertyBase_T (const TAO_NS_PropertyBase_T &rhs) +{ + this->name_ = rhs.name_; + this->value_ = rhs.value_; + this->valid_ = rhs.valid_; +} + +template <class TYPE> +TAO_NS_PropertyBase_T<TYPE>::~TAO_NS_PropertyBase_T () +{ +} + +template <class TYPE> void +TAO_NS_PropertyBase_T<TYPE>::get (CosNotification::PropertySeq& prop_seq) +{ + /// Make space + prop_seq.length (prop_seq.length () + 1); + + prop_seq[prop_seq.length () - 1].value <<= this->value_; +} + +/*******************************************************************************/ + +template <class TYPE> +TAO_NS_Property_T<TYPE>::TAO_NS_Property_T (const ACE_CString& name) + :TAO_NS_PropertyBase_T <TYPE> (name) +{ +} + +template <class TYPE> +TAO_NS_Property_T<TYPE>::TAO_NS_Property_T (const ACE_CString& name, const TYPE& initial) + :TAO_NS_PropertyBase_T <TYPE> (name, initial) +{ +} + +template <class TYPE> int +TAO_NS_Property_T<TYPE>::set (const TAO_NS_PropertySeq& property_seq) +{ + CosNotification::PropertyValue value; + + if (property_seq.find (this->name_, value) == -1) + { + this->valid_ = 0; + return -1; + } + + value >>= this->value_; + + this->valid_ = 1; + + return 0; +} + +/*******************************************************************************/ + +template <class TYPE> +TAO_NS_StructProperty_T<TYPE>::TAO_NS_StructProperty_T (const ACE_CString& name) + :name_ (name), valid_(0) +{ +} + +template <class TYPE> +TAO_NS_StructProperty_T<TYPE>::TAO_NS_StructProperty_T (const ACE_CString& name, const TYPE& initial) + :name_ (name), value_ (initial), valid_ (1) +{ +} + +template <class TYPE> int +TAO_NS_StructProperty_T<TYPE>::set (const TAO_NS_PropertySeq& property_seq) +{ + CosNotification::PropertyValue value; + + if (property_seq.find (this->name_, value) == -1) + { + this->valid_ = 0; + return -1; + } + + TYPE* extract_type; + value >>= extract_type; + + this->value_ = *extract_type; // copy + + this->valid_ = 1; + + return 0; +} + +#endif /* TAO_NS_PROPERTY_T_CPP */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Property_T.h b/TAO/orbsvcs/orbsvcs/Notify/Property_T.h new file mode 100644 index 00000000000..c4200fc2b63 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Property_T.h @@ -0,0 +1,155 @@ +/* -*- C++ -*- */ +/** + * @file Property_T.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_PROPERTY_T_H +#define TAO_NS_PROPERTY_T_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/SString.h" +#include "orbsvcs/CosNotificationC.h" + +class TAO_NS_PropertySeq; + +/** + * @class TAO_NS_PropertyBase_T + * + * @brief + * + */ +template <class TYPE> +class TAO_NS_PropertyBase_T +{ +public: + /// Constuctor + TAO_NS_PropertyBase_T (const ACE_CString& name, const TYPE& initial); + + /// Constuctor + TAO_NS_PropertyBase_T (const ACE_CString& name); + + /// Copy Constuctor + TAO_NS_PropertyBase_T (const TAO_NS_PropertyBase_T &rhs); + + /// Destructor + ~TAO_NS_PropertyBase_T (); + + /// Assignment from TAO_NS_PropertyBase_T + TAO_NS_PropertyBase_T& operator= (const TAO_NS_PropertyBase_T& rhs); + + /// Assignment from TYPE + TAO_NS_PropertyBase_T& operator= (const TYPE& rhs); + + /// Equality comparison operator. + int operator== (const TYPE &rhs) const; + + /// Inequality comparison operator. + int operator!= (const TYPE &rhs) const; + + /// Populate the Property Sequence with this valid value. + void get (CosNotification::PropertySeq& prop_seq); + + /// Return the value. + const TYPE& value (void) const; + + /// Is the current value valid + CORBA::Boolean is_valid (void) const; + +protected: + /// The Property name. + ACE_CString name_; + + /// The value + TYPE value_; + + /// Is the value valid + CORBA::Boolean valid_; +}; + + +/*******************************************************************************/ +/** + * @class TAO_NS_Property_T + * + * @brief + * + */ +template <class TYPE> +class TAO_NS_Property_T : public TAO_NS_PropertyBase_T<TYPE> +{ +public: + /// Constuctor + TAO_NS_Property_T (const ACE_CString& name, const TYPE& initial); + + /// Constuctor + TAO_NS_Property_T (const ACE_CString& name); + + /// Init this Property from the sequence. + /// Returns 0 on success, -1 on error + int set (const TAO_NS_PropertySeq& property_seq); +}; + +/*******************************************************************************/ +/** + * @class TAO_NS_StructProperty_T + * + * @brief + * + */ +template <class TYPE> +class TAO_NS_StructProperty_T +{ +public: + /// Constuctor + TAO_NS_StructProperty_T (const ACE_CString& name, const TYPE& initial); + + /// Constuctor + TAO_NS_StructProperty_T (const ACE_CString& name); + + /// Init this Property from the sequence. + /// Returns 0 on success, -1 on error + int set (const TAO_NS_PropertySeq& property_seq); + + /// Return the value. + const TYPE& value (void) const; + + /// Is the current value valid + CORBA::Boolean is_valid (void) const; + +protected: + /// The Property name. + ACE_CString name_; + + /// The value + TYPE value_; + + /// Is the value valid + CORBA::Boolean valid_; +}; + +#if defined (__ACE_INLINE__) +#include "Property_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Property_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Property_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* TAO_NS_PROPERTY_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Property_T.inl b/TAO/orbsvcs/orbsvcs/Notify/Property_T.inl new file mode 100644 index 00000000000..fefa4ec01d2 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Property_T.inl @@ -0,0 +1,63 @@ +// $Id$ + +template <class TYPE> ACE_INLINE const TYPE& +TAO_NS_PropertyBase_T<TYPE>::value (void) const +{ + return this->value_; +} + +template <class TYPE> ACE_INLINE CORBA::Boolean +TAO_NS_PropertyBase_T<TYPE>::is_valid (void) const +{ + return this->valid_; +} + +template <class TYPE> ACE_INLINE int +TAO_NS_PropertyBase_T<TYPE>::operator== (const TYPE &rhs) const +{ + return (this->value_ == rhs); +} + +template <class TYPE> ACE_INLINE int +TAO_NS_PropertyBase_T<TYPE>::operator!= (const TYPE &rhs) const +{ + return (this->value_ != rhs); +} + +template <class TYPE> ACE_INLINE TAO_NS_PropertyBase_T<TYPE>& +TAO_NS_PropertyBase_T<TYPE>::operator= (const TAO_NS_PropertyBase_T<TYPE>& rhs) +{ + if (this == &rhs) + return *this; + + if (rhs.is_valid ()) + { + this->name_ = rhs.name_; + this->value_ = rhs.value_; + this->valid_ = rhs.valid_; + } + + return *this; +} + +template <class TYPE> ACE_INLINE TAO_NS_PropertyBase_T<TYPE>& +TAO_NS_PropertyBase_T<TYPE>::operator=(const TYPE& value) +{ + this->value_ = value; + + return *this; +} + +/******************************************************************************/ + +template <class TYPE> ACE_INLINE const TYPE& +TAO_NS_StructProperty_T<TYPE>::value (void) const +{ + return this->value_; +} + +template <class TYPE> ACE_INLINE CORBA::Boolean +TAO_NS_StructProperty_T<TYPE>::is_valid (void) const +{ + return this->valid_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Proxy.cpp b/TAO/orbsvcs/orbsvcs/Notify/Proxy.cpp new file mode 100644 index 00000000000..48549ecac07 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Proxy.cpp @@ -0,0 +1,110 @@ +// $Id$ + +#include "Proxy.h" + +#if ! defined (__ACE_INLINE__) +#include "Proxy.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Proxy, "$Id$") + +#include "Peer.h" +#include "Proxy.h" +#include "Admin.h" +#include "EventChannel.h" +#include "EventChannelFactory.h" +#include "Notify_Service.h" + +TAO_NS_Proxy::TAO_NS_Proxy (void) +{ + // Set initial proxy mode to broadcast. + this->subscribed_types_.insert (TAO_NS_EventType::special ()); +} + +TAO_NS_Proxy::~TAO_NS_Proxy () +{ +} + +void +TAO_NS_Proxy::type_added (const TAO_NS_EventType& added) +{ + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_); + this->added_.insert (added); + this->removed_.remove (added); +} + +void +TAO_NS_Proxy::type_removed (const TAO_NS_EventType& removed) +{ + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_); + this->removed_.insert (removed); + this->added_.remove (removed); +} + +CORBA::Boolean +TAO_NS_Proxy::check_filters (TAO_NS_Event_var &event ACE_ENV_ARG_DECL) +{ + // check if it passes the parent filter. + CORBA::Boolean parent_val = + this->parent_->filter_admin ().match (event ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + CORBA::Boolean val = 0; + + if (this->parent_->filter_operator () == CosNotifyChannelAdmin::AND_OP) + { + val = parent_val && this->filter_admin_.match (event ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + } + else + { + val = parent_val || this->filter_admin_.match (event ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + } + + return val; +} + +CosNotification::EventTypeSeq* +TAO_NS_Proxy::obtain_types (CosNotifyChannelAdmin::ObtainInfoMode mode ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + CosNotification::EventTypeSeq_var event_type_seq; + + ACE_NEW_THROW_EX (event_type_seq, + CosNotification::EventTypeSeq (), + CORBA::NO_MEMORY ()); + + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, CORBA::INTERNAL ()); + ACE_CHECK_RETURN (event_type_seq._retn ()); + + if (mode == CosNotifyChannelAdmin::ALL_NOW_UPDATES_OFF || + mode == CosNotifyChannelAdmin::ALL_NOW_UPDATES_ON) + { + this->added_.populate (event_type_seq); + } + + if (mode == CosNotifyChannelAdmin::NONE_NOW_UPDATES_ON || + mode == CosNotifyChannelAdmin::ALL_NOW_UPDATES_ON) + { + this->updates_off_ = 0; + } + else + { + this->updates_off_ = 1; + } + + return event_type_seq._retn (); +} + +void +TAO_NS_Proxy::qos_changed (void) +{ + //Inform Peers of qos changes. + TAO_NS_Peer* peer = this->peer (); + + if (peer != 0) + peer->qos_changed (this->qos_properties_); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Proxy.h b/TAO/orbsvcs/orbsvcs/Notify/Proxy.h new file mode 100644 index 00000000000..0bb33c1a91d --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Proxy.h @@ -0,0 +1,106 @@ +/* -*- C++ -*- */ +/** + * @file Proxy.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_PROXY_H +#define TAO_NS_PROXY_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Object_T.h" +#include "EventTypeSeq.h" +#include "FilterAdmin.h" + +class TAO_NS_Admin; +class TAO_NS_Peer; + +/** + * @class TAO_NS_Proxy + * + * @brief Base class proxy for all proxys in NS. + * + */ +class TAO_Notify_Export TAO_NS_Proxy : public virtual TAO_NS_Object_T <TAO_NS_Proxy, TAO_NS_Admin> +{ + friend class TAO_NS_Peer; + +public: + /// Constuctor + TAO_NS_Proxy (void); + + /// Destructor + ~TAO_NS_Proxy (); + + /// Subscribed types. + TAO_NS_EventTypeSeq& subscribed_types (void); + + /// Check if this event passes the admin and proxy filters. + CORBA::Boolean check_filters (TAO_NS_Event_var &event ACE_ENV_ARG_DECL); + + /// Subscription type added + void type_added (const TAO_NS_EventType& added); + + /// Subscription type removed + void type_removed (const TAO_NS_EventType& removed); + + /// Have updates been turned off. + CORBA::Boolean updates_off (void); + + /// Destroy this object. + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL) = 0; + + /// Access our Peer. + virtual TAO_NS_Peer* peer (void) = 0; + + /// Obtain Types. + virtual CosNotification::EventTypeSeq* obtain_types (CosNotifyChannelAdmin::ObtainInfoMode mode ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + /// Notification of subscriptions/offers set at the admin. + virtual void admin_subscription (const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL) = 0; + + + /// Override, TAO_NS_Object::qos_changed + virtual void qos_changed (void); + +protected: + typedef TAO_NS_Object_T <TAO_NS_Proxy, TAO_NS_Admin> inherited; + + /// Filter Administration + TAO_NS_FilterAdmin filter_admin_; + + /// Types added. + TAO_NS_EventTypeSeq added_; + + /// Types removed. + TAO_NS_EventTypeSeq removed_; + + /// The types that we're subscribed with the event manager. + TAO_NS_EventTypeSeq subscribed_types_; + + /// True if updates have been turned off. + CORBA::Boolean updates_off_; +}; + +#if defined (__ACE_INLINE__) +#include "Proxy.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_PROXY_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Proxy.inl b/TAO/orbsvcs/orbsvcs/Notify/Proxy.inl new file mode 100644 index 00000000000..16bb8abd7e2 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Proxy.inl @@ -0,0 +1,13 @@ +// $Id$ + +ACE_INLINE TAO_NS_EventTypeSeq& +TAO_NS_Proxy::subscribed_types (void) +{ + return this->subscribed_types_; +} + +ACE_INLINE CORBA::Boolean +TAO_NS_Proxy::updates_off (void) +{ + return this->updates_off_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.cpp new file mode 100644 index 00000000000..da2911b74c2 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.cpp @@ -0,0 +1,112 @@ +// $Id$ + +#include "ProxyConsumer.h" + +#if ! defined (__ACE_INLINE__) +#include "ProxyConsumer.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_ProxyConsumer, "$Id$") + +#include "tao/debug.h" +#include "ace/Atomic_Op.h" +#include "Supplier.h" +#include "AdminProperties.h" +#include "Property.h" +#include "Proxy.h" +#include "Admin.h" +#include "EventChannel.h" +#include "EventChannelFactory.h" +#include "Notify_Service.h" +#include "Event_Manager.h" +#include "Method_Request_Lookup.h" +#include "Worker_Task.h" + +TAO_NS_ProxyConsumer::TAO_NS_ProxyConsumer (void) + :supplier_ (0) +{ +} + +TAO_NS_ProxyConsumer::~TAO_NS_ProxyConsumer () +{ +} + +TAO_NS_Peer* +TAO_NS_ProxyConsumer::peer (void) +{ + return this->supplier (); +} + +void +TAO_NS_ProxyConsumer::connect (TAO_NS_Supplier *supplier ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosEventChannelAdmin::AlreadyConnected + )) +{ + TAO_NS_Atomic_Property_Long& supplier_count = this->admin_properties_->suppliers (); + const TAO_NS_Property_Long& max_suppliers = this->admin_properties_->max_suppliers (); + + if (max_suppliers != 0 && + supplier_count >= max_suppliers.value ()) + ACE_THROW (CORBA::IMP_LIMIT ()); // we've reached the limit of suppliers connected. + + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK; + + if (this->is_connected ()) + { + supplier->release (); + ACE_THROW (CosEventChannelAdmin::AlreadyConnected ()); + } + else + { + supplier_ = supplier; + + supplier->updates_dispatch_observer (this->event_manager_->updates_dispatch_observer ()); + + this->parent_->subscribed_types (this->subscribed_types_ ACE_ENV_ARG_PARAMETER); // get the parents subscribed types. + ACE_CHECK; + + // Inform QoS values. + supplier_->qos_changed (this->qos_properties_); + + event_manager_->publish (this, this->subscribed_types_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Increment the global supplier count + ++supplier_count; + } +} + +void +TAO_NS_ProxyConsumer::disconnect (ACE_ENV_SINGLE_ARG_DECL) +{ + event_manager_->un_publish (this, this->subscribed_types_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Decrement the global supplier count + this->admin_properties_->suppliers ()--; +} + +void +TAO_NS_ProxyConsumer::shutdown (ACE_ENV_SINGLE_ARG_DECL) +{ + this->disconnect (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->inherited::shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + if (this->supplier_ != 0) + this->supplier_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +void +TAO_NS_ProxyConsumer::push (TAO_NS_Event_var &event) +{ + TAO_NS_Method_Request_Lookup request (event, this, this->event_manager_->consumer_map ()); + + this->worker_task ()->exec (request); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.h b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.h new file mode 100644 index 00000000000..781a03b6a0e --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.h @@ -0,0 +1,77 @@ +/* -*- C++ -*- */ +/** + * @file ProxyConsumer.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_PROXYCONSUMER_H +#define TAO_NS_PROXYCONSUMER_H +#include "ace/pre.h" + +#include "notify_export.h" +#include "ace/Auto_Ptr.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Event.h" +#include "Supplier.h" +#include "Proxy.h" +#include "orbsvcs/CosEventChannelAdminC.h" + +/** + * @class TAO_NS_ProxyConsumer + * + * @brief Base class for all types of ProxyConsumer implementations. + * + */ +class TAO_Notify_Export TAO_NS_ProxyConsumer : public virtual TAO_NS_Proxy +{ +public: + /// Constuctor + TAO_NS_ProxyConsumer (void); + + /// Destructor + ~TAO_NS_ProxyConsumer (); + + /// Connect + void connect (TAO_NS_Supplier* supplier ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosEventChannelAdmin::AlreadyConnected + )); + + /// Disconnect + void disconnect (ACE_ENV_SINGLE_ARG_DECL); + + /// Shutdown (TAO_NS_Container_T method) + virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL); + + virtual void push (TAO_NS_Event_var &event); + + /// Access our Peer. + virtual TAO_NS_Peer* peer (void); + + /// Access the Supplier + TAO_NS_Supplier* supplier (void); + +protected: + /// Return 1 if connected + int is_connected (void); + + /// The Supplier that we're connect to. + TAO_NS_Supplier* supplier_; +}; + +#if defined (__ACE_INLINE__) +#include "ProxyConsumer.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_PROXYCONSUMER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.inl b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.inl new file mode 100644 index 00000000000..b8dc2b1357f --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer.inl @@ -0,0 +1,13 @@ +// $Id$ + +ACE_INLINE int +TAO_NS_ProxyConsumer::is_connected (void) +{ + return supplier_ == 0 ? 0 : 1; +} + +ACE_INLINE TAO_NS_Supplier* +TAO_NS_ProxyConsumer::supplier (void) +{ + return this->supplier_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.cpp new file mode 100644 index 00000000000..23bee77b8fc --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.cpp @@ -0,0 +1,82 @@ +// $Id$ + +#ifndef TAO_NS_PROXYCONSUMER_T_CPP +#define TAO_NS_PROXYCONSUMER_T_CPP + +#include "ProxyConsumer_T.h" + +#if ! defined (__ACE_INLINE__) +#include "ProxyConsumer_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_ProxyConsumer_T, "$id$") + +#include "Event_Manager.h" + +template <class SERVANT_TYPE> +TAO_NS_ProxyConsumer_T<SERVANT_TYPE>::TAO_NS_ProxyConsumer_T (void) +{ +} + +template <class SERVANT_TYPE> +TAO_NS_ProxyConsumer_T<SERVANT_TYPE>::~TAO_NS_ProxyConsumer_T () +{ +} + +template <class SERVANT_TYPE> void +TAO_NS_ProxyConsumer_T<SERVANT_TYPE>::admin_subscription (const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL) +{ + this->offer_change (added, removed ACE_ENV_ARG_PARAMETER); +} + +template <class SERVANT_TYPE> CosNotifyChannelAdmin::SupplierAdmin_ptr +TAO_NS_ProxyConsumer_T<SERVANT_TYPE>::MyAdmin (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + CosNotifyChannelAdmin::SupplierAdmin_var ret; + + CORBA::Object_var object = this->parent_->ref (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (ret._retn ()); + + ret = CosNotifyChannelAdmin::SupplierAdmin::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + + return ret._retn (); +} + +template <class SERVANT_TYPE> void +TAO_NS_ProxyConsumer_T<SERVANT_TYPE>::offer_change (const CosNotification::EventTypeSeq & added, const CosNotification::EventTypeSeq & removed ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyComm::InvalidEventType + )) +{ + TAO_NS_EventTypeSeq seq_added (added); + TAO_NS_EventTypeSeq seq_removed (removed); + + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK; + + this->subscribed_types_.init (seq_added, seq_removed); + + if (this->is_connected () == 1) + { + event_manager_->publish (this, seq_added ACE_ENV_ARG_PARAMETER); + event_manager_->un_publish (this, seq_removed ACE_ENV_ARG_PARAMETER); + } +} + +template <class SERVANT_TYPE> CosNotification::EventTypeSeq* +TAO_NS_ProxyConsumer_T<SERVANT_TYPE>::obtain_subscription_types (CosNotifyChannelAdmin::ObtainInfoMode mode ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->obtain_types (mode ACE_ENV_ARG_PARAMETER); +} + +#endif /* TAO_NS_PROXYCONSUMER_T_CPP */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.h b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.h new file mode 100644 index 00000000000..475559088ab --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.h @@ -0,0 +1,84 @@ +/* -*- C++ -*- */ +/** + * @file ProxyConsumer_T.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_PROXYCONSUMER_T_H +#define TAO_NS_PROXYCONSUMER_T_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Proxy_T.h" +#include "ProxyConsumer.h" + +/** + * @class TAO_NS_ProxyConsumer_T + * + * @brief + * + */ +template <class SERVANT_TYPE> +class TAO_Notify_Export TAO_NS_ProxyConsumer_T : public virtual TAO_NS_Proxy_T <SERVANT_TYPE>, public virtual TAO_NS_ProxyConsumer +{ +public: + /// Constuctor + TAO_NS_ProxyConsumer_T (void); + + /// Destructor + ~TAO_NS_ProxyConsumer_T (); + + /// Notification of subscriptions set at the admin. + virtual void admin_subscription (const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL); + + virtual CosNotifyChannelAdmin::SupplierAdmin_ptr MyAdmin (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual CosNotification::EventTypeSeq * obtain_subscription_types ( + CosNotifyChannelAdmin::ObtainInfoMode mode + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void offer_change ( + const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyComm::InvalidEventType + )); + +}; + +#if defined (__ACE_INLINE__) +#include "ProxyConsumer_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ProxyConsumer_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("ProxyConsumer_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* TAO_NS_PROXYCONSUMER_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.inl b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxyConsumer_T.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.cpp new file mode 100644 index 00000000000..dc9270191de --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.cpp @@ -0,0 +1,115 @@ +// $Id$ + +#include "ProxySupplier.h" + +#if ! defined (__ACE_INLINE__) +#include "ProxySupplier.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_ProxySupplier, "$Id$") + +#include "Method_Request_Dispatch_No_Filtering.h" +#include "Event_Manager.h" +#include "AdminProperties.h" +#include "Consumer.h" +#include "Proxy.h" +#include "Admin.h" +#include "EventChannel.h" +#include "EventChannelFactory.h" +#include "Notify_Service.h" +#include "Method_Request_Dispatch.h" +#include "Worker_Task.h" + +TAO_NS_ProxySupplier::TAO_NS_ProxySupplier (void) + :consumer_ (0) +{ +} + +TAO_NS_ProxySupplier::~TAO_NS_ProxySupplier () +{ +} + +void +TAO_NS_ProxySupplier::init_ps (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ +} + +TAO_NS_Peer* +TAO_NS_ProxySupplier:: peer (void) +{ + return this->consumer (); +} + +void +TAO_NS_ProxySupplier::connect (TAO_NS_Consumer *consumer ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosEventChannelAdmin::AlreadyConnected + )) +{ + const TAO_NS_Atomic_Property_Long& consumer_count = this->admin_properties_->consumers (); + const TAO_NS_Property_Long& max_consumers = this->admin_properties_->max_consumers (); + + if (max_consumers != 0 && + consumer_count >= max_consumers.value ()) + ACE_THROW (CORBA::IMP_LIMIT ()); // we've reached the limit of consumers connected. + + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK; + + if (this->is_connected ()) + { + consumer->release (); + ACE_THROW (CosEventChannelAdmin::AlreadyConnected ()); + } + else + { + consumer_ = consumer; + + consumer->event_dispatch_observer (this->event_manager_->event_dispatch_observer ()); + consumer->updates_dispatch_observer (this->event_manager_->updates_dispatch_observer ()); + + // Inform QoS values. + consumer_->qos_changed (this->qos_properties_); + + this->parent_->subscribed_types (this->subscribed_types_ ACE_ENV_ARG_PARAMETER); // get the parents subscribed types. + ACE_CHECK; + + event_manager_->subscribe (this, this->subscribed_types_ ACE_ENV_ARG_PARAMETER); + } +} + +void +TAO_NS_ProxySupplier::disconnect (ACE_ENV_SINGLE_ARG_DECL) +{ + event_manager_->un_subscribe (this, this->subscribed_types_ ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +TAO_NS_ProxySupplier::shutdown (ACE_ENV_SINGLE_ARG_DECL) +{ + this->disconnect (ACE_ENV_SINGLE_ARG_PARAMETER); + + this->inherited::shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + + if (this->consumer_ != 0) + this->consumer_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +void +TAO_NS_ProxySupplier::push (TAO_NS_Event_var &event) +{ + TAO_NS_Method_Request_Dispatch request (event, this); + + this->worker_task ()->exec (request); +} + +void +TAO_NS_ProxySupplier::push_no_filtering (TAO_NS_Event_var &event) +{ + TAO_NS_Method_Request_Dispatch_No_Filtering request (event, this); + + this->worker_task ()->exec (request); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.h b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.h new file mode 100644 index 00000000000..1fc1075cb3c --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.h @@ -0,0 +1,85 @@ +/* -*- C++ -*- */ +/** + * @file ProxySupplier.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_PROXYSUPPLIER_H +#define TAO_NS_PROXYSUPPLIER_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Event.h" +#include "Proxy.h" +#include "orbsvcs/CosEventChannelAdminC.h" + +class TAO_NS_Consumer; + +/** + * @class TAO_NS_ProxySupplier + * + * @brief Base class for all the ProxySuppliers. + * + */ +class TAO_Notify_Export TAO_NS_ProxySupplier : public virtual TAO_NS_Proxy +{ + friend class TAO_NS_Consumer; + +public: + /// Constuctor + TAO_NS_ProxySupplier (void); + + /// Destructor + virtual ~TAO_NS_ProxySupplier (); + + /// Init method. + virtual void init_ps (ACE_ENV_SINGLE_ARG_DECL); + + /// Connect + void connect (TAO_NS_Consumer* consumer ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosEventChannelAdmin::AlreadyConnected + )); + /// Disconnect + void disconnect (ACE_ENV_SINGLE_ARG_DECL); + + /// Dispatch Event to consumer + virtual void push (TAO_NS_Event_var &event); + + /// Dispatch Event to consumer, no filtering + virtual void push_no_filtering (TAO_NS_Event_var &event); + + /// Override TAO_NS_Container_T::shutdown method + virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL); + + /// Access our Peer. + virtual TAO_NS_Peer* peer (void); + + /// Access the Consumer + TAO_NS_Consumer* consumer (void); + +protected: + /// Return 1 if connected + int is_connected (void); + + /// The Consumer that we're connect to. + TAO_NS_Consumer* consumer_; +}; + +#if defined (__ACE_INLINE__) +#include "ProxySupplier.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_PROXYSUPPLIER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.inl b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.inl new file mode 100644 index 00000000000..e2aae869cd7 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier.inl @@ -0,0 +1,13 @@ +// $Id$ + +ACE_INLINE int +TAO_NS_ProxySupplier::is_connected (void) +{ + return consumer_ == 0 ? 0 : 1; +} + +ACE_INLINE TAO_NS_Consumer* +TAO_NS_ProxySupplier::consumer (void) +{ + return this->consumer_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.cpp new file mode 100644 index 00000000000..38196db6784 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.cpp @@ -0,0 +1,220 @@ +// $Id$ + +#ifndef TAO_NS_PROXYSUPPLIER_T_C +#define TAO_NS_PROXYSUPPLIER_T_C + +#include "ProxySupplier_T.h" + +#if ! defined (__ACE_INLINE__) +#include "ProxySupplier_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_ProxySupplier_T, "$id$") + +#include "Consumer.h" +#include "Structured/StructuredEvent.h" +#include "Any/AnyEvent.h" + +#include "Method_Request_Dispatch.h" +#include "Method_Request_Dispatch_No_Filtering.h" +#include "Worker_Task.h" +#include "Event_Manager.h" + +template <class SERVANT_TYPE> +TAO_NS_ProxySupplier_T<SERVANT_TYPE>::TAO_NS_ProxySupplier_T (void) + :is_suspended_ (0) +{ +} + +template <class SERVANT_TYPE> +TAO_NS_ProxySupplier_T<SERVANT_TYPE>::~TAO_NS_ProxySupplier_T () +{ +} + +template <class SERVANT_TYPE> void +TAO_NS_ProxySupplier_T<SERVANT_TYPE>::admin_subscription (const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL) +{ + this->subscription_change (added, removed ACE_ENV_ARG_PARAMETER); +} + +template <class SERVANT_TYPE> void +TAO_NS_ProxySupplier_T<SERVANT_TYPE>::forward_structured (const CosNotification::StructuredEvent& notification ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + TAO_NS_Event_var event (new TAO_NS_StructuredEvent (notification)); + + TAO_NS_Method_Request_Dispatch request (event, this); + + this->worker_task ()->exec (request); +} + +template <class SERVANT_TYPE> void +TAO_NS_ProxySupplier_T<SERVANT_TYPE>::forward_structured_no_filtering (const CosNotification::StructuredEvent& notification ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + TAO_NS_Event_var event (new TAO_NS_StructuredEvent (notification)); + + TAO_NS_Method_Request_Dispatch_No_Filtering request (event, this); + + this->worker_task ()->exec (request); +} + +template <class SERVANT_TYPE> void +TAO_NS_ProxySupplier_T<SERVANT_TYPE>::forward_any (const CORBA::Any & data ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + TAO_NS_Event_var event (new TAO_NS_AnyEvent (data)); + + TAO_NS_Method_Request_Dispatch request (event, this); + + this->worker_task ()->exec (request); +} + +template <class SERVANT_TYPE> void +TAO_NS_ProxySupplier_T<SERVANT_TYPE>::forward_any_no_filtering (const CORBA::Any& data ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + TAO_NS_Event_var event (new TAO_NS_AnyEvent (data)); + + TAO_NS_Method_Request_Dispatch_No_Filtering request (event, this); + + this->worker_task ()->exec (request); +} + +template <class SERVANT_TYPE> CosNotification::EventTypeSeq* +TAO_NS_ProxySupplier_T<SERVANT_TYPE>::obtain_offered_types (CosNotifyChannelAdmin::ObtainInfoMode mode ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->obtain_types (mode ACE_ENV_ARG_PARAMETER); +} + +template <class SERVANT_TYPE> void +TAO_NS_ProxySupplier_T<SERVANT_TYPE>::subscription_change (const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + CosNotifyComm::InvalidEventType)) +{ + TAO_NS_EventTypeSeq seq_added (added); + TAO_NS_EventTypeSeq seq_removed (removed); + + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK; + + this->subscribed_types_.init (seq_added, seq_removed); + + if (this->is_connected () == 1) + { + event_manager_->subscribe (this, seq_added ACE_ENV_ARG_PARAMETER); + event_manager_->un_subscribe (this, seq_removed ACE_ENV_ARG_PARAMETER); + } +} + +template <class SERVANT_TYPE> void +TAO_NS_ProxySupplier_T<SERVANT_TYPE>::suspend_connection (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyChannelAdmin::ConnectionAlreadyInactive, + CosNotifyChannelAdmin::NotConnected + )) +{ + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, CORBA::INTERNAL ()); + + if (this->is_connected () == 0) + ACE_THROW (CosNotifyChannelAdmin::NotConnected ()); + + if (this->consumer_->is_suspended () == 1) + ACE_THROW (CosNotifyChannelAdmin::ConnectionAlreadyInactive ()); + + this->consumer_->suspend (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +template <class SERVANT_TYPE> void +TAO_NS_ProxySupplier_T<SERVANT_TYPE>::resume_connection (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyChannelAdmin::ConnectionAlreadyActive, + CosNotifyChannelAdmin::NotConnected + )) +{ + { + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, CORBA::INTERNAL ()); + + if (this->is_connected () == 0) + ACE_THROW (CosNotifyChannelAdmin::NotConnected ()); + + if (this->consumer_->is_suspended () == 0) + ACE_THROW (CosNotifyChannelAdmin::ConnectionAlreadyActive ()); + } + + this->consumer_->suspend (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +template <class SERVANT_TYPE> CosNotifyChannelAdmin::ConsumerAdmin_ptr +TAO_NS_ProxySupplier_T<SERVANT_TYPE>::MyAdmin (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + CosNotifyChannelAdmin::ConsumerAdmin_var ret; + + CORBA::Object_var object = this->parent_->ref (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (ret._retn ()); + + ret = CosNotifyChannelAdmin::ConsumerAdmin::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + + return ret._retn (); +} + +template <class SERVANT_TYPE> CosNotifyFilter::MappingFilter_ptr +TAO_NS_ProxySupplier_T<SERVANT_TYPE>::priority_filter (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), + CosNotifyFilter::MappingFilter::_nil ()); +} + +template <class SERVANT_TYPE> void +TAO_NS_ProxySupplier_T<SERVANT_TYPE>::priority_filter (CosNotifyFilter::MappingFilter_ptr /*priority_filter*/ ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +template <class SERVANT_TYPE> CosNotifyFilter::MappingFilter_ptr +TAO_NS_ProxySupplier_T<SERVANT_TYPE>::lifetime_filter (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), + CosNotifyFilter::MappingFilter::_nil ()); +} + +template <class SERVANT_TYPE> void +TAO_NS_ProxySupplier_T<SERVANT_TYPE>::lifetime_filter (CosNotifyFilter::MappingFilter_ptr /*lifetime_filter*/ ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +#endif /* #define TAO_NS_PROXYSUPPLIER_T_C */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.h b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.h new file mode 100644 index 00000000000..1364569e244 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.h @@ -0,0 +1,162 @@ +/* -*- C++ -*- */ +/** + * @file ProxySupplier_T.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_PROXYSUPPLIER_T_H +#define TAO_NS_PROXYSUPPLIER_T_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Proxy_T.h" +#include "ProxySupplier.h" + +/** + * @class TAO_NS_ProxySupplier_T + * + * @brief + * + */ +template <class SERVANT_TYPE> +class TAO_NS_ProxySupplier_T : public virtual TAO_NS_Proxy_T <SERVANT_TYPE>, public virtual TAO_NS_ProxySupplier +{ +public: + /// Constuctor + TAO_NS_ProxySupplier_T (void); + + /// Destructor + ~TAO_NS_ProxySupplier_T (); + + /// Notification of subscriptions set at the admin. + virtual void admin_subscription (const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL); + + ///= POA_Notify_Internal methods + /// POA_Notify_Internal::Event_Forwarder method + virtual void forward_structured (const CosNotification::StructuredEvent & event ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + /// POA_Notify_Internal::Event_Forwarder method + virtual void forward_structured_no_filtering (const CosNotification::StructuredEvent & event ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + /// POA_Notify_Internal::Event_Forwarder method + virtual void forward_any (const CORBA::Any & event ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + /// POA_Notify_Internal::Event_Forwarder method + virtual void forward_any_no_filtering (const CORBA::Any & event ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); +protected: + //= Data Members + CORBA::Boolean is_suspended_; + + // = Interface methods + virtual CosNotifyChannelAdmin::ConsumerAdmin_ptr MyAdmin ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void suspend_connection ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyChannelAdmin::ConnectionAlreadyInactive, + CosNotifyChannelAdmin::NotConnected + )); + + virtual void resume_connection ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyChannelAdmin::ConnectionAlreadyActive, + CosNotifyChannelAdmin::NotConnected + )); + + virtual CosNotifyFilter::MappingFilter_ptr priority_filter ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void priority_filter ( + CosNotifyFilter::MappingFilter_ptr priority_filter + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual CosNotifyFilter::MappingFilter_ptr lifetime_filter ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void lifetime_filter ( + CosNotifyFilter::MappingFilter_ptr lifetime_filter + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual CosNotification::EventTypeSeq * obtain_offered_types ( + CosNotifyChannelAdmin::ObtainInfoMode mode + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void subscription_change ( + const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyComm::InvalidEventType + )); +}; + +#if defined (__ACE_INLINE__) +#include "ProxySupplier_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ProxySupplier_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("ProxySupplier_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* TAO_NS_PROXYSUPPLIER_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.inl b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Proxy_T.cpp b/TAO/orbsvcs/orbsvcs/Notify/Proxy_T.cpp new file mode 100644 index 00000000000..df767f312f1 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Proxy_T.cpp @@ -0,0 +1,135 @@ +// $Id$ + +#include "Proxy_T.h" + +#ifndef TAO_NS_PROXY_T_CPP +#define TAO_NS_PROXY_T_CPP + +#if ! defined (__ACE_INLINE__) +#include "Proxy_T.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_Proxy_T, "$id$") + +template <class SERVANT_TYPE> +TAO_NS_Proxy_T<SERVANT_TYPE>::TAO_NS_Proxy_T (void) +{ +} + +template <class SERVANT_TYPE> +TAO_NS_Proxy_T<SERVANT_TYPE>::~TAO_NS_Proxy_T () +{ +} + +template <class SERVANT_TYPE> PortableServer::Servant +TAO_NS_Proxy_T<SERVANT_TYPE>::servant (void) +{ + return this; +} + +template <class SERVANT_TYPE> void +TAO_NS_Proxy_T<SERVANT_TYPE>::_add_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->_incr_refcnt (); +} + +template <class SERVANT_TYPE> void +TAO_NS_Proxy_T<SERVANT_TYPE>::_remove_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->_decr_refcnt (); +} + +template <class SERVANT_TYPE> void +TAO_NS_Proxy_T<SERVANT_TYPE>::validate_event_qos (const CosNotification::QoSProperties & /*required_qos*/, CosNotification::NamedPropertyRangeSeq_out /*available_qos*/ ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotification::UnsupportedQoS + )) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +template <class SERVANT_TYPE> CosNotification::QoSProperties* +TAO_NS_Proxy_T<SERVANT_TYPE>::get_qos (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->TAO_NS_Object::get_qos (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +template <class SERVANT_TYPE> void +TAO_NS_Proxy_T<SERVANT_TYPE>::set_qos (const CosNotification::QoSProperties & qos ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotification::UnsupportedQoS + )) +{ + this->TAO_NS_Object::set_qos (qos ACE_ENV_ARG_PARAMETER); +} + +template <class SERVANT_TYPE> void +TAO_NS_Proxy_T<SERVANT_TYPE>::validate_qos ( + const CosNotification::QoSProperties & /*required_qos*/, + CosNotification::NamedPropertyRangeSeq_out /*available_qos*/ + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotification::UnsupportedQoS + )) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +template <class SERVANT_TYPE> CosNotifyFilter::FilterID +TAO_NS_Proxy_T<SERVANT_TYPE>::add_filter (CosNotifyFilter::Filter_ptr new_filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->filter_admin_.add_filter (new_filter ACE_ENV_ARG_PARAMETER); +} + +template <class SERVANT_TYPE> void +TAO_NS_Proxy_T<SERVANT_TYPE>::remove_filter ( + CosNotifyFilter::FilterID filter + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::FilterNotFound + )) +{ + this->filter_admin_.remove_filter (filter ACE_ENV_ARG_PARAMETER); +} + +template <class SERVANT_TYPE> CosNotifyFilter::Filter_ptr +TAO_NS_Proxy_T<SERVANT_TYPE>::get_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::FilterNotFound + )) +{ + return this->filter_admin_.get_filter (filter ACE_ENV_ARG_PARAMETER); +} + +template <class SERVANT_TYPE> CosNotifyFilter::FilterIDSeq* +TAO_NS_Proxy_T<SERVANT_TYPE>::get_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->filter_admin_.get_all_filters (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +template <class SERVANT_TYPE> void +TAO_NS_Proxy_T<SERVANT_TYPE>::remove_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + this->filter_admin_.remove_all_filters (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +#endif /* TAO_NS_PROXY_T_CPP */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Proxy_T.h b/TAO/orbsvcs/orbsvcs/Notify/Proxy_T.h new file mode 100644 index 00000000000..04c331dc7c6 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Proxy_T.h @@ -0,0 +1,139 @@ +/* -*- C++ -*- */ +/** + * @file Proxy_T.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_PROXY_T_H +#define TAO_NS_PROXY_T_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Proxy.h" + +/** + * @class TAO_NS_Proxy_T + * + * @brief The is a base class for all proxys , templatized by the servant + * type. All the Filter Admin and QoS Admin interface methods are + * implemented here by delegating to the admin implementations. + * + */ +template <class SERVANT_TYPE> +class TAO_NS_Proxy_T : public SERVANT_TYPE, public virtual TAO_NS_Proxy +{ +public: + /// Constuctor + TAO_NS_Proxy_T (void); + + /// Destructor + ~TAO_NS_Proxy_T (); + + /// Implements TAO_NS_Object::servant method. + virtual PortableServer::Servant servant (void); + + /// ServantBase refcount methods. + virtual void _add_ref (ACE_ENV_SINGLE_ARG_DECL); + virtual void _remove_ref (ACE_ENV_SINGLE_ARG_DECL); + + virtual void validate_event_qos ( + const CosNotification::QoSProperties & required_qos, + CosNotification::NamedPropertyRangeSeq_out available_qos + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotification::UnsupportedQoS + )); + + virtual CosNotification::QoSProperties * get_qos ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void set_qos ( + const CosNotification::QoSProperties & qos + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotification::UnsupportedQoS + )); + + virtual void validate_qos ( + const CosNotification::QoSProperties & required_qos, + CosNotification::NamedPropertyRangeSeq_out available_qos + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotification::UnsupportedQoS + )); + + virtual CosNotifyFilter::FilterID add_filter ( + CosNotifyFilter::Filter_ptr new_filter + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void remove_filter ( + CosNotifyFilter::FilterID filter + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::FilterNotFound + )); + + virtual CosNotifyFilter::Filter_ptr get_filter ( + CosNotifyFilter::FilterID filter + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosNotifyFilter::FilterNotFound + )); + + virtual CosNotifyFilter::FilterIDSeq * get_all_filters ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void remove_all_filters ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); +}; + +#if defined (__ACE_INLINE__) +#include "Proxy_T.inl" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "Proxy_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Proxy_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* TAO_NS_PROXY_T_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Proxy_T.inl b/TAO/orbsvcs/orbsvcs/Notify/Proxy_T.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Proxy_T.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.cpp b/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.cpp new file mode 100644 index 00000000000..2a8672aa1f6 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.cpp @@ -0,0 +1,126 @@ +// $Id$ + +#include "QoSProperties.h" + +#if ! defined (__ACE_INLINE__) +#include "QoSProperties.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_QoSProperties, "$id$") + +#include "Property.h" + +TAO_NS_QoSProperties::TAO_NS_QoSProperties (void) + :priority_ (CosNotification::Priority), + timeout_ (CosNotification::Timeout), + stop_time_supported_ (CosNotification::StopTimeSupported), + maximum_batch_size_ (CosNotification::MaximumBatchSize), + pacing_interval_ (CosNotification::PacingInterval), + thread_pool_ (NotifyExt::ThreadPool), + thread_pool_lane_ (NotifyExt::ThreadPoolLanes) +{ + unsupported_[0] = CosNotification::EventReliability; + unsupported_[1] = CosNotification::ConnectionReliability; + unsupported_[2] = CosNotification::StartTimeSupported; +} + +TAO_NS_QoSProperties::~TAO_NS_QoSProperties () +{ +} + +int +TAO_NS_QoSProperties::unsupported (ACE_CString& name) +{ + for (int i = 0; i < UNSUPPORTED_PROPERTY_COUNT; ++i) + { + if (this->unsupported_[i] == name) + return 1; + } + + return 0; +} + +int +TAO_NS_QoSProperties::init (const CosNotification::PropertySeq& prop_seq, CosNotification::PropertyErrorSeq& err_seq) +{ + int err_index = -1; + + ACE_CString name; + for (CORBA::ULong i = 0; i < prop_seq.length (); ++i) + { + name = prop_seq[i].name.in(); + + if (this->unsupported (name)) + { + err_index = err_seq.length (); + err_seq.length (err_seq.length () + 1); + + err_seq[err_index].code = CosNotification::UNSUPPORTED_PROPERTY; + err_seq[err_index].name = CORBA::string_dup (prop_seq[i].name); + } + else if (this->property_map_.rebind (prop_seq[i].name.in (), prop_seq[i].value) == -1) + return -1; + // Note call to rebind. This allows to call <init> to set updates. + } + + // Now, init the supported properties + this->priority_.set (*this); + this->timeout_.set (*this); + this->stop_time_supported_.set (*this); + this->maximum_batch_size_.set (*this); + this->pacing_interval_.set (*this); + this->thread_pool_.set (*this); + this->thread_pool_lane_.set (*this); + + return err_index == -1 ? 0 : 1; +} + +void +TAO_NS_QoSProperties::transfer (TAO_NS_QoSProperties& qos_properties) +{ + qos_properties.priority_ = this->priority_; + qos_properties.timeout_ = this->timeout_; + qos_properties.stop_time_supported_ = this->stop_time_supported_; + qos_properties.maximum_batch_size_ = this->maximum_batch_size_; + qos_properties.pacing_interval_ = this->pacing_interval_; + + PROPERTY_MAP::ITERATOR iter (this->property_map_); + PROPERTY_MAP::ENTRY *entry; + + for (; iter.next (entry); iter.advance ()) + { + qos_properties.property_map_.bind (entry->ext_id_, entry->int_id_); + } + + // unbind the properties that we don't want to transfer. + qos_properties.property_map_.unbind (NotifyExt::ThreadPool); + qos_properties.property_map_.unbind (NotifyExt::ThreadPoolLanes); +} + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) + +template class TAO_NS_PropertyBase_T<CORBA::Long>; +template class TAO_NS_PropertyBase_T<CORBA::Short>; +template class TAO_NS_PropertyBase_T<TimeBase::TimeT>; + +template class TAO_NS_Property_T<CORBA::Long>; +template class TAO_NS_Property_T<CORBA::Short>; +template class TAO_NS_Property_T<TimeBase::TimeT>; + +template class TAO_NS_StructProperty_T<NotifyExt::ThreadPoolParams>; +template class TAO_NS_StructProperty_T<NotifyExt::ThreadPoolLanesParams>; + +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) + +#pragma instantiate TAO_NS_PropertyBase_T<CORBA::Long> +#pragma instantiate TAO_NS_PropertyBase_T<CORBA::Short> +#pragma instantiate TAO_NS_PropertyBase_T<TimeBase::TimeT> + +#pragma instantiate TAO_NS_Property_T<CORBA::Long> +#pragma instantiate TAO_NS_Property_T<CORBA::Short> +#pragma instantiate TAO_NS_Property_T<TimeBase::TimeT> + +#pragma instantiate TAO_NS_StructProperty_T<NotifyExt::ThreadPoolParams> +#pragma instantiate TAO_NS_StructProperty_T<NotifyExt::ThreadPoolLanesParams> + +#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.h b/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.h new file mode 100644 index 00000000000..08911f86ef4 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.h @@ -0,0 +1,99 @@ +/* -*- C++ -*- */ +/** + * @file QoSProperties.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_QOSPROPERTIES_H +#define TAO_NS_QOSPROPERTIES_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "PropertySeq.h" +#include "Property_T.h" +#include "Property_Boolean.h" +#include "Property.h" + +/** + * @class TAO_NS_QoSProperties + * + * @brief + * + */ +class TAO_Notify_Export TAO_NS_QoSProperties : public TAO_NS_PropertySeq +{ +public: + /// Constuctor + TAO_NS_QoSProperties (void); + + /// Destructor + ~TAO_NS_QoSProperties (); + + /// Return 0 on success, 1 if unsupported properties were detected and -1 on error. + int init (const CosNotification::PropertySeq& prop_seq, CosNotification::PropertyErrorSeq& err_seq); + + /// Populate <qos_properties> with properties that can be transfered. + void transfer (TAO_NS_QoSProperties& qos_properties); + + ///= Accessors + /// ThreadPool + const TAO_NS_Property_ThreadPool& thread_pool (void) const; + + /// ThreadPoolLane + const TAO_NS_Property_ThreadPoolLanes& thread_pool_lane (void) const; + + /// Maximum Batch Size + const TAO_NS_Property_Long& maximum_batch_size (void) const; + + /// Pacing Interval + const TAO_NS_Property_Time& pacing_interval (void) const; + +protected: + /// Return 1 if <value> is unsupported. + int unsupported (ACE_CString& name); + + enum {UNSUPPORTED_PROPERTY_COUNT = 3}; + + ///= Unsupported Properties. + ACE_CString unsupported_[UNSUPPORTED_PROPERTY_COUNT]; + + ///= Supported properties + + /// Priority + TAO_NS_Property_Short priority_; + + /// Timeout + TAO_NS_Property_Time timeout_; + + /// Stop Time Supported + TAO_NS_Property_Boolean stop_time_supported_; + + /// Maximum Batch Size + TAO_NS_Property_Long maximum_batch_size_; + + /// Pacing Interval + TAO_NS_Property_Time pacing_interval_; + + /// ThreadPool Params. + TAO_NS_Property_ThreadPool thread_pool_; + + /// ThreadPoolLane Params. + TAO_NS_Property_ThreadPoolLanes thread_pool_lane_; +}; + +#if defined (__ACE_INLINE__) +#include "QoSProperties.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_QOSPROPERTIES_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.inl b/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.inl new file mode 100644 index 00000000000..e331e8b1046 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/QoSProperties.inl @@ -0,0 +1,25 @@ +// $Id$ + +ACE_INLINE const TAO_NS_Property_ThreadPool& +TAO_NS_QoSProperties::thread_pool (void) const +{ + return this->thread_pool_; +} + +ACE_INLINE const TAO_NS_Property_ThreadPoolLanes& +TAO_NS_QoSProperties::thread_pool_lane (void) const +{ + return this->thread_pool_lane_; +} + +ACE_INLINE const TAO_NS_Property_Long& +TAO_NS_QoSProperties::maximum_batch_size (void) const +{ + return this->maximum_batch_size_; +} + +ACE_INLINE const TAO_NS_Property_Time& +TAO_NS_QoSProperties::pacing_interval (void) const +{ + return this->pacing_interval_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.cpp b/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.cpp new file mode 100644 index 00000000000..346e66ab334 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.cpp @@ -0,0 +1,24 @@ +// $Id$ + +#include "Reactive_Task.h" + +#if ! defined (__ACE_INLINE__) +#include "Reactive_Task.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Reactive_Task, "$Id$") + +TAO_NS_Reactive_Task::TAO_NS_Reactive_Task (void) +{ +} + +TAO_NS_Reactive_Task::~TAO_NS_Reactive_Task () +{ +} + +void +TAO_NS_Reactive_Task::exec (TAO_NS_Method_Request& method_request) +{ + ACE_DECLARE_NEW_CORBA_ENV; + method_request.execute (ACE_ENV_SINGLE_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.h b/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.h new file mode 100644 index 00000000000..81ca7876efb --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.h @@ -0,0 +1,48 @@ +/* -*- C++ -*- */ +/** + * @file Reactive_Task.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_REACTIVE_TASK_H +#define TAO_NS_REACTIVE_TASK_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Worker_Task.h" + +/** + * @class TAO_NS_Reactive_Task + * + * @brief A reactive worker task. Simply executes the command in the caller's context. + * + */ +class TAO_Notify_Export TAO_NS_Reactive_Task : public TAO_NS_Worker_Task +{ +public: + /// Constuctor + TAO_NS_Reactive_Task (void); + + /// Destructor + ~TAO_NS_Reactive_Task (); + + /// Exec the request. + virtual void exec (TAO_NS_Method_Request& method_request); +}; + +#if defined (__ACE_INLINE__) +#include "Reactive_Task.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_REACTIVE_TASK_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.inl b/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Reactive_Task.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Refcountable.cpp b/TAO/orbsvcs/orbsvcs/Notify/Refcountable.cpp new file mode 100644 index 00000000000..46178ac6b46 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Refcountable.cpp @@ -0,0 +1,59 @@ +// $Id$ + +#include "Refcountable.h" +#include "Destroy_Callback.h" + +#include "tao/debug.h" + +#if ! defined (__ACE_INLINE__) +#include "Refcountable.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Refcountable, "$Id$") + +TAO_NS_Refcountable::TAO_NS_Refcountable (void) + :refcount_ (1) +{ +} + +TAO_NS_Refcountable::~TAO_NS_Refcountable () +{ +} + +CORBA::ULong +TAO_NS_Refcountable::_incr_refcnt (void) +{ + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0); + + if (TAO_debug_level > 0 ) + ACE_DEBUG ((LM_DEBUG,"object:%x incr refcount = %d\n", this, refcount_+1 )); + + + return this->refcount_++; +} + +CORBA::ULong +TAO_NS_Refcountable::_decr_refcnt (void) +{ + { + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0); + + if (TAO_debug_level > 0 ) + ACE_DEBUG ((LM_DEBUG,"object:%x decr refcount = %d\n", this, refcount_-1 )); + + this->refcount_--; + if (this->refcount_ != 0) + return this->refcount_; + } + + if (this->destroy_callback_ != 0) + this->destroy_callback_->release (); + + return 0; +} + +void +TAO_NS_Refcountable::destroy_callback (TAO_NS_Destroy_Callback* destroy_callback) +{ + destroy_callback_ = destroy_callback; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Refcountable.h b/TAO/orbsvcs/orbsvcs/Notify/Refcountable.h new file mode 100644 index 00000000000..33dbbb22ed7 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Refcountable.h @@ -0,0 +1,66 @@ +/* -*- C++ -*- */ +/** + * @file Refcountable.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_REFCOUNTABLE_H +#define TAO_NS_REFCOUNTABLE_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Synch_T.h" +#include "tao/orbconf.h" +#include "tao/corbafwd.h" + +class TAO_NS_Destroy_Callback; + +/** + * @class TAO_NS_Refcountable + * + * @brief Thread-safe refounting, calls a Destroy_Callback when refcount falls to 0. + * + */ +class TAO_Notify_Export TAO_NS_Refcountable +{ +public: + /// Constuctor + TAO_NS_Refcountable (void); + + /// Destructor + ~TAO_NS_Refcountable (); + + /// Set the destroy callback. + void destroy_callback (TAO_NS_Destroy_Callback* destroy_callback); + + /// This method sigantures deliberately match the RefCounting methods required for ESF Proxy + CORBA::ULong _incr_refcnt (void); + CORBA::ULong _decr_refcnt (void); + +protected: + /// The reference count. + CORBA::ULong refcount_; + + /// The mutex to serialize access to state variables. + TAO_SYNCH_MUTEX lock_; + + /// The callback when refcount falls to 0. + TAO_NS_Destroy_Callback* destroy_callback_; +}; + +#if defined (__ACE_INLINE__) +#include "Refcountable.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_REFCOUNTABLE_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Refcountable.inl b/TAO/orbsvcs/orbsvcs/Notify/Refcountable.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Refcountable.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/EventBatch.cpp b/TAO/orbsvcs/orbsvcs/Notify/Sequence/EventBatch.cpp new file mode 100644 index 00000000000..8e19f095b41 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/EventBatch.cpp @@ -0,0 +1,71 @@ +// $Id$ + +#include "EventBatch.h" + +#if ! defined (__ACE_INLINE__) +#include "EventBatch.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_EventBatch, "$id$") + +#include "ace/Refcounted_Auto_Ptr.h" +#include "../Event.h" + +TAO_NS_EventBatch::TAO_NS_EventBatch (void) + :batch_size_ (1) +{ +} + +TAO_NS_EventBatch::~TAO_NS_EventBatch () +{ +} + +void +TAO_NS_EventBatch::insert (const TAO_NS_Event_var& event) +{ + this->event_collection_.enqueue_tail (event); +} + +void +TAO_NS_EventBatch::insert (const TAO_NS_Event_Collection& event_collection) +{ + TAO_NS_Event_var* item = 0; + + for (size_t i = 0; i < event_collection.size (); ++i) + { + if (event_collection.get (item, i) == 0) + this->event_collection_.enqueue_tail (*item); + } +} + +void +TAO_NS_EventBatch::extract (TAO_NS_Event_Collection& event_collection) +{ + int copy_length = this->event_collection_.size () <= this->batch_size_ ? + this->event_collection_.size () : this->batch_size_; + + for (int i = 0; i < copy_length; ++i) + { + TAO_NS_Event_var item; + + if (this->event_collection_.dequeue_head (item) == 0) + event_collection.enqueue_tail (item); + } +} + +void +TAO_NS_EventBatch::populate (const TAO_NS_Event_Collection& event_collection, CosNotification::EventBatch& event_batch) +{ + TAO_NS_Event_var* item = 0; + + event_batch.length (event_collection.size ()); + + for (size_t i = 0; i < event_collection.size (); ++i) + { + if (event_collection.get (item, i) == 0) + { + // Convert item to CosNotification::StructuredEvent + (*item)->convert (event_batch[i]); + } + } +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/EventBatch.h b/TAO/orbsvcs/orbsvcs/Notify/Sequence/EventBatch.h new file mode 100644 index 00000000000..0330fe78061 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/EventBatch.h @@ -0,0 +1,71 @@ +/* -*- C++ -*- */ +/** + * @file EventBatch.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_EVENTBATCH_H +#define TAO_NS_EVENTBATCH_H +#include "ace/pre.h" + +#include "../notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Unbounded_Queue.h" +#include "orbsvcs/CosNotificationC.h" +#include "../Event.h" +#include "../Types.h" + +/** + * @class TAO_NS_EventBatch + * + * @brief + * + */ +class TAO_Notify_Export TAO_NS_EventBatch +{ +public: + /// Constructor + TAO_NS_EventBatch (void); + + /// Destructor. + ~TAO_NS_EventBatch (void); + + /// Set the Batch size. + void batch_size (CORBA::Long batch_size); + + /// Insert + void insert (const TAO_NS_Event_var& event); + + /// Insert + void insert (const TAO_NS_Event_Collection& event_collection); + + /// Populate the event_batch with max size <batch_size_> + /// The first <batch_size_> number of events are removed. + void extract (TAO_NS_Event_Collection& event_collection); + + /// Populate <event_batch> with <event_collection> + static void populate (const TAO_NS_Event_Collection& event_collection, CosNotification::EventBatch& event_batch); + +protected: + // Event Batch + TAO_NS_Event_Collection event_collection_; + + /// Max. batch size. + CORBA::Long batch_size_; +}; + +#if defined (__ACE_INLINE__) +#include "EventBatch.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_EVENTBATCH_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/EventBatch.inl b/TAO/orbsvcs/orbsvcs/Notify/Sequence/EventBatch.inl new file mode 100644 index 00000000000..b934c9deeef --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/EventBatch.inl @@ -0,0 +1,9 @@ +// $Id$ + +#include "EventBatch.h" + +ACE_INLINE void +TAO_NS_EventBatch::batch_size (CORBA::Long batch_size) +{ + this->batch_size_ = batch_size; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/Method_Request_Dispatch_EventBatch.cpp b/TAO/orbsvcs/orbsvcs/Notify/Sequence/Method_Request_Dispatch_EventBatch.cpp new file mode 100644 index 00000000000..c9655a80921 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/Method_Request_Dispatch_EventBatch.cpp @@ -0,0 +1,58 @@ +// $Id$ + +#include "Method_Request_Dispatch_EventBatch.h" + +#if ! defined (__ACE_INLINE__) +#include "Method_Request_Dispatch_EventBatch.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_Method_Request_Dispatch_EventBatch, "$id$") + +#include "SequencePushConsumer.h" +#include "../Proxy.h" + +TAO_NS_Method_Request_Dispatch_EventBatch::TAO_NS_Method_Request_Dispatch_EventBatch (TAO_NS_Event_Collection& event_collection, TAO_NS_SequencePushConsumer* consumer) + :consumer_ (consumer), event_collection_ (event_collection) +{ + consumer_->_incr_refcnt (); +} + +TAO_NS_Method_Request_Dispatch_EventBatch::~TAO_NS_Method_Request_Dispatch_EventBatch () +{ + consumer_->_decr_refcnt (); +} + +TAO_NS_Method_Request* +TAO_NS_Method_Request_Dispatch_EventBatch::copy (void) +{ + /// @@use factory + return new TAO_NS_Method_Request_Dispatch_EventBatch (this->event_collection_, this->consumer_); +} + +int +TAO_NS_Method_Request_Dispatch_EventBatch::execute (ACE_ENV_SINGLE_ARG_DECL) +{ + if (this->consumer_->proxy ()->has_shutdown ()) + return 0; // If we were shutdown while waiting in the queue, return with no action. + + ACE_TRY + { + this->consumer_->push (this->event_collection_ ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::UserException, ue) + { + ACE_PRINT_EXCEPTION (ue, + "TAO_NS_Method_Request_Dispatch_EventBatch::: error sending event. "); + //ACE_RE_THROW; + } + ACE_CATCH (CORBA::SystemException, se) + { + ACE_PRINT_EXCEPTION (se, + "TAO_NS_Method_Request_Dispatch_EventBatch:: error sending event. "); + //ACE_RE_THROW; + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/Method_Request_Dispatch_EventBatch.h b/TAO/orbsvcs/orbsvcs/Notify/Sequence/Method_Request_Dispatch_EventBatch.h new file mode 100644 index 00000000000..b3a63cabfbd --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/Method_Request_Dispatch_EventBatch.h @@ -0,0 +1,64 @@ +/* -*- C++ -*- */ +/** + * @file Method_Request_Dispatch_EventBatch.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_METHOD_REQUEST_DISPATCH_EVENTBATCH_H +#define TAO_NS_METHOD_REQUEST_DISPATCH_EVENTBATCH_H +#include "ace/pre.h" + +#include "../notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Unbounded_Queue.h" +#include "orbsvcs/CosNotificationC.h" +#include "../Method_Request.h" +#include "../Types.h" +#include "../Event.h" + +class TAO_NS_SequencePushConsumer; + +/** + * @class TAO_NS_Method_Request_Dispatch_EventBatch + * + * @brief + * + */ +class TAO_Notify_Export TAO_NS_Method_Request_Dispatch_EventBatch : public TAO_NS_Method_Request +{ +public: + /// Constuctor + TAO_NS_Method_Request_Dispatch_EventBatch (TAO_NS_Event_Collection& event_collection, TAO_NS_SequencePushConsumer* consumer); + + /// Destructor + ~TAO_NS_Method_Request_Dispatch_EventBatch (); + + /// Execute the Request + int execute (ACE_ENV_SINGLE_ARG_DECL); + + /// Create a copy of this object. + TAO_NS_Method_Request* copy (void); + +protected: + /// The consumer to push to. + TAO_NS_SequencePushConsumer* consumer_; + + /// Event Collection + TAO_NS_Event_Collection event_collection_; +}; + +#if defined (__ACE_INLINE__) +#include "Method_Request_Dispatch_EventBatch.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_METHOD_REQUEST_DISPATCH_EVENTBATCH_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/Method_Request_Dispatch_EventBatch.inl b/TAO/orbsvcs/orbsvcs/Notify/Sequence/Method_Request_Dispatch_EventBatch.inl new file mode 100644 index 00000000000..334338e26b3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/Method_Request_Dispatch_EventBatch.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "Method_Request_Dispatch_EventBatch.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushConsumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushConsumer.cpp new file mode 100644 index 00000000000..2d2cc7468ea --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushConsumer.cpp @@ -0,0 +1,105 @@ +// $Id$ + +#include "SequenceProxyPushConsumer.h" + +#if ! defined (__ACE_INLINE__) +#include "SequenceProxyPushConsumer.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_SequenceProxyPushConsumer, "$id$") + +#include "ace/Refcounted_Auto_Ptr.h" +#include "tao/debug.h" +#include "SequencePushSupplier.h" +#include "EventBatch.h" +#include "../Admin.h" +#include "../AdminProperties.h" +#include "../Structured/StructuredEvent.h" + +TAO_NS_SequenceProxyPushConsumer::TAO_NS_SequenceProxyPushConsumer (void) +:pacing_interval_ (CosNotification::PacingInterval) +{ +} + +TAO_NS_SequenceProxyPushConsumer::~TAO_NS_SequenceProxyPushConsumer () +{ +} + +void +TAO_NS_SequenceProxyPushConsumer::release (void) +{ + delete this; + //@@ inform factory +} + +void +TAO_NS_SequenceProxyPushConsumer::destroy (ACE_ENV_SINGLE_ARG_DECL) +{ + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "In TAO_NS_SequenceProxyPushConsumer::destroy \n")); + + this->inherited::destroy (this ACE_ENV_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::ProxyType +TAO_NS_SequenceProxyPushConsumer::MyType (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return CosNotifyChannelAdmin::PUSH_SEQUENCE; +} + +void +TAO_NS_SequenceProxyPushConsumer::connect_sequence_push_supplier (CosNotifyComm::SequencePushSupplier_ptr push_supplier ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosEventChannelAdmin::AlreadyConnected + )) +{ + // Convert Supplier to Base Type + TAO_NS_SequencePushSupplier *supplier; + ACE_NEW_THROW_EX (supplier, + TAO_NS_SequencePushSupplier (this), + CORBA::NO_MEMORY ()); + + supplier->init (push_supplier ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->connect (supplier ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_SequenceProxyPushConsumer::push_structured_events (const CosNotification::EventBatch& event_batch ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosEventComm::Disconnected + )) +{ + // Check if we should proceed at all. + if (this->admin_properties_->reject_new_events () == 1 && this->admin_properties_->queue_full ()) + ACE_THROW (CORBA::IMP_LIMIT ()); + + if (this->is_connected () == 0) + { + ACE_THROW (CosEventComm::Disconnected ()); + } + + for (CORBA::ULong i = 0; i < event_batch.length (); ++i) + { + const CosNotification::StructuredEvent& notification = event_batch[i]; + + TAO_NS_Event_var event (new TAO_NS_StructuredEvent (notification)); + + this->push (event); + } +} + +void +TAO_NS_SequenceProxyPushConsumer::disconnect_sequence_push_consumer (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + this->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushConsumer.h b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushConsumer.h new file mode 100644 index 00000000000..647ce01b185 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushConsumer.h @@ -0,0 +1,98 @@ +/* -*- C++ -*- */ +/** + * @file SequenceProxyPushConsumer.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_SEQUENCEPROXYPUSHCONSUMER_H +#define TAO_NS_SEQUENCEPROXYPUSHCONSUMER_H +#include "ace/pre.h" + +#include "../notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyChannelAdminS.h" +#include "../ProxyConsumer_T.h" +#include "../Destroy_Callback.h" + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/** + * @class TAO_NS_SequenceProxyPushConsumer + * + * @brief + * + */ +class TAO_Notify_Export TAO_NS_SequenceProxyPushConsumer : public virtual TAO_NS_ProxyConsumer_T <POA_CosNotifyChannelAdmin::SequenceProxyPushConsumer>, public TAO_NS_Destroy_Callback +{ + friend class TAO_NS_Builder; +public: + /// Constuctor + TAO_NS_SequenceProxyPushConsumer (void); + + /// Destructor + ~TAO_NS_SequenceProxyPushConsumer (); + + /// TAO_NS_Destroy_Callback methods + virtual void release (void); + + /// Destroy this object. + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL); + +protected: + ///= Data Members + TAO_NS_Property_Time pacing_interval_; + + ///= Protected Methods + + //= interface methods + virtual CosNotifyChannelAdmin::ProxyType MyType (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void connect_sequence_push_supplier (CosNotifyComm::SequencePushSupplier_ptr push_supplier + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosEventChannelAdmin::AlreadyConnected + )); + + virtual void push_structured_events (const CosNotification::EventBatch & notifications + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosEventComm::Disconnected + )); + + virtual void disconnect_sequence_push_consumer (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__ACE_INLINE__) +#include "SequenceProxyPushConsumer.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_SEQUENCEPROXYPUSHCONSUMER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushConsumer.inl b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushConsumer.inl new file mode 100644 index 00000000000..5470ff89e39 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushConsumer.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "SequenceProxyPushConsumer.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushSupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushSupplier.cpp new file mode 100644 index 00000000000..fb3a6a72a6b --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushSupplier.cpp @@ -0,0 +1,83 @@ +// $Id$ + +#include "SequenceProxyPushSupplier.h" + +#if ! defined (__ACE_INLINE__) +#include "SequenceProxyPushSupplier.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_SequenceProxyPushSupplier, "$id$") + +#include "tao/debug.h" +#include "SequencePushConsumer.h" +#include "../Proxy.h" +#include "../Admin.h" +#include "../EventChannel.h" +#include "../EventChannelFactory.h" +#include "../Notify_Service.h" + + +TAO_NS_SequenceProxyPushSupplier::TAO_NS_SequenceProxyPushSupplier (void) +{ +} + +TAO_NS_SequenceProxyPushSupplier::~TAO_NS_SequenceProxyPushSupplier () +{ +} + +void +TAO_NS_SequenceProxyPushSupplier::destroy (ACE_ENV_SINGLE_ARG_DECL) +{ + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "In TAO_NS_SequenceProxyPushConsumer::destroy \n")); + + this->inherited::destroy (this ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_SequenceProxyPushSupplier::release (void) +{ + this->consumer_->release (); + + delete this; + //@@ inform factory +} + +void +TAO_NS_SequenceProxyPushSupplier::connect_sequence_push_consumer (CosNotifyComm::SequencePushConsumer_ptr push_consumer ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosEventChannelAdmin::AlreadyConnected + , CosEventChannelAdmin::TypeError + )) +{ + // Convert Consumer to Base Type + TAO_NS_SequencePushConsumer* consumer; + ACE_NEW_THROW_EX (consumer, + TAO_NS_SequencePushConsumer (this), + CORBA::NO_MEMORY ()); + + consumer->init (push_consumer ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->connect (consumer ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_SequenceProxyPushSupplier::disconnect_sequence_push_supplier (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) + +{ + this->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::ProxyType +TAO_NS_SequenceProxyPushSupplier::MyType (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return CosNotifyChannelAdmin::PUSH_SEQUENCE; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushSupplier.h b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushSupplier.h new file mode 100644 index 00000000000..0eba8479006 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushSupplier.h @@ -0,0 +1,89 @@ +/* -*- C++ -*- */ +/** + * @file SequenceProxyPushSupplier.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_SEQUENCEPROXYPUSHSUPPLIER_H +#define TAO_NS_SEQUENCEPROXYPUSHSUPPLIER_H +#include "ace/pre.h" + +#include "../notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyChannelAdminS.h" +#include "../ProxySupplier_T.h" + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/** + * @class TAO_NS_SequenceProxyPushSupplier + * + * @brief Implements the CosNotifyChannelAdmin::SequenceProxyPushSupplier methods. + * + * + */ +class TAO_Notify_Export TAO_NS_SequenceProxyPushSupplier : public virtual TAO_NS_ProxySupplier_T <POA_CosNotifyChannelAdmin::SequenceProxyPushSupplier>, public TAO_NS_Destroy_Callback +{ + friend class TAO_NS_Builder; + +public: + /// Constuctor + TAO_NS_SequenceProxyPushSupplier (void); + + /// Destructor + ~TAO_NS_SequenceProxyPushSupplier (); + + /// Destroy this object. + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL); + + /// TAO_NS_Destroy_Callback methods + virtual void release (void); + + /// = Servant methods + virtual CosNotifyChannelAdmin::ProxyType MyType (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void connect_sequence_push_consumer ( + CosNotifyComm::SequencePushConsumer_ptr push_consumer + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosEventChannelAdmin::AlreadyConnected, + CosEventChannelAdmin::TypeError + )); + + virtual void disconnect_sequence_push_supplier ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__ACE_INLINE__) +#include "SequenceProxyPushSupplier.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_SEQUENCEPROXYPUSHSUPPLIER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushSupplier.inl b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushSupplier.inl new file mode 100644 index 00000000000..5f4ceeb6181 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequenceProxyPushSupplier.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "SequenceProxyPushSupplier.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.cpp new file mode 100644 index 00000000000..d5830fdb6da --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.cpp @@ -0,0 +1,227 @@ +// $Id$ + +#include "SequencePushConsumer.h" + +#if ! defined (__ACE_INLINE__) +#include "SequencePushConsumer.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_SequencePushConsumer, "$id$") + +#include "ace/Reactor.h" +#include "tao/ORB_Core.h" +#include "../QoSProperties.h" +#include "../Properties.h" +#include "../ProxySupplier.h" +#include "../Worker_Task.h" +#include "../Consumer.h" +#include "../Dispatch_Observer_T.h" +#include "Method_Request_Dispatch_EventBatch.h" +#include "EventBatch.h" + +TAO_NS_SequencePushConsumer::TAO_NS_SequencePushConsumer (TAO_NS_ProxySupplier* proxy) + :TAO_NS_Consumer (proxy), pacing_interval_ (CosNotification::PacingInterval), timer_id_ (-1) +{ +} + +TAO_NS_SequencePushConsumer::~TAO_NS_SequencePushConsumer () +{ +} + +void +TAO_NS_SequencePushConsumer::init (CosNotifyComm::SequencePushConsumer_ptr push_consumer ACE_ENV_ARG_DECL) +{ + this->push_consumer_ = CosNotifyComm::SequencePushConsumer::_duplicate (push_consumer); + + ACE_TRY + { + this->publish_ = CosNotifyComm::NotifyPublish::_narrow (push_consumer ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + // Ignore + // if the client is not running an event loop and _narrow goes remote, we get a transient exception! + } + ACE_ENDTRY; +} + +void +TAO_NS_SequencePushConsumer::shutdown (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + // Get the ORB + CORBA::ORB_var orb = TAO_NS_PROPERTIES::instance()->orb (); + + ACE_Reactor* reactor = orb->orb_core ()->reactor (); + + this->cancel_timer (reactor); +} + +void +TAO_NS_SequencePushConsumer::release (void) +{ + delete this; + //@@ inform factory +} + +void +TAO_NS_SequencePushConsumer::qos_changed (TAO_NS_QoSProperties& qos_properties) +{ + const TAO_NS_Property_Long& maximum_batch_size = qos_properties.maximum_batch_size (); + + if (maximum_batch_size.is_valid ()) + this->event_batch_.batch_size (maximum_batch_size.value ()); + + this->pacing_interval_ = qos_properties.pacing_interval (); + + if (!this->pacing_interval_.is_valid ()) + return; + + // Get the ORB + CORBA::ORB_var orb = TAO_NS_PROPERTIES::instance()->orb (); + + ACE_Reactor* reactor = orb->orb_core ()->reactor (); + + if (this->cancel_timer (reactor) != 1) // Cancel existing timer. + return; + + if (this->pacing_interval_.value () != ACE_Time_Value::zero) + this->schedule_timer (reactor); +} + +int +TAO_NS_SequencePushConsumer::cancel_timer (ACE_Reactor* reactor) +{ + if (this->timer_id_ == -1) + return 1; + else + return reactor->cancel_timer (this->timer_id_); +} + +void +TAO_NS_SequencePushConsumer::schedule_timer (ACE_Reactor* reactor) +{ + TimeBase::TimeT pacing_interval = this->pacing_interval_.value(); + +# if defined (ACE_CONFIG_WIN32_H) + ACE_Time_Value interval (ACE_static_cast (long, pacing_interval)); +# else + ACE_Time_Value interval (pacing_interval / 1); +# endif /* ACE_CONFIG_WIN32_H */ + + // Schedule the timer. + this->timer_id_ = reactor->schedule_timer (this, 0, interval, interval); + + if (this->timer_id_ == -1) + { + // Failed to set the timer, treat as if no timer was required. + //this->pacing_interval_ = 0;//ACE_Time_Value::zero; + } +} + +void +TAO_NS_SequencePushConsumer::push_i (const TAO_NS_Event_var& event ACE_ENV_ARG_DECL_NOT_USED) +{ + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, *this->proxy_lock ()); + this->event_batch_.insert (event); + } + + if (this->timer_id_ == -1 && this->is_suspended_ == 0) + this->dispatch_immediate (); +} + +void +TAO_NS_SequencePushConsumer::push (const CORBA::Any& /*event*/ ACE_ENV_ARG_DECL_NOT_USED) +{ + //NOP +} + +void +TAO_NS_SequencePushConsumer::push (const CosNotification::StructuredEvent& /*notification*/ ACE_ENV_ARG_DECL_NOT_USED) +{ + //NOP +} + +void +TAO_NS_SequencePushConsumer::dispatch_immediate (void) +{ + TAO_NS_Event_Collection event_collection; + + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, *this->proxy_lock ()); + this->event_batch_.extract (event_collection); + } + + ACE_DECLARE_NEW_CORBA_ENV; + this->push (event_collection ACE_ENV_ARG_PARAMETER); +} + +int +TAO_NS_SequencePushConsumer::handle_timeout (const ACE_Time_Value& /*current_time*/, + const void* /*act*/) +{ + TAO_NS_Event_Collection event_collection; + + { + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, *this->proxy_lock (), 0); + this->event_batch_.extract (event_collection); + } + + TAO_NS_Method_Request_Dispatch_EventBatch request (event_collection, this); + + this->proxy_->worker_task ()->exec (request); + + return 0; +} + +void +TAO_NS_SequencePushConsumer::push (const TAO_NS_Event_Collection event_collection ACE_ENV_ARG_DECL) +{ + if (this->is_suspended_ == 1) // If we're suspended, queue for later delivery. + { + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, *this->proxy_lock ()); + this->event_batch_.insert (event_collection); + } + } + + ACE_TRY + { + CosNotification::EventBatch event_batch; + + TAO_NS_EventBatch::populate (event_collection, event_batch); + + this->push_consumer_->push_structured_events (event_batch ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (this->event_dispatch_observer_ != 0) + { + this->event_dispatch_observer_->dispatch_success (this ACE_ENV_ARG_PARAMETER); + + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, *this->proxy_lock ()); + this->retry_count_ = 0; + } + } + ACE_CATCHANY + { + if (TAO_debug_level > 0) + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "TAO_NS_SequenceConsumer::push: error sending event. informing dispatch observer\n "); + } + //ACE_RE_THROW; + + if (this->event_dispatch_observer_ != 0) + { + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, *this->proxy_lock ()); + + ++this->retry_count_; + this->event_batch_.insert (event_collection); + } + + this->event_dispatch_observer_->dispatch_failure (this, this->retry_count_ ACE_ENV_ARG_PARAMETER); + } + } + ACE_ENDTRY; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.h b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.h new file mode 100644 index 00000000000..9d8f4aa9068 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.h @@ -0,0 +1,108 @@ +/* -*- C++ -*- */ +/** + * @file SequencePushConsumer.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_SEQUENCEPUSHCONSUMER_H +#define TAO_NS_SEQUENCEPUSHCONSUMER_H +#include "ace/pre.h" + +#include "../notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Event_Handler.h" +#include "../Event.h" +#include "../Property.h" +#include "../Property_T.h" +#include "../Consumer.h" +#include "EventBatch.h" + +class ACE_Reactor; +class TAO_NS_ProxySupplier; +class TAO_NS_QoSProperties; + +/** + * @class TAO_NS_SequencePushConsumer + * + * @brief + * + */ +class TAO_Notify_Export TAO_NS_SequencePushConsumer : public ACE_Event_Handler, public TAO_NS_Consumer +{ +public: + /// Constuctor + TAO_NS_SequencePushConsumer (TAO_NS_ProxySupplier* proxy); + + /// Destructor + ~TAO_NS_SequencePushConsumer (); + + /// Init the Consumer + void init (CosNotifyComm::SequencePushConsumer_ptr push_consumer ACE_ENV_ARG_DECL); + + /// Shutdown the consumer + virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL); + + /// TAO_NS_Destroy_Callback methods. + virtual void release (void); + + /// Push <event> to this consumer. + void push_i (const TAO_NS_Event_var& event ACE_ENV_ARG_DECL); + + /// Push <event> to this consumer. + virtual void push (const CORBA::Any& event ACE_ENV_ARG_DECL); + + // Push event. + virtual void push (const CosNotification::StructuredEvent & event ACE_ENV_ARG_DECL); + + /// Push <event> to this consumer. + // virtual void push (const CosNotification::EventBatch& event ACE_ENV_ARG_DECL); + + /// Push Collection. + void push (const TAO_NS_Event_Collection event_collection ACE_ENV_ARG_DECL); + + /// Override, Peer::qos_changed + virtual void qos_changed (TAO_NS_QoSProperties& qos_properties); + +protected: + /// When the pacing interval is used, handle_timeout () is called by + /// the reactor. + virtual int handle_timeout (const ACE_Time_Value& current_time, + const void* act = 0); + + /// Dispatch events immediately if no pacing is set. + void dispatch_immediate (void); + + /// Schedule timer + void schedule_timer (ACE_Reactor* reactor); + + /// Cancel timer. Return 1 on success. + int cancel_timer (ACE_Reactor* reactor); + + /// The Pacing Interval + TAO_NS_Property_Time pacing_interval_; + + /// Timer Id. + long timer_id_; + + /// The Consumer + CosNotifyComm::SequencePushConsumer_var push_consumer_; + + /// EventBatch + TAO_NS_EventBatch event_batch_; +}; + +#if defined (__ACE_INLINE__) +#include "SequencePushConsumer.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_SEQUENCEPUSHCONSUMER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.inl b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.inl new file mode 100644 index 00000000000..d050292323e --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushConsumer.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "SequencePushConsumer.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushSupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushSupplier.cpp new file mode 100644 index 00000000000..04e35ce779b --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushSupplier.cpp @@ -0,0 +1,33 @@ +// $Id$ + +#include "SequencePushSupplier.h" + +#if ! defined (__ACE_INLINE__) +#include "SequencePushSupplier.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_NS_SequencePushSupplier, "$id$") + +TAO_NS_SequencePushSupplier::TAO_NS_SequencePushSupplier (TAO_NS_ProxyConsumer* proxy) + :TAO_NS_Supplier (proxy) +{ +} + +TAO_NS_SequencePushSupplier::~TAO_NS_SequencePushSupplier () +{ +} + +void +TAO_NS_SequencePushSupplier::init (CosNotifyComm::SequencePushSupplier_ptr push_supplier ACE_ENV_ARG_DECL) +{ + this->push_supplier_ = CosNotifyComm::SequencePushSupplier::_duplicate (push_supplier); + + this->subscribe_ = CosNotifyComm::NotifySubscribe::_narrow (push_supplier ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_SequencePushSupplier::release (void) +{ + delete this; + //@@ inform factory +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushSupplier.h b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushSupplier.h new file mode 100644 index 00000000000..b83256362da --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushSupplier.h @@ -0,0 +1,59 @@ +/* -*- C++ -*- */ +/** + * @file SequencePushSupplier.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_SEQUENCEPUSHSUPPLIER_H +#define TAO_NS_SEQUENCEPUSHSUPPLIER_H +#include "ace/pre.h" + +#include "../notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyCommC.h" +#include "../Supplier.h" +#include "../Destroy_Callback.h" + +class TAO_NS_ProxyConsumer; + +/** + * @class TAO_NS_SequencePushSupplier + * + * @brief Wrapper for the SequencePushSupplier that connect to the EventChannel. + * + */ +class TAO_Notify_Export TAO_NS_SequencePushSupplier : public TAO_NS_Supplier +{ +public: + /// Constuctor + TAO_NS_SequencePushSupplier (TAO_NS_ProxyConsumer* proxy); + + /// Destructor + ~TAO_NS_SequencePushSupplier (); + + /// Init + void init (CosNotifyComm::SequencePushSupplier_ptr push_supplier ACE_ENV_ARG_DECL); + + /// TAO_NS_Destroy_Callback methods + virtual void release (void); + +protected: + /// The Supplier + CosNotifyComm::SequencePushSupplier_var push_supplier_; +}; + +#if defined (__ACE_INLINE__) +#include "SequencePushSupplier.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_SEQUENCEPUSHSUPPLIER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushSupplier.inl b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushSupplier.inl new file mode 100644 index 00000000000..507cd0b85c6 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Sequence/SequencePushSupplier.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "SequencePushSupplier.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Service.h b/TAO/orbsvcs/orbsvcs/Notify/Service.h new file mode 100644 index 00000000000..37575cef1a7 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Service.h @@ -0,0 +1,44 @@ +/* -*- C++ -*- */ +/** + * @file Service.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_SERVICE_H +#define TAO_NS_SERVICE_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Service_Config.h" +#include "orbsvcs/CosNotifyChannelAdminS.h" +#include "tao/PortableServer/PortableServer.h" + +/** + * @class TAO_NS_Service + * + * @brief Abstract ACE_Service_Object interface that is a factory for creating a Notify EventChannelFactory. + * Note that a Service creates only 1 Factory object. + * + */ +class TAO_Notify_Export TAO_NS_Service : public ACE_Service_Object +{ +public: + /// Init the service. + virtual void init (CORBA::ORB_ptr orb ACE_ENV_ARG_DECL) = 0; + + /// Create the Channel Factory. + virtual CosNotifyChannelAdmin::EventChannelFactory_ptr create (PortableServer::POA_ptr default_POA ACE_ENV_ARG_DECL) = 0; +}; + +#include "ace/post.h" +#endif /* TAO_NS_SERVICE_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/RTCORBA_StructuredProxyPushConsumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Structured/RTCORBA_StructuredProxyPushConsumer.cpp new file mode 100644 index 00000000000..59a846d63b2 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/RTCORBA_StructuredProxyPushConsumer.cpp @@ -0,0 +1,27 @@ +// $Id$ + +#include "RTCORBA_StructuredProxyPushConsumer.h" + +#if ! defined (__ACE_INLINE__) +#include "RTCORBA_StructuredProxyPushConsumer.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_RTCORBA_StructuredProxyPushConsumer, "$Id$") + +#include "ace/Refcounted_Auto_Ptr.h" +#include "StructuredEvent.h" +#include "../Proxy.h" +#include "../Admin.h" +#include "../EventChannel.h" +#include "../EventChannelFactory.h" +#include "../Notify_Service.h" + +TAO_NS_RTCORBA_StructuredProxyPushConsumer::TAO_NS_RTCORBA_StructuredProxyPushConsumer (void) +{ +} + +TAO_NS_RTCORBA_StructuredProxyPushConsumer::~TAO_NS_RTCORBA_StructuredProxyPushConsumer () +{ +} + + diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/RTCORBA_StructuredProxyPushConsumer.h b/TAO/orbsvcs/orbsvcs/Notify/Structured/RTCORBA_StructuredProxyPushConsumer.h new file mode 100644 index 00000000000..4d2d1bd9f2f --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/RTCORBA_StructuredProxyPushConsumer.h @@ -0,0 +1,46 @@ +/* -*- C++ -*- */ +/** + * @file RTCORBA_StructuredProxyPushConsumer.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_RTCORBA_STRUCTUREDPROXYPUSHCONSUMER_H +#define TAO_NS_RTCORBA_STRUCTUREDPROXYPUSHCONSUMER_H +#include "ace/pre.h" + +#include "../rt_notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "StructuredProxyPushConsumer.h" +#include "../RTCORBA_ProxyConsumer.h" + +/** + * @class TAO_NS_RTCORBA_StructuredProxyPushConsumer + * + * @brief RTCORBA specific StructuredProxyPushConsumer + * + */ +class TAO_RT_Notify_Export TAO_NS_RTCORBA_StructuredProxyPushConsumer : public TAO_NS_StructuredProxyPushConsumer, public TAO_NS_RTCORBA_ProxyConsumer +{ +public: + /// Constuctor + TAO_NS_RTCORBA_StructuredProxyPushConsumer (void); + + /// Destructor + ~TAO_NS_RTCORBA_StructuredProxyPushConsumer (); +}; + +#if defined (__ACE_INLINE__) +#include "RTCORBA_StructuredProxyPushConsumer.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_RTCORBA_STRUCTUREDPROXYPUSHCONSUMER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/RTCORBA_StructuredProxyPushConsumer.inl b/TAO/orbsvcs/orbsvcs/Notify/Structured/RTCORBA_StructuredProxyPushConsumer.inl new file mode 100644 index 00000000000..cf92fc592e7 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/RTCORBA_StructuredProxyPushConsumer.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "RTCORBA_StructuredProxyPushConsumer.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/RTCORBA_StructuredProxyPushSupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/Structured/RTCORBA_StructuredProxyPushSupplier.cpp new file mode 100644 index 00000000000..b1a74162e55 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/RTCORBA_StructuredProxyPushSupplier.cpp @@ -0,0 +1,47 @@ +// $Id$ + +#include "RTCORBA_StructuredProxyPushSupplier.h" + +#if ! defined (__ACE_INLINE__) +#include "RTCORBA_StructuredProxyPushSupplier.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_RTCORBA_StructuredProxyPushSupplier, "$Id$") + +#include "tao/debug.h" +#include "StructuredPushConsumer.h" +#include "StructuredEvent.h" +#include "../Worker_Task.h" +#include "../RTCORBA_Properties.h" +#include "../Method_Request_Dispatch.h" +#include "../Method_Request_Dispatch_No_Filtering.h" +#include "../Event_Manager.h" +#include "../Proxy.h" +#include "../Admin.h" +#include "../EventChannel.h" +#include "../EventChannelFactory.h" +#include "../Notify_Service.h" + +TAO_NS_RTCORBA_StructuredProxyPushSupplier::TAO_NS_RTCORBA_StructuredProxyPushSupplier (void) +{ +} + +TAO_NS_RTCORBA_StructuredProxyPushSupplier::~TAO_NS_RTCORBA_StructuredProxyPushSupplier () +{ +} + +void +TAO_NS_RTCORBA_StructuredProxyPushSupplier::destroy (ACE_ENV_SINGLE_ARG_DECL) +{ + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "In TAO_NS_RTCORBA_StructuredProxyPushConsumer::destroy \n")); + + this->inherited::destroy (this ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_RTCORBA_StructuredProxyPushSupplier::release (void) +{ + delete this; + //@@ inform factory +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/RTCORBA_StructuredProxyPushSupplier.h b/TAO/orbsvcs/orbsvcs/Notify/Structured/RTCORBA_StructuredProxyPushSupplier.h new file mode 100644 index 00000000000..cae53487ad5 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/RTCORBA_StructuredProxyPushSupplier.h @@ -0,0 +1,54 @@ +/* -*- C++ -*- */ +/** + * @file RTCORBA_StructuredProxyPushSupplier.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_RTCORBA_STRUCTUREDPROXYPUSHSUPPLIER_H +#define TAO_NS_RTCORBA_STRUCTUREDPROXYPUSHSUPPLIER_H +#include "ace/pre.h" + +#include "../rt_notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "StructuredProxyPushSupplier.h" +#include "../RTCORBA_ProxySupplier.h" + +/** + * @class TAO_NS_RTCORBA_StructuredProxyPushSupplier + * + * @brief RTCORBA specific StructuredProxyPushSupplier + * + */ +class TAO_RT_Notify_Export TAO_NS_RTCORBA_StructuredProxyPushSupplier : public virtual TAO_NS_StructuredProxyPushSupplier, public TAO_NS_RTCORBA_ProxySupplier +{ + friend class TAO_NS_Builder; + +public: + /// Constuctor + TAO_NS_RTCORBA_StructuredProxyPushSupplier (void); + + /// Destructor + ~TAO_NS_RTCORBA_StructuredProxyPushSupplier (); + + /// Destroy this object. + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL); + + /// TAO_NS_Destroy_Callback methods + virtual void release (void); +}; + +#if defined (__ACE_INLINE__) +#include "RTCORBA_StructuredProxyPushSupplier.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_RTCORBA_STRUCTUREDPROXYPUSHSUPPLIER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/RTCORBA_StructuredProxyPushSupplier.inl b/TAO/orbsvcs/orbsvcs/Notify/Structured/RTCORBA_StructuredProxyPushSupplier.inl new file mode 100644 index 00000000000..b667bb40908 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/RTCORBA_StructuredProxyPushSupplier.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "RTCORBA_StructuredProxyPushSupplier.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.cpp b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.cpp new file mode 100644 index 00000000000..61caa605668 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.cpp @@ -0,0 +1,92 @@ +// $Id$ + +#include "StructuredEvent.h" + +#if ! defined (__ACE_INLINE__) +#include "StructuredEvent.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_StructuredEvent, "$Id$") + +#include "../Consumer.h" +#include "tao/debug.h" + +TAO_NS_StructuredEvent::TAO_NS_StructuredEvent (const CosNotification::StructuredEvent ¬ification) + : notification_ (notification), type_ (notification.header.fixed_header.event_type) +{ + TAO_NS_PropertySeq qos; + + if (qos.init (this->notification_.header.variable_header) != -1) + { + this->priority_.set (qos); + this->timeout_.set (qos); + } +} + +const TAO_NS_EventType& +TAO_NS_StructuredEvent::type (void) const +{ + return this->type_; +} + +TAO_NS_StructuredEvent::~TAO_NS_StructuredEvent () +{ +} + +CORBA::Boolean +TAO_NS_StructuredEvent::do_match (CosNotifyFilter::Filter_ptr filter ACE_ENV_ARG_DECL) +{ + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - " + "TAO_Notify_StructuredEvent::do_match ()\n")); + + return filter->match_structured (this->notification_ ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_StructuredEvent::convert (CosNotification::StructuredEvent& notification) +{ + notification = this->notification_; +} + +void +TAO_NS_StructuredEvent::push (TAO_NS_Consumer* consumer ACE_ENV_ARG_DECL) const +{ + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - " + "TAO_Notify_StructuredEvent::do_push (" + "CosNotifyComm::StructuredPushConsumer_ptr)\n")); + + consumer->push (notification_ ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_StructuredEvent::push (Event_Forwarder::StructuredProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) +{ + forwarder->forward_structured (notification_ ACE_ENV_ARG_PARAMETER); +} +void +TAO_NS_StructuredEvent::push_no_filtering (Event_Forwarder::StructuredProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) +{ + forwarder->forward_structured_no_filtering (notification_ ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_StructuredEvent::push (Event_Forwarder::ProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) +{ + CORBA::Any any; + + TAO_NS_Event::translate (this->notification_, any); + + forwarder->forward_any (any ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_StructuredEvent::push_no_filtering (Event_Forwarder::ProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) +{ + CORBA::Any any; + + TAO_NS_Event::translate (this->notification_, any); + + forwarder->forward_any_no_filtering (any ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.h b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.h new file mode 100644 index 00000000000..5cf88887188 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.h @@ -0,0 +1,77 @@ +/* -*- C++ -*- */ +/** + * @file StructuredEvent.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ +#ifndef TAO_NS_STRUCTUREDEVENT_H +#define TAO_NS_STRUCTUREDEVENT_H + +#include "ace/pre.h" +#include "../notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "../Event.h" +#include "../EventType.h" +#include "orbsvcs/CosNotificationC.h" + +/** + * @class TAO_NS_StructuredEvent + * + * @brief StructuredEvent implementation. + * + */ + +class TAO_Notify_Export TAO_NS_StructuredEvent : public TAO_NS_Event +{ +public: + /// Constuctor + TAO_NS_StructuredEvent (const CosNotification::StructuredEvent& notification); + + /// Destructor + ~TAO_NS_StructuredEvent (); + + CORBA::Boolean do_match (CosNotifyFilter::Filter_ptr filter ACE_ENV_ARG_DECL); + + /// Convert to CosNotification::Structured type + virtual void convert (CosNotification::StructuredEvent& notification); + + /// Get the event type. + virtual const TAO_NS_EventType& type (void) const; + + /// Push event to consumer + virtual void push (TAO_NS_Consumer* consumer ACE_ENV_ARG_DECL) const; + + /// Push event to the Event_Forwarder interface + virtual void push (Event_Forwarder::StructuredProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL); + + /// Push event to the Event_Forwarder interface + virtual void push_no_filtering (Event_Forwarder::StructuredProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL); + + /// Push event to the Event_Forwarder interface + virtual void push (Event_Forwarder::ProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL); + + /// Push event to the Event_Forwarder interface + virtual void push_no_filtering (Event_Forwarder::ProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL); + +protected: + /// Structured Event + CosNotification::StructuredEvent notification_; + + /// Our type. + const TAO_NS_EventType type_; +}; + +#if defined (__ACE_INLINE__) +#include "StructuredEvent.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_STRUCTUREDEVENT_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.inl b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.inl new file mode 100644 index 00000000000..f92715e126c --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.inl @@ -0,0 +1,4 @@ +// $Id$ + +#include "StructuredEvent.h" + diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.cpp new file mode 100644 index 00000000000..465b476dae4 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.cpp @@ -0,0 +1,109 @@ +// $Id$ + +#include "StructuredProxyPushConsumer.h" + +#if ! defined (__ACE_INLINE__) +#include "StructuredProxyPushConsumer.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_StructuredProxyPushConsumer, "$Id$") + +#include "ace/Refcounted_Auto_Ptr.h" +#include "ace/Auto_Ptr.h" +#include "tao/debug.h" +#include "StructuredPushSupplier.h" +#include "StructuredEvent.h" +#include "../AdminProperties.h" +#include "../Proxy.h" +#include "../Admin.h" +#include "../EventChannel.h" +#include "../EventChannelFactory.h" +#include "../Notify_Service.h" + +TAO_NS_StructuredProxyPushConsumer::TAO_NS_StructuredProxyPushConsumer (void) +{ +} + +TAO_NS_StructuredProxyPushConsumer::~TAO_NS_StructuredProxyPushConsumer () +{ + +} + +void +TAO_NS_StructuredProxyPushConsumer::release (void) +{ + this->supplier_->release (); + + delete this; + //@@ inform factory +} + +void +TAO_NS_StructuredProxyPushConsumer::destroy (ACE_ENV_SINGLE_ARG_DECL) +{ + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "In TAO_NS_StructuredProxyPushConsumer::destroy \n")); + + this->inherited::destroy (this ACE_ENV_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::ProxyType +TAO_NS_StructuredProxyPushConsumer::MyType (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return CosNotifyChannelAdmin::PUSH_STRUCTURED; +} + +void +TAO_NS_StructuredProxyPushConsumer::connect_structured_push_supplier (CosNotifyComm::StructuredPushSupplier_ptr push_supplier ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosEventChannelAdmin::AlreadyConnected + )) +{ + // Convert Supplier to Base Type + TAO_NS_StructuredPushSupplier * supplier; + ACE_NEW_THROW_EX (supplier, + TAO_NS_StructuredPushSupplier (this), + CORBA::NO_MEMORY ()); + + supplier->init (push_supplier ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->connect (supplier ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_StructuredProxyPushConsumer::push_structured_event (const CosNotification::StructuredEvent & notification ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosEventComm::Disconnected + )) +{ + // Check if we should proceed at all. + if (this->admin_properties_->reject_new_events () == 1 + && this->admin_properties_->queue_full ()) + ACE_THROW (CORBA::IMP_LIMIT ()); + + if (this->is_connected () == 0) + { + ACE_THROW (CosEventComm::Disconnected ()); + } + + // Convert + TAO_NS_Event_var event (new TAO_NS_StructuredEvent (notification)); + + // Continue processing. + this->push (event); +} + +void +TAO_NS_StructuredProxyPushConsumer::disconnect_structured_push_consumer (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + this->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.h b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.h new file mode 100644 index 00000000000..1ece4fba9ab --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.h @@ -0,0 +1,99 @@ +/* -*- C++ -*- */ +/** + * @file StructuredProxyPushConsumer.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_STRUCTUREDPROXYPUSHCONSUMER_H +#define TAO_NS_STRUCTUREDPROXYPUSHCONSUMER_H +#include "ace/pre.h" + +#include "../notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyChannelAdminS.h" +#include "../ProxyConsumer_T.h" +#include "../Destroy_Callback.h" + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/** + * @class TAO_NS_StructuredProxyPushConsumer + * + * @brief CosNotifyChannelAdmin::StructuredProxyPushConsumer implementation. + * + */ +class TAO_Notify_Export TAO_NS_StructuredProxyPushConsumer : public virtual TAO_NS_ProxyConsumer_T <POA_CosNotifyChannelAdmin::StructuredProxyPushConsumer>, public TAO_NS_Destroy_Callback +{ + friend class TAO_NS_Builder; + +public: + /// Constuctor + TAO_NS_StructuredProxyPushConsumer (void); + + /// Destructor + ~TAO_NS_StructuredProxyPushConsumer (); + + /// TAO_NS_Destroy_Callback methods + virtual void release (void); + + /// Destroy this object. + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL); + +protected: + + // = interface methods + virtual CosNotifyChannelAdmin::ProxyType MyType (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void connect_structured_push_supplier ( + CosNotifyComm::StructuredPushSupplier_ptr push_supplier + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosEventChannelAdmin::AlreadyConnected + )); + +virtual void push_structured_event ( + const CosNotification::StructuredEvent & notification + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosEventComm::Disconnected + )); + + virtual void disconnect_structured_push_consumer ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__ACE_INLINE__) +#include "StructuredProxyPushConsumer.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_STRUCTUREDPROXYPUSHCONSUMER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.inl b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.inl new file mode 100644 index 00000000000..0ae697976e7 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushConsumer.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "StructuredProxyPushConsumer.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.cpp new file mode 100644 index 00000000000..0023cf697ad --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.cpp @@ -0,0 +1,84 @@ +// $Id$ + +#include "StructuredProxyPushSupplier.h" +#include "tao/PortableServer/Servant_Base.h" +#include "tao/debug.h" + +#include "StructuredPushConsumer.h" +#include "../Event_Manager.h" +#include "../Proxy.h" +#include "../Admin.h" +#include "../EventChannel.h" +#include "../EventChannelFactory.h" +#include "../Notify_Service.h" + +#if ! defined (__ACE_INLINE__) +#include "StructuredProxyPushSupplier.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_StructuredProxyPushSupplier, "$Id$") + +TAO_NS_StructuredProxyPushSupplier::TAO_NS_StructuredProxyPushSupplier (void) +{ +} + +TAO_NS_StructuredProxyPushSupplier::~TAO_NS_StructuredProxyPushSupplier () +{ +} + +void +TAO_NS_StructuredProxyPushSupplier::destroy (ACE_ENV_SINGLE_ARG_DECL) +{ + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "In TAO_NS_StructuredProxyPushConsumer::destroy \n")); + + this->inherited::destroy (this ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_StructuredProxyPushSupplier::release (void) +{ + this->consumer_->release (); + + delete this; + //@@ inform factory +} + +CosNotifyChannelAdmin::ProxyType +TAO_NS_StructuredProxyPushSupplier::MyType (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return CosNotifyChannelAdmin::PUSH_STRUCTURED; +} + +void +TAO_NS_StructuredProxyPushSupplier::connect_structured_push_consumer (CosNotifyComm::StructuredPushConsumer_ptr push_consumer ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosEventChannelAdmin::AlreadyConnected + , CosEventChannelAdmin::TypeError + )) +{ + // Convert Consumer to Base Type + TAO_NS_StructuredPushConsumer* consumer; + ACE_NEW_THROW_EX (consumer, + TAO_NS_StructuredPushConsumer (this), + CORBA::NO_MEMORY ()); + + consumer->init (push_consumer ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->connect (consumer ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_StructuredProxyPushSupplier::disconnect_structured_push_supplier (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) + +{ + this->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.h b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.h new file mode 100644 index 00000000000..3efcd5168ba --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.h @@ -0,0 +1,93 @@ +/* -*- C++ -*- */ +/** + * @file StructuredProxyPushSupplier.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_STRUCTUREDPROXYPUSHSUPPLIER_H +#define TAO_NS_STRUCTUREDPROXYPUSHSUPPLIER_H +#include "ace/pre.h" + +#include "../notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyChannelAdminS.h" +#include "orbsvcs/Event_ForwarderS.h" +#include "../ProxySupplier_T.h" + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/** + * @class TAO_NS_StructuredProxyPushSupplier + * + * @brief Implements the CosNotifyChannelAdmin::StructuredProxyPushSupplier methods. + * + * + */ +class TAO_Notify_Export TAO_NS_StructuredProxyPushSupplier : public virtual TAO_NS_ProxySupplier_T <POA_Event_Forwarder::StructuredProxyPushSupplier>, public TAO_NS_Destroy_Callback +{ + friend class TAO_NS_Builder; + +public: + /// Constuctor + TAO_NS_StructuredProxyPushSupplier (void); + + /// Destructor + ~TAO_NS_StructuredProxyPushSupplier (); + + /// Destroy this object. + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL); + + /// TAO_NS_Destroy_Callback methods + virtual void release (void); + + /// = Servant methods + // = interface methods + virtual CosNotifyChannelAdmin::ProxyType MyType (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void connect_structured_push_consumer ( + CosNotifyComm::StructuredPushConsumer_ptr push_consumer + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException, + CosEventChannelAdmin::AlreadyConnected, + CosEventChannelAdmin::TypeError + )); + + virtual void disconnect_structured_push_supplier ( + ACE_ENV_SINGLE_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__ACE_INLINE__) +#include "StructuredProxyPushSupplier.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_STRUCTUREDPROXYPUSHSUPPLIER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.inl b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.inl new file mode 100644 index 00000000000..1e0efbafba2 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredProxyPushSupplier.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "StructuredProxyPushSupplier.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.cpp b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.cpp new file mode 100644 index 00000000000..660e1c3e3ab --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.cpp @@ -0,0 +1,66 @@ +// $Id$ +#include "StructuredPushConsumer.h" +#include "ace/Refcounted_Auto_Ptr.h" +#include "../Event.h" + +#if ! defined (__ACE_INLINE__) +#include "StructuredPushConsumer.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_StructuredPushConsumer, "$Id$") + +TAO_NS_StructuredPushConsumer::TAO_NS_StructuredPushConsumer (TAO_NS_ProxySupplier* proxy) + :TAO_NS_Consumer (proxy) +{ +} + +TAO_NS_StructuredPushConsumer::~TAO_NS_StructuredPushConsumer () +{ +} + +void +TAO_NS_StructuredPushConsumer::init (CosNotifyComm::StructuredPushConsumer_ptr push_consumer ACE_ENV_ARG_DECL) +{ + this->push_consumer_ = CosNotifyComm::StructuredPushConsumer::_duplicate (push_consumer); + + ACE_TRY + { + this->publish_ = CosNotifyComm::NotifyPublish::_narrow (push_consumer ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + // Ignore + // if the client is not running an event loop and _narrow goes remote, we get a transient exception! + } + ACE_ENDTRY; +} + +void +TAO_NS_StructuredPushConsumer::release (void) +{ + delete this; + //@@ inform factory +} + +void +TAO_NS_StructuredPushConsumer::push_i (const TAO_NS_Event_var& event ACE_ENV_ARG_DECL) +{ + event->push (this ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_StructuredPushConsumer::push (const CORBA::Any& event ACE_ENV_ARG_DECL) +{ + CosNotification::StructuredEvent notification; + + TAO_NS_Event::translate (event, notification); + + this->push_consumer_->push_structured_event (notification ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_StructuredPushConsumer::push (const CosNotification::StructuredEvent& event ACE_ENV_ARG_DECL) +{ + this->push_consumer_->push_structured_event (event ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.h b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.h new file mode 100644 index 00000000000..64cff330f84 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.h @@ -0,0 +1,68 @@ +/* -*- C++ -*- */ +/** + * @file StructuredPushConsumer.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_STRUCTUREDPUSHCONSUMER_H +#define TAO_NS_STRUCTUREDPUSHCONSUMER_H +#include "ace/pre.h" + +#include "../notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyCommC.h" +#include "../Consumer.h" +#include "../Destroy_Callback.h" + +class TAO_NS_ProxySupplier; + +/** + * @class TAO_NS_StructuredPushConsumer + * + * @brief Wrapper for the StructuredPushConsumer that connect to the EventChannel. + * + */ +class TAO_Notify_Export TAO_NS_StructuredPushConsumer : public TAO_NS_Consumer +{ +public: + /// Constuctor + TAO_NS_StructuredPushConsumer (TAO_NS_ProxySupplier* proxy); + + /// Init the Consumer + void init (CosNotifyComm::StructuredPushConsumer_ptr push_consumer ACE_ENV_ARG_DECL); + + /// Destructor + ~TAO_NS_StructuredPushConsumer (); + + /// TAO_NS_Destroy_Callback methods. + virtual void release (void); + + /// Push <event> to this consumer. + void push_i (const TAO_NS_Event_var& event ACE_ENV_ARG_DECL); + + /// Push <event> to this consumer. + virtual void push (const CORBA::Any& event ACE_ENV_ARG_DECL); + + /// Push <event> to this consumer. + virtual void push (const CosNotification::StructuredEvent& event ACE_ENV_ARG_DECL); + +protected: + /// The Consumer + CosNotifyComm::StructuredPushConsumer_var push_consumer_; +}; + +#if defined (__ACE_INLINE__) +#include "StructuredPushConsumer.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_STRUCTUREDPUSHCONSUMER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.inl b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.inl new file mode 100644 index 00000000000..24e952b7ae8 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushConsumer.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "StructuredPushConsumer.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.cpp new file mode 100644 index 00000000000..60050651b1e --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.cpp @@ -0,0 +1,33 @@ +// $Id$ + +#include "StructuredPushSupplier.h" + +#if ! defined (__ACE_INLINE__) +#include "StructuredPushSupplier.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_StructuredPushSupplier, "$Id$") + +TAO_NS_StructuredPushSupplier::TAO_NS_StructuredPushSupplier (TAO_NS_ProxyConsumer* proxy) + :TAO_NS_Supplier (proxy) +{ +} + +TAO_NS_StructuredPushSupplier::~TAO_NS_StructuredPushSupplier () +{ +} + +void +TAO_NS_StructuredPushSupplier::init (CosNotifyComm::StructuredPushSupplier_ptr push_supplier ACE_ENV_ARG_DECL) +{ + this->push_supplier_ = CosNotifyComm::StructuredPushSupplier::_duplicate (push_supplier); + + this->subscribe_ = CosNotifyComm::NotifySubscribe::_narrow (push_supplier ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_StructuredPushSupplier::release (void) +{ + delete this; + //@@ inform factory +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.h b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.h new file mode 100644 index 00000000000..4308e4a99d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.h @@ -0,0 +1,59 @@ +/* -*- C++ -*- */ +/** + * @file StructuredPushSupplier.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_STRUCTUREDPUSHSUPPLIER_H +#define TAO_NS_STRUCTUREDPUSHSUPPLIER_H +#include "ace/pre.h" + +#include "../notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyCommC.h" +#include "../Supplier.h" +#include "../Destroy_Callback.h" + +class TAO_NS_ProxyConsumer; + +/** + * @class TAO_NS_StructuredPushSupplier + * + * @brief Wrapper for the StructuredPushSupplier that connect to the EventChannel. + * + */ +class TAO_Notify_Export TAO_NS_StructuredPushSupplier : public TAO_NS_Supplier +{ +public: + /// Constuctor + TAO_NS_StructuredPushSupplier (TAO_NS_ProxyConsumer* proxy); + + /// Destructor + ~TAO_NS_StructuredPushSupplier (); + + /// Init + void init (CosNotifyComm::StructuredPushSupplier_ptr push_supplier ACE_ENV_ARG_DECL); + + /// TAO_NS_Destroy_Callback methods + virtual void release (void); + +protected: + /// The Supplier + CosNotifyComm::StructuredPushSupplier_var push_supplier_; +}; + +#if defined (__ACE_INLINE__) +#include "StructuredPushSupplier.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_STRUCTUREDPUSHSUPPLIER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.inl b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.inl new file mode 100644 index 00000000000..12cb29daaef --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredPushSupplier.inl @@ -0,0 +1,3 @@ +// $Id$ + +#include "StructuredPushSupplier.h" diff --git a/TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.cpp b/TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.cpp new file mode 100644 index 00000000000..12210af6fc4 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.cpp @@ -0,0 +1,18 @@ +// $Id$ + +#include "Subscription_Change_Worker.h" + +#if ! defined (__ACE_INLINE__) +#include "Subscription_Change_Worker.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Notify, TAO_Subscription_Change_Worker, "$id$") + +TAO_NS_Subscription_Change_Worker::TAO_NS_Subscription_Change_Worker (const CosNotification::EventTypeSeq & added, const CosNotification::EventTypeSeq & removed) +:added_ (added), removed_ (removed) +{ +} + +TAO_NS_Subscription_Change_Worker::~TAO_NS_Subscription_Change_Worker () +{ +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.h b/TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.h new file mode 100644 index 00000000000..2baea73b727 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.h @@ -0,0 +1,55 @@ +/* -*- C++ -*- */ +/** + * @file Subscription_Change_Worker.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_SUBSCRIPTION_CHANGE_WORKER_H +#define TAO_SUBSCRIPTION_CHANGE_WORKER_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotificationC.h" +#include "orbsvcs/ESF/ESF_Worker.h" + +class TAO_NS_Proxy; + +/** + * @class TAO_Subscription_Change_Worker + * + * @brief + * + */ +class TAO_Notify_Export TAO_NS_Subscription_Change_Worker : public TAO_ESF_Worker<TAO_NS_Proxy> +{ +public: + /// Constuctor + TAO_NS_Subscription_Change_Worker (const CosNotification::EventTypeSeq & added, const CosNotification::EventTypeSeq & removed); + + /// Destructor + ~TAO_NS_Subscription_Change_Worker (); + + ///= TAO_ESF_Worker method + void work (TAO_NS_Proxy* proxy ACE_ENV_ARG_DECL); + +protected: + const CosNotification::EventTypeSeq & added_; + const CosNotification::EventTypeSeq & removed_; +}; + +#if defined (__ACE_INLINE__) +#include "Subscription_Change_Worker.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_SUBSCRIPTION_CHANGE_WORKER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.inl b/TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.inl new file mode 100644 index 00000000000..82ebfbe8c69 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Subscription_Change_Worker.inl @@ -0,0 +1,9 @@ +// $Id$ + +#include "Proxy.h" + +ACE_INLINE void +TAO_NS_Subscription_Change_Worker::work (TAO_NS_Proxy* proxy ACE_ENV_ARG_DECL) +{ + proxy->admin_subscription (this->added_, this->removed_ ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Supplier.cpp b/TAO/orbsvcs/orbsvcs/Notify/Supplier.cpp new file mode 100644 index 00000000000..f1867c3e2fc --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Supplier.cpp @@ -0,0 +1,45 @@ +// $Id$ + +#include "Supplier.h" + +#if ! defined (__ACE_INLINE__) +#include "Supplier.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Supplier, "$Id$") + +#include "ProxyConsumer.h" +#include "Proxy.h" +#include "Admin.h" +#include "EventChannel.h" +#include "EventChannelFactory.h" +#include "Notify_Service.h" + +TAO_NS_Supplier::TAO_NS_Supplier (TAO_NS_ProxyConsumer* proxy) + :proxy_ (proxy) +{ +} + +TAO_NS_Supplier::~TAO_NS_Supplier () +{ +} + +TAO_NS_Proxy* +TAO_NS_Supplier::proxy (void) +{ + return this->proxy_consumer (); +} + +void +TAO_NS_Supplier::dispatch_updates_i (const TAO_NS_EventTypeSeq & added, const TAO_NS_EventTypeSeq & removed + ACE_ENV_ARG_DECL) +{ + CosNotification::EventTypeSeq cos_added; + CosNotification::EventTypeSeq cos_removed; + + added.populate (cos_added); + removed.populate (cos_removed); + + if (!CORBA::is_nil (this->subscribe_.in ())) + this->subscribe_->subscription_change (cos_added, cos_removed ACE_ENV_ARG_PARAMETER); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Supplier.h b/TAO/orbsvcs/orbsvcs/Notify/Supplier.h new file mode 100644 index 00000000000..813560ae893 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Supplier.h @@ -0,0 +1,66 @@ +/* -*- C++ -*- */ +/** + * @file Supplier.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_SUPPLIER_H +#define TAO_NS_SUPPLIER_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Peer.h" + +#include "orbsvcs/CosNotifyCommC.h" +class TAO_NS_ProxyConsumer; + +/** + * @class TAO_NS_Supplier + * + * @brief Base Wrappers for Suppliers that connect to the EventChannel. + * + */ +class TAO_Notify_Export TAO_NS_Supplier : public TAO_NS_Peer +{ +public: + /// Constuctor + TAO_NS_Supplier (TAO_NS_ProxyConsumer* proxy); + + /// Destructor + ~TAO_NS_Supplier (); + + /// Access Specific Proxy. + TAO_NS_ProxyConsumer* proxy_consumer (void); + + /// Access Base Proxy. + virtual TAO_NS_Proxy* proxy (void); + +protected: + /// Dispatch updates implementation. + virtual void dispatch_updates_i (const TAO_NS_EventTypeSeq & added, + const TAO_NS_EventTypeSeq & removed + ACE_ENV_ARG_DECL); + + /// The proxy that we associate with. + TAO_NS_ProxyConsumer* proxy_; + + /// Interface that accepts subscription_changes + CosNotifyComm::NotifySubscribe_var subscribe_; +}; + +#if defined (__ACE_INLINE__) +#include "Supplier.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_SUPPLIER_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Supplier.inl b/TAO/orbsvcs/orbsvcs/Notify/Supplier.inl new file mode 100644 index 00000000000..6df91e0fd9a --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Supplier.inl @@ -0,0 +1,7 @@ +// $Id$ + +ACE_INLINE TAO_NS_ProxyConsumer* +TAO_NS_Supplier::proxy_consumer (void) +{ + return this->proxy_; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.cpp b/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.cpp new file mode 100644 index 00000000000..71c33ab4166 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.cpp @@ -0,0 +1,308 @@ +// $Id$ + +#include "SupplierAdmin.h" + +#if ! defined (__ACE_INLINE__) +#include "SupplierAdmin.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_SupplierAdmin, "$Id$") + +#include "orbsvcs/ESF/ESF_Proxy_Collection.h" +#include "Builder.h" +#include "Proxy.h" +#include "Admin.h" +#include "EventChannel.h" +#include "EventChannelFactory.h" +#include "Notify_Service.h" +#include "Subscription_Change_Worker.h" + +TAO_NS_SupplierAdmin::TAO_NS_SupplierAdmin (void) +:TAO_NS_Admin (TAO_NS_Admin::SUPPLIER_ADMIN) +{ +} + +TAO_NS_SupplierAdmin::~TAO_NS_SupplierAdmin () +{ +} + +PortableServer::Servant +TAO_NS_SupplierAdmin::servant (void) +{ + return this; +} + +void +TAO_NS_SupplierAdmin::_add_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->_incr_refcnt (); +} + +void +TAO_NS_SupplierAdmin::_remove_ref (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + this->_decr_refcnt (); +} + +void +TAO_NS_SupplierAdmin::release (void) +{ + delete this; + //@@ inform factory +} + +void +TAO_NS_SupplierAdmin::destroy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + this->inherited::destroy (this ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_SupplierAdmin::set_qos (const CosNotification::QoSProperties & qos ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )) +{ + this->TAO_NS_Object::set_qos (qos ACE_ENV_ARG_PARAMETER); +} + +CosNotification::QoSProperties* +TAO_NS_SupplierAdmin::get_qos (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->TAO_NS_Object::get_qos (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::ProxyConsumer_ptr +TAO_NS_SupplierAdmin::obtain_notification_push_consumer (CosNotifyChannelAdmin::ClientType ctype, CosNotifyChannelAdmin::ProxyID_out proxy_id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )) + +{ + return TAO_NS_PROPERTIES::instance()->builder ()->build_notification_push_consumer (this, + ctype, + proxy_id ACE_ENV_ARG_PARAMETER); +} + +CosNotifyChannelAdmin::AdminID +TAO_NS_SupplierAdmin::MyID (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->id (); +} + +CosNotifyChannelAdmin::EventChannel_ptr +TAO_NS_SupplierAdmin::MyChannel (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + CORBA::Object_var object = this->parent_->ref (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::EventChannel::_nil ()); + + CosNotifyChannelAdmin::EventChannel_var ec_ret; + + ec_ret = CosNotifyChannelAdmin::EventChannel::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::EventChannel::_nil ()); + + return ec_ret._retn (); +} + +::CosNotifyChannelAdmin::InterFilterGroupOperator +TAO_NS_SupplierAdmin::MyOperator (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->filter_operator_; +} + + +CosNotifyChannelAdmin::ProxyIDSeq* +TAO_NS_SupplierAdmin::push_consumers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + CosNotifyChannelAdmin::ProxyIDSeq* seq; + + ACE_NEW_THROW_EX (seq, + CosNotifyChannelAdmin::ProxyIDSeq (), + CORBA::NO_MEMORY ()); + + seq->length (this->proxy_id_list_.size ()); + + TAO_NS_Object_Id_Seq::CONST_ITERATOR iter (this->proxy_id_list_); + + TAO_NS_Object_Id* object_id; + + CORBA::ULong i = 0; + for (iter.first (); iter.next (object_id); iter.advance (), ++i) + seq[i] = *object_id; + + return seq; +} + +CosNotifyChannelAdmin::ProxyConsumer_ptr +TAO_NS_SupplierAdmin::get_proxy_consumer (CosNotifyChannelAdmin::ProxyID proxy_id ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::ProxyNotFound + )) +{ + TAO_NS_Object* ns_object = this->find (proxy_id ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::ProxyConsumer::_nil ()); + + if (ns_object != 0) + { + CORBA::Object_var object = ns_object->ref (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::ProxyConsumer::_nil ()); + + CosNotifyChannelAdmin::ProxyConsumer_var pc_ret; + + pc_ret = CosNotifyChannelAdmin::ProxyConsumer::_narrow (object.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (CosNotifyChannelAdmin::ProxyConsumer::_nil ()); + + return pc_ret._retn (); + } + else + ACE_THROW_RETURN (CosNotifyChannelAdmin::ProxyNotFound (), CosNotifyChannelAdmin::ProxyConsumer::_nil ()); +} + +void +TAO_NS_SupplierAdmin::offer_change (const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyComm::InvalidEventType + )) + +{ + TAO_NS_EventTypeSeq seq_added (added); + TAO_NS_EventTypeSeq seq_removed (removed); + + { + ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, + CORBA::INTERNAL ()); + ACE_CHECK; + + this->subscribed_types_.init (seq_added, seq_removed); + } + + TAO_NS_Subscription_Change_Worker worker (added, removed); + + this->collection_->for_each (&worker ACE_ENV_ARG_PARAMETER); +} + +CosNotifyFilter::FilterID +TAO_NS_SupplierAdmin::add_filter (CosNotifyFilter::Filter_ptr new_filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->filter_admin_.add_filter (new_filter ACE_ENV_ARG_PARAMETER); +} + +void +TAO_NS_SupplierAdmin::remove_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyFilter::FilterNotFound + )) +{ + this->filter_admin_.remove_filter (filter ACE_ENV_ARG_PARAMETER); +} + +::CosNotifyFilter::Filter_ptr +TAO_NS_SupplierAdmin::get_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyFilter::FilterNotFound + )) +{ + return this->filter_admin_.get_filter (filter ACE_ENV_ARG_PARAMETER); +} + +::CosNotifyFilter::FilterIDSeq* +TAO_NS_SupplierAdmin::get_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return this->filter_admin_.get_all_filters (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +void +TAO_NS_SupplierAdmin::remove_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + this->filter_admin_.get_all_filters (ACE_ENV_SINGLE_ARG_PARAMETER); +} + +CosEventChannelAdmin::ProxyPushConsumer_ptr +TAO_NS_SupplierAdmin::obtain_push_consumer (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + return TAO_NS_PROPERTIES::instance()->builder ()->build_push_consumer (this ACE_ENV_ARG_PARAMETER); +} + +/************** UNIMPLEMENTED METHODS ***************/ + +CosEventChannelAdmin::ProxyPullConsumer_ptr +TAO_NS_SupplierAdmin::obtain_pull_consumer (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CosEventChannelAdmin::ProxyPullConsumer::_nil ()); +} + +CosNotifyChannelAdmin::ProxyIDSeq* +TAO_NS_SupplierAdmin::pull_consumers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); +} + + +void +TAO_NS_SupplierAdmin::validate_qos (const CosNotification::QoSProperties & /*required_qos*/, + CosNotification::NamedPropertyRangeSeq_out /*available_qos*/ + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )) +{ + ACE_THROW (CORBA::NO_IMPLEMENT ()); +} + +CosNotifyChannelAdmin::ProxyConsumer_ptr +TAO_NS_SupplierAdmin::obtain_notification_pull_consumer (CosNotifyChannelAdmin::ClientType /*ctype*/, + CosNotifyChannelAdmin::ProxyID_out /*proxy_id*/ + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )) +{ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CosNotifyChannelAdmin::ProxyConsumer::_nil ()); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.h b/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.h new file mode 100644 index 00000000000..76e27a6ff51 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.h @@ -0,0 +1,190 @@ +/* -*- C++ -*- */ +/** + * @file SupplierAdmin.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_SUPPLIERADMIN_H +#define TAO_NS_SUPPLIERADMIN_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/CosNotifyChannelAdminS.h" +#include "Admin.h" +#include "Destroy_Callback.h" + +#if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +#pragma warning(push) +#endif /* _MSC_VER >= 1200 */ +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/** + * @class TAO_NS_SupplierAdmin + * + * @brief Implementation of CosNotifyChannelAdmin::SupplierAdmin + * + */ +class TAO_Notify_Export TAO_NS_SupplierAdmin : public virtual POA_CosNotifyChannelAdmin::SupplierAdmin, public virtual TAO_NS_Admin, public TAO_NS_Destroy_Callback +{ + friend class TAO_NS_Builder; +public: + /// Constuctor + TAO_NS_SupplierAdmin (void); + + /// Destructor + ~TAO_NS_SupplierAdmin (); + + /// Return servant + virtual PortableServer::Servant servant (void); + + /// ServantBase refcount methods. + virtual void _add_ref (ACE_ENV_SINGLE_ARG_DECL); + virtual void _remove_ref (ACE_ENV_SINGLE_ARG_DECL); + + /// TAO_NS_Destroy_Callback methods + virtual void release (void); + +protected: + /// = CosNotifyChannelAdmin::SupplierAdmin methods + virtual CosNotifyChannelAdmin::AdminID MyID (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::EventChannel_ptr MyChannel (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::InterFilterGroupOperator MyOperator (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::ProxyIDSeq * pull_consumers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::ProxyIDSeq * push_consumers (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotifyChannelAdmin::ProxyConsumer_ptr get_proxy_consumer (CosNotifyChannelAdmin::ProxyID proxy_id + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::ProxyNotFound + )); + + virtual ::CosNotifyChannelAdmin::ProxyConsumer_ptr obtain_notification_pull_consumer (CosNotifyChannelAdmin::ClientType ctype, + CosNotifyChannelAdmin::ProxyID_out proxy_id + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )); + + virtual ::CosNotifyChannelAdmin::ProxyConsumer_ptr obtain_notification_push_consumer (CosNotifyChannelAdmin::ClientType ctype, + CosNotifyChannelAdmin::ProxyID_out proxy_id + ACE_ENV_ARG_DECL + ) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyChannelAdmin::AdminLimitExceeded + )); + + virtual void destroy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosNotification::QoSProperties* get_qos (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void set_qos (const CosNotification::QoSProperties& qos ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )); + + virtual void validate_qos (const CosNotification::QoSProperties & required_qos, + CosNotification::NamedPropertyRangeSeq_out available_qos + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotification::UnsupportedQoS + )); + + virtual void offer_change (const CosNotification::EventTypeSeq & added, + const CosNotification::EventTypeSeq & removed + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyComm::InvalidEventType + )); + + virtual CosNotifyFilter::FilterID add_filter (CosNotifyFilter::Filter_ptr new_filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void remove_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyFilter::FilterNotFound + )); + + virtual ::CosNotifyFilter::Filter_ptr get_filter (CosNotifyFilter::FilterID filter ACE_ENV_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + , CosNotifyFilter::FilterNotFound + )); + + virtual ::CosNotifyFilter::FilterIDSeq * get_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual void remove_all_filters (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosEventChannelAdmin::ProxyPushConsumer_ptr obtain_push_consumer (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); + + virtual ::CosEventChannelAdmin::ProxyPullConsumer_ptr obtain_pull_consumer (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC (( + CORBA::SystemException + )); +}; + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#if defined (__ACE_INLINE__) +#include "SupplierAdmin.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_SUPPLIERADMIN_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.inl b/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/SupplierAdmin.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.cpp b/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.cpp new file mode 100644 index 00000000000..484d0167d73 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.cpp @@ -0,0 +1,125 @@ +// $Id$ + +#include "ThreadPool_Task.h" + +#if ! defined (__ACE_INLINE__) +#include "ThreadPool_Task.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_ThreadPool_Task, "$Id$") + +#include "tao/debug.h" +#include "Properties.h" +#include "Method_Request_Shutdown.h" +#include "AdminProperties.h" + +TAO_NS_ThreadPool_Task::TAO_NS_ThreadPool_Task (void) + : msg_queue_ (*msg_queue ()), buffering_strategy_ (0), queue_length_ (0) +{ +} + +TAO_NS_ThreadPool_Task::~TAO_NS_ThreadPool_Task () +{ + delete this->buffering_strategy_; +} + +void +TAO_NS_ThreadPool_Task::init (const NotifyExt::ThreadPoolParams& tp_params, TAO_NS_AdminProperties& admin_properties ACE_ENV_ARG_DECL) +{ + long flags = THR_NEW_LWP | THR_JOINABLE; + + flags |= + TAO_NS_PROPERTIES::instance()->scope_policy () | + TAO_NS_PROPERTIES::instance()->sched_policy (); + + // Become an active object. + if (this->ACE_Task <ACE_SYNCH>::activate (flags, + tp_params.static_threads, + 0, + tp_params.default_priority) == -1) + { + if (TAO_debug_level > 0) + { + if (ACE_OS::last_error () == EPERM) + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Insufficient privilege.\n"))); + else + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("(%t) task activation at priority %d failed\n") + ACE_TEXT ("exiting!\n%a"), + tp_params.default_priority)); + } + + ACE_THROW (CORBA::BAD_PARAM ()); + } + + // Store the admin properties... + this->queue_length_ = &admin_properties.queue_length (); + + ACE_NEW_THROW_EX (this->buffering_strategy_, + TAO_NS_Buffering_Strategy (this->msg_queue_, admin_properties), + CORBA::NO_MEMORY ()); +} + +void +TAO_NS_ThreadPool_Task::exec (TAO_NS_Method_Request& method_request) +{ + TAO_NS_Method_Request& request_copy = *method_request.copy (); + + ACE_Time_Value tv; + this->buffering_strategy_->execute (request_copy, &tv); +} + +int +TAO_NS_ThreadPool_Task::svc (void) +{ + int done = 0; + while (!done) + { + ACE_TRY_NEW_ENV + { + ACE_Message_Block *mb; + if (this->getq (mb) == -1) + if (ACE_OS::last_error () == ESHUTDOWN) + return 0; + else + ACE_ERROR ((LM_ERROR, + "EC (%P|%t) getq error in Dispatching Queue\n")); + + // Decrement the global event count. + this->queue_length_--; + + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, "removing from queue\n")); + TAO_NS_Method_Request *request = + ACE_dynamic_cast (TAO_NS_Method_Request*, mb); + + int result = 0; + + if (request != 0) + { + result = request->execute (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + + ACE_Message_Block::release (mb); + + if (result == -1) + done = 1; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "EC (%P|%t) exception in dispatching queue"); + } + ACE_ENDTRY; + } + return 0; +} + +void +TAO_NS_ThreadPool_Task::shutdown (void) +{ + this->msg_queue_.enqueue (new TAO_NS_Method_Request_Shutdown (this)); + this->wait (); + return; +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.h b/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.h new file mode 100644 index 00000000000..cb205b6d8ba --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.h @@ -0,0 +1,79 @@ +/* -*- C++ -*- */ +/** + * @file ThreadPool_Task.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_THREADPOOL_TASK_H +#define TAO_NS_THREADPOOL_TASK_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "ace/Task.h" +#include "ace/Message_Queue.h" +#include "Worker_Task.h" +#include "Types.h" + +class TAO_NS_Buffering_Strategy; + +/** + * @class TAO_NS_ThreadPool_Task + * + * @brief Implements a Thread Pool Worker Task. + * + */ +class TAO_Notify_Export TAO_NS_ThreadPool_Task : public TAO_NS_Worker_Task, ACE_Task<ACE_SYNCH> +{ + friend class TAO_NS_Method_Request_Shutdown; + +public: + /// Constuctor + TAO_NS_ThreadPool_Task (void); + + /// Destructor + ~TAO_NS_ThreadPool_Task (); + + /// Activate the threadpool + void init (const NotifyExt::ThreadPoolParams& tp_params, TAO_NS_AdminProperties& admin_properties ACE_ENV_ARG_DECL); + + /// Queue the request + virtual void exec (TAO_NS_Method_Request& method_request); + + /// Shutdown task + virtual void shutdown (void); + + /// Update QoS Properties. + virtual void update_qos_properties (const TAO_NS_QoSProperties& qos_properties); + +protected: + /// task svc + virtual int svc (void); + +private: + /// Message Queue + ACE_Message_Queue<ACE_SYNCH>& msg_queue_; + + /// The buffering strategy to use. + TAO_NS_Buffering_Strategy* buffering_strategy_; + + /// We need to decrement the event_count_ everytime we dequeue a command + /// object. + TAO_NS_Signal_Property_Long* queue_length_; +}; + +#if defined (__ACE_INLINE__) +#include "ThreadPool_Task.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_THREADPOOL_TASK_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.inl b/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.inl new file mode 100644 index 00000000000..6d1375055f2 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/ThreadPool_Task.inl @@ -0,0 +1,9 @@ +// $Id$ + +#include "Buffering_Strategy.h" + +ACE_INLINE void +TAO_NS_ThreadPool_Task::update_qos_properties (const TAO_NS_QoSProperties& qos_properties) +{ + this->buffering_strategy_->update_qos_properties (qos_properties); +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Types.cpp b/TAO/orbsvcs/orbsvcs/Notify/Types.cpp new file mode 100644 index 00000000000..6701d0ca8fa --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Types.cpp @@ -0,0 +1,10 @@ +// $Id$ + +#include "Types.h" +#include "orbsvcs/NotifyExtC.h" + +#if ! defined (__ACE_INLINE__) +#include "Types.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Types, "$Id$") diff --git a/TAO/orbsvcs/orbsvcs/Notify/Types.h b/TAO/orbsvcs/orbsvcs/Notify/Types.h new file mode 100644 index 00000000000..210cdce699c --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Types.h @@ -0,0 +1,85 @@ +/* -*- C++ -*- */ +/** + * @file Types.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_TYPES_H +#define TAO_NS_TYPES_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/corba.h" +#include "tao/orbconf.h" + +/** + * Forward declare templates + */ + +template <class PROXY> class TAO_ESF_Proxy_Collection; +template <class TYPE> class TAO_ESF_RefCount_Guard; +template <class PROXY, class ACE_LOCK> class TAO_NS_Event_Map_T; +template <class PEER> class TAO_NS_Dispatch_Observer_T; +template <class PROXY> class TAO_NS_Event_Map_Observer_T; +template <class PEER> class TAO_NS_Pending_Worker_T; + +/** + * Forward declare classes + */ +class TAO_NS_Supplier; +class TAO_NS_Consumer; +class TAO_NS_Object; +class TAO_NS_EventChannel; +class TAO_NS_Admin; +class TAO_NS_Proxy; +class TAO_NS_Event; +class TAO_NS_ProxySupplier; +class TAO_NS_ProxyConsumer; +class TAO_NS_Peer; +class TAO_NS_EventType; +class TAO_NS_EventTypeSeq; + +/** + * Define common types + */ +typedef ACE_Reverse_Lock<TAO_SYNCH_MUTEX> TAO_NS_Reverse_Lock; + +typedef CORBA::Long TAO_NS_Object_Id; + +typedef TAO_ESF_Proxy_Collection<TAO_NS_ProxyConsumer> TAO_NS_ProxyConsumer_Collection; +typedef TAO_ESF_Proxy_Collection<TAO_NS_ProxySupplier> TAO_NS_ProxySupplier_Collection; + +typedef TAO_ESF_Proxy_Collection<TAO_NS_EventChannel> TAO_NS_EventChannel_Collection; +typedef TAO_ESF_Proxy_Collection<TAO_NS_Admin> TAO_NS_Admin_Collection; +typedef TAO_ESF_Proxy_Collection<TAO_NS_Proxy> TAO_NS_Proxy_Collection; + +typedef TAO_ESF_Proxy_Collection<TAO_NS_Consumer> TAO_NS_Consumer_Collection; +typedef TAO_ESF_Proxy_Collection<TAO_NS_Supplier> TAO_NS_Supplier_Collection; +typedef TAO_ESF_Proxy_Collection<TAO_NS_Peer> TAO_NS_Peer_Collection; + +typedef TAO_ESF_RefCount_Guard<CORBA::ULong> TAO_NS_Object_RefCount_Guard; + +typedef TAO_NS_Event_Map_T<TAO_NS_ProxySupplier, TAO_SYNCH_RW_MUTEX> TAO_NS_Consumer_Map; +typedef TAO_NS_Event_Map_T<TAO_NS_ProxyConsumer, TAO_SYNCH_RW_MUTEX> TAO_NS_Supplier_Map; + +typedef TAO_NS_Event_Map_Observer_T<TAO_NS_ProxyConsumer> TAO_NS_Consumer_Map_Observer; +typedef TAO_NS_Event_Map_Observer_T<TAO_NS_ProxySupplier> TAO_NS_Supplier_Map_Observer; + +typedef TAO_NS_Dispatch_Observer_T<TAO_NS_Peer> TAO_NS_Updates_Dispatch_Observer; +typedef TAO_NS_Dispatch_Observer_T<TAO_NS_Consumer> TAO_NS_Event_Dispatch_Observer; + +typedef TAO_NS_Pending_Worker_T<TAO_NS_Peer> TAO_NS_Updates_Pending_Worker; +typedef TAO_NS_Pending_Worker_T<TAO_NS_Consumer> TAO_NS_Event_Pending_Worker; + +#include "ace/post.h" +#endif /* TAO_NS_TYPES_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Types.inl b/TAO/orbsvcs/orbsvcs/Notify/Types.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Types.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.cpp b/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.cpp new file mode 100644 index 00000000000..dd91b1a7c4d --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.cpp @@ -0,0 +1,33 @@ +// $Id$ + +#include "Worker_Task.h" + +#if ! defined (__ACE_INLINE__) +#include "Worker_Task.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(RT_Notify, TAO_NS_Worker_Task, "$Id$") + +TAO_NS_Worker_Task::TAO_NS_Worker_Task (void) +{ +} + +TAO_NS_Worker_Task::~TAO_NS_Worker_Task () +{ +} + +void +TAO_NS_Worker_Task::shutdown (void) +{ + return; +} + +void +TAO_NS_Worker_Task::init (TAO_NS_AdminProperties& /*admin_properties*/) +{ +} + +void +TAO_NS_Worker_Task::update_qos_properties (const TAO_NS_QoSProperties& /*qos_properties*/) +{ +} diff --git a/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.h b/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.h new file mode 100644 index 00000000000..5082051fa1b --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.h @@ -0,0 +1,60 @@ +/* -*- C++ -*- */ +/** + * @file Worker_Task.h + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + * + * + */ + +#ifndef TAO_NS_WORKER_TASK_H +#define TAO_NS_WORKER_TASK_H +#include "ace/pre.h" + +#include "notify_export.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Method_Request.h" + +class TAO_NS_AdminProperties; +class TAO_NS_QoSProperties; + +/** + * @class TAO_NS_Worker_Task + * + * @brief Base Worker Task. + * + */ +class TAO_Notify_Export TAO_NS_Worker_Task +{ +public: + /// Constuctor + TAO_NS_Worker_Task (void); + + /// Destructor + virtual ~TAO_NS_Worker_Task (); + + /// Init AdminProperties + virtual void init (TAO_NS_AdminProperties& admin_properties); + + /// Exec the request. + virtual void exec (TAO_NS_Method_Request& method_request) = 0; + + /// Shutdown task + virtual void shutdown (void); + + /// Update QoS Properties. + virtual void update_qos_properties (const TAO_NS_QoSProperties& qos_properties); +}; + +#if defined (__ACE_INLINE__) +#include "Worker_Task.inl" +#endif /* __ACE_INLINE__ */ + +#include "ace/post.h" +#endif /* TAO_NS_WORKER_TASK_H */ diff --git a/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.inl b/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.inl new file mode 100644 index 00000000000..cfa1da318d3 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/Notify/Worker_Task.inl @@ -0,0 +1 @@ +// $Id$ diff --git a/TAO/orbsvcs/orbsvcs/NotifyExt.idl b/TAO/orbsvcs/orbsvcs/NotifyExt.idl new file mode 100644 index 00000000000..6a4692ad867 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/NotifyExt.idl @@ -0,0 +1,70 @@ +/** + * @file NotifyExt.idl + * + * @brief Additional interfaces for QoS properties to Notify. + * + * $Id$ + * + * @author Pradeep Gore <pradeep@oomworks.com> + */ + +#ifndef _NOTIFY_EXT_IDL_ +#define _NOTIFY_EXT_IDL_ + +#pragma prefix "" + +/** + * @namespace NotifyExt + * + * @brief Notify Extensions. + */ +module NotifyExt +{ + // Priority defs. same as RTCORBA + typedef short Priority; + const Priority minPriority = 0; + const Priority maxPriority = 32767; + + /* + * ThreadPool QoS property, + */ + const string ThreadPool = "ThreadPool"; + + // ThreadPoolParams : same as RTCORBA::create_threadpool + struct ThreadPoolParams + { + unsigned long stacksize; + unsigned long static_threads; + unsigned long dynamic_threads; + Priority default_priority; + boolean allow_request_buffering; + unsigned long max_buffered_requests; + unsigned long max_request_buffer_size; + }; + + /* + * ThreadPoolLanes QoS property, + */ + const string ThreadPoolLanes = "ThreadPoolLanes"; + + struct ThreadPoolLane + { + Priority lane_priority; + unsigned long static_threads; + unsigned long dynamic_threads; + }; + + typedef sequence <ThreadPoolLane> ThreadPoolLanes_List; + + struct ThreadPoolLanesParams + { + unsigned long stacksize; + ThreadPoolLanes_List lanes; + boolean allow_borrowing; + boolean allow_request_buffering; + unsigned long max_buffered_requests; + unsigned long max_request_buffer_size; + }; +}; + +#endif /* _NOTIFY_EXT_IDL_ */ |