com.judoscript.user.httpserver
Class Serve

java.lang.Object
  extended by com.judoscript.user.httpserver.Serve
All Implemented Interfaces:
javax.servlet.RequestDispatcher, javax.servlet.ServletContext

public class Serve
extends java.lang.Object
implements javax.servlet.ServletContext, javax.servlet.RequestDispatcher


Nested Class Summary
static interface Serve.SocketFactory
           
 
Field Summary
static org.apache.commons.logging.Log accessLogger
           
static int DEF_PORT
           
static int DEF_SESSION_TIMEOUT
           
static org.apache.commons.logging.Log logger
           
protected  com.judoscript.user.httpserver.PathTreeDictionary realms
           
static java.lang.String serverName
           
static java.lang.String serverVersion
           
protected  WildcardMap servletRegistry
           
static java.lang.String tjwsLink
           
static java.lang.String tjwsName
           
static java.lang.String tjwsUrl
           
 
Constructor Summary
Serve(int port, java.lang.String baseDir)
           
 
Method Summary
 void addCallMapping(java.lang.String urlPat, java.lang.Object fxn)
           
 void addFileThrottle(java.lang.String urlPat, long bps)
           
 void addPathMapping(java.lang.String srcpath, java.lang.String realpath)
           
 void addRealm(java.lang.String name, java.lang.String dir, java.lang.String user, java.lang.String password)
           
 void addServlet(java.lang.String urlPat, java.lang.Object servlet_)
           
 void addServlet(java.lang.String urlPat, java.lang.Object servlet_, java.lang.Object initParams)
          Takes many variations of parameters
 void addServlet(java.lang.String urlPat, javax.servlet.Servlet servlet, java.util.Hashtable initParams)
           
static Serve createHttpServer()
           
static Serve createHttpServer(int port)
           
static Serve createHttpServer(int port, java.lang.String baseDir)
           
protected  java.net.ServerSocket createServerSocket()
           
 void destroyAllServlets()
           
 void forward(javax.servlet.ServletRequest _request, javax.servlet.ServletResponse _response)
           
 java.lang.Object getAttribute(java.lang.String name)
           
 java.util.Enumeration getAttributeNames()
           
 javax.servlet.ServletContext getContext(java.lang.String uripath)
           
 java.lang.String getInitParameter(java.lang.String param)
           
 java.util.Enumeration getInitParameterNames()
           
 int getMajorVersion()
           
 java.lang.String getMimeType(java.lang.String file)
           
 int getMinorVersion()
           
 javax.servlet.RequestDispatcher getNamedDispatcher(java.lang.String name)
           
 java.lang.String getRealPath(java.lang.String path)
           
 javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String urlpath)
           
 java.net.URL getResource(java.lang.String path)
           
 java.io.InputStream getResourceAsStream(java.lang.String path)
           
 java.util.Set getResourcePaths(java.lang.String path)
          Returns a directory-like listing of all the paths to resources within the web application whose longest sub-path matches the supplied path argument.
 java.lang.String getServerInfo()
           
 javax.servlet.Servlet getServlet(java.lang.String name)
           
 java.lang.String getServletContextName()
          Returns the name of this web application correponding to this ServletContext as specified in the deployment descriptor for this web application by the display-name element.
 java.util.Enumeration getServletNames()
           
 java.util.Enumeration getServlets()
           
 void include(javax.servlet.ServletRequest _request, javax.servlet.ServletResponse _response)
           
 void log(java.lang.Exception th, java.lang.String message)
           
 void log(java.lang.String message)
           
 void log(java.lang.String message, java.lang.Throwable th)
           
 void logError(java.lang.String message)
           
 void removeAttribute(java.lang.String name)
           
 void setAttribute(java.lang.String name, java.lang.Object object)
           
 void setBrowseDirectory(boolean set)
           
 void setLogUserAccess(boolean doLog, boolean logUserAgent, boolean logReferer)
           
 void setPort(int port)
           
 void setQuitCommand(java.lang.String cmd)
           
 void setSessionTimeout(int minutes)
           
 void setSocketFactory(java.lang.String sfc)
           
 void start()
           
static void writeServerInfo(java.io.PrintStream ps)
           
static void writeServerInfo(java.lang.StringBuffer sb)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

public static org.apache.commons.logging.Log logger

accessLogger

public static org.apache.commons.logging.Log accessLogger

DEF_SESSION_TIMEOUT

public static final int DEF_SESSION_TIMEOUT
See Also:
Constant Field Values

DEF_PORT

public static final int DEF_PORT
See Also:
Constant Field Values

serverName

public static final java.lang.String serverName
See Also:
Constant Field Values

serverVersion

public static final java.lang.String serverVersion
See Also:
Constant Field Values

tjwsUrl

public static final java.lang.String tjwsUrl
See Also:
Constant Field Values

tjwsName

public static final java.lang.String tjwsName
See Also:
Constant Field Values

tjwsLink

public static final java.lang.String tjwsLink
See Also:
Constant Field Values

servletRegistry

protected WildcardMap servletRegistry

realms

protected com.judoscript.user.httpserver.PathTreeDictionary realms
Constructor Detail

Serve

public Serve(int port,
             java.lang.String baseDir)
Method Detail

createHttpServer

public static Serve createHttpServer()

createHttpServer

public static Serve createHttpServer(int port)

createHttpServer

public static Serve createHttpServer(int port,
                                     java.lang.String baseDir)

writeServerInfo

public static void writeServerInfo(java.lang.StringBuffer sb)
                            throws java.io.IOException
Throws:
java.io.IOException

writeServerInfo

public static void writeServerInfo(java.io.PrintStream ps)
                            throws java.io.IOException
Throws:
java.io.IOException

setPort

public void setPort(int port)

setSessionTimeout

public void setSessionTimeout(int minutes)

setLogUserAccess

public void setLogUserAccess(boolean doLog,
                             boolean logUserAgent,
                             boolean logReferer)

setQuitCommand

public void setQuitCommand(java.lang.String cmd)

setBrowseDirectory

public void setBrowseDirectory(boolean set)

addPathMapping

public void addPathMapping(java.lang.String srcpath,
                           java.lang.String realpath)

addFileThrottle

public void addFileThrottle(java.lang.String urlPat,
                            long bps)

addRealm

public void addRealm(java.lang.String name,
                     java.lang.String dir,
                     java.lang.String user,
                     java.lang.String password)

addCallMapping

public void addCallMapping(java.lang.String urlPat,
                           java.lang.Object fxn)
                    throws ExceptionRuntime
Throws:
ExceptionRuntime

addServlet

public void addServlet(java.lang.String urlPat,
                       java.lang.Object servlet_)

addServlet

public void addServlet(java.lang.String urlPat,
                       java.lang.Object servlet_,
                       java.lang.Object initParams)
Takes many variations of parameters


addServlet

public void addServlet(java.lang.String urlPat,
                       javax.servlet.Servlet servlet,
                       java.util.Hashtable initParams)

start

public void start()

setSocketFactory

public void setSocketFactory(java.lang.String sfc)

createServerSocket

protected java.net.ServerSocket createServerSocket()
                                            throws java.io.IOException
Throws:
java.io.IOException

getServlet

public javax.servlet.Servlet getServlet(java.lang.String name)
Specified by:
getServlet in interface javax.servlet.ServletContext

getServlets

public java.util.Enumeration getServlets()
Specified by:
getServlets in interface javax.servlet.ServletContext

getServletNames

public java.util.Enumeration getServletNames()
Specified by:
getServletNames in interface javax.servlet.ServletContext

destroyAllServlets

public void destroyAllServlets()

log

public void log(java.lang.String message)
Specified by:
log in interface javax.servlet.ServletContext

logError

public void logError(java.lang.String message)

log

public void log(java.lang.String message,
                java.lang.Throwable th)
Specified by:
log in interface javax.servlet.ServletContext

log

public void log(java.lang.Exception th,
                java.lang.String message)
Specified by:
log in interface javax.servlet.ServletContext

getRealPath

