00001 // StructuredProxyPushConsumer.cpp,v 1.17 2006/03/15 21:29:10 jtc Exp 00002 00003 #include "orbsvcs/Notify/Structured/StructuredProxyPushConsumer.h" 00004 00005 ACE_RCSID(RT_Notify, TAO_Notify_StructuredProxyPushConsumer, "StructuredProxyPushConsumer.cpp,v 1.17 2006/03/15 21:29:10 jtc Exp") 00006 00007 #include "ace/Bound_Ptr.h" 00008 #include "ace/Auto_Ptr.h" 00009 #include "tao/debug.h" 00010 #include "orbsvcs/Notify/Structured/StructuredPushSupplier.h" 00011 #include "orbsvcs/Notify/Structured/StructuredEvent.h" 00012 #include "orbsvcs/Notify/AdminProperties.h" 00013 #include "orbsvcs/Notify/Properties.h" 00014 00015 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00016 00017 TAO_Notify_StructuredProxyPushConsumer::TAO_Notify_StructuredProxyPushConsumer (void) 00018 { 00019 } 00020 00021 TAO_Notify_StructuredProxyPushConsumer::~TAO_Notify_StructuredProxyPushConsumer () 00022 { 00023 } 00024 00025 void 00026 TAO_Notify_StructuredProxyPushConsumer::release (void) 00027 { 00028 delete this; 00029 //@@ inform factory 00030 } 00031 00032 CosNotifyChannelAdmin::ProxyType 00033 TAO_Notify_StructuredProxyPushConsumer::MyType (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) 00034 ACE_THROW_SPEC (( 00035 CORBA::SystemException 00036 )) 00037 { 00038 return CosNotifyChannelAdmin::PUSH_STRUCTURED; 00039 } 00040 00041 void 00042 TAO_Notify_StructuredProxyPushConsumer::connect_structured_push_supplier (CosNotifyComm::StructuredPushSupplier_ptr push_supplier ACE_ENV_ARG_DECL) 00043 ACE_THROW_SPEC (( 00044 CORBA::SystemException 00045 , CosEventChannelAdmin::AlreadyConnected 00046 )) 00047 { 00048 // Convert Supplier to Base Type 00049 TAO_Notify_StructuredPushSupplier * supplier; 00050 ACE_NEW_THROW_EX (supplier, 00051 TAO_Notify_StructuredPushSupplier (this), 00052 CORBA::NO_MEMORY ()); 00053 00054 supplier->init (push_supplier ACE_ENV_ARG_PARAMETER); 00055 ACE_CHECK; 00056 this->connect (supplier ACE_ENV_ARG_PARAMETER); 00057 ACE_CHECK; 00058 this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER); 00059 } 00060 00061 void 00062 TAO_Notify_StructuredProxyPushConsumer::push_structured_event (const CosNotification::StructuredEvent & notification ACE_ENV_ARG_DECL) 00063 ACE_THROW_SPEC (( 00064 CORBA::SystemException 00065 , CosEventComm::Disconnected 00066 )) 00067 { 00068 // Check if we should proceed at all. 00069 if (this->admin_properties().reject_new_events () == 1 00070 && this->admin_properties().queue_full ()) 00071 ACE_THROW (CORBA::IMP_LIMIT ()); 00072 00073 if (this->is_connected () == 0) 00074 { 00075 ACE_THROW (CosEventComm::Disconnected ()); 00076 } 00077 00078 TAO_Notify_StructuredEvent_No_Copy event (notification); 00079 this->push_i (&event ACE_ENV_ARG_PARAMETER); 00080 } 00081 00082 void 00083 TAO_Notify_StructuredProxyPushConsumer::disconnect_structured_push_consumer (ACE_ENV_SINGLE_ARG_DECL) 00084 ACE_THROW_SPEC (( 00085 CORBA::SystemException 00086 )) 00087 { 00088 TAO_Notify_StructuredProxyPushConsumer::Ptr guard( this ); 00089 this->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); 00090 ACE_CHECK; 00091 this->self_change (ACE_ENV_SINGLE_ARG_PARAMETER); 00092 } 00093 00094 const char * 00095 TAO_Notify_StructuredProxyPushConsumer::get_proxy_type_name (void) const 00096 { 00097 return "structured_proxy_push_consumer"; 00098 } 00099 00100 void 00101 TAO_Notify_StructuredProxyPushConsumer::load_attrs (const TAO_Notify::NVPList& attrs) 00102 { 00103 SuperClass::load_attrs(attrs); 00104 ACE_CString ior; 00105 if (attrs.load("PeerIOR", ior)) 00106 { 00107 CORBA::ORB_var orb = TAO_Notify_PROPERTIES::instance()->orb(); 00108 ACE_DECLARE_NEW_CORBA_ENV; 00109 ACE_TRY 00110 { 00111 ACE_TRY_CHECK; 00112 CosNotifyComm::StructuredPushSupplier_var ps = CosNotifyComm::StructuredPushSupplier::_nil(); 00113 if ( ior.length() > 0 ) 00114 { 00115 CORBA::Object_var obj = orb->string_to_object(ior.c_str() ACE_ENV_ARG_PARAMETER); 00116 ACE_TRY_CHECK; 00117 ps = CosNotifyComm::StructuredPushSupplier::_unchecked_narrow(obj.in() ACE_ENV_ARG_PARAMETER); 00118 ACE_TRY_CHECK; 00119 } 00120 // minor hack: suppress generating subscription updates during reload. 00121 bool save_updates = this->updates_off_; 00122 this->updates_off_ = true; 00123 this->connect_structured_push_supplier(ps.in() ACE_ENV_ARG_PARAMETER); 00124 ACE_TRY_CHECK; 00125 this->updates_off_ = save_updates; 00126 } 00127 ACE_CATCHANY 00128 { 00129 // if we can't reconnect to peer, tough... 00130 } 00131 ACE_ENDTRY; 00132 } 00133 } 00134 00135 TAO_END_VERSIONED_NAMESPACE_DECL