Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes

TAO_Notify_StructuredPushConsumer Class Reference

Wrapper for the StructuredPushConsumer that connect to the EventChannel. More...

#include <StructuredPushConsumer.h>

Inheritance diagram for TAO_Notify_StructuredPushConsumer:
Inheritance graph
[legend]
Collaboration diagram for TAO_Notify_StructuredPushConsumer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TAO_Notify_StructuredPushConsumer (TAO_Notify_ProxySupplier *proxy)
 Constructor.
void init (CosNotifyComm::StructuredPushConsumer_ptr push_consumer)
 Init the Consumer.
virtual ~TAO_Notify_StructuredPushConsumer ()
 Destructor.
virtual void push (const CORBA::Any &event)
virtual void push (const CosNotification::StructuredEvent &event)
 Push <event> to this consumer.
virtual void push (const CosNotification::EventBatch &event)
 Push a batch of events to this consumer.
virtual ACE_CString get_ior (void) const
 Retrieve the ior of this peer.
virtual void reconnect_from_consumer (TAO_Notify_Consumer *old_consumer)

Protected Member Functions

virtual CORBA::Object_ptr get_consumer (void)

Protected Attributes

CosNotifyComm::StructuredPushConsumer_var push_consumer_
 The Consumer.

Private Member Functions

virtual void release (void)
 Release.

Private Attributes

int connection_valid
 Connection valid flag.

Detailed Description

Wrapper for the StructuredPushConsumer that connect to the EventChannel.

Definition at line 35 of file StructuredPushConsumer.h.


Constructor & Destructor Documentation

TAO_Notify_StructuredPushConsumer::TAO_Notify_StructuredPushConsumer ( TAO_Notify_ProxySupplier proxy  ) 

Constructor.

Definition at line 14 of file StructuredPushConsumer.cpp.

TAO_Notify_StructuredPushConsumer::~TAO_Notify_StructuredPushConsumer (  )  [virtual]

Destructor.

Definition at line 19 of file StructuredPushConsumer.cpp.

{
}


Member Function Documentation

CORBA::Object_ptr TAO_Notify_StructuredPushConsumer::get_consumer ( void   )  [protected, virtual]

This method is called by the is_alive() method. It should provide the connected consumer or nil if there is none.

Implements TAO_Notify_Consumer.

Definition at line 184 of file StructuredPushConsumer.cpp.

{
  return CosNotifyComm::StructuredPushConsumer::_duplicate (this->push_consumer_.in ());
}

ACE_CString TAO_Notify_StructuredPushConsumer::get_ior ( void   )  const [virtual]

Retrieve the ior of this peer.

Definition at line 167 of file StructuredPushConsumer.cpp.

{
  ACE_CString result;
  CORBA::ORB_var orb = TAO_Notify_PROPERTIES::instance()->orb();
  try
  {
    CORBA::String_var ior = orb->object_to_string(this->push_consumer_.in());
    result = static_cast<const char*> (ior.in ());
  }
  catch (const CORBA::Exception&)
  {
    result.fast_clear();
  }
  return result;
}

void TAO_Notify_StructuredPushConsumer::init ( CosNotifyComm::StructuredPushConsumer_ptr  push_consumer  ) 

Init the Consumer.

Definition at line 24 of file StructuredPushConsumer.cpp.

{
  // Initialize only once
  ACE_ASSERT( CORBA::is_nil (this->push_consumer_.in()) );

  if (CORBA::is_nil (push_consumer))
  {
    throw CORBA::BAD_PARAM();
  }

  if (!TAO_Notify_PROPERTIES::instance()->separate_dispatching_orb ())
    {
      this->push_consumer_ = CosNotifyComm::StructuredPushConsumer::_duplicate (push_consumer);
      this->publish_ = CosNotifyComm::NotifyPublish::_duplicate (push_consumer);
    }
  else
    {
      // "Port" consumer's object reference from receiving ORB to dispatching ORB.
      CORBA::String_var temp =
        TAO_Notify_PROPERTIES::instance()->orb()->object_to_string(push_consumer);

      CORBA::Object_var obj =
        TAO_Notify_PROPERTIES::instance()->dispatching_orb()->string_to_object(temp.in());

      try
        {
          CosNotifyComm::StructuredPushConsumer_var new_push_consumer =
            CosNotifyComm::StructuredPushConsumer::_unchecked_narrow(obj.in());

          this->push_consumer_ = CosNotifyComm::StructuredPushConsumer::_duplicate (new_push_consumer.in());
          this->publish_ = CosNotifyComm::NotifyPublish::_duplicate (new_push_consumer.in());

          //--cj verify dispatching ORB
          if (TAO_debug_level >= 10)
            {
              ACE_DEBUG ((LM_DEBUG,
                          "(%P|%t) Structured push init dispatching ORB id is %s.\n",
                          obj->_stubobj()->orb_core()->orbid()));
          }
          //--cj end
        }
      catch (const CORBA::TRANSIENT& ex)
        {
          ex._tao_print_exception (
            "Got a TRANSIENT in NS_StructuredPushConsumer::init");
          ACE_DEBUG ((LM_DEBUG, "(%P|%t) got it for NS_StructuredPushConsumer %@\n", this));
        }
      catch (const CORBA::Exception&)
        {
          // _narrow failed
        }
    }
}

