Top Inners Fields Constructors Methods
org.eclipse.jetty.ee10.servlet

public Class FilterHolder

extends Holder<Filter>
Class Inheritance
Imports
java.io.IOException, java.util.ArrayList, .Arrays, .Collection, .EnumSet, .List, .Objects, jakarta.servlet.AsyncContext, .DispatcherType, .Filter, .FilterChain, .FilterConfig, .FilterRegistration, .ServletContext, .ServletException, .ServletRequest, .ServletRequestWrapper, .ServletResponse, jakarta.servlet.http.HttpServletRequest, .HttpServletRequestWrapper, org.eclipse.jetty.util.TypeUtil, org.eclipse.jetty.util.component.Dumpable, .DumpableCollection, org.eclipse.jetty.util.thread.AutoLock, org.slf4j.Logger, .LoggerFactory

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
protected class
public static interface
FilterHolder.WrapFunction

Experimental Wrapper mechanism for Filter objects.

public static class

Field Summary

Modifier and TypeField and Description
private transient FilterHolder.Config
private transient Filter
private transient FilterRegistration.Dynamic
private static final Logger

Constructor Summary

AccessConstructor and Description
public
FilterHolder()

Constructor

public
FilterHolder(Source
the holder source
source
)

Constructor

public
FilterHolder(Class<? extends Filter>
the filter class
filter
)

Constructor

public
FilterHolder(Filter
the filter
filter
)

Constructor for existing filter.

Method Summary

Modifier and TypeMethod and Description
protected Filter
public void
public void
public void
doStart()

Overrides org.eclipse.jetty.ee10.servlet.BaseHolder.doStart.

Method to override to start the lifecycle
public void
doStop()

Overrides org.eclipse.jetty.ee10.servlet.BaseHolder.doStop.

Method to override to stop the lifecycle
public void
dump(Appendable
The appendable to dump to
out
,
String
The indent to apply after any new lines.
indent
)

Overrides org.eclipse.jetty.ee10.servlet.BaseHolder.dump.

Implements org.eclipse.jetty.util.component.Dumpable.dump.

Dump this object (and children) into an Appendable using the provided indent after any new lines.
public Filter
public FilterRegistration.Dynamic
public void
initialize()

Overrides org.eclipse.jetty.ee10.servlet.BaseHolder.initialize.

Do any setup necessary after starting
public void
setFilter(Filter filter)

public String
toString()

Overrides org.eclipse.jetty.ee10.servlet.Holder.toString.

Returns a string representation of the object.
Inherited from org.eclipse.jetty.ee10.servlet.Holder:
dumpgetDisplayNamegetInitParametergetInitParameterNamesgetInitParametersgetNameisAsyncSupportedsetAsyncSupportedsetClassNamesetDisplayNamesetHeldClasssetInitParametersetInitParameterssetInstancesetName

Field Detail

_configback to summary
private transient FilterHolder.Config _config
_filterback to summary
private transient Filter _filter
_registrationback to summary
private transient FilterRegistration.Dynamic _registration
LOGback to summary
private static final Logger LOG

Hides org.eclipse.jetty.ee10.servlet.Holder.LOG.

Constructor Detail

FilterHolderback to summary
public FilterHolder()

Constructor

FilterHolderback to summary
public FilterHolder(Source source)

Constructor

Parameters
source:Source

the holder source

FilterHolderback to summary
public FilterHolder(Class<? extends Filter> filter)

Constructor

Parameters
filter:Class<? extends Filter>

the filter class

FilterHolderback to summary
public FilterHolder(Filter filter)

Constructor for existing filter.

Parameters
filter:Filter

the filter

Method Detail

createInstanceback to summary
protected Filter createInstance() throws Exception

Overrides org.eclipse.jetty.ee10.servlet.BaseHolder.createInstance.

Annotations
@Override
destroyInstanceback to summary
public void destroyInstance(Object o)

Overrides org.eclipse.jetty.ee10.servlet.Holder.destroyInstance.

Annotations
@Override
doFilterback to summary
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
doStartback to summary
public void doStart() throws Exception

Overrides org.eclipse.jetty.ee10.servlet.BaseHolder.doStart.

Doc from org.eclipse.jetty.util.component.AbstractLifeCycle.doStart.

Method to override to start the lifecycle

Annotations
@Override
Exceptions
Exception:
If there was a problem starting. Will cause a transition to FAILED state
doStopback to summary
public void doStop() throws Exception

Overrides org.eclipse.jetty.ee10.servlet.BaseHolder.doStop.

Doc from org.eclipse.jetty.util.component.AbstractLifeCycle.doStop.

Method to override to stop the lifecycle

Annotations
@Override
Exceptions
Exception:
If there was a problem stopping. Will cause a transition to FAILED state
dumpback to summary
public void dump(Appendable out, String indent) throws IOException

Overrides org.eclipse.jetty.ee10.servlet.BaseHolder.dump.

Implements org.eclipse.jetty.util.component.Dumpable.dump.

Doc from org.eclipse.jetty.util.component.Dumpable.dump.

Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.

Parameters
out:Appendable

The appendable to dump to

indent:String

The indent to apply after any new lines.

Annotations
@Override
Exceptions
IOException:
if unable to write to Appendable
getFilterback to summary
public Filter getFilter()
getRegistrationback to summary
public FilterRegistration.Dynamic getRegistration()
initializeback to summary
public void initialize() throws Exception

Overrides org.eclipse.jetty.ee10.servlet.BaseHolder.initialize.

Doc from org.eclipse.jetty.ee10.servlet.BaseHolder.initialize.

Do any setup necessary after starting

Annotations
@Override
Exceptions
Exception:
if unable to initialize
setFilterback to summary
public void setFilter(Filter filter)
toStringback to summary
public String toString()

Overrides org.eclipse.jetty.ee10.servlet.Holder.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
org.eclipse.jetty.ee10.servlet back to summary

pack-priv Class FilterHolder.Config

extends Holder<Filter>.HolderConfig
implements FilterConfig
Class Inheritance
All Implemented Interfaces
jakarta.servlet.FilterConfig

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public String
getFilterName()

Implements jakarta.servlet.FilterConfig.getFilterName.

Returns the filter-name of this filter as defined in the deployment descriptor.
Inherited from org.eclipse.jetty.ee10.servlet.Holder.HolderConfig:
getInitParametergetInitParameterNamesgetServletContext

Constructor Detail

Configback to summary
pack-priv Config()

Method Detail

getFilterNameback to summary
public String getFilterName()

Implements jakarta.servlet.FilterConfig.getFilterName.

Doc from jakarta.servlet.FilterConfig.getFilterName.

Returns the filter-name of this filter as defined in the deployment descriptor.

Returns:String

the filter name of this filter

Annotations
@Override
org.eclipse.jetty.ee10.servlet back to summary

protected Class FilterHolder.Registration

extends Holder<Filter>.HolderRegistration
implements Dynamic
Class Inheritance
All Implemented Interfaces
jakarta.servlet.FilterRegistration.Dynamic, jakarta.servlet.Registration.Dynamic, jakarta.servlet.Registration, jakarta.servlet.FilterRegistration

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public void
addMappingForServletNames(EnumSet<DispatcherType>
the dispatcher types of the filter mapping, or null if the default DispatcherType.REQUEST is to be used
dispatcherTypes
,
boolean
true if the given filter mapping should be matched after any declared filter mappings, and false if it is supposed to be matched before any declared filter mappings of the ServletContext from which this FilterRegistration was obtained
isMatchAfter
,
String...
the servlet names of the filter mapping
servletNames
)

Implements jakarta.servlet.FilterRegistration.addMappingForServletNames.

Adds a filter mapping with the given servlet names and dispatcher types for the Filter represented by this FilterRegistration.
public void
addMappingForUrlPatterns(EnumSet<DispatcherType>
the dispatcher types of the filter mapping, or null if the default DispatcherType.REQUEST is to be used
dispatcherTypes
,
boolean
true if the given filter mapping should be matched after any declared filter mappings, and false if it is supposed to be matched before any declared filter mappings of the ServletContext from which this FilterRegistration was obtained
isMatchAfter
,
String...
the url patterns of the filter mapping
urlPatterns
)

Implements jakarta.servlet.FilterRegistration.addMappingForUrlPatterns.

Adds a filter mapping with the given url patterns and dispatcher types for the Filter represented by this FilterRegistration.
public Collection<String>
getServletNameMappings()

Implements jakarta.servlet.FilterRegistration.getServletNameMappings.

Gets the currently available servlet name mappings of the Filter represented by this FilterRegistration.
public Collection<String>
getUrlPatternMappings()

Implements jakarta.servlet.FilterRegistration.getUrlPatternMappings.

Gets the currently available URL pattern mappings of the Filter represented by this FilterRegistration.
Inherited from org.eclipse.jetty.ee10.servlet.Holder.HolderRegistration:
getClassNamegetInitParametergetInitParametersgetNamesetAsyncSupportedsetDescriptionsetInitParametersetInitParameters

Constructor Detail

Registrationback to summary
protected Registration()

Method Detail

addMappingForServletNamesback to summary
public void addMappingForServletNames(EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter, String... servletNames)

Implements jakarta.servlet.FilterRegistration.addMappingForServletNames.

Doc from jakarta.servlet.FilterRegistration.addMappingForServletNames.

Adds a filter mapping with the given servlet names and dispatcher types for the Filter represented by this FilterRegistration.

Filter mappings are matched in the order in which they were added.

Depending on the value of the isMatchAfter parameter, the given filter mapping will be considered after or before any declared filter mappings of the ServletContext from which this FilterRegistration was obtained.

If this method is called multiple times, each successive call adds to the effects of the former.

Parameters
dispatcherTypes:EnumSet<DispatcherType>

the dispatcher types of the filter mapping, or null if the default DispatcherType.REQUEST is to be used

isMatchAfter:boolean

true if the given filter mapping should be matched after any declared filter mappings, and false if it is supposed to be matched before any declared filter mappings of the ServletContext from which this FilterRegistration was obtained

servletNames:String[]

the servlet names of the filter mapping

Annotations
@Override
addMappingForUrlPatternsback to summary
public void addMappingForUrlPatterns(EnumSet<DispatcherType> dispatcherTypes, boolean isMatchAfter, String... urlPatterns)

Implements jakarta.servlet.FilterRegistration.addMappingForUrlPatterns.

Doc from jakarta.servlet.FilterRegistration.addMappingForUrlPatterns.

Adds a filter mapping with the given url patterns and dispatcher types for the Filter represented by this FilterRegistration.

Filter mappings are matched in the order in which they were added.

Depending on the value of the isMatchAfter parameter, the given filter mapping will be considered after or before any declared filter mappings of the ServletContext from which this FilterRegistration was obtained.

If this method is called multiple times, each successive call adds to the effects of the former.

Parameters
dispatcherTypes:EnumSet<DispatcherType>

the dispatcher types of the filter mapping, or null if the default DispatcherType.REQUEST is to be used

isMatchAfter:boolean

true if the given filter mapping should be matched after any declared filter mappings, and false if it is supposed to be matched before any declared filter mappings of the ServletContext from which this FilterRegistration was obtained

urlPatterns:String[]

the url patterns of the filter mapping

Annotations
@Override
getServletNameMappingsback to summary
public Collection<String> getServletNameMappings()

Implements jakarta.servlet.FilterRegistration.getServletNameMappings.

Doc from jakarta.servlet.FilterRegistration.getServletNameMappings.

Gets the currently available servlet name mappings of the Filter represented by this FilterRegistration.

If permitted, any changes to the returned Collection must not affect this FilterRegistration.

Returns:Collection<String>

a (possibly empty) Collection of the currently available servlet name mappings of the Filter represented by this FilterRegistration

Annotations
@Override
getUrlPatternMappingsback to summary
public Collection<String> getUrlPatternMappings()

Implements jakarta.servlet.FilterRegistration.getUrlPatternMappings.

Doc from jakarta.servlet.FilterRegistration.getUrlPatternMappings.

Gets the currently available URL pattern mappings of the Filter represented by this FilterRegistration.

If permitted, any changes to the returned Collection must not affect this FilterRegistration.

Returns:Collection<String>

a (possibly empty) Collection of the currently available URL pattern mappings of the Filter represented by this FilterRegistration

Annotations
@Override
org.eclipse.jetty.ee10.servlet back to summary

public Interface FilterHolder.WrapFunction


Experimental Wrapper mechanism for Filter objects.

