00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "ProxyPullSupplier.h"
00025 #include "Orb.h"
00026 #include "omniEventsLog.h"
00027
00028 #define DB(l,x) ((omniORB::traceLevel >= l) && (cerr << x << endl))
00029
00030 namespace OmniEvents {
00031
00032
00033
00034
00035
00036 PortableServer::Servant ProxyPullSupplierManager::incarnate(
00037 const PortableServer::ObjectId& oid,
00038 PortableServer::POA_ptr poa
00039 )
00040 {
00041
00042 ProxyPullSupplier_i* result =new ProxyPullSupplier_i(_managedPoa,_queue);
00043 _servants.insert(result);
00044 return result;
00045 }
00046
00047 ProxyPullSupplierManager::ProxyPullSupplierManager(
00048 PortableServer::POA_ptr parentPoa,
00049 EventQueue& q
00050 )
00051 : ProxyManager(parentPoa,"ProxyPullSupplier"),
00052 _queue(q)
00053 {
00054
00055 }
00056
00057 CosEventChannelAdmin::ProxyPullSupplier_ptr
00058 ProxyPullSupplierManager::createObject()
00059 {
00060 return createNarrowedReference<CosEventChannelAdmin::ProxyPullSupplier>(
00061 _managedPoa,
00062 CosEventChannelAdmin::_tc_ProxyPullSupplier->id()
00063 );
00064 }
00065
00066
00067
00068
00069
00070
00071
00072
00073 void ProxyPullSupplier_i::connect_pull_consumer(
00074 CosEventComm::PullConsumer_ptr pullConsumer
00075 )
00076 {
00077 try
00078 {
00079 if(CORBA::is_nil(pullConsumer))
00080 throw CORBA::BAD_PARAM();
00081 if(!CORBA::is_nil(_target) || !CORBA::is_nil(_req))
00082 throw CosEventChannelAdmin::AlreadyConnected();
00083 _target=CosEventComm::PullConsumer::_duplicate(pullConsumer);
00084
00085 omniEventsLog::persist();
00086 }
00087 catch(...)
00088 {
00089 _target=CosEventComm::PullConsumer::_nil();
00090 deactivateObject();
00091 throw;
00092 }
00093 }
00094
00095 void ProxyPullSupplier_i::disconnect_pull_supplier()
00096 {
00097 DB(5,"ProxyPullSupplier_i::disconnect_pull_supplier()");
00098 deactivateObject();
00099 if(CORBA::is_nil(_target))
00100 {
00101 throw CORBA::BAD_INV_ORDER(
00102 omni::BAD_INV_ORDER_RequestUsedMoreThanOnce,
00103 CORBA::COMPLETED_YES
00104 );
00105 }
00106 else
00107 {
00108 CORBA::Request_var req=_target->_request("disconnect_pull_consumer");
00109 req->send_deferred();
00110 Orb::inst().orphanRequest(req._retn());
00111 _target=CosEventComm::PullConsumer::_nil();
00112 }
00113 }
00114
00115 CORBA::Any* ProxyPullSupplier_i::pull()
00116 {
00117 if(moreEvents())
00118 return new CORBA::Any(*nextEvent());
00119 else
00120 throw CORBA::TRANSIENT(
00121 omni::TRANSIENT_CallTimedout,
00122 CORBA::COMPLETED_NO
00123 );
00124 }
00125
00126 CORBA::Any* ProxyPullSupplier_i::try_pull(CORBA::Boolean& has_event)
00127 {
00128 if(moreEvents())
00129 {
00130 has_event=1;
00131 return new CORBA::Any(*nextEvent());
00132 }
00133 else
00134 {
00135 has_event=0;
00136 return new CORBA::Any();
00137 }
00138 }
00139
00140
00141
00142 ProxyPullSupplier_i::ProxyPullSupplier_i(
00143 PortableServer::POA_ptr poa,
00144 EventQueue& q
00145 )
00146 : Proxy(poa),
00147 EventQueue::Reader(q),
00148 _target(CosEventComm::PullConsumer::_nil())
00149 {
00150
00151 }
00152
00153 void ProxyPullSupplier_i::reincarnate(const OEP_prxy& prxy)
00154 {
00155 CosEventComm::PullConsumer_var pullConsumer =
00156 string_to_<CosEventComm::PullConsumer>(prxy.getIor());
00157
00158 activateObjectWithId(prxy.getKey());
00159 connect_pull_consumer(pullConsumer.in());
00160 }
00161
00162 void ProxyPullSupplier_i::output(ostream& os)
00163 {
00164 Output out =basicOutput(os,"pxyPullSupplier",3,this,_target.in());
00165 }
00166
00167
00168 };