org.apache.tuscany.sca.implementation.node.webapp
Class NodeWebAppServletHost

java.lang.Object
  extended by org.apache.tuscany.sca.implementation.node.webapp.NodeWebAppServletHost
All Implemented Interfaces:
ServletHost

public class NodeWebAppServletHost
extends java.lang.Object
implements ServletHost

ServletHost implementation for use in a Webapp Node environment.


Method Summary
 void addServletMapping(java.lang.String suri, Servlet servlet)
          Add a mapping for an instance of a Servlet.
 void destroy()
          Destroy the Servlet host.
 void doFilter(ServletRequest request, ServletResponse response, javax.servlet.FilterChain chain)
           
 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.
 void init(FilterConfig filterConfig)
          Initialize the Servlet host.
 Servlet removeServletMapping(java.lang.String suri)
          Remove a Servlet mapping.
static NodeWebAppServletHost servletHost()
          Returns the Servlet host for the current Web app.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

servletHost

public static NodeWebAppServletHost servletHost()
Returns the Servlet host for the current Web app.

Returns:

init

public void init(FilterConfig filterConfig)
          throws ServletException
Initialize the Servlet host.

Parameters:
filterConfig -
Throws:
ServletException

addServletMapping

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

removeServletMapping

public Servlet removeServletMapping(java.lang.String suri)
                             throws ServletMappingException
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
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

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

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

destroy

public void destroy()
Destroy the Servlet host.

Throws:
ServletException

doFilter

public void doFilter(ServletRequest request,
                     ServletResponse response,
                     javax.servlet.FilterChain chain)
              throws java.io.IOException,
                     ServletException
Throws:
java.io.IOException
ServletException

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

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