Beans in ServletContextHandler or WebAppContext that implement this interface will be called to optionally wrap any newly created Filters (before their Filter#init(FilterConfig) method is called)

Method Summary

Modifier and TypeMethod and Description
public Filter

Returns:

the Filter (extend from Wrapper if you do wrap the Filter)
wrapFilter
(Filter
the Filter being passed in.
filter
)

Optionally wrap the Filter.

Method Detail

wrapFilterback to summary
public Filter wrapFilter(Filter filter)

Optionally wrap the Filter.

Parameters
filter:Filter

the Filter being passed in.

Returns:Filter

the Filter (extend from Wrapper if you do wrap the Filter)

org.eclipse.jetty.ee10.servlet back to summary

public Class FilterHolder.Wrapper

extends Object
implements Filter, BaseHolder.Wrapped<Filter>
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.ee10.servlet.BaseHolder.Wrapped, jakarta.servlet.Filter

Field Summary

Modifier and TypeField and Description
private final Filter

Constructor Summary

AccessConstructor and Description
public
Wrapper(Filter filter)

Method Summary

Modifier and TypeMethod and Description
public void
destroy()

Overrides default jakarta.servlet.Filter.destroy.

Called by the web container to indicate to a filter that it is being taken out of service.

public void
doFilter(ServletRequest
the ServletRequest object contains the client's request
request
,
ServletResponse
the ServletResponse object contains the filter's response
response
,
FilterChain
the FilterChain for invoking the next filter or the resource
chain
)

Implements jakarta.servlet.Filter.doFilter.

The doFilter method of the Filter is called by the container each time a request/response pair is passed through the chain due to a client request for a resource at the end of the chain.
public Filter
public void
init(FilterConfig
a FilterConfig object containing the filter's configuration and initialization parameters
filterConfig
)

Overrides default jakarta.servlet.Filter.init.

Called by the web container to indicate to a filter that it is being placed into service.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_filterback to summary
private final Filter _filter

Constructor Detail

Wrapperback to summary
public Wrapper(Filter filter)

Method Detail

destroyback to summary
public void destroy()

Overrides default jakarta.servlet.Filter.destroy.

Doc from jakarta.servlet.Filter.destroy.

Called by the web container to indicate to a filter that it is being taken out of service.

This method is only called once all threads within the filter's doFilter method have exited or after a timeout period has passed. After the web container calls this method, it will not call the doFilter method again on this instance of the filter.

This method gives the filter an opportunity to clean up any resources that are being held (for example, memory, file handles, threads) and make sure that any persistent state is synchronized with the filter's current state in memory.

Annotations
@Override
doFilterback to summary
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException

Implements jakarta.servlet.Filter.doFilter.

Doc from jakarta.servlet.Filter.doFilter.

The doFilter method of the Filter is called by the container each time a request/response pair is passed through the chain due to a client request for a resource at the end of the chain. The FilterChain passed in to this method allows the Filter to pass on the request and response to the next entity in the chain.

A typical implementation of this method would follow the following pattern:

  1. Examine the request
  2. Optionally wrap the request object with a custom implementation to filter content or headers for input filtering
  3. Optionally wrap the response object with a custom implementation to filter content or headers for output filtering
    • Either invoke the next entity in the chain using the FilterChain object (chain.doFilter()),
    • or not pass on the request/response pair to the next entity in the filter chain to block the request processing
  4. Directly set headers on the response after invocation of the next entity in the filter chain.
Parameters
request:ServletRequest

the ServletRequest object contains the client's request

response:ServletResponse

the ServletResponse object contains the filter's response

chain:FilterChain

the FilterChain for invoking the next filter or the resource

Annotations
@Override
Exceptions
IOException:
if an I/O related error has occurred during the processing
ServletException:
if an exception occurs that interferes with the filter's normal operation
getWrappedback to summary
public Filter getWrapped()

Implements org.eclipse.jetty.ee10.servlet.BaseHolder.Wrapped.getWrapped.

Annotations
@Override
initback to summary
public void init(FilterConfig filterConfig) throws ServletException

Overrides default jakarta.servlet.Filter.init.

Doc from jakarta.servlet.Filter.init.

Called by the web container to indicate to a filter that it is being placed into service.

The servlet container calls the init method exactly once after instantiating the filter. The init method must complete successfully before the filter is asked to do any filtering work. The container will ensure that actions performed in the init method will be visible to any threads that subsequently call the doFilter method according to the rules in JSR-133 (i.e. there is a 'happens before' relationship between init and doFilter).

The web container cannot place the filter into service if the init method either

  1. Throws a ServletException
  2. Does not return within a time period defined by the web container
Parameters
filterConfig:FilterConfig

a FilterConfig object containing the filter's configuration and initialization parameters

Annotations
@Override
Exceptions
ServletException:
if an exception has occurred that interferes with the filter's normal operation
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override