HydraExpress™ C++ 2020 |
HydraExpress™ C++ API Reference Guide |
Product Documentation: HydraExpress C++ Documentation Home |
Provides a handle to all listener instances. More...
#include <rwsf/webservice/listener/MessageListener.h>
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 |
HandleBase & | operator= (const HandleBase &second) |
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.
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 |
Destructor.
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:
isInitialized_
to false
.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:
isInitialized_
is false
, throws an rwsf::Exception.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. |