Project

General

Profile

Actions

WebApps » History » Revision 6

« Previous | Revision 6/7 (diff) | Next »
Gregg -, 09/10/2009 11:31 AM
servlet - database communication


= Web Application Architecture =

Mulgara is designed to work as an embedded component. The standard distribution includes a variety of build configurations, including a web services application.

See [http://mulgara.org/pipermail/mulgara-general/2009-September/000935.html this message] for info on how the default app is structured.

The basic idea is that EmbeddedMulgaraServer is the ringmaster, glue code that creates and launches service providers.

In directory src/jar/server/java/org/mulgara/server:

  • org.mulgara.server.EmbeddedMulgaraServer * "main" - entry point for default server? * sets up configuration, options parsing, etc. * creates instance of EmbeddedMulgaraServer, whose constuctor * creates a Mulgara Server instance (a "ServerMBean", which is an RMI server) * creates an HttpServices intance, passing itself, hostname, and MulgaraConfig as args * launches its services (i.e. Mulgara and webserver) via "startServices", which * invokes {{{init()}}} and {{{start()}}} on the Mulgara Server instance * launches HttpServices instance (which maintains reference to {{{this}}} so it can access the Mulgara server instance) * implements SessionFactoryProvider (in src/jar/query/java/org/mulgara/server/?) * reads config parms using MulgaraConfig object
  • org.mulgara.server.HttpServices * no inheritance * retains reference to Mulgara Server instance * creates two Jetty "Http Servlet server" instances * adds services using getContextServices * this is what creates the servlets (e.g. SparqlServlet), using * addWebServicesWebAppContext * addServletContext * addWebQueryContext * {{{start()}}} method invokes Jetty Server.start() on both servers (does this work? isn't {{{start()}}} synchronous?)
  • org.mulgara.server.AbstractServer implements ServerMBean (?)

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

In directory src/jar/querylang/java/org/mulgara/protocol/http:

  • javax.servlet.http.HttpServlet * org.mulgara.protocol.http.MulgaraServlet * org.mulgara.protocol.http.ProtocolServlet * org.mulgara.protocol.http.SparqlServlet * org.mulgara.protocol.http.TqlServlet

==== Interaction of servlet and database ====
How does a servlet talk to a database?

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

In src/jar/server/java/org/mulgara/server/:

  • ServerMBean - handrolled mgmt interface for org.mulgara.server.SessionFactory * init, start, stop, config stuff, etc.
  • AbstractServer implements ServerMBean

Updated by Gregg - over 14 years ago · 6 revisions