use of javax.servlet.SessionTrackingMode in project undertow by undertow-io.
the class ServletContextImpl method initDone.
public void initDone() {
initialized = true;
Set<SessionTrackingMode> trackingMethods = sessionTrackingModes;
SessionConfig sessionConfig = sessionCookieConfig;
if (trackingMethods != null && !trackingMethods.isEmpty()) {
if (sessionTrackingModes.contains(SessionTrackingMode.SSL)) {
sessionConfig = new SslSessionConfig(deployment.getSessionManager());
} else {
if (sessionTrackingModes.contains(SessionTrackingMode.COOKIE) && sessionTrackingModes.contains(SessionTrackingMode.URL)) {
sessionCookieConfig.setFallback(new PathParameterSessionConfig(sessionCookieConfig.getName().toLowerCase(Locale.ENGLISH)));
} else if (sessionTrackingModes.contains(SessionTrackingMode.URL)) {
sessionConfig = new PathParameterSessionConfig(sessionCookieConfig.getName().toLowerCase(Locale.ENGLISH));
}
}
}
SessionConfigWrapper wrapper = deploymentInfo.getSessionConfigWrapper();
if (wrapper != null) {
sessionConfig = wrapper.wrap(sessionConfig, deployment);
}
this.sessionConfig = new ServletContextSessionConfig(sessionConfig);
this.onWritePossibleTask = deployment.createThreadSetupAction(new ThreadSetupHandler.Action<Void, WriteListener>() {
@Override
public Void call(HttpServerExchange exchange, WriteListener context) throws Exception {
context.onWritePossible();
return null;
}
});
this.runnableTask = new ThreadSetupHandler.Action<Void, Runnable>() {
@Override
public Void call(HttpServerExchange exchange, Runnable context) throws Exception {
context.run();
return null;
}
};
this.onDataAvailableTask = deployment.createThreadSetupAction(new ThreadSetupHandler.Action<Void, ReadListener>() {
@Override
public Void call(HttpServerExchange exchange, ReadListener context) throws Exception {
context.onDataAvailable();
return null;
}
});
this.onAllDataReadTask = deployment.createThreadSetupAction(new ThreadSetupHandler.Action<Void, ReadListener>() {
@Override
public Void call(HttpServerExchange exchange, ReadListener context) throws Exception {
context.onAllDataRead();
return null;
}
});
this.invokeActionTask = deployment.createThreadSetupAction(new ThreadSetupHandler.Action<Void, ThreadSetupHandler.Action<Void, Object>>() {
@Override
public Void call(HttpServerExchange exchange, ThreadSetupHandler.Action<Void, Object> context) throws Exception {
context.call(exchange, null);
return null;
}
});
}
use of javax.servlet.SessionTrackingMode 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