Tynamo™-TINI
v1.0.4

com.qindesign.tini.http
Class ServletHttpServer

java.lang.Object
  extended by com.qindesign.tini.http.HttpServer
      extended by com.qindesign.tini.http.ServletHttpServer
All Implemented Interfaces:
Runnable, ServletContext

public class ServletHttpServer
extends com.qindesign.tini.http.HttpServer
implements ServletContext

Implements a servlet container. This implements the Runnable interface, so it can be started in a new thread.

Version:
1.0.4
Author:
Shawn Silverman

Field Summary
 
Fields inherited from class com.qindesign.tini.http.HttpServer
logger
 
Constructor Summary
ServletHttpServer(Properties props)
          Convenience method that calls ServletHttpServer(Properties, Properties) with a value of null for the second parameter.
ServletHttpServer(Properties props, Properties servletProps)
          Creates a new servlet server.
 
Method Summary
 Object getAttribute(String name)
           
 Enumeration getAttributeNames()
           
 ServletContext getContext(String uripath)
          Returns this.
 String getInitParameter(String name)
           
 Enumeration getInitParameterNames()
           
 int getMajorVersion()
          Returns 2.
 String getMimeType(String file)
           
 int getMinorVersion()
          Returns 2.
 RequestDispatcher getNamedDispatcher(String name)
          This can return null if there was an error initializing an unloaded servlet.
 String getRealPath(String path)
          Returns the path if the file is a normal file.
 RequestDispatcher getRequestDispatcher(String path)
          Returns null if the path does not start with a '/'.
 URL getResource(String path)
          Currently only returns a "file:" URL.
 InputStream getResourceAsStream(String path)
           
 Servlet getServlet(String name)
          Deprecated.  
 Enumeration getServletNames()
          Deprecated.  
 Enumeration getServlets()
          Deprecated.  
 void log(Exception exception, String message)
          Deprecated.  
 void log(String msg)
          Logs a message.
 void log(String msg, Throwable th)
          Logs a string plus a Throwable object.
protected  void performGC()
          Perform some cleanup.
protected  void performShutdown()
          Performs shutdown cleanup.
 void removeAttribute(String name)
           
protected  void service(com.qindesign.tini.http.HttpRequest req, com.qindesign.tini.http.HttpResponse resp)
          Services an HTTP request.
 void setAttribute(String name, Object object)
           
 
Methods inherited from class com.qindesign.tini.http.HttpServer
currentTimeMillis, getContentTypeFor, getIntProperty, getProperty, getServerInfo, kill, run, shutdown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.ServletContext
getServerInfo
 

Constructor Detail

ServletHttpServer

public ServletHttpServer(Properties props)
Convenience method that calls ServletHttpServer(Properties, Properties) with a value of null for the second parameter.

Parameters:
props - server initialization properties
See Also:
ServletHttpServer(Properties, Properties)

ServletHttpServer

public ServletHttpServer(Properties props,
                         Properties servletProps)
Creates a new servlet server. This implements the Runnable interface, so it can be run from a new thread.

If servletProps is null, then the servlet properties will be loaded from the file specified in the server properties as usual. Otherwise, the file is ignored and the properties from this parameter will be used instead.

Parameters:
props - server initialization properties
servletProps - servlet initialization properties, can be null
Method Detail

log

public void log(String msg)
Logs a message.

Specified by:
log in interface ServletContext

log

public void log(String msg,
                Throwable th)
Logs a string plus a Throwable object.

Specified by:
log in interface ServletContext

service

protected void service(com.qindesign.tini.http.HttpRequest req,
                       com.qindesign.tini.http.HttpResponse resp)
                throws IOException
Description copied from class: com.qindesign.tini.http.HttpServer
Services an HTTP request. The server ensures that the output is flushed.

Specified by:
service in class com.qindesign.tini.http.HttpServer
Throws:
IOException

performGC

protected void performGC()
Perform some cleanup.

Overrides:
performGC in class com.qindesign.tini.http.HttpServer

performShutdown

protected void performShutdown()
Performs shutdown cleanup.

Overrides:
performShutdown in class com.qindesign.tini.http.HttpServer

getContext

public ServletContext getContext(String uripath)
Returns this.

Specified by:
getContext in interface ServletContext

getMajorVersion

public int getMajorVersion()
Returns 2.

Specified by:
getMajorVersion in interface ServletContext

getMinorVersion

public int getMinorVersion()
Returns 2.

Specified by:
getMinorVersion in interface ServletContext

getMimeType

public String getMimeType(String file)
Specified by:
getMimeType in interface ServletContext

getResource

public URL getResource(String path)
                throws MalformedURLException
Currently only returns a "file:" URL.

Specified by:
getResource in interface ServletContext
Throws:
MalformedURLException

getResourceAsStream

public InputStream getResourceAsStream(String path)
Specified by:
getResourceAsStream in interface ServletContext

getRequestDispatcher

public RequestDispatcher getRequestDispatcher(String path)
Returns null if the path does not start with a '/'.

Specified by:
getRequestDispatcher in interface ServletContext

getNamedDispatcher

public RequestDispatcher getNamedDispatcher(String name)
This can return null if there was an error initializing an unloaded servlet.

Specified by:
getNamedDispatcher in interface ServletContext

getRealPath

public String getRealPath(String path)
Returns the path if the file is a normal file. Note that it is possible to return a file above the root directory via things like "..". The reason for this is that the Servlet 2.2 spec and API docs say nothing about the path having to be rooted in the root directory.

Specified by:
getRealPath in interface ServletContext

getAttribute

public Object getAttribute(String name)
Specified by:
getAttribute in interface ServletContext

getAttributeNames

public Enumeration getAttributeNames()
Specified by:
getAttributeNames in interface ServletContext

setAttribute

public void setAttribute(String name,
                         Object object)
Specified by:
setAttribute in interface ServletContext

removeAttribute

public void removeAttribute(String name)
Specified by:
removeAttribute in interface ServletContext

getInitParameter

public String getInitParameter(String name)
Specified by:
getInitParameter in interface ServletContext

getInitParameterNames

public Enumeration getInitParameterNames()
Specified by:
getInitParameterNames in interface ServletContext

getServlet

public Servlet getServlet(String name)
                   throws ServletException
Deprecated. 

Specified by:
getServlet in interface ServletContext
Throws:
ServletException

getServletNames

public Enumeration getServletNames()
Deprecated. 

Specified by:
getServletNames in interface ServletContext

getServlets

public Enumeration getServlets()
Deprecated. 

Specified by:
getServlets in interface ServletContext

log

public void log(Exception exception,
                String message)
Deprecated. 

Specified by:
log in interface ServletContext

Tynamo™-TINI
v1.0.4

© 2001-2007 Shawn Silverman