[fpc-devel] Inversion of control for TCustomHTTPModule and descendants
pascaldragon at googlemail.com
Tue Mar 6 17:52:39 CET 2012
Am 06.03.2012 17:35, schrieb michael.vancanneyt at wisa.be:
> On Tue, 6 Mar 2012, Sven Barth wrote:
>> Hello together!
>> I'm currently playing around with fcl-web a bit.
>> As I'd like to utilize inversion of control (e.g. passing things like
>> database connections through the constructor [as one possible
>> implementation of this pattern]) for my modules I'd like to ask
>> whether it would be an idea
> whooohoo - expensive terminology detected !!
> "Inversion of Control" :-)
Sorry, but I don't get what you want to tell with that statement... :(
(maybe my brain is all smashed today after I've read the documentation
of a Delphi ORM ^^)
>> for a feature request (maybe even with patch) to add an
>> "OnCreateModule" event to TWebHandler which is called inside
>> TWebHandler.HandleRequest before the module is created using CreateNew
>> or Create?
> Well, it can only be after create. You need the instance first, and it
> is constructed with Create(New).
That's the point: add an event which creates the module with custom
parameters (because the module then can use a custom constructor). But
> If you need to do something before that, there already is the
> OnGetModule handler.
But OnGetModule only returns the class, not an instance...
> But yes, a centralized initialization handler for webmodules is OK.
> Something like 'OnInitModule' or so ?
That's also an idea. At least then the creation of the module is kept
inside TWebHandler (to use another expression: "open for extension, but
closed for modification" ;) )
More information about the fpc-devel