use of org.glassfish.jersey.servlet.spi.FilterUrlMappingsProvider in project jersey by jersey.
the class ServletContainer method getFilterUrlMappingsProvider.
/**
* Resolve the {@link FilterUrlMappingsProvider} service via hk2.
*
* Will only work in Servlet 3 container, as the older API version
* does not provide access to the filter mapping structure.
*
* @return {@code FilterContextPath} instance, if available, {@code null} otherwise.
*/
private FilterUrlMappingsProvider getFilterUrlMappingsProvider() {
FilterUrlMappingsProvider filterUrlMappingsProvider = null;
final Iterator<FilterUrlMappingsProvider> providers = Providers.getAllProviders(getApplicationHandler().getInjectionManager(), FilterUrlMappingsProvider.class).iterator();
if (providers.hasNext()) {
filterUrlMappingsProvider = providers.next();
}
return filterUrlMappingsProvider;
}
use of org.glassfish.jersey.servlet.spi.FilterUrlMappingsProvider in project jersey by jersey.
the class ServletContainer method init.
// Filter
@Override
public void init(final FilterConfig filterConfig) throws ServletException {
this.filterConfig = filterConfig;
init(new WebFilterConfig(filterConfig));
final String regex = (String) getConfiguration().getProperty(ServletProperties.FILTER_STATIC_CONTENT_REGEX);
if (regex != null && !regex.isEmpty()) {
try {
staticContentPattern = Pattern.compile(regex);
} catch (final PatternSyntaxException ex) {
throw new ContainerException(LocalizationMessages.INIT_PARAM_REGEX_SYNTAX_INVALID(regex, ServletProperties.FILTER_STATIC_CONTENT_REGEX), ex);
}
}
this.filterContextPath = filterConfig.getInitParameter(ServletProperties.FILTER_CONTEXT_PATH);
if (filterContextPath != null) {
if (filterContextPath.isEmpty()) {
filterContextPath = null;
} else {
if (!filterContextPath.startsWith("/")) {
filterContextPath = '/' + filterContextPath;
}
if (filterContextPath.endsWith("/")) {
filterContextPath = filterContextPath.substring(0, filterContextPath.length() - 1);
}
}
}
// get the url-pattern defined (e.g.) in the filter-mapping section of web.xml
final FilterUrlMappingsProvider filterUrlMappingsProvider = getFilterUrlMappingsProvider();
if (filterUrlMappingsProvider != null) {
filterUrlMappings = filterUrlMappingsProvider.getFilterUrlMappings(filterConfig);
}
// not work (won't be accessible)
if (filterUrlMappings == null && filterContextPath == null) {
LOGGER.warning(LocalizationMessages.FILTER_CONTEXT_PATH_MISSING());
}
}
Aggregations