org.apache.tuscany.sca.host.webapp
Class WebAppServletHost

java.lang.Object
  extended by org.apache.tuscany.sca.host.webapp.WebAppServletHost
All Implemented Interfaces:
ServletHost

public class WebAppServletHost
extends java.lang.Object
implements ServletHost

ServletHost implementation for use in a webapp environment. FIXME: using a static singleton seems a big hack but how should it be shared? Need some way for TuscanyServlet to pull it out.


Field Summary
static java.lang.String SCA_DOMAIN_ATTRIBUTE
           
 
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
 java.lang.String getContributionRoot()
           
protected  java.lang.String getContributionRoot(ServletContext servletContext)
           
 int getDefaultPort()
          Returns the default port for the server.
static WebAppServletHost getInstance()
           
 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(ServletConfig config)
           
 void initContextPath(ServletConfig config)
          Initializes the contextPath The 2.5 Servlet API has a getter for this, for pre 2.5 Servlet containers use an init parameter.
 Servlet removeServletMapping(java.lang.String suri)
          Remove a Servlet mapping.
 void setAttribute(java.lang.String name, java.lang.Object value)
           
 void setContextPath(java.lang.String path)
          Sets the portion of the request URI that indicates the context of the request
 void setContextPath2(java.lang.String path)
          TODO: How context paths work is still up in the air so for now this hacks in a path that gets some samples working can't use setContextPath as NodeImpl calls that later
 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
 

Field Detail

SCA_DOMAIN_ATTRIBUTE

public static final java.lang.String SCA_DOMAIN_ATTRIBUTE
See Also:
Constant Field Values
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

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

getInstance

public static WebAppServletHost getInstance()

init

public void init(ServletConfig config)
          throws ServletException
Throws:
ServletException

getContributionRoot

protected java.lang.String getContributionRoot(ServletContext servletContext)

initContextPath

public void initContextPath(ServletConfig config)
Initializes the contextPath The 2.5 Servlet API has a getter for this, for pre 2.5 Servlet containers use an init parameter.


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

setContextPath2

public void setContextPath2(java.lang.String path)
TODO: How context paths work is still up in the air so for now this hacks in a path that gets some samples working can't use setContextPath as NodeImpl calls that later


getContributionRoot

public java.lang.String getContributionRoot()

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)