rwlogo
HydraExpress 4.6

HydraExpress C++ API Reference Guide


   


Rogue Wave web site:  Home Page  |  Main Documentation Page

rwsf::AgentContext Class Reference
[Message Handling]

Holds state information about the entire Agent process. More...

#include <rwsf/handlers/AgentContext.h>

Inheritance diagram for rwsf::AgentContext:
rwsf::MessageInfo rwsf::HandleBase

List of all members.

Public Types

enum  AgentState { AgentStateUnknown, AgentStateInitializing, AgentStateNormal, AgentStateBackup }

Public Member Functions

 AgentContext (const AgentContext &context)
AgentContextoperator= (const AgentContext &context)
void init (const rwsf::Config &config)
rwsf::MessageInfoHandlerChain getHandlerChain (const std::string &name) const
void setHandlerChain (const std::string &name, const rwsf::MessageInfoHandlerChain &chain)
rwsf::Connector getConnector (const std::string &name) const
rwsf::Enumeration
< rwsf::Connector
getConnectors () const
void setConnector (const std::string &name, const rwsf::Connector &connector)
rwsf::Logger getLogger () const
void setLogger (const rwsf::Logger &logger)
rwsf::AgentContext::AgentState getAgentState () const
std::string getConfigurationFile () const

Static Public Member Functions

static
rwsf::AgentContext::AgentState 
strToAgentState (const std::string &type)
static std::string agentStateToStr (const rwsf::AgentContext::AgentState &state)

Detailed Description

The AgentContext holds state information about the entire Agent process. It initializes based on the main configuration file (usually <installdir>/conf/rwagent.xml) and sets up important Agent modules, such as the connectors, handler chains, and loggers.

Note:
There should only be one instance of an AgentContext in the Agent. This class uses reference semantics wherein copies and assignments always point to the same object instance.

Querying and/or modifying the context can inspect or change the state of the running Agent, so care should be taken when using this class directly.

Note:
Do not instantiate this class directly. The AgentContext process instance is available only through certain features, such as within a Connector instance. See the Connector chapter in the RWSF User Guide for an example.

Member Enumeration Documentation

Enumeration containing all possible Agent states. For more information on Agent state, please see

Enumerator:
AgentStateUnknown 

The state is unknown, and therefore likely to be down.

AgentStateInitializing 

The Agent is initializing startup.

AgentStateNormal 

The Agent is operating normally.

AgentStateBackup 

Not used.


Constructor & Destructor Documentation

rwsf::AgentContext::AgentContext ( const AgentContext context  ) 

Copy constructor.


Member Function Documentation

static std::string rwsf::AgentContext::agentStateToStr ( const rwsf::AgentContext::AgentState state  )  [static]

Helper method to convert the given state to a string, as follows:

Agent State Types
rwsf:AgentContext::AgentStateNormal Normal
rwsf:AgentContext::AgentStateBackup Backup
rwsf:AgentContext::AgentStateInitializing Initializing
Any other value Unknown
rwsf::AgentContext::AgentState rwsf::AgentContext::getAgentState (  )  const

Gets the Agent's state.

std::string rwsf::AgentContext::getConfigurationFile (  )  const

Returns the path to the configuration file used to start the Agent (i.e. the file passed with the "-c" argument on the command line when the Agent was started).

rwsf::Connector rwsf::AgentContext::getConnector ( const std::string &  name  )  const

Retrieves the connector name, usually derived from the name of a configured connector in rwagent.xml. If name does not exist, an invalid handle is returned.

rwsf::Enumeration<rwsf::Connector> rwsf::AgentContext::getConnectors (  )  const

Returns an enumeration of all of the connectors registered in the Agent.

rwsf::MessageInfoHandlerChain rwsf::AgentContext::getHandlerChain ( const std::string &  name  )  const

Retrieves the handler chain associated with the provided handler chain name, usually derived from the handler chain of that name in the Agent configuration file rwagent.xml. If one does not exist, an empty chain is returned.

rwsf::Logger rwsf::AgentContext::getLogger (  )  const

Gets the current default logger for this AgentContext.

void rwsf::AgentContext::init ( const rwsf::Config config  ) 

Initializes the AgentContext with any special properties provided by config.

AgentContext& rwsf::AgentContext::operator= ( const AgentContext context  ) 

Assignment operator.

void rwsf::AgentContext::setConnector ( const std::string &  name,
const rwsf::Connector connector 
)

Sets a new connector with specified name. If name already exists, it is replaced.

Note:
Applications are responsible for stopping any existing connectors before replacing them.
void rwsf::AgentContext::setHandlerChain ( const std::string &  name,
const rwsf::MessageInfoHandlerChain chain 
)

Sets a new handler chain with the specified name. Any modules (connectors, etc) that use name for their handler chain will run the new chain specified in chain for any message processing. If the handler chain name already exists, it is replaced.

void rwsf::AgentContext::setLogger ( const rwsf::Logger logger  ) 

Sets the default logger for this AgentContext to logger.

static rwsf::AgentContext::AgentState rwsf::AgentContext::strToAgentState ( const std::string &  type  )  [static]

Helper method to convert the given type to an rwsf::AgentContext::AgentState. Case-insensitive. The possible types and the conversion to state are:

Types Agent State
Normal rwsf:AgentContext::AgentStateNormal
Backup rwsf:AgentContext::AgentStateBackup
Initializing rwsf:AgentContext::AgentStateInitializing
.* rwsf:AgentContext::AgentStateUnknown

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.