Project

General

Profile

WebApps » History » Version 6

Gregg -, 09/10/2009 11:31 AM
servlet - database communication

1 1 Gregg -
= Web Application Architecture =
2
3
Mulgara is designed to work as an embedded component.  The standard distribution includes a variety of build configurations, including a web services application.
4
5 2 Gregg -
See [http://mulgara.org/pipermail/mulgara-general/2009-September/000935.html this message] for info on how the default app is structured.
6
7 4 Gregg -
The basic idea is that EmbeddedMulgaraServer is the ringmaster, glue code that creates and launches service providers.
8
9 3 Gregg -
In directory src/jar/server/java/org/mulgara/server:
10 1 Gregg -
11 3 Gregg -
 * org.mulgara.server.EmbeddedMulgaraServer
12
  * "main" - entry point for default server?
13
   * sets up configuration, options parsing, etc.
14
   * creates instance of EmbeddedMulgaraServer, whose constuctor 
15
    * creates a Mulgara Server instance (a "ServerMBean", which is an RMI server)
16
    * creates an HttpServices intance, passing itself, hostname, and MulgaraConfig as args
17
   * launches its services (i.e. Mulgara and webserver) via "startServices", which
18
    * invokes {{{init()}}} and {{{start()}}} on the Mulgara Server instance
19
    * launches HttpServices instance (which maintains reference to {{{this}}} so it can access the Mulgara server instance) 
20
  * implements SessionFactoryProvider (in src/jar/query/java/org/mulgara/server/?)
21
  * reads config parms using MulgaraConfig object
22 4 Gregg -
23 3 Gregg -
 * org.mulgara.server.HttpServices
24
  * no inheritance
25 1 Gregg -
  * retains reference to Mulgara Server instance
26 4 Gregg -
  * creates two Jetty "Http Servlet server" instances
27 5 Gregg -
  * adds services using getContextServices
28
   * this is what creates the servlets (e.g. SparqlServlet), using 
29
    * addWebServicesWebAppContext
30
    * addServletContext
31
    * addWebQueryContext
32 4 Gregg -
  * {{{start()}}} method invokes Jetty Server.start() on both servers (does this work? isn't {{{start()}}} synchronous?)
33 1 Gregg -
 * org.mulgara.server.AbstractServer implements ServerMBean (?)
34 4 Gregg -
35
'''NB''': I don't see anything in the Jetty docs about how servers get forked into daemon-hood.  Does {{{Server.start()}}} fork a child process?
36 3 Gregg -
37 1 Gregg -
In directory src/jar/querylang/java/org/mulgara/protocol/http:
38
39
 * javax.servlet.http.HttpServlet
40
  * org.mulgara.protocol.http.MulgaraServlet
41
   * org.mulgara.protocol.http.ProtocolServlet
42
    * org.mulgara.protocol.http.SparqlServlet
43
    * org.mulgara.protocol.http.TqlServlet
44 6 Gregg -
45
==== Interaction of servlet and database ====
46
How does a servlet talk to a database?
47
48
The servlet constructors take a {{{SessionFactoryProvider}}} argument; this is an interface, implemented by {{{EmbeddedMulgaraServer}}}, with one operation, getSessionFactory, that (for EmbeddedMulgaraServer), invokes the getSessionFactory of the Mulgara Server instance (a ServerMBean) that is held by EmbeddedMulgaraServer; in short, the servlet retains a reference to a "session factory", which provides the means of accessing a database (??).
49
50
In src/jar/server/java/org/mulgara/server/:
51
52
 * ServerMBean - handrolled mgmt interface for org.mulgara.server.SessionFactory
53
  * init, start, stop, config stuff, etc.
54
 * AbstractServer implements ServerMBean
55