Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / examples / Content_Server / AMI_Observer / Push_Iterator_Handler.cpp
blobad1b852321ccd3fc551daea4a430def0a1e3d291
1 // -*- C++ -*-
2 // Ossama Othman <ossama@uci.edu>
4 #include "ace/Log_Msg.h"
5 #include "ace/Process_Manager.h"
6 #include "Push_Iterator_Handler.h"
7 #include "Callback_i.h"
9 Push_Iterator_Handler::Push_Iterator_Handler (void)
10 : callback_servant_ (0),
11 callback_ (),
12 ami_handler_ ()
14 // Nothing else
17 Push_Iterator_Handler::~Push_Iterator_Handler (void)
19 // Nothing else
22 void
23 Push_Iterator_Handler::register_callback
24 (const Web_Server::Metadata_Type &metadata)
26 this->callback_servant_->metadata (metadata);
28 // This handler is no longer needed, so deactivate it.
29 this->deactivate ();
32 void
33 Push_Iterator_Handler::run (int *request_count,
34 const char *pathname,
35 Web_Server::Iterator_Factory_ptr factory)
37 ACE_NEW_THROW_EX (this->callback_servant_,
38 Callback_i (request_count),
39 CORBA::NO_MEMORY ());
41 // Pass ownership of the Callback servant to the POA.
42 PortableServer::ServantBase_var tmp (this->callback_servant_);
44 // Activate the Callback.
45 this->callback_ =
46 this->callback_servant_->_this ();
48 // Activate this Reply Handler.
49 this->ami_handler_ =
50 this->_this ();
52 // Register the client callback with the server asynchronously.
53 factory->sendc_register_callback (this->ami_handler_.in (),
54 pathname,
55 this->callback_.in ());
58 void
59 Push_Iterator_Handler::deactivate (void)
61 // Get the POA used when activating the Reply Handler object.
62 PortableServer::POA_var poa = this->_default_POA ();
64 // Get the object ID associated with this servant.
65 PortableServer::ObjectId_var oid =
66 poa->servant_to_id (this);
68 // Now deactivate the AMI_CallbackHandler object.
69 poa->deactivate_object (oid.in ());