net.officefloor.plugin.servlet.context
Class OfficeServletContextImpl

java.lang.Object
  extended by net.officefloor.plugin.servlet.context.OfficeServletContextImpl
All Implemented Interfaces:
OfficeServletContext

public class OfficeServletContextImpl
extends Object
implements OfficeServletContext

OfficeServletContext implementation.

Author:
Daniel Sagenschneider

Constructor Summary
OfficeServletContextImpl(String servletContextName, Map<String,String> initParameters, Map<String,String> fileExtensionToMimeType, Properties filterConfiguration, ClassLoader classLoader)
          Initiate.
 
Method Summary
 Object getAttribute(Office office, String name)
           
 Enumeration getAttributeNames(Office office)
           
 javax.servlet.ServletContext getContext(Office office, String uripath)
           
 String getContextPath(Office office)
           
 FilterChainFactory getFilterChainFactory(Office office)
           Obtains the FilterChainFactory for the Office.
 String getInitParameter(Office office, String name)
           
 Enumeration getInitParameterNames(Office office)
           
 String getMimeType(Office office, String file)
           
 javax.servlet.RequestDispatcher getNamedDispatcher(Office office, String name)
           
 String getRealPath(Office office, String path)
           
 javax.servlet.RequestDispatcher getRequestDispatcher(Office office, String path)
           
 URL getResource(Office office, String path)
           
 InputStream getResourceAsStream(Office office, String path)
           
 Set getResourcePaths(Office office, String path)
           
 String getServerInfo(Office office)
           
 String getServletContextName(Office office)
           
 void init(ServletServer servletServer)
           Loads the ServletServer.
 void log(Office office, String msg)
           
 void log(Office office, String message, Throwable throwable)
           
 ServletTaskReference mapPath(Office office, String path)
           Obtains the ServletTaskReference to the Servlet Task corresponding the the input path.
 void removeAttribute(Office office, String name)
           
 void setAttribute(Office office, String name, Object object)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OfficeServletContextImpl

public OfficeServletContextImpl(String servletContextName,
                                Map<String,String> initParameters,
                                Map<String,String> fileExtensionToMimeType,
                                Properties filterConfiguration,
                                ClassLoader classLoader)
                         throws javax.servlet.ServletException
Initiate.

Parameters:
servletContextName - ServletContext name.
initParameters - Init parameters.
fileExtensionToMimeType - Mapping of file extension to MIME type.
filterConfiguration - Filter configuration.
classLoader - ClassLoader.
Throws:
javax.servlet.ServletException - If fails to initialise.
Method Detail

init

public void init(ServletServer servletServer)

Loads the ServletServer.

This method only uses the ServletServer on first invocation. After this point further invocations ignore the input ServletServer.

Parameters:
servletServer - ServletServer.

getFilterChainFactory

public FilterChainFactory getFilterChainFactory(Office office)
                                         throws javax.servlet.ServletException
Description copied from interface: OfficeServletContext

Obtains the FilterChainFactory for the Office.

This is a non ServletContext method and is provided as filtering is applied across an application. It is expected that the HttpServletContainer will make use of this FilterChainFactory for filtering Servlet servicing.

Specified by:
getFilterChainFactory in interface OfficeServletContext
Parameters:
office - Office.
Returns:
FilterChainFactory.
Throws:
javax.servlet.ServletException - Filter instances are lazy loaded and initialising may fail for new Filter instances.

mapPath

public ServletTaskReference mapPath(Office office,
                                    String path)
Description copied from interface: OfficeServletContext

Obtains the ServletTaskReference to the Servlet Task corresponding the the input path.

This is a non ServletContext method and is provided to allow routing to a Servlet for servicing the HttpRequest.

Specified by:
mapPath in interface OfficeServletContext
Parameters:
office - Office.
path - Path to be mapped to a Servlet Task.
Returns:
ServletTaskReference for the path or null if path does not map to a Servlet Task.

getContextPath

public String getContextPath(Office office)
Specified by:
getContextPath in interface OfficeServletContext
Parameters:
office - Office.
Returns:
Context path.
See Also:
ServletContext.getContextPath()

getContext

public javax.servlet.ServletContext getContext(Office office,
                                               String uripath)
Specified by:
getContext in interface OfficeServletContext
Parameters:
office - Office.
uripath - URI path.
Returns:
ServletContext.
See Also:
ServletContext.getContext(String)

getMimeType

