Save This Page
Home » cactus-1.8.0-src » org.apache.cactus.server » [javadoc | source]
org.apache.cactus.server
abstract public class: AbstractServletContextWrapper [javadoc | source]
java.lang.Object
   org.apache.cactus.server.AbstractServletContextWrapper

All Implemented Interfaces:
    ServletContext

Direct Known Subclasses:
    ServletContextWrapper

Abstract wrapper around ServletContext. This class provides a common implementation of the wrapper for the different servlet API. In addition to implementing the ServletContext interface it provides additional features helpful for writing unit tests. More specifically the getRequestDispatcher() method is overrided to return an request dispatcher wrapper. In addition logs generated by calls to the log() methods can be retrieved and asserted by calling the getLogs() method.
Field Summary
protected  ServletContext originalContext    The original servlet context object. 
protected  Hashtable initParameters    List of parameters set using the setInitParameter() method. 
Constructor:
 public AbstractServletContextWrapper(ServletContext theOriginalContext) 
    Parameters:
    theOriginalContext - the original servlet context object
Method from org.apache.cactus.server.AbstractServletContextWrapper Summary:
getAttribute,   getAttributeNames,   getContext,   getInitParameter,   getInitParameterNames,   getLogs,   getMajorVersion,   getMimeType,   getMinorVersion,   getNamedDispatcher,   getOriginalContext,   getRealPath,   getRequestDispatcher,   getResource,   getResourceAsStream,   getServerInfo,   getServlet,   getServletNames,   getServlets,   log,   log,   log,   newInstance,   removeAttribute,   setAttribute,   setInitParameter
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.cactus.server.AbstractServletContextWrapper Detail:
 public Object getAttribute(String theName) 
    {@inheritDoc}
 public Enumeration getAttributeNames() 
    {@inheritDoc}
 public ServletContext getContext(String theUripath) 
 public String getInitParameter(String theName) 
 public Enumeration getInitParameterNames() 
 public Vector getLogs() 
    Returns all the text logs that have been generated using the log() methods so that it is possible to easily assert the content of the logs. This method does not return the exceptions or throwable sent for logging; it only returns the messages.
 public int getMajorVersion() 
    {@inheritDoc}
 public String getMimeType(String theFilename) 
    {@inheritDoc}
 public int getMinorVersion() 
    {@inheritDoc}
 public RequestDispatcher getNamedDispatcher(String theName) 
 public ServletContext getOriginalContext() 
 public String getRealPath(String thePath) 
    {@inheritDoc}
 public RequestDispatcher getRequestDispatcher(String thePath) 
 public URL getResource(String thePath) throws MalformedURLException 
    {@inheritDoc}
 public InputStream getResourceAsStream(String thePath) 
    {@inheritDoc}
 public String getServerInfo() 
    {@inheritDoc}
 public Servlet getServlet(String theName) throws ServletException 
    {@inheritDoc}
 public Enumeration getServletNames() 
    {@inheritDoc}
 public Enumeration getServlets() 
    {@inheritDoc}
 public  void log(String theMessage) 
    Intercept the log call and add the message to an internal vector of log messages that can then later be retrieved and asserted by the test case writer. Note that the throwable is not saved.
 public  void log(String theMessage,
    Throwable theCause) 
    Intercept the log call and add the message to an internal vector of log messages that can then later be retrieved and asserted by the test case writer. Note that the throwable is not saved.
 public  void log(Exception theException,
    String theMessage) 
Deprecated! As - of Java Servlet API 2.1, use #log(String message, Throwable throwable) instead. This method was originally defined to write an exception's stack trace and an explanatory error message to the servlet log file.

    Intercept the log call and add the message to an internal vector of log messages that can then later be retrieved and asserted by the test case writer. Note that the throwable is not saved.
 public static AbstractServletContextWrapper newInstance(ServletContext theOriginalContext) 
 public  void removeAttribute(String theName) 
    {@inheritDoc}
 public  void setAttribute(String theName,
    Object theAttribute) 
    {@inheritDoc}
 public  void setInitParameter(String theName,
    String theValue) 
    Sets a parameter as if it were set in the web.xml file (using the <context-param> element).