use of org.apache.tomcat.util.descriptor.web.FilterMap in project tomee by apache.
the class TomcatWebAppBuilder method beforeStart.
/**
* {@inheritDoc}
*/
@Override
public void beforeStart(final StandardContext standardContext) {
if (standardContext.getResources() != null && LazyStopStandardRoot.class.isInstance(standardContext.getResources())) {
// reset after reload
Reflections.set(standardContext, "resources", LazyStopStandardRoot.class.cast(standardContext.getResources()).getDelegate());
}
final ServletContext sc = standardContext.getServletContext();
if (sc != null && !SystemInstance.get().getOptions().get(OPENEJB_JSESSION_ID_SUPPORT, true)) {
final Set<SessionTrackingMode> defaultTrackingModes = sc.getEffectiveSessionTrackingModes();
if (defaultTrackingModes.contains(SessionTrackingMode.URL)) {
final Set<SessionTrackingMode> newModes = new HashSet<>();
newModes.remove(SessionTrackingMode.URL);
sc.setSessionTrackingModes(newModes);
}
}
initContextLoader(standardContext);
// used to add custom filters first - our arquillian integration uses it for instance
// needs to be done now (= before start event) because of addFilterMapBefore() usage
final String filters = SystemInstance.get().getProperty("org.apache.openejb.servlet.filters");
if (filters != null) {
final String[] names = filters.split(",");
for (final String name : names) {
final String[] clazzMapping = name.split("=");
final FilterDef filterDef = new FilterDef();
filterDef.setFilterClass(clazzMapping[0]);
filterDef.setFilterName(clazzMapping[0]);
standardContext.addFilterDef(filterDef);
final FilterMap filterMap = new FilterMap();
filterMap.setFilterName(clazzMapping[0]);
filterMap.addURLPattern(clazzMapping[1]);
standardContext.addFilterMapBefore(filterMap);
}
}
// mainly to get back compatibility with tomcat <= 8.0
final String cookieProcessor = SystemInstance.get().getProperty("tomee.tomcat.cookieProcessor");
if (cookieProcessor != null) {
// not that important for now if we use the container loader, we mainly want to be able to access
// the legacy one
final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
final Class<?> cookieProcessorClass = contextClassLoader.loadClass(cookieProcessor.trim());
standardContext.setCookieProcessor(CookieProcessor.class.cast(cookieProcessorClass.newInstance()));
} catch (final Exception e) {
throw new IllegalArgumentException("Cannot set CookieProcessor: " + cookieProcessor);
}
}
}
Aggregations