(The same question exists in Spring4d google group)
I have a big doubt (it's more than a doubt, I have some thread related troubles...): I am developing a web app with Delphi WebBroker technology; where do I put my registrations with the Spring4D Container?
- In the main application core? (I don't know if it is good for webservers, like apache, IIS)
- In the OnCreate of the webmodule? (I have done my job here, but I don't know if it is a good practice. The TContainer instance is a field of the webbroker)
- Any suggestion? And last but not least: where do I destroy the Container? For now I destroy it in OnDestroy of the TWebModule.
Thanks in advance for your help.
Eddy
This is a bit of code for the TWebModule: ... ...
type
TMyWebModule = class(TWebModule)
procedure WebModuleCreate(Sender: TObject);
procedure WebModuleDestroy(Sender: TObject);
private
FContainer: TContainer;
FMVC: TMVCEngine;
public
{ Public declarations }
end;
...
...
procedure TMyWebModule.WebModuleCreate(Sender: TObject);
begin
FContainer := TContainer.Create;
registerDependecies(FContainer);
registerServices(FContainer);
FContainer.Build;
//Teti's MVC
FMVC := TMVCEngine.Create(Self,
...
...
...
procedure TMyWebModule.WebModuleDestroy(Sender: TObject);
begin
FMVC.Free;
FContainer.Free;
end;