org.apache.tuscany.sca.http.tomcat
Class TomcatServer

java.lang.Object
  extended by org.apache.tuscany.sca.http.tomcat.TomcatServer
All Implemented Interfaces:
ServletHost

public class TomcatServer
extends java.lang.Object
implements ServletHost

A Tomcat based implementation of ServletHost.


Constructor Summary
TomcatServer(WorkScheduler workScheduler)
          Constructs a new embedded Tomcat server.
 
Method Summary
 void addServletMapping(java.lang.String suri, Servlet servlet)
          Add a mapping for an instance of a Servlet.
 java.lang.String getContextPath()
          Returns the portion of the request URI that indicates the context of the request
 int getDefaultPort()
          Returns the default port for the server.
 RequestDispatcher getRequestDispatcher(java.lang.String suri)
          Returns a Servlet request dispatcher for the Servlet mapped to the specified URI.
 Servlet getServletMapping(java.lang.String suri)
          Returns the Servlet mapped to the given URI.
 java.net.URL getURLMapping(java.lang.String suri)
          Returns the complete URL mapped to the specified URI.
 Servlet removeServletMapping(java.lang.String suri)
          Remove a Servlet mapping.
 void setContextPath(java.lang.String path)
          Sets the portion of the request URI that indicates the context of the request
 void setDefaultPort(int port)
          Sets the default port for the server.
 void stop()
          Stop all the started servers.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TomcatServer

public TomcatServer(WorkScheduler workScheduler)
Constructs a new embedded Tomcat server.

Parameters:
workScheduler - the WorkScheduler to use to process requests.
Method Detail

setDefaultPort

public void setDefaultPort(int port)
Description copied from interface: ServletHost
Sets the default port for the server.

Specified by:
setDefaultPort in interface ServletHost
Parameters:
port - the default port

getDefaultPort

public int getDefaultPort()
Description copied from interface: ServletHost
Returns the default port for the server.

Specified by:
getDefaultPort in interface ServletHost
Returns:
the default port

stop

public void stop()
          throws ServletMappingException
Stop all the started servers.

Throws:
ServletMappingException

addServletMapping

public void addServletMapping(java.lang.String suri,
                              Servlet servlet)
Description copied from interface: ServletHost
Add a mapping for an instance of a Servlet. This requests that the Servlet container direct all requests to the designated mapping to the supplied Servlet instance.

Specified by:
addServletMapping in interface ServletHost
Parameters:
suri - the URI-mapping for the Servlet
servlet - the Servlet that should be invoked

getURLMapping

public java.net.URL getURLMapping(java.lang.String suri)
                           throws ServletMappingException
Description copied from interface: ServletHost
Returns the complete URL mapped to the specified URI.

Specified by:
getURLMapping in interface ServletHost
Returns:
the URL mapped to the specified URI
Throws:
ServletMappingException

getServletMapping

public Servlet getServletMapping(java.lang.String suri)
                          throws ServletMappingException
Description copied from interface: ServletHost
Returns the Servlet mapped to the given URI.

Specified by:
getServletMapping in interface ServletHost
Parameters:
suri - the URI-mapping for the Servlet
Returns:
the Servlet registered with the mapping
Throws:
ServletMappingException

removeServletMapping

public Servlet removeServletMapping(java.lang.String suri)
Description copied from interface: ServletHost
Remove a Servlet mapping. This directs the Servlet container not to direct any more requests to a previously registered Servlet.

Specified by:
removeServletMapping in interface ServletHost
Parameters:
suri - the URI-mapping for the Servlet
Returns:
the Servlet that was registered to the mapping, null if nothing was registered to the mapping

getRequestDispatcher

public RequestDispatcher getRequestDispatcher(java.lang.String suri)
                                       throws ServletMappingException
Description copied from interface: ServletHost
Returns a Servlet request dispatcher for the Servlet mapped to the specified URI.

Specified by:
getRequestDispatcher in interface ServletHost
Parameters:
suri - the URI mapped to a Servlet
Returns:
a RequestDispatcher that can be used to dispatch requests to that Servlet
Throws:
ServletMappingException

getContextPath

public java.lang.String getContextPath()
Description copied from interface: ServletHost
Returns the portion of the request URI that indicates the context of the request

Specified by:
getContextPath in interface ServletHost
Returns:
a String specifying the portion of the request URI that indicates the context of the request

setContextPath

public void setContextPath(java.lang.String path)
Description copied from interface: ServletHost
Sets the portion of the request URI that indicates the context of the request

Specified by:
setContextPath in interface ServletHost
Parameters:
path - the context path