void TAO_Notify_StructuredPushConsumer::push ( const CosNotification::EventBatch event  )  [virtual]

Push a batch of events to this consumer.

Implements TAO_Notify_Consumer.

Definition at line 150 of file StructuredPushConsumer.cpp.

{
  ACE_ASSERT(false);
  ACE_UNUSED_ARG (event);
  // TODO exception?
}

void TAO_Notify_StructuredPushConsumer::push ( const CORBA::Any event  )  [virtual]

Push <event> to this consumer.

Implements TAO_Notify_Consumer.

Definition at line 86 of file StructuredPushConsumer.cpp.

{
  CosNotification::StructuredEvent notification;

  TAO_Notify_Event::translate (event, notification);

  // Check if we have to validate connection
  if ( !connection_valid ) {
    try
      {
        CORBA::PolicyList_var inconsistent_policies; 
        this->push_consumer_->_validate_connection (inconsistent_policies.out()); 
      }
    catch (const CORBA::COMM_FAILURE&)
      {
        // Expected exception when a bad connection is found
        if (TAO_debug_level >= 1)
          {
            ACE_DEBUG ((LM_DEBUG, "(%P|%t) Found bad connection.\n"));
          }
      }
    connection_valid = 1;
  }

  last_ping_ = ACE_OS::gettimeofday ();

  this->push_consumer_->push_structured_event (notification);
}

void TAO_Notify_StructuredPushConsumer::push ( const CosNotification::StructuredEvent event  )  [virtual]

Push <event> to this consumer.

Implements TAO_Notify_Consumer.

Definition at line 116 of file StructuredPushConsumer.cpp.

{
  //--cj verify dispatching ORB
  if (TAO_debug_level >= 10) {
    ACE_DEBUG ((LM_DEBUG, "(%P|%t) Structured push dispatching ORB id is %s.\n",
                this->push_consumer_->_stubobj()->orb_core()->orbid()));
  }
  //--cj end

  // Check if we have to validate connection
  if ( !connection_valid ) {
    try
      {
        CORBA::PolicyList_var inconsistent_policies; 
        this->push_consumer_->_validate_connection (inconsistent_policies.out()); 
      }
    catch (const CORBA::COMM_FAILURE&)
      {
        // Expected exception when a bad connection is found
        if (TAO_debug_level >= 1)
          {
            ACE_DEBUG ((LM_DEBUG, "(%P|%t) Found bad connection.\n"));
          }
      }
    connection_valid = 1;
  }

  last_ping_ = ACE_OS::gettimeofday ();

  this->push_consumer_->push_structured_event (event);
}

void TAO_Notify_StructuredPushConsumer::reconnect_from_consumer ( TAO_Notify_Consumer old_consumer  )  [virtual]

on reconnect we need to move events from the old consumer to the new one

Implements TAO_Notify_Consumer.

Definition at line 158 of file StructuredPushConsumer.cpp.

{
  TAO_Notify_StructuredPushConsumer* tmp = dynamic_cast<TAO_Notify_StructuredPushConsumer *> (old_consumer);
  ACE_ASSERT(tmp != 0);
  this->init(tmp->push_consumer_.in());
  this->schedule_timer(false);
}

void TAO_Notify_StructuredPushConsumer::release ( void   )  [private, virtual]

Release.

Definition at line 79 of file StructuredPushConsumer.cpp.

{
  delete this;
  //@@ inform factory
}


Member Data Documentation

Connection valid flag.

Definition at line 80 of file StructuredPushConsumer.h.

CosNotifyComm::StructuredPushConsumer_var TAO_Notify_StructuredPushConsumer::push_consumer_ [protected]

The Consumer.

Definition at line 73 of file StructuredPushConsumer.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines