|Version 4 (modified by 5 years ago) ( diff ),|
Matreshka provides server-independent implementation of Servlet API. Web-application based on this module can be executed by Spikedog application server.
See examples of applications.
Initialization of application
When Spikedog loading application it lookup in loaded application's library for special symbol to resolve reference to object of application's initializer tagged type. This type should support Servlet.Container_Initializers.Servlet_Container_Initializer interface. Its On_Startup subprogram will be called after successful loading and initialization of application's dependencies. Application can do additional initialization in this subprogram (connect to database, for example) or create, register and configure listeners/servlets.
To provide this symbol application must instantiate Spikedog.Generic_Application_Initializer to application's initializer tagged type and link it in application's library. When you use GNAT tools you need to add instantiated package to the list of Library_Interfaces attribute of project file.
Here is example of application initializer tagged type:
with Servlet.Container_Initializers; with Servlet.Contexts; package Initializers is type Server_Initializer is limited new Servlet.Container_Initializers.Servlet_Container_Initializer with null record; overriding procedure On_Startup (Self : in out Server_Initializer; Context : in out Servlet.Contexts.Servlet_Context'Class); end Initializers;
and instantiation of Spikedog.Generic_Application_Initializer package:
with Spikedog.Generic_Application_Initializer; with Initializers; package Initializer is new Spikedog.Generic_Application_Initializer (Initializers.Server_Initializer);