public String getMimeType(Office office,
                          String file)
Specified by:
getMimeType in interface OfficeServletContext
Parameters:
office - Office.
file - File name.
Returns:
Mime type.
See Also:
ServletContext.getMimeType(String)

getResourcePaths

public Set getResourcePaths(Office office,
                            String path)
Specified by:
getResourcePaths in interface OfficeServletContext
Parameters:
office - Office.
path - Path.
Returns:
Resource paths.
See Also:
ServletContext.getResourcePaths(String)

getResource

public URL getResource(Office office,
                       String path)
                throws MalformedURLException
Specified by:
getResource in interface OfficeServletContext
Parameters:
office - Office.
path - Path.
Returns:
URL.
Throws:
MalformedURLException - If malformed URL.
See Also:
ServletContext.getResource(String)

getResourceAsStream

public InputStream getResourceAsStream(Office office,
                                       String path)
Specified by:
getResourceAsStream in interface OfficeServletContext
Parameters:
office - Office.
path - Path.
Returns:
InputStream.
See Also:
ServletContext.getResourceAsStream(String)

getRequestDispatcher

public javax.servlet.RequestDispatcher getRequestDispatcher(Office office,
                                                            String path)
Specified by:
getRequestDispatcher in interface OfficeServletContext
Parameters:
office - Office.
path - Path.
Returns:
RequestDispatcher.
See Also:
ServletContext.getRequestDispatcher(String)

getNamedDispatcher

public javax.servlet.RequestDispatcher getNamedDispatcher(Office office,
                                                          String name)
Specified by:
getNamedDispatcher in interface OfficeServletContext
Parameters:
office - Office.
name - Name.
Returns:
RequestDispatcher.
See Also:
ServletContext.getNamedDispatcher(String)

log

public void log(Office office,
                String msg)
Specified by:
log in interface OfficeServletContext
Parameters:
office - Office.
msg - Message.
See Also:
ServletContext.log(String)

log

public void log(Office office,
                String message,
                Throwable throwable)
Specified by:
log in interface OfficeServletContext
Parameters:
office - Office.
message - Message.
throwable - Cause.
See Also:
ServletContext.log(String, Throwable)

getRealPath

public String getRealPath(Office office,
                          String path)
Specified by:
getRealPath in interface OfficeServletContext
Parameters:
office - Office.
path - Path.
Returns:
Real path.
See Also:
ServletContext.getRealPath(String)

getServerInfo

public String getServerInfo(Office office)
Specified by:
getServerInfo in interface OfficeServletContext
Parameters:
office - Office.
Returns:
Server information.
See Also:
ServletContext.getServerInfo()

getInitParameter

public String getInitParameter(Office office,
                               String name)
Specified by:
getInitParameter in interface OfficeServletContext
Parameters:
office - Office.
name - Name.
Returns:
Initialisation parameter value.
See Also:
ServletContext.getInitParameter(String)

getInitParameterNames

public Enumeration getInitParameterNames(Office office)
Specified by:
getInitParameterNames in interface OfficeServletContext
Parameters:
office - Office.
Returns:
Initialisation parameter names.
See Also:
ServletContext.getInitParameterNames()

getAttribute

public Object getAttribute(Office office,
                           String name)
Specified by:
getAttribute in interface OfficeServletContext
Parameters:
office - Office.
name - Name.
Returns:
Attribute value.
See Also:
ServletContext.getAttribute(String)

getAttributeNames

public Enumeration getAttributeNames(Office office)
Specified by:
getAttributeNames in interface OfficeServletContext
Parameters:
office - Office.
Returns:
Attribute names.
See Also:
ServletContext.getAttributeNames()

removeAttribute

public void removeAttribute(Office office,
                            String name)
Specified by:
removeAttribute in interface OfficeServletContext
Parameters:
office - Office.
name - Name.
See Also:
ServletContext.removeAttribute(String)

setAttribute

public void setAttribute(Office office,
                         String name,
                         Object object)
Specified by:
setAttribute in interface OfficeServletContext
Parameters:
office - Office.
name - Name.
object - Attribute value.
See Also:
ServletContext.setAttribute(String, Object)

getServletContextName

public String getServletContextName(Office office)
Specified by:
getServletContextName in interface OfficeServletContext
Parameters:
office - Office.
Returns:
ServletContext name.
See Also:
ServletContext.getServletContextName()


Copyright © 2005-2012. All Rights Reserved.