Package org.jivesoftware.admin
Class PluginFilter
- java.lang.Object
-
- org.jivesoftware.admin.PluginFilter
-
- All Implemented Interfaces:
javax.servlet.Filter
public class PluginFilter extends Object implements javax.servlet.Filter
A servlet filter that plugin classes can use to dynamically register and un-register filter logic. The original, now deprecated, filter logic that each plugin can register was fairly limited; instead of having full control over the filter chain, each instance ofPluginFilter.SimpleFilter
only has the ability to use the ServletRequest and ServletResponse objects and then returntrue
if further filters in the chain should be run. The new, non-deprecated functionality allows for regularFilter
instances to be registered with this class, which removes much of the limitations that was present in the SimpleFilter approach. This implementation assumes, but does not enforce, that filters installed by plugins are applied to URL patterns that match the plugin. When filters installed by different plugins are applied to the same URL, the behavior of this implementation is undetermined.- Author:
- Matt Tucker, Guus der Kinderen, guus.der.kinderen@gmail.com
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
PluginFilter.SimpleFilter
Deprecated.UseFilter
instead.
-
Constructor Summary
Constructors Constructor Description PluginFilter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
addPluginFilter(String filterUrl, javax.servlet.Filter filter)
Adds a filter to the list of filters that will be run on every request of which the URL matches the URL that is registered with this filter.static void
addPluginFilter(PluginFilter.SimpleFilter filter)
Deprecated.Replaced byaddPluginFilter(String, Filter)
void
destroy()
void
doFilter(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, javax.servlet.FilterChain filterChain)
This class is a Filter implementation itself.void
init(javax.servlet.FilterConfig filterConfig)
static javax.servlet.Filter
removePluginFilter(String filterUrl, String filterClassName)
Removes a filter that is applied to a certain URL.static void
removePluginFilter(PluginFilter.SimpleFilter filter)
Deprecated.
-
-
-
Method Detail
-
addPluginFilter
@Deprecated public static void addPluginFilter(PluginFilter.SimpleFilter filter)
Deprecated.Replaced byaddPluginFilter(String, Filter)
Adds a filter to the list of filters that will be run on every request. This method should be called by plugins when starting up.- Parameters:
filter
- the filter.
-
addPluginFilter
public static void addPluginFilter(String filterUrl, javax.servlet.Filter filter)
Adds a filter to the list of filters that will be run on every request of which the URL matches the URL that is registered with this filter. More specifically, the request URL should be equal to, or start with, the filter URL. Multiple filters can be registered on the same URL, in which case they will be executed in the order in which they were added. Adding a filter does not initialize the plugin instance.- Parameters:
filterUrl
- The URL pattern to which the filter is to be applied. Cannot be null nor an empty string.filter
- The filter. Cannot be null.
-
removePluginFilter
@Deprecated public static void removePluginFilter(PluginFilter.SimpleFilter filter)
Deprecated.Removes a filter from the list of filters that will be run on every request. This method should be called by plugins when shutting down.- Parameters:
filter
- the filter.
-
removePluginFilter
public static javax.servlet.Filter removePluginFilter(String filterUrl, String filterClassName)
Removes a filter that is applied to a certain URL. Removing a filter does not destroy the plugin instance.- Parameters:
filterUrl
- The URL pattern to which the filter is applied. Cannot be null nor an empty string.filterClassName
- The filter class name. Cannot be null or empty string.- Returns:
- The filter instance that was removed, or null if the URL and name combination did not match a filter.
-
init
public void init(javax.servlet.FilterConfig filterConfig) throws javax.servlet.ServletException
- Specified by:
init
in interfacejavax.servlet.Filter
- Throws:
javax.servlet.ServletException
-
doFilter
public void doFilter(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse, javax.servlet.FilterChain filterChain) throws IOException, javax.servlet.ServletException
This class is a Filter implementation itself. It acts as a dynamic proxy to filters that are registered by Openfire plugins.- Specified by:
doFilter
in interfacejavax.servlet.Filter
- Throws:
IOException
javax.servlet.ServletException
-
destroy
public void destroy()
- Specified by:
destroy
in interfacejavax.servlet.Filter
-
-