public class

PluginServletContextWrapper

extends Object
implements ServletContext
java.lang.Object
   ↳ com.atlassian.plugin.servlet.PluginServletContextWrapper

Class Overview

A wrapper around servlet context that allows plugin servlets to add attributes which will not be shared/clobbered by other plugins.

Summary

Public Constructors
PluginServletContextWrapper(Plugin plugin, ServletContext context, ConcurrentMap<StringObject> attributes, Map<StringString> initParams)
Public Methods
Object getAttribute(String name)

Gets the named attribute.

Enumeration getAttributeNames()
ServletContext getContext(String uripath)
String getContextPath()
String getInitParameter(String name)
Enumeration getInitParameterNames()
int getMajorVersion()
String getMimeType(String file)
int getMinorVersion()
RequestDispatcher getNamedDispatcher(String name)
String getRealPath(String path)
RequestDispatcher getRequestDispatcher(String path)
URL getResource(String path)
InputStream getResourceAsStream(String path)
Set getResourcePaths(String arg0)
String getServerInfo()
Servlet getServlet(String name)
String getServletContextName()
Enumeration getServletNames()
Enumeration getServlets()
void log(String message, Throwable throwable)
void log(Exception exception, String msg)
void log(String msg)
void removeAttribute(String name)
Removes an attribute from the local context.
void setAttribute(String name, Object object)

Sets an attribute in the local attribute map, leaving the wrapped context untouched.

[Expand]
Inherited Methods
From class java.lang.Object
From interface javax.servlet.ServletContext

Public Constructors

public PluginServletContextWrapper (Plugin plugin, ServletContext context, ConcurrentMap<StringObject> attributes, Map<StringString> initParams)

Public Methods

public Object getAttribute (String name)

Gets the named attribute. The attribute is first looked for in the local attribute map, if it is not found there it is looked for in the wrapped contexts attribute map. If it is not there, null is returned.

A consequence of this ordering is that servlets may, in their own context, override but not overwrite attributes from the wrapped context.

public Enumeration getAttributeNames ()

Returns
  • an enumeration of all the attributes from the wrapped context as well as the local attributes.

public ServletContext getContext (String uripath)

Returns
  • null so that servlet plugins can't escape their box

public String getContextPath ()

public String getInitParameter (String name)

Returns
  • the init parameter from the servlet module descriptor.

public Enumeration getInitParameterNames ()

Returns
  • an enumeration of the init parameters from the servlet module descriptor.

public int getMajorVersion ()

public String getMimeType (String file)

public int getMinorVersion ()

public RequestDispatcher getNamedDispatcher (String name)

public String getRealPath (String path)

public RequestDispatcher getRequestDispatcher (String path)

public URL getResource (String path)

Returns
  • the resource from the plugin classloader if it exists, otherwise the resource is looked up from the wrapped context and returned

public InputStream getResourceAsStream (String path)

Returns
  • the resource stream from the plugin classloader if it exists, otherwise the resource stream is attempted to be retrieved from the wrapped context

public Set getResourcePaths (String arg0)

public String getServerInfo ()

public Servlet getServlet (String name)

Throws
ServletException

public String getServletContextName ()

public Enumeration getServletNames ()

public Enumeration getServlets ()

public void log (String message, Throwable throwable)

public void log (Exception exception, String msg)

public void log (String msg)

public void removeAttribute (String name)

Removes an attribute from the local context. Leaves the wrapped context completely untouched.

public void setAttribute (String name, Object object)

Sets an attribute in the local attribute map, leaving the wrapped context untouched.

Servlets may use this and the lookup ordering of the getAttribute() method to effectively override the value of an attribute in the wrapped servlet context with their own value and this overridden value will only be seen in the plugins own scope.