3

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

  1. In the main application core? (I don't know if it is good for webservers, like apache, IIS)
  2. 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)
  3. 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;
Eddy M.
  • 31
  • 1
  • 3

0 Answers0