HydraExpress™ C++ API Reference Guide

Product Documentation:
   HydraExpress C++
Documentation Home
List of all members | Public Member Functions
rwsf::MessageListener Class Reference

Provides a handle to all listener instances. More...

#include <rwsf/webservice/listener/MessageListener.h>

Inheritance diagram for rwsf::MessageListener:
rwsf::MessageHandler rwsf::HandleBase

Public Member Functions

 MessageListener ()
 
 MessageListener (MessageListenerImp *imp)
 
 MessageListener (const MessageListener &listener)
 
virtual ~MessageListener ()
 
MessageListenerImpbody () const
 
std::string getProperty (const std::string &key)
 
bool isStopped ()
 
void log (const std::string &message, rwsf::CallInfo::LogLevel l=rwsf::CallInfo::Error)
 
void log (rwsf::CallInfo &callInfo, rwsf::CallInfo::LogLevel l=rwsf::CallInfo::Error)
 
MessageListeneroperator= (const MessageListener &listener)
 
void reset ()
 
void setHandler (const rwsf::MessageHandler &handler)
 
void setProperty (const std::string &key, const std::string &value)
 
void start ()
 
void stop ()
 
- Public Member Functions inherited from rwsf::MessageHandler
 MessageHandler ()
 
 MessageHandler (const MessageHandler &handler)
 
 MessageHandler (MessageHandlerImp *impl)
 
 ~MessageHandler ()
 
void destroy ()
 
void init (const rwsf::Config &initParams)
 
void invoke (rwsf::CallInfo &callInfo)
 
MessageHandleroperator= (const MessageHandler &obj)
 
- Public Member Functions inherited from rwsf::HandleBase
bool isValid (void) const
 
bool operator!= (const HandleBase &second) const
 
bool operator== (const HandleBase &second) const
 

Additional Inherited Members

- Protected Member Functions inherited from rwsf::HandleBase
 HandleBase (void)
 
 HandleBase (StaticCtor)
 
 HandleBase (BodyBase *body)
 
 HandleBase (const HandleBase &second)
 
virtual ~HandleBase (void)
 
BodyBase & body (void) const
 
HandleBaseoperator= (const HandleBase &second)
 

Detailed Description

rwsf::MessageListener is the handle class for all listeners and uses reference semantics.

Listeners wait for messages in a separate thread and forward received messages to the relevant handler. Listeners are used in clients when there is need for the client to listen for messages, such as when implementing the notification and solicit-response patterns.

For more information about the notification pattern, asynchronous processing and handlers, see the Web Service Development Guide.

To create a new listener, extend the body class rwsf::MessageHandlerImp. Configure your listener in the configuration file client-transports.xml located in the conf directory of your RWSF installation. This file is a static file that is copied to your output directory at the time of code generation. It contains initialization parameters for client transports and listeners. For a discussion on creating or customizing transports or listeners, see the Web Service Development Guide.

rwsf::MessageListener implements the handle/body idiom in which rwsf::MessageListener is the handle, and a class derived from the abstract class rwsf::MessageListenerImp is the body.

Constructor & Destructor Documentation

rwsf::MessageListener::MessageListener ( )

Default constructor. Creates an empty message handler.

rwsf::MessageListener::MessageListener ( MessageListenerImp imp)

Constructs a new handler bound to a new listener body instance, and increments a reference count.

rwsf::MessageListener::MessageListener ( const MessageListener listener)

Copy constructor.

virtual rwsf::MessageListener::~MessageListener ( )
virtual

Destructor.

Member Function Documentation

MessageListenerImp& rwsf::MessageListener::body ( ) const

Returns the listener body.

std::string rwsf::MessageListener::getProperty ( const std::string &  key)

Given a property key, returns its value.

bool rwsf::MessageListener::isStopped ( )

Returns true if this listener is stopped, else false.

void rwsf::MessageListener::log ( const std::string &  message,
rwsf::CallInfo::LogLevel  l = rwsf::CallInfo::Error 
)

Invokes the logger and adds a message to it, forwarding to the service implementation. Sets the log level to Error.

void rwsf::MessageListener::log ( rwsf::CallInfo callInfo,
rwsf::CallInfo::LogLevel  l = rwsf::CallInfo::Error 
)

Invokes the logger and forwards to the service implementation. Sets the log level to Error.

MessageListener& rwsf::MessageListener::operator= ( const MessageListener listener)

Assignment operator.

void rwsf::MessageListener::reset ( )

Before calling reset(), be sure to stop the listener. This method calls isStopped() to determine whether the listener is still active, and throws an rwsf::Exception if it is.

Resets the listener through the following steps:

  • Calls doReset(), which is implemented in the derived class.
  • Sets the value of isInitialized_ to false.
  • Sets the value of isStopped_ to true.
void rwsf::MessageListener::setHandler ( const rwsf::MessageHandler handler)

Accepts the incoming handler, making it available to invoke() and other methods. The handler object handler should have a body of the type rwsf::MessageService. Typically, the associated rwsf::MessageService is configured automatically when the client's handler configuration file client-handlers.xml is processed. The message service is looked up via the rwsf::HandlerManager::findHandler() method, with the name of the service listed in the client-handlers file.

void rwsf::MessageListener::setProperty ( const std::string &  key,
const std::string &  value 
)

Sets a key/value property on the listener.

void rwsf::MessageListener::start ( )

Starts the listener thread using these steps:

  • Checks to see if this listener has been initialized.
  • If isInitialized_ is false, throws an rwsf::Exception.
  • Calls the pure virtual functions initServer() and start(), which are implemented in the derived listener class.
void rwsf::MessageListener::stop ( )

Calls the pure virtual method doStop(), which is implemented in the derived listener class.

Copyright © 2020 Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is registered trademark of Rogue Wave Software, Inc. in the United States and other countries, and HydraExpress is a trademark of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.