APIServer Class Reference

#include <APIServer.hpp>

Public Member Functions

 APIServer ()
 
virtual ~APIServer ()
 
void terminateServer ()
 
void initServer ()
 
void listenForConnections ()
 
void processMessages (SysServerConnection *connection)
 
ServiceReturn shutdown ()
 
virtual bool isStoppable ()
 
void cleanupProcessResources (ServiceMessage &message)
 
virtual void stop ()
 
void requestLock ()
 
void releaseLock ()
 
APIServerInstancegetInstance (ServiceMessage &m)
 
void dispatch (ServiceMessage &message)
 
void sessionTerminated (APIServerThread *thread)
 
void cleanupTerminatedSessions ()
 

Protected Attributes

SysMutex lock
 
SysServerStream server
 
bool serverActive
 
APIServerInstanceinstances
 
std::list< APIServerThread * > terminatedThreads
 

Detailed Description

Definition at line 52 of file APIServer.hpp.

Constructor & Destructor Documentation

◆ APIServer()

APIServer::APIServer ( )
inline

Definition at line 55 of file APIServer.hpp.

◆ ~APIServer()

virtual APIServer::~APIServer ( )
inlinevirtual

Definition at line 56 of file APIServer.hpp.

Member Function Documentation

◆ cleanupProcessResources()

void APIServer::cleanupProcessResources ( ServiceMessage message)

Cleanup sessions specific resources after a Rexx process terminates.

Parameters
messageThe service message with the session information.

Definition at line 352 of file APIServer.cpp.

References APIServerInstance::cleanupProcessResources(), and getInstance().

Referenced by dispatch().

◆ cleanupTerminatedSessions()

void APIServer::cleanupTerminatedSessions ( )

Cleanup the resources devoted to threads that have terminated.

Definition at line 124 of file APIServer.cpp.

References SysThread::terminate(), and terminatedThreads.

Referenced by listenForConnections().

◆ dispatch()

void APIServer::dispatch ( ServiceMessage message)

Dispatch an API server control message.

Parameters
messageThe control message parameter.

Definition at line 315 of file APIServer.cpp.

References cleanupProcessResources(), CONNECTION_ACTIVE, MESSAGE_OK, ServiceMessage::operation, ServiceMessage::parameter1, PROCESS_CLEANUP, ServiceMessage::result, REXXAPI_VERSION, SERVER_FAILURE, ServiceMessage::setExceptionInfo(), shutdown(), and SHUTDOWN_SERVER.

Referenced by processMessages().

◆ getInstance()

APIServerInstance * APIServer::getInstance ( ServiceMessage m)

Get the server instance associate with a particular userid, creating a new instance if this is the first time we've processed a request for this id.

Parameters
mThe service message associated with the request.
Returns
A pointer to the correct instance.

Definition at line 415 of file APIServer.cpp.

References instances, APIServerInstance::isUser(), and APIServerInstance::next.

Referenced by cleanupProcessResources(), and processMessages().

◆ initServer()

void APIServer::initServer ( )

Initialize the server side of the operation.

Definition at line 53 of file APIServer.cpp.

References SysMutex::create(), lock, SysServerStream::make(), REXX_API_PORT, server, SERVER_FAILURE, and serverActive.

Referenced by Run().

◆ isStoppable()

bool APIServer::isStoppable ( )
virtual

Test to see if the api server is in a state where it can be stopped. A stoppable state implies there are no session specific resources currently active in the server.

Returns
True if the server is stoppable, false otherwise.

Definition at line 391 of file APIServer.cpp.

References instances, APIServerInstance::isStoppable(), and APIServerInstance::next.

Referenced by shutdown().

◆ listenForConnections()

void APIServer::listenForConnections ( )

Process the Rexx API requests as a queue of messages. Each message is handled through to completion, so the message queue is the synchronization point.

Definition at line 82 of file APIServer.cpp.

References cleanupTerminatedSessions(), SysServerStream::connect(), server, serverActive, and APIServerThread::start().

Referenced by Run().

◆ processMessages()

◆ releaseLock()

void APIServer::releaseLock ( )

Release the global server API lock.

Definition at line 449 of file APIServer.cpp.

References lock, and SysMutex::release().

Referenced by ServerLock::~ServerLock().

◆ requestLock()

void APIServer::requestLock ( )

Request the global server API lock.

Definition at line 440 of file APIServer.cpp.

References lock, and SysMutex::request().

Referenced by ServerLock::ServerLock().

◆ sessionTerminated()

void APIServer::sessionTerminated ( APIServerThread thread)

Handle a session termination event.

Parameters
thread

Definition at line 110 of file APIServer.cpp.

References terminatedThreads.

Referenced by APIServerThread::dispatch().

◆ shutdown()

ServiceReturn APIServer::shutdown ( )

Cause the API server to shutdown.

Returns
SERVER_STOPPED if a stoppage is possible, SERVER_NOT_STOPPED if it was not in a stoppable state.

Definition at line 364 of file APIServer.cpp.

References isStoppable(), SERVER_NOT_STOPPABLE, SERVER_STOPPED, and serverActive.

Referenced by dispatch().

◆ stop()

void APIServer::stop ( )
virtual

Stop the server.

Definition at line 378 of file APIServer.cpp.

References serverActive.

◆ terminateServer()

void APIServer::terminateServer ( )

Do server shutdown processing and resource cleanup.

Definition at line 69 of file APIServer.cpp.

References SysServerStream::close(), server, and serverActive.

Referenced by OnStop(), Run(), and Stop().

Member Data Documentation

◆ instances

APIServerInstance* APIServer::instances
protected

Definition at line 77 of file APIServer.hpp.

Referenced by getInstance(), and isStoppable().

◆ lock

SysMutex APIServer::lock
protected

Definition at line 74 of file APIServer.hpp.

Referenced by initServer(), releaseLock(), and requestLock().

◆ server

SysServerStream APIServer::server
protected

Definition at line 75 of file APIServer.hpp.

Referenced by initServer(), listenForConnections(), and terminateServer().

◆ serverActive

bool APIServer::serverActive
protected

◆ terminatedThreads

std::list<APIServerThread *> APIServer::terminatedThreads
protected

Definition at line 78 of file APIServer.hpp.

Referenced by cleanupTerminatedSessions(), and sessionTerminated().


The documentation for this class was generated from the following files: