Daraja HTTP Framework 3.0.7-SNAPSHOT
HTTP server framework for Object Pascal
Loading...
Searching...
No Matches
TdjWebComponentContextHandler Class Reference

Context Handler for Web Components (and Web Filters). More...

Inheritance diagram for TdjWebComponentContextHandler:
TdjContextHandler TdjHandlerWrapper TdjAbstractHandlerContainer TdjAbstractHandler IHandlerContainer TdjLifeCycle IHandler ILifeCycle TdjWebAppContext

Public Member Functions

 TdjWebComponentContextHandler (const string ContextPath, Boolean Sessions=False)
 Constructor.
 ~TdjWebComponentContextHandler ()
 Destructor.
TdjWebComponentHolder Add (TdjWebComponentClass ComponentClass, const string UrlPattern)
 Add a Web Component.
TdjWebFilterHolder Add (TdjWebFilterClass FilterClass, const string UrlPattern)
 Add a Web Filter, specifying a WebFilter class.
 AddHandler (const IHandler Handler)
 Add a handler to the container.
TdjWebComponentHolder AddWebComponent (TdjWebComponentClass ComponentClass, const string UrlPattern)
 Add a Web Component.
TdjWebFilterHolder AddWebFilter (TdjWebFilterClass FilterClass, const string UrlPattern)
 Add a Web Filter, specifying a WebFilter class.
IContext GetCurrentContext ()
 The internal IContext field.
Boolean IsStarted ()
Boolean IsStopped ()
 RemoveHandler (const IHandler Handler)
 Removes a handler from this container.
 SetInitParameter (const string Key, const string Value)
 Set initialization parameter.
 Start ()
 Starts the component.
 Stop ()
 Stops the component.

Public Attributes

TStrings ConnectorNames
string ContextPath
IHandler ErrorHandler
IHandler Handler
Boolean Started
Boolean Stopped

Protected Member Functions

 AddWebComponent (TdjWebComponentHolder Holder, const string UrlPattern)
 Add a Web Component.
 AddWebFilter (TdjWebFilterHolder Holder, const string UrlPattern)
 Add a Web Filter Holder.
 CheckStarted ()
 Raises an exception if the lifecycle is in "started" state.
 CheckStopped ()
 Raises an exception if the lifecycle is in "stopped" state.
Boolean ContextMatches (const string ConnectorName, const string Target)
 Check if the Document matches this context.
 DoHandle (const string Target, TdjServerContext Context, TdjRequest Request, TdjResponse Response)
 DoStart ()
 Start the handler.
 DoStop ()
 Start the handler.
TIdHTTPSession GetSession (TdjServerContext Context, TdjRequest Request, TdjResponse Response, const Boolean Create)
 Get a HTTP session.
 Handle (const string Target, TdjServerContext Context, TdjRequest Request, TdjResponse Response)
 Handles an HTTP request.
string ToConnectorName (TdjServerContext Context)
 Creates connector name in the form 'host:port'.

Detailed Description

Context Handler for Web Components (and Web Filters).

Constructor & Destructor Documentation

◆ TdjWebComponentContextHandler()

TdjWebComponentContextHandler::TdjWebComponentContextHandler ( const string ContextPath,
Boolean Sessions = False )

Constructor.

Parameters
ContextPaththe context path
Sessionsenable HTTP sessions

References TdjWebComponentContextHandler(), AddWebComponent(), and TdjContextHandler::GetCurrentContext().

Referenced by TdjWebComponentContextHandler(), ~TdjWebComponentContextHandler(), and AddWebComponent().

◆ ~TdjWebComponentContextHandler()

TdjWebComponentContextHandler::~TdjWebComponentContextHandler ( )

Destructor.

References TdjWebComponentContextHandler().

Member Function Documentation

◆ Add() [1/2]

TdjWebComponentHolder TdjWebComponentContextHandler::Add ( TdjWebComponentClass ComponentClass,
const string UrlPattern )

Add a Web Component.

Parameters
ComponentClassWebComponent class
UrlPatternpath specification
Returns
the Web Component holder, which can be used for further configuration.
Exceptions
EWebComponentExceptionif the Web Component can not be added

References DoHandle().

◆ Add() [2/2]

TdjWebFilterHolder TdjWebComponentContextHandler::Add ( TdjWebFilterClass FilterClass,
const string UrlPattern )

Add a Web Filter, specifying a WebFilter class.

Parameters
FilterClassWebFilter class
UrlPatternpath specification
Returns
the Web Filter holder, which can be used for further configuration.
Exceptions
Exceptionif the WebFilter can not be added

◆ AddHandler()

TdjHandlerWrapper::AddHandler ( const IHandler Handler)
inherited

Add a handler to the container.

This implementation of AddHandler calls SetHandler with the passed handler. If this HandlerWrapper had a previous wrapped handler, then it is passed to a call to AddHandler on the passed handler.

Parameters
Handlerthe handler to be added

Implements IHandlerContainer.

◆ AddWebComponent() [1/2]

TdjWebComponentHolder TdjWebComponentContextHandler::AddWebComponent ( TdjWebComponentClass ComponentClass,
const string UrlPattern )

Add a Web Component.

Parameters
ComponentClassWebComponent class
UrlPatternpath specification
Returns
the Web Component holder, which can be used for further configuration.
Exceptions
EWebComponentExceptionif the Web Component can not be added

References TdjWebComponentContextHandler(), AddWebFilter(), TdjContextHandler::ContextMatches(), TdjContextHandler::ContextPath, TdjHandlerWrapper::GetSession(), Handle(), and TdjContextHandler::ToConnectorName().

