org.apache.tuscany.sca.host.http
Interface ServletHost

All Known Implementing Classes:
ExtensibleServletHost, JettyServer, NodeWebAppServletHost, TomcatServer, WebAppServletHost

public interface ServletHost

Interface implemented by host environments that allow Servlets to be registered.

This interface allows a system service to register a Servlet to handle inbound requests.


Method Summary
 void addServletMapping(java.lang.String uri, 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 uri)
          Returns a Servlet request dispatcher for the Servlet mapped to the specified URI.
 Servlet getServletMapping(java.lang.String uri)
          Returns the Servlet mapped to the given URI.
 java.net.URL getURLMapping(java.lang.String uri)
          Returns the complete URL mapped to the specified URI.
 Servlet removeServletMapping(java.lang.String uri)
          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.
 

Method Detail

setDefaultPort

void setDefaultPort(int port)
Sets the default port for the server.

Parameters:
port - the default port

getDefaultPort

int getDefaultPort()
Returns the default port for the server.

Returns:
the default port

addServletMapping

void addServletMapping(java.lang.String uri,
                       Servlet servlet)
                       throws ServletMappingException
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.

Parameters:
uri - the URI-mapping for the Servlet
servlet - the Servlet that should be invoked
Throws:
ServletMappingException

removeServletMapping

Servlet removeServletMapping(java.lang.String uri)
                             throws ServletMappingException
Remove a Servlet mapping. This directs the Servlet container not to direct any more requests to a previously registered Servlet.

Parameters:
uri - the URI-mapping for the Servlet
Returns:
the Servlet that was registered to the mapping, null if nothing was registered to the mapping
Throws:
ServletMappingException

getServletMapping

Servlet getServletMapping(java.lang.String uri)
                          throws ServletMappingException
Returns the Servlet mapped to the given URI.

Parameters:
uri - the URI-mapping for the Servlet
Returns:
the Servlet registered with the mapping
Throws:
ServletMappingException

getRequestDispatcher

RequestDispatcher getRequestDispatcher(java.lang.String uri)
                                       throws ServletMappingException
Returns a Servlet request dispatcher for the Servlet mapped to the specified URI.

Parameters:
uri - the URI mapped to a Servlet
Returns:
a RequestDispatcher that can be used to dispatch requests to that Servlet
Throws:
ServletMappingException

getContextPath

java.lang.String getContextPath()
Returns the portion of the request URI that indicates the context of the request

Returns:
a String specifying the portion of the request URI that indicates the context of the request

setContextPath

void setContextPath(java.lang.String path)
Sets the portion of the request URI that indicates the context of the request

Parameters:
path - the context path

getURLMapping

java.net.URL getURLMapping(java.lang.String uri)
Returns the complete URL mapped to the specified URI.

Returns:
the URL mapped to the specified URI