org.trippi.server.http
Class TrippiServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.trippi.server.http.TrippiServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class TrippiServlet
extends javax.servlet.http.HttpServlet

A Java servlet that exposes TrippiServer(s) via HTTP.

The required servlet initialization parameter, configFile specifies the full path to the trippi.config file. When responding to a call at the base URL of this servlet, all profiles in the configFile will be listed. They can be accessed separately at baseURL/profileId.

The optional parameter, profileId, indicates a particular triplestore to expose. If specified, this changes the behavior of this servlet so that only one triplestore is exposed. It is accessed directly at the baseURL of this servlet.

Author:
cwilper@cs.cornell.edu
See Also:
Serialized Form

Constructor Summary
TrippiServlet()
           
 
Method Summary
 boolean closeOnDestroy()
          Override this method to return false if the connector(s) should not be closed when the servlet is stopped.
 void destroy()
          Close the connector instance when cleaning up if closeOnDestroy().
 void doFind(TrippiServer server, java.lang.String type, java.lang.String template, java.lang.String lang, java.lang.String query, java.lang.String limit, java.lang.String distinct, java.lang.String format, java.lang.String dumbTypes, boolean streamImmediately, java.lang.String flush, javax.servlet.http.HttpServletResponse response)
           
 void doForm(TrippiServer server, java.io.PrintWriter out, java.lang.String requestURI, java.lang.String contextPath)
           
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Dispatch the request to the appropriate server.
 void doGet(TrippiServer server, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 void doIndex(java.io.PrintWriter out, java.lang.String requestURI, java.lang.String contextPath)
           
 void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Exactly the same behavior as doGet.
 TriplestoreConnector getConnector()
          Get the single connector that this servlet is configured to expose, pre-configured with aliases.
 java.lang.String getContext(java.lang.String origContext)
           
 java.lang.String getErrorStylesheetLocation()
           
 java.lang.String getFormStylesheetLocation()
           
 java.lang.String getIndexStylesheetLocation()
           
 TriplestoreReader getReader()
           
 TriplestoreWriter getWriter()
           
 void init()
          Initialize the servlet.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TrippiServlet

public TrippiServlet()
Method Detail

getReader

public TriplestoreReader getReader()
                            throws javax.servlet.ServletException
Throws:
javax.servlet.ServletException

getWriter

public TriplestoreWriter getWriter()
                            throws javax.servlet.ServletException
Throws:
javax.servlet.ServletException

getConnector

public TriplestoreConnector getConnector()
                                  throws javax.servlet.ServletException
Get the single connector that this servlet is configured to expose, pre-configured with aliases. Otherwise, return null.

Throws:
javax.servlet.ServletException

closeOnDestroy

public boolean closeOnDestroy()
Override this method to return false if the connector(s) should not be closed when the servlet is stopped.


getContext

public java.lang.String getContext(java.lang.String origContext)

getErrorStylesheetLocation

public java.lang.String getErrorStylesheetLocation()

getIndexStylesheetLocation

public java.lang.String getIndexStylesheetLocation()

getFormStylesheetLocation

public java.lang.String getFormStylesheetLocation()

init

public final void init()
                throws javax.servlet.ServletException
Initialize the servlet.

Overrides:
init in class javax.servlet.GenericServlet
Throws:
javax.servlet.ServletException

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws javax.servlet.ServletException,
                  java.io.IOException
Dispatch the request to the appropriate server. If no server is specified in the request URI, and the servlet is running in multi-server mode, show an index of servers.

Overrides:
doGet in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
java.io.IOException

doGet

public void doGet(TrippiServer server,
                  javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws java.lang.Exception
Throws:
java.lang.Exception

doIndex

public void doIndex(java.io.PrintWriter out,
                    java.lang.String requestURI,
                    java.lang.String contextPath)
             throws java.lang.Exception
Throws:
java.lang.Exception

doForm

public void doForm(TrippiServer server,
                   java.io.PrintWriter out,
                   java.lang.String requestURI,
                   java.lang.String contextPath)
            throws java.lang.Exception
Throws:
java.lang.Exception

doFind

public void doFind(TrippiServer server,
                   java.lang.String type,
                   java.lang.String template,
                   java.lang.String lang,
                   java.lang.String query,
                   java.lang.String limit,
                   java.lang.String distinct,
                   java.lang.String format,
                   java.lang.String dumbTypes,
                   boolean streamImmediately,
                   java.lang.String flush,
                   javax.servlet.http.HttpServletResponse response)
            throws java.lang.Exception
Throws:
java.lang.Exception

destroy

public void destroy()
Close the connector instance when cleaning up if closeOnDestroy().

Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class javax.servlet.GenericServlet

doPost

public void doPost(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
            throws javax.servlet.ServletException,
                   java.io.IOException
Exactly the same behavior as doGet.

Overrides:
doPost in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
java.io.IOException