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

Web Component handler. More...

Inheritance diagram for TdjWebComponentHandler:
TdjAbstractHandler TdjLifeCycle IHandler ILifeCycle

Public Member Functions

 TdjWebComponentHandler ()
 ~TdjWebComponentHandler ()
TdjWebComponentHolder AddWebComponent (TdjWebComponentClass ComponentClass, const string UrlPattern)
 Add a Web Component.
 AddWebFilter (TdjWebFilterHolder Holder, const string UrlPattern)
 Add a Web Filter, specifying a WebFilter class and the mapped path.
 AddWithMapping (TdjWebComponentHolder Holder, const string UrlPattern)
 Add a Web Component holder with mapping.
TdjWebComponentHolder FindHolder (TdjWebComponentClass WebComponentClass)
 Find a TdjWebComponentHolder for a WebComponentClass.
 InvokeService (TdjWebComponent Comp, TdjServerContext Context, TdjRequest Request, TdjResponse Response)
 Invokes a service for the specified web component.
Boolean IsStarted ()
Boolean IsStopped ()
 SetContext (const IContext Context)
 Sets the context for the component handler.
 Start ()
 Starts the component.
 Stop ()
 Stops the component.

Public Attributes

Boolean Started
Boolean Stopped

Protected Member Functions

 AddMapping (TdjWebComponentMapping Mapping)
 Adds a new web component mapping to the handler.
 CheckNotStarted ()
 Raises an exception if the lifecycle is already in "started" state.
 CheckNotStopped ()
 Raises an exception if the lifecycle is already in "stopped" state.
 DoStart ()
 Starts the web component handler.
 DoStop ()
 Stops the web component handler.
TdjWebComponentHolder FindComponent (const string ATarget)
 Finds a web component holder by its target identifier.
IWebFilterChain GetFilterChain (const string PathInContext, TdjRequest Request, TdjWebComponentHolder Holder)
 Builds the filter chain that applies to a request path.
 Handle (const string Target, TdjServerContext Context, TdjRequest Request, TdjResponse Response)

Protected Attributes

TdjWebComponentHolders WebComponents
TdjWebFilterHolders WebFilters

Detailed Description

Web Component handler.

An instance of this class is created per context.

It holds a list of web components and their path mappings, and passes incoming requests to the matching web component.

Constructor & Destructor Documentation

◆ TdjWebComponentHandler()

TdjWebComponentHandler::TdjWebComponentHandler ( )

Referenced by AddWebFilter(), and InvokeService().

◆ ~TdjWebComponentHandler()

TdjWebComponentHandler::~TdjWebComponentHandler ( )

Member Function Documentation

◆ AddMapping()

TdjWebComponentHandler::AddMapping ( TdjWebComponentMapping Mapping)
protected

Adds a new web component mapping to the handler.

Parameters
MappingThe TdjWebComponentMapping instance to be added.

References AddWithMapping().

◆ AddWebComponent()

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

Add a Web Component.

Parameters
ComponentClassWebComponent class
UrlPatternpath specification
Exceptions
EWebComponentExceptionif the Web Component can not be added

◆ AddWebFilter()

TdjWebComponentHandler::AddWebFilter ( TdjWebFilterHolder Holder,
const string UrlPattern )

Add a Web Filter, specifying a WebFilter class and the mapped path.

Parameters
HolderWebFilter holder
UrlPatternmapped path
Exceptions
Exceptionif the WebFilter can not be added

References TdjWebComponentHandler().

◆ AddWithMapping()

TdjWebComponentHandler::AddWithMapping ( TdjWebComponentHolder Holder,
const string UrlPattern )

Add a Web Component holder with mapping.

Parameters
Holdera Web Component holder
UrlPatterna path spec

Referenced by AddMapping(), and InvokeService().

◆ CheckNotStarted()

TdjLifeCycle::CheckNotStarted ( )
protectedinherited

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

References Started, and Stopped.

Referenced by TdjWebFilterHolders::TdjWebFilterHolders().

◆ CheckNotStopped()

TdjLifeCycle::CheckNotStopped ( )
protectedinherited

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

References TdjLifeCycle().

◆ DoStart()

TdjWebComponentHandler::DoStart ( )
protected

Starts the web component handler.

This method is called to initialize and start the handler.

Implements IHandler.

◆ DoStop()

TdjWebComponentHandler::DoStop ( )
protected

Stops the web component handler.

This method is called to clean up and stop the handler.

Implements IHandler.

◆ FindComponent()

TdjWebComponentHolder TdjWebComponentHandler::FindComponent ( const string ATarget)
protected

Finds a web component holder by its target identifier.

Parameters
ATargetThe identifier of the target component to find.
Returns
A TdjWebComponentHolder instance representing the found component, or nil if not found.

◆ FindHolder()

TdjWebComponentHolder TdjWebComponentHandler::FindHolder ( TdjWebComponentClass WebComponentClass)

Find a TdjWebComponentHolder for a WebComponentClass.

Parameters
WebComponentClassthe Web Component class
Returns
a TdjWebComponentHolder with the WebComponentClass or nil if the WebComponentClass is not registered

◆ GetFilterChain()

IWebFilterChain TdjWebComponentHandler::GetFilterChain ( const string PathInContext,
TdjRequest Request,
TdjWebComponentHolder Holder )
protected

Builds the filter chain that applies to a request path.

Parameters
PathInContextThe request path relative to the context. An empty path yields no chain.
RequestThe HTTP request being processed.
HolderThe web component holder at the end of the chain.
Returns
The filter chain, or nil if no filter is mapped to the path.

◆ Handle()

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

Implements IHandler.

◆ InvokeService()

TdjWebComponentHandler::InvokeService ( TdjWebComponent Comp,
TdjServerContext Context,
TdjRequest Request,
TdjResponse Response )

Invokes a service for the specified web component.

Parameters
CompThe web component instance to handle.
ContextThe server context in which the service is invoked.
RequestThe incoming request to be processed.
ResponseThe outgoing response to be sent.

References TdjWebComponentHandler(), AddWithMapping(), TdjLifeCycle::IsStarted(), and TdjLifeCycle::Stop().

◆ IsStarted()

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

Implements ILifeCycle.

References TdjLifeCycle().

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

◆ IsStopped()

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

Implements ILifeCycle.

References Stopped.

Referenced by DoStop().

◆ SetContext()

TdjWebComponentHandler::SetContext ( const IContext Context)

Sets the context for the component handler.

Parameters
ContextThe context to be set, implementing the IContext interface.

◆ Start()

TdjLifeCycle::Start ( )
inherited

Starts the component.

Implements ILifeCycle.

References TdjLifeCycle().

Referenced by DoStop().

◆ Stop()

TdjLifeCycle::Stop ( )
inherited

Stops the component.

Note
Unlike Start, a failure in the custom stop code is logged and swallowed rather than re-raised; the component is still marked stopped.

Implements ILifeCycle.

References Started.

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

Member Data Documentation

◆ Started

Boolean TdjLifeCycle::Started
inherited

Referenced by CheckNotStarted(), and Stop().

◆ Stopped

Boolean TdjLifeCycle::Stopped
inherited

Referenced by CheckNotStarted(), and IsStopped().

◆ WebComponents

TdjWebComponentHolders TdjWebComponentHandler::WebComponents
protected

◆ WebFilters

TdjWebFilterHolders TdjWebComponentHandler::WebFilters
protected