◆ AddWebComponent() [2/2]

TdjWebComponentContextHandler::AddWebComponent ( TdjWebComponentHolder Holder,
const string UrlPattern )
protected

Add a Web Component.

Parameters
Holderholds information about the Web Component
UrlPatternpath specification
Exceptions
EWebComponentExceptionif the Web Component can not be added
Deprecated
for removal

Referenced by TdjWebComponentContextHandler().

◆ AddWebFilter() [1/2]

TdjWebFilterHolder TdjWebComponentContextHandler::AddWebFilter ( TdjWebFilterClass FilterClass,
const string UrlPattern )

Add a Web Filter, specifying a WebFilter class.

Parameters
FilterClassWebFilter class
UrlPatternpath specification
Returns
the Web Filter holder, which can be used for further configuration.
Exceptions
Exceptionif the WebFilter can not be added

◆ AddWebFilter() [2/2]

TdjWebComponentContextHandler::AddWebFilter ( TdjWebFilterHolder Holder,
const string UrlPattern )
protected

Add a Web Filter Holder.

Parameters
Holderholds information about the Web Filter
UrlPatternpath specification
Exceptions
Exceptionif the Web Filter can not be added
Deprecated
for removal

Referenced by AddWebComponent().

◆ CheckStarted()

TdjLifeCycle::CheckStarted ( )
protectedinherited

Raises an exception if the lifecycle is in "started" state.

References TdjLifeCycle().

◆ CheckStopped()

TdjLifeCycle::CheckStopped ( )
protectedinherited

Raises an exception if the lifecycle is in "stopped" state.

References TdjLifeCycle(), and Started.

◆ ContextMatches()

Boolean TdjContextHandler::ContextMatches ( const string ConnectorName,
const string Target )
protectedinherited

Check if the Document matches this context.

Parameters
ConnectorNamethe connector name (like 'host:port'
Targetthe target URL document
Returns
True if the context matches the connector name and target URL document

Referenced by TdjWebComponentContextHandler::AddWebComponent().

◆ DoHandle()

TdjWebComponentContextHandler::DoHandle ( const string Target,
TdjServerContext Context,
TdjRequest Request,
TdjResponse Response )
protected
Parameters
TargetRequest target
ContextHTTP server context
RequestHTTP request
ResponseHTTP response

Referenced by Add().

◆ DoStart()

TdjContextHandler::DoStart ( )
protectedinherited

Start the handler.

See also
TdjLifeCycle

◆ DoStop()

TdjContextHandler::DoStop ( )
protectedinherited

Start the handler.

See also
TdjLifeCycle

◆ GetCurrentContext()

IContext TdjContextHandler::GetCurrentContext ( )
inherited

◆ GetSession()

TIdHTTPSession TdjHandlerWrapper::GetSession ( TdjServerContext Context,
TdjRequest Request,
TdjResponse Response,
const Boolean Create )
protectedinherited

Get a HTTP session.

References TdjHandlerWrapper(), Create(), and Handler.

Referenced by TdjWebComponentContextHandler::AddWebComponent().

◆ Handle()

TdjWebComponentContextHandler::Handle ( const string Target,
TdjServerContext Context,
TdjRequest Request,
TdjResponse Response )
protected

Handles an HTTP request.

Parameters
TargetTarget path or resource identifier
ContextServer context for this request
RequestHTTP request object
ResponseHTTP response object to populate
Exceptions
EWebComponentExceptionif an exception occurs that interferes with the component's normal operation.

Implements IHandler.

Referenced by AddWebComponent().

◆ IsStarted()

Boolean TdjLifeCycle::IsStarted ( )
inherited
Returns
True if component is started

Implements ILifeCycle.

References Create().

Referenced by DoStart(), and TdjWebComponentHandler::FindHolder().

◆ IsStopped()

Boolean TdjLifeCycle::IsStopped ( )
inherited
Returns
True if component is stopped

Implements ILifeCycle.

Referenced by DoStart().

◆ RemoveHandler()

TdjHandlerWrapper::RemoveHandler ( const IHandler Handler)
inherited

Removes a handler from this container.

Parameters
HandlerHandler to remove

Implements IHandlerContainer.

References Handler.

◆ SetInitParameter()

TdjContextHandler::SetInitParameter ( const string Key,
const string Value )
inherited

Set initialization parameter.

Parameters
Keyinit parameter name
Valueinit parameter value

◆ Start()

TdjLifeCycle::Start ( )
inherited

Starts the component.

Implements ILifeCycle.

References Stopped.

◆ Stop()

TdjLifeCycle::Stop ( )
inherited

Stops the component.

Implements ILifeCycle.

References TdjLifeCycle().

Referenced by DoStart(), and TdjWebComponentHandler::InvokeService().

◆ ToConnectorName()

string TdjContextHandler::ToConnectorName ( TdjServerContext Context)
protectedinherited

Creates connector name in the form 'host:port'.

Returns
connector name

Referenced by TdjWebComponentContextHandler::AddWebComponent().

Member Data Documentation

◆ ConnectorNames

TStrings TdjContextHandler::ConnectorNames
inherited

◆ ContextPath

string TdjContextHandler::ContextPath
inherited

◆ ErrorHandler

IHandler TdjContextHandler::ErrorHandler
inherited

◆ Handler

IHandler TdjHandlerWrapper::Handler
inherited

Referenced by GetSession(), and RemoveHandler().

◆ Started

◆ Stopped

Boolean TdjLifeCycle::Stopped
inherited

Referenced by DoStop(), and Start().