public java.lang.String getRealPath(java.lang.String path)
Specified by:
getRealPath in interface javax.servlet.ServletContext

getMimeType

public java.lang.String getMimeType(java.lang.String file)
Specified by:
getMimeType in interface javax.servlet.ServletContext

getServerInfo

public java.lang.String getServerInfo()
Specified by:
getServerInfo in interface javax.servlet.ServletContext

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Specified by:
getAttribute in interface javax.servlet.ServletContext

removeAttribute

public void removeAttribute(java.lang.String name)
Specified by:
removeAttribute in interface javax.servlet.ServletContext

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object object)
Specified by:
setAttribute in interface javax.servlet.ServletContext

getAttributeNames

public java.util.Enumeration getAttributeNames()
Specified by:
getAttributeNames in interface javax.servlet.ServletContext

getContext

public javax.servlet.ServletContext getContext(java.lang.String uripath)
Specified by:
getContext in interface javax.servlet.ServletContext

getMajorVersion

public int getMajorVersion()
Specified by:
getMajorVersion in interface javax.servlet.ServletContext

getMinorVersion

public int getMinorVersion()
Specified by:
getMinorVersion in interface javax.servlet.ServletContext

getResourcePaths

public java.util.Set getResourcePaths(java.lang.String path)
Returns a directory-like listing of all the paths to resources within the web application whose longest sub-path matches the supplied path argument. Paths indicating subdirectory paths end with a '/'. The returned paths are all relative to the root of the web application and have a leading '/'. For example, for a web application containing

/welcome.html
/catalog/index.html
/catalog/products.html
/catalog/offers/books.html
/catalog/offers/music.html
/customer/login.jsp
/WEB-INF/web.xml
/WEB-INF/classes/com.acme.OrderServlet.class,

getResourcePaths("/") returns {"/welcome.html", "/catalog/", "/customer/", "/WEB-INF/"}
getResourcePaths("/catalog/") returns {"/catalog/index.html", "/catalog/products.html", "/catalog/offers/"}.

Specified by:
getResourcePaths in interface javax.servlet.ServletContext
Parameters:
the - - partial path used to match the resources, which must start with a /
Returns:
a Set containing the directory listing, or null if there are no resources in the web application whose path begins with the supplied path.
Since:
Servlet 2.3

getServletContextName

public java.lang.String getServletContextName()
Returns the name of this web application correponding to this ServletContext as specified in the deployment descriptor for this web application by the display-name element.

Specified by:
getServletContextName in interface javax.servlet.ServletContext
Returns:
The name of the web application or null if no name has been declared in the deployment descriptor.
Since:
Servlet 2.3

getResource

public java.net.URL getResource(java.lang.String path)
                         throws java.net.MalformedURLException
Specified by:
getResource in interface javax.servlet.ServletContext
Throws:
java.net.MalformedURLException

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String path)
Specified by:
getResourceAsStream in interface javax.servlet.ServletContext

getRequestDispatcher

public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String urlpath)
Specified by:
getRequestDispatcher in interface javax.servlet.ServletContext

getInitParameter

public java.lang.String getInitParameter(java.lang.String param)
Specified by:
getInitParameter in interface javax.servlet.ServletContext

getInitParameterNames

public java.util.Enumeration getInitParameterNames()
Specified by:
getInitParameterNames in interface javax.servlet.ServletContext

getNamedDispatcher

public javax.servlet.RequestDispatcher getNamedDispatcher(java.lang.String name)
Specified by:
getNamedDispatcher in interface javax.servlet.ServletContext

forward

public void forward(javax.servlet.ServletRequest _request,
                    javax.servlet.ServletResponse _response)
             throws javax.servlet.ServletException,
                    java.io.IOException
Specified by:
forward in interface javax.servlet.RequestDispatcher
Throws:
javax.servlet.ServletException
java.io.IOException

include

public void include(javax.servlet.ServletRequest _request,
                    javax.servlet.ServletResponse _response)
             throws javax.servlet.ServletException,
                    java.io.IOException
Specified by:
include in interface javax.servlet.RequestDispatcher
Throws:
javax.servlet.ServletException
java.io.IOException