summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannelFactory_i.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannelFactory_i.cpp')
-rw-r--r--TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannelFactory_i.cpp221
1 files changed, 22 insertions, 199 deletions
diff --git a/TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannelFactory_i.cpp b/TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannelFactory_i.cpp
index 6e98a60de08..d2c836538e2 100644
--- a/TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannelFactory_i.cpp
+++ b/TAO/orbsvcs/orbsvcs/Notify/Notify_EventChannelFactory_i.cpp
@@ -1,224 +1,47 @@
// $Id$
#include "Notify_EventChannelFactory_i.h"
-#include "Notify_EventChannel_i.h"
-#include "Notify_Channel_Objects_Factory.h"
-#include "Notify_POA_Factory.h"
-#include "Notify_Factory.h"
-#include "Notify_FilterFactory_i.h"
-#include "Notify_Event.h"
-#include "tao/debug.h"
-
-ACE_RCSID(Notify, Notify_EventChannelFactory_i, "$Id$")
-
-TAO_Notify_EventChannelFactory_i::TAO_Notify_EventChannelFactory_i (void)
-{
-}
-
-TAO_Notify_EventChannelFactory_i::~TAO_Notify_EventChannelFactory_i (void)
-{
- TAO_Notify_Factory::shutdown ();
- delete this->lock_;
-}
+#include "Service.h"
+#include "ace/Dynamic_Service.h"
+#include "tao/PortableServer/POA.h"
+#include "tao/ORB_Core.h"
CosNotifyChannelAdmin::EventChannelFactory_ptr
TAO_Notify_EventChannelFactory_i::create (PortableServer::POA_ptr default_POA ACE_ENV_ARG_DECL)
{
- TAO_Notify_EventChannelFactory_i* channelfactory;
- ACE_NEW_THROW_EX (channelfactory,
- TAO_Notify_EventChannelFactory_i (),
- CORBA::NO_MEMORY ());
- ACE_CHECK_RETURN (CosNotifyChannelAdmin::EventChannelFactory::_nil ());
-
- PortableServer::ServantBase_var channelfactory_var (channelfactory);
-
- channelfactory->init_i (default_POA ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (CosNotifyChannelAdmin::EventChannelFactory::_nil ());
-
- CORBA::Object_var obj = channelfactory->poa_factory_->
- activate_object (channelfactory->my_POA_.in (),
- channelfactory ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (CosNotifyChannelAdmin::EventChannelFactory::_nil ());
-
- return CosNotifyChannelAdmin::EventChannelFactory
- ::_narrow (obj.in () ACE_ENV_ARG_PARAMETER);
-}
-
-void
-TAO_Notify_EventChannelFactory_i::init_i (PortableServer::POA_ptr default_POA ACE_ENV_ARG_DECL)
-{
- TAO_Notify_Factory::init (ACE_ENV_SINGLE_ARG_PARAMETER);
- ACE_CHECK;
-
- this->my_POA_ = PortableServer::POA::_duplicate (default_POA);
-
- this->channel_objects_factory_ =
- TAO_Notify_Factory::get_channel_objects_factory ();
-
- this->poa_factory_ = TAO_Notify_Factory::get_poa_factory ();
-
- // The POA that we should activate the Event Channels in.
- this->ec_POA_ = this->poa_factory_->
- create_event_channel_POA (this->my_POA_.in () ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
-
- this->lock_ =
- this->channel_objects_factory_->create_channel_factory_lock (ACE_ENV_SINGLE_ARG_PARAMETER);
- ACE_CHECK;
-
- this->default_filter_factory_ =
- this->create_default_filter_factory_i (ACE_ENV_SINGLE_ARG_PARAMETER);
-}
-
-CosNotifyChannelAdmin::EventChannelFactory_ptr
-TAO_Notify_EventChannelFactory_i::get_ref (ACE_ENV_SINGLE_ARG_DECL)
-{
- return CosNotifyChannelAdmin::EventChannelFactory
- ::_narrow (this->poa_factory_->
- servant_to_reference (this->my_POA_.in (), this ACE_ENV_ARG_PARAMETER));
-}
-
-void
-TAO_Notify_EventChannelFactory_i::event_channel_destroyed (CosNotifyChannelAdmin::ChannelID channel_id)
-{
- this->ec_ids_.put (channel_id);
-
- if (TAO_debug_level > 0)
- ACE_DEBUG ((LM_DEBUG, "event_channel_destroyed %d\n", channel_id));
-}
+ CosNotifyChannelAdmin::EventChannelFactory_var notify_factory;
-void TAO_Notify_EventChannelFactory_i::shutdown (ACE_ENV_SINGLE_ARG_DECL
-#if !defined (TAO_HAS_EXCEPTIONS) || defined (ACE_ENV_BKWD_COMPAT)
- ,
-#endif
- CORBA::Boolean destroy_children)
-{
- if (destroy_children == 1)
- {
- this->poa_factory_->destroy_POA (this->ec_POA_.in () ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
-
- this->poa_factory_->deactivate_object(this->default_filter_factory_.in (),
- this->my_POA_.in ()
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK;
- }
- // Deactivate ourselves.
- this->poa_factory_->deactivate_object (this,
- this->my_POA_.in ()
- ACE_ENV_ARG_PARAMETER);
-}
-
-CosNotifyChannelAdmin::EventChannel_ptr
-TAO_Notify_EventChannelFactory_i::create_channel(const CosNotification::QoSProperties& initial_qos,
- const CosNotification::AdminProperties& initial_admin,
- CosNotifyChannelAdmin::ChannelID_out ec_id
- ACE_ENV_ARG_DECL
- )
- ACE_THROW_SPEC ((
- CORBA::SystemException,
- CosNotification::UnsupportedQoS,
- CosNotification::UnsupportedAdmin
- ))
-{
- TAO_Notify_EventChannel_i* channel =
- this->channel_objects_factory_->create_event_channel (this
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (CosNotifyChannelAdmin::EventChannel::_nil ());
-
- PortableServer::ServantBase_var channel_var (channel);
+ TAO_NS_Service* notify_service = ACE_Dynamic_Service<TAO_NS_Service>::instance (TAO_NS_COS_NOTIFICATION_SERVICE_NAME);
+ if (notify_service == 0)
{
- ACE_GUARD_THROW_EX (ACE_Lock, ace_mon, *this->lock_,
- CORBA::INTERNAL ());
- ACE_CHECK_RETURN (CosNotifyChannelAdmin::EventChannel::_nil ());
-
- ec_id = this->ec_ids_.get ();
-
- ACE_DEBUG ((LM_DEBUG, "event_channel created %d\n", ec_id));
+ ACE_DEBUG ((LM_DEBUG, "Service not found! check conf. file\n"));
+ return notify_factory._retn ();
}
- channel->init (ec_id, initial_qos, initial_admin, this->my_POA_.in (), this->ec_POA_.in ()
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (CosNotifyChannelAdmin::EventChannel::_nil ());
-
- CORBA::Object_var obj = this->poa_factory_->
- activate_object_with_id (ec_id, this->ec_POA_.in (), channel
- ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (CosNotifyChannelAdmin::EventChannel::_nil ());
-
- this->ec_ids_.next ();
- return CosNotifyChannelAdmin::EventChannel::_narrow (obj.in ());
-}
-
-CosNotifyChannelAdmin::ChannelIDSeq*
-TAO_Notify_EventChannelFactory_i::get_all_channels (ACE_ENV_SINGLE_ARG_DECL)
- ACE_THROW_SPEC ((
- CORBA::SystemException
- ))
-{
- ACE_GUARD_RETURN (ACE_Lock, ace_mon, *this->lock_, 0);
+ TAO_POA *poa = default_POA->_tao_poa_downcast();
- return this->ec_ids_.get_sequence (ACE_ENV_SINGLE_ARG_PARAMETER);
-}
+ if (poa == 0)
+ return notify_factory._retn ();
-CosNotifyChannelAdmin::EventChannel_ptr
-TAO_Notify_EventChannelFactory_i::get_event_channel (CosNotifyChannelAdmin::ChannelID id ACE_ENV_ARG_DECL)
- ACE_THROW_SPEC ((
- CORBA::SystemException,
- CosNotifyChannelAdmin::ChannelNotFound
- ))
-{
- CORBA::Object_var obj;
-
- ACE_TRY
- {
- obj = this->poa_factory_->id_to_reference (id, this->ec_POA_.in ()
- ACE_ENV_ARG_PARAMETER);
- ACE_TRY_CHECK;
- }
- ACE_CATCHANY // Translate any exception to "not found"
- {
- ACE_TRY_THROW (CosNotifyChannelAdmin::ChannelNotFound ());
- }
- ACE_ENDTRY;
- ACE_CHECK_RETURN (CosNotifyChannelAdmin::EventChannel::_nil ());
-
- return CosNotifyChannelAdmin::EventChannel::_narrow (obj.in () ACE_ENV_ARG_PARAMETER);
-}
-
-CosNotifyFilter::FilterFactory_ptr
-TAO_Notify_EventChannelFactory_i::create_default_filter_factory_i (ACE_ENV_SINGLE_ARG_DECL)
-{
- TAO_Notify_FilterFactory_i* filterfactory =
- this->channel_objects_factory_->create_filter_factory (ACE_ENV_SINGLE_ARG_PARAMETER);
- ACE_CHECK_RETURN (CosNotifyFilter::FilterFactory::_nil ());
+ CORBA::ORB_ptr orb = poa->orb_core ().orb () ;
- PortableServer::ServantBase_var filterfactory_var (filterfactory);
+ notify_service->init (orb ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (notify_factory._retn ());
- // Init goes here.
- // ACE_CHECK_RETURN (CosNotifyFilter::FilterFactory::_nil ());
+ notify_factory = notify_service->create (default_POA ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (notify_factory._retn ());
- CORBA::Object_var obj =
- this->poa_factory_->activate_object (this->my_POA_.in (),
- filterfactory ACE_ENV_ARG_PARAMETER);
- ACE_CHECK_RETURN (CosNotifyFilter::FilterFactory::_nil ());
-
- return CosNotifyFilter::FilterFactory::_narrow (obj.in ());
-}
-
-CosNotifyFilter::FilterFactory_ptr
-TAO_Notify_EventChannelFactory_i::get_default_filter_factory (void)
-{
- return CosNotifyFilter::FilterFactory::
- _duplicate (this->default_filter_factory_.in ());
+ return notify_factory._retn ();
}
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
-template class TAO_Notify_ID_Pool_Ex<CosNotifyChannelAdmin::ChannelID, CosNotifyChannelAdmin::ChannelIDSeq>;
+
+template class ACE_Dynamic_Service<TAO_NS_Service>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
-#pragma instantiate TAO_Notify_ID_Pool_Ex<CosNotifyChannelAdmin::ChannelID, CosNotifyChannelAdmin::ChannelIDSeq>
+
+#pragma instantiate ACE_Dynamic_Service<TAO_NS_Service>
#endif /*ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */