Daraja HTTP Framework 3.1.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.
 CheckUniqueName (TdjWebComponentHolder Holder)
 CreateOrUpdateMapping (const string UrlPattern, TdjWebComponentHolder Holder)
TdjWebComponentHolder FindHolder (TdjWebComponentClass WebComponentClass)
 Find a TdjWebComponentHolder for a WebComponentClass.
TdjWebComponentMapping FindMapping (const string WebComponentName)
IWebFilterChain GetFilterChain (const string PathInContext, TdjRequest Request, TdjWebComponentHolder Holder)
 InitializeHolders (TdjWebFilterHolders Holders)
 InvokeService (TdjWebComponent Comp, TdjServerContext Context, TdjRequest Request, TdjResponse Response)
 Invokes a service for the specified web component.
Boolean IsStarted ()
Boolean IsStopped ()
IWebFilterChain NewFilterChain (TdjWebFilterHolder Holder, IWebFilterChain Chain)
 SetContext (const IContext Context)
 Sets the context for the component handler.
 SetFilters (TdjWebFilterHolders Holders)
 SetStarted (const Boolean Value)
 SetStopped (const Boolean Value)
 Start ()
 Starts the component.
 Stop ()
 Stops the component.
string StripContext (const string Doc)
 UpdateMappings ()
 UpdateNameMappings ()
 ValidateMappingUrlPattern (const string UrlPattern, TdjWebComponentHolder Holder)

Public Attributes

TCriticalSection CS
TdjPathMap FPathMap
Boolean FStopped
IContext FWebComponentContext
TdjWebComponentHolders FWebComponentHolders
TdjWebComponentMappings FWebComponentMappings
TdjWebFilterHolders FWebFilterHolders
TdjWebFilterMappings FWebFilterMappings
< ><> TdjWebFilterMappings FWebFilterPathMappings
Boolean Started
Boolean Stopped
IContext WebComponentContext
TdjWebComponentMappings WebComponentMappings

Protected Member Functions

 AddMapping (TdjWebComponentMapping Mapping)
 Adds a new web component mapping to the handler.
 CheckStarted ()
 Raises an exception if the lifecycle is in "started" state.
 CheckStopped ()
 Raises an exception if the lifecycle is 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.
 Handle (const string Target, TdjServerContext Context, TdjRequest Request, TdjResponse Response)
 Handles an HTTP request.

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 ( )

◆ ~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.

Referenced by GetFilterChain().

◆ 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 DoStop(), and InvokeService().

◆ CheckStarted()

TdjLifeCycle::CheckStarted ( )
protectedinherited

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

◆ CheckStopped()

TdjLifeCycle::CheckStopped ( )
protectedinherited

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

References TdjLifeCycle().

◆ CheckUniqueName()

TdjWebComponentHandler::CheckUniqueName ( TdjWebComponentHolder Holder)

◆ CreateOrUpdateMapping()

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

◆ DoStart()

TdjWebComponentHandler::DoStart ( )
protected

Starts the web component handler.

This method is called to initialize and start the handler.

References Add().

◆ DoStop()

TdjWebComponentHandler::DoStop ( )
protected

Stops the web component handler.

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

References Add(), and AddWithMapping().

◆ 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

References TdjWebComponentHandler(), FPathMap, FWebComponentMappings, FWebFilterHolders, and FWebFilterMappings.

◆ FindMapping()

TdjWebComponentMapping TdjWebComponentHandler::FindMapping ( const string WebComponentName)

◆ GetFilterChain()

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

◆ Handle()

TdjWebComponentHandler::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.

References InvokeService().

Referenced by NewFilterChain().

◆ InitializeHolders()

TdjWebComponentHandler::InitializeHolders ( TdjWebFilterHolders Holders)

◆ 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(), FPathMap, FWebComponentContext, FWebComponentHolders, FWebComponentMappings, FWebFilterHolders, FWebFilterMappings, FWebFilterPathMappings, TdjLifeCycle::IsStarted(), and TdjLifeCycle::Stop().

Referenced by Handle().

◆ IsStarted()

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

Implements ILifeCycle.

References TdjLifeCycle().

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

◆ IsStopped()

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

Implements ILifeCycle.

References Create().

Referenced by DoStart().

◆ NewFilterChain()

IWebFilterChain TdjWebComponentHandler::NewFilterChain ( TdjWebFilterHolder Holder,
IWebFilterChain Chain )

References Create(), Destroy(), and Handle().

◆ SetContext()

TdjWebComponentHandler::SetContext ( const IContext Context)

Sets the context for the component handler.

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

◆ SetFilters()

TdjWebComponentHandler::SetFilters ( TdjWebFilterHolders Holders)

◆ SetStarted()

TdjLifeCycle::SetStarted ( const Boolean Value)
inherited

Referenced by DoStop().

◆ SetStopped()

TdjLifeCycle::SetStopped ( const Boolean Value)
inherited

Referenced by DoStop().

◆ Start()

TdjLifeCycle::Start ( )
inherited

Starts the component.

Implements ILifeCycle.

References TdjLifeCycle().

Referenced by DoStart().

◆ Stop()

TdjLifeCycle::Stop ( )
inherited

Stops the component.

Implements ILifeCycle.

References Stopped.

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

◆ StripContext()

string TdjWebComponentHandler::StripContext ( const string Doc)

◆ UpdateMappings()

TdjWebComponentHandler::UpdateMappings ( )

Referenced by SetFilters().

◆ UpdateNameMappings()

TdjWebComponentHandler::UpdateNameMappings ( )

◆ ValidateMappingUrlPattern()

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

Member Data Documentation

◆ CS

TCriticalSection TdjLifeCycle::CS
inherited

Referenced by ~TdjLifeCycle().

◆ FPathMap

TdjPathMap TdjWebComponentHandler::FPathMap

Referenced by FindHolder(), and InvokeService().

◆ FStopped

Boolean TdjLifeCycle::FStopped
inherited

Referenced by ~TdjLifeCycle(), and DoStop().

◆ FWebComponentContext

IContext TdjWebComponentHandler::FWebComponentContext

Referenced by InvokeService(), and SetFilters().

◆ FWebComponentHolders

TdjWebComponentHolders TdjWebComponentHandler::FWebComponentHolders

Referenced by GetFilterChain(), and InvokeService().

◆ FWebComponentMappings

TdjWebComponentMappings TdjWebComponentHandler::FWebComponentMappings

◆ FWebFilterHolders

TdjWebFilterHolders TdjWebComponentHandler::FWebFilterHolders

◆ FWebFilterMappings

TdjWebFilterMappings TdjWebComponentHandler::FWebFilterMappings

Referenced by FindHolder(), and InvokeService().

◆ FWebFilterPathMappings

< ><> TdjWebFilterMappings TdjWebComponentHandler::FWebFilterPathMappings

Referenced by InvokeService().

◆ Started

Boolean TdjLifeCycle::Started
inherited

◆ Stopped

Boolean TdjLifeCycle::Stopped
inherited

Referenced by DoStop(), and Stop().

◆ WebComponentContext

IContext TdjWebComponentHandler::WebComponentContext

Referenced by SetFilters().

◆ WebComponentMappings

TdjWebComponentMappings TdjWebComponentHandler::WebComponentMappings

Referenced by InitializeHolders().

◆ WebComponents

TdjWebComponentHolders TdjWebComponentHandler::WebComponents
protected

Referenced by GetFilterChain().

◆ WebFilters

TdjWebFilterHolders TdjWebComponentHandler::WebFilters
protected

Referenced by GetFilterChain().