rwlogo
HydraExpress 4.6

HydraExpress C++ API Reference Guide


   


Rogue Wave web site:  Home Page  |  Main Documentation Page

rwsf::MessageListener Class Reference
[Transports]

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

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

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

List of all members.

Public Member Functions

 MessageListener ()
 MessageListener (MessageListenerImp *imp)
 MessageListener (const MessageListener &listener)
virtual ~MessageListener ()
MessageListeneroperator= (const MessageListener &listener)
void setProperty (const std::string &key, const std::string &value)
std::string getProperty (const std::string &key)
void start ()
void stop ()
void reset ()
bool isStopped ()
void setHandler (const rwsf::MessageHandler &handler)
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)
MessageListenerImpbody () const

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.

Reimplemented from rwsf::MessageHandler.

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 ( 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.

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.

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 © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo are registered trademarks of Rogue Wave Software, and HydraExpress is a trademark of Rogue Wave Software. All other trademarks are the property of their respective owners.