Daraja HTTP Framework 3.0.7-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.
 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 InvokeService().

◆ 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

References TdjWebComponentHandler(), and Create().

Referenced by InvokeService().

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

◆ DoStart()

TdjWebComponentHandler::DoStart ( )
protected

Starts the web component handler.

This method is called to initialize and start the handler.

◆ DoStop()

TdjWebComponentHandler::DoStop ( )
protected

Stops the web component handler.

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

◆ 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(), and TdjLifeCycle::IsStarted().

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

◆ 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(), AddMapping(), AddWithMapping(), ROOT_CONTEXT, TdjLifeCycle::Started, TdjLifeCycle::Stop(), WebComponents, and WebFilters.

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

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

◆ Stop()

TdjLifeCycle::Stop ( )
inherited

Stops the component.

Implements ILifeCycle.

References TdjLifeCycle().

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

Member Data Documentation

◆ Started

◆ Stopped

Boolean TdjLifeCycle::Stopped
inherited

Referenced by DoStop(), and Start().

◆ WebComponents

TdjWebComponentHolders TdjWebComponentHandler::WebComponents
protected

Referenced by InvokeService().

◆ WebFilters

TdjWebFilterHolders TdjWebComponentHandler::WebFilters
protected

Referenced by InvokeService().