Main application class for stand alone webapplication. More...

#include <tnt/tntnet.h>

Public Member Functions

 Tntnet ()
 Initialize a default Tntnet-application without mappings.
void init (const TntConfig &config)
 Initialize from global configuration.
void listen (const std::string &ipaddr, unsigned short int port)
 Set up a listener on the specified ip address and port.
void listen (unsigned short int port)
 Listen on all local interfaces on the specified port.
void sslListen (const std::string &certificateFile, const std::string &keyFile, const std::string &ipaddr, unsigned short int port)
 Set up a ssl listener on the specified ip address and port.
void sslListen (const std::string &certificateFile, const std::string &keyFile, unsigned short int port)
 Listen on all local interfaces on the specified port for ssl requests.
void run ()
 Starts all needed threads and the application loop.
JobqueuegetQueue ()
 Returns the queue, which helds active http requests.
PollergetPoller ()
 Returns a reference to the poller thread object.
const DispatchergetDispatcher () const
 Returns a reference to the dispatcher object.
ScopeManagergetScopemanager ()
 Returns a reference to the scope manager object.
unsigned getMinThreads () const
 Returns the minimum number of worker threads.
void setMinThreads (unsigned n)
 Sets the minimum number of worker threads.
unsigned getMaxThreads () const
 Returns the maximum number of worker threads.
void setMaxThreads (unsigned n)
 Sets the maximum number of worker threads.
MappingmapUrl (const std::string &url, const std::string &ci)
 Adds a mapping from a url to a component.
void mapUrl (const std::string &url, const std::string &pathinfo, const std::string &ci_)
MappingmapUrl (const std::string &url, const Maptarget &ci)
MappingvMapUrl (const std::string &vhost, const std::string &url, const Maptarget &ci)
void setAppName (const std::string &appname_)
 Set the app name.
const std::string & getAppName () const
void setAccessLog (const std::string &accesslog)

Static Public Member Functions

static void shutdown ()
 Shut down all instances of tntnet servers.
static bool shouldStop ()
 Tells, if a shutdown request was initiated.

Friends

class Worker

Detailed Description

Main application class for stand alone webapplication.

This is the class to use to run a webapplication as a stand alone application. Using this a application runs itself as a webserver instead of using a tntnet application server.

To create a application you need to: instantiate a Tntnet class call listen and/or sslListen for each ip address to listen on set up your url mappings using mapUrl or vMapUrl call run()

Constructor & Destructor Documentation

tnt::Tntnet::Tntnet ( )

Initialize a default Tntnet-application without mappings.

Member Function Documentation

const std::string& tnt::Tntnet::getAppName ( ) const
inline
const Dispatcher& tnt::Tntnet::getDispatcher ( ) const
inline

Returns a reference to the dispatcher object.

unsigned tnt::Tntnet::getMaxThreads ( ) const
inline

Returns the maximum number of worker threads.

unsigned tnt::Tntnet::getMinThreads ( ) const
inline

Returns the minimum number of worker threads.

Poller& tnt::Tntnet::getPoller ( )
inline

Returns a reference to the poller thread object.

Jobqueue& tnt::Tntnet::getQueue ( )
inline

Returns the queue, which helds active http requests.

ScopeManager& tnt::Tntnet::getScopemanager ( )
inline

Returns a reference to the scope manager object.

void tnt::Tntnet::init ( const TntConfig config)

Initialize from global configuration.

void tnt::Tntnet::listen ( const std::string &  ipaddr,
unsigned short int  port 
)

Set up a listener on the specified ip address and port.

Listening on the port does not actually happen here but when the application is started using the run-method.

void tnt::Tntnet::listen ( unsigned short int  port)
inline

Listen on all local interfaces on the specified port.

Mapping& tnt::Tntnet::mapUrl ( const std::string &  url,
const std::string &  ci 
)
inline

Adds a mapping from a url to a component.

The url is specified using a regular expression and the mapped target may contain back references to the expression using $1, $2, ... .

void tnt::Tntnet::mapUrl ( const std::string &  url,
const std::string &  pathinfo,
const std::string &  ci_ 
)
inline
Mapping& tnt::Tntnet::mapUrl ( const std::string &  url,
const Maptarget ci 
)
inline
void tnt::Tntnet::run ( )

Starts all needed threads and the application loop.

If no listeners are set up using listen or sslListen, a default listener is instantiated. By default it listens on the ip address 0.0.0.0 (i.e. all addresses). The port 80 is used, when started as root user, port 8000 otherwise.

void tnt::Tntnet::setAccessLog ( const std::string &  accesslog)
inline
void tnt::Tntnet::setAppName ( const std::string &  appname_)
inline

Set the app name.

The app name is used for the session cookie name if the webapplication is linked directly to a stand alone application. The name of the session cookie is then "tntnet." plus the library name of the web application. Since there is no library name, if the application is run through the Tntnet application class, this application name is used instead.

Setting the application explicitely reduces potential conflicts if multiple tntnet application servers are run on the same host on different ports.

void tnt::Tntnet::setMaxThreads ( unsigned  n)
inline

Sets the maximum number of worker threads.

void tnt::Tntnet::setMinThreads ( unsigned  n)

Sets the minimum number of worker threads.

static bool tnt::Tntnet::shouldStop ( )
inlinestatic

Tells, if a shutdown request was initiated.

static void tnt::Tntnet::shutdown ( )
static

Shut down all instances of tntnet servers.

void tnt::Tntnet::sslListen ( const std::string &  certificateFile,
const std::string &  keyFile,
const std::string &  ipaddr,
unsigned short int  port 
)

Set up a ssl listener on the specified ip address and port.

Listening on the port does not actually happen here but when the application is started using the run-method.

void tnt::Tntnet::sslListen ( const std::string &  certificateFile,
const std::string &  keyFile,
unsigned short int  port 
)
inline

Listen on all local interfaces on the specified port for ssl requests.

Mapping& tnt::Tntnet::vMapUrl ( const std::string &  vhost,
const std::string &  url,
const Maptarget ci 
)
inline

Friends And Related Function Documentation

friend class Worker
friend

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