use of org.eclipse.jetty.server.session.SessionHandler in project jetty.project by eclipse.
the class ServletContextHandler method setSessionHandler.
/* ------------------------------------------------------------ */
/**
* @param sessionHandler The sessionHandler to set.
*/
public void setSessionHandler(SessionHandler sessionHandler) {
if (isStarted())
throw new IllegalStateException("STARTED");
Handler next = null;
if (_sessionHandler != null) {
next = _sessionHandler.getHandler();
_sessionHandler.setHandler(null);
replaceHandler(_sessionHandler, sessionHandler);
}
_sessionHandler = sessionHandler;
if (next != null && _sessionHandler.getHandler() == null)
_sessionHandler.setHandler(next);
relinkHandlers();
}
use of org.eclipse.jetty.server.session.SessionHandler in project qi4j-sdk by Qi4j.
the class AbstractJettyMixin method startJetty.
@Override
public final void startJetty() throws Exception {
// Configure Server
configureServer(server, configuration());
// Set up HTTP
HttpConfiguration httpConfig = new HttpConfiguration();
configureHttp(httpConfig, configuration());
httpConfig = specializeHttp(httpConfig);
// Set up connector
ServerConnector connector = buildConnector(server, httpConfig);
configureConnector(connector, configuration());
// Bind Connector to Server
server.addConnector(connector);
if (mBeanServer != null) {
server.addEventListener(new MBeanContainer(mBeanServer));
}
// Prepare ServletContext
ServletContextHandler root = new ServletContextHandler(server, "/", new SessionHandler(), buildSecurityHandler(), new ServletHandler(), new ErrorHandler());
root.setDisplayName(identity);
configureContext(root, configuration());
// Register ContextListeners, Servlets and Filters
addContextListeners(root, contextListeners);
addServlets(root, servlets);
addFilters(root, filters);
// Start
server.start();
}
use of org.eclipse.jetty.server.session.SessionHandler in project jfinal by jfinal.
the class JettyServer method persistSession.
private void persistSession(WebAppContext webApp) {
String storeDir = getStoreDir();
SessionManager sm = webApp.getSessionHandler().getSessionManager();
if (sm instanceof HashSessionManager) {
((HashSessionManager) sm).setStoreDirectory(new File(storeDir));
return;
}
HashSessionManager hsm = new HashSessionManager();
hsm.setStoreDirectory(new File(storeDir));
SessionHandler sh = new SessionHandler();
sh.setSessionManager(hsm);
webApp.setSessionHandler(sh);
}
use of org.eclipse.jetty.server.session.SessionHandler in project jfinal by jfinal.
the class JettyServerForIDEA method persistSession.
private void persistSession(WebAppContext webApp) {
String storeDir = getStoreDir();
SessionManager sm = webApp.getSessionHandler().getSessionManager();
if (sm instanceof HashSessionManager) {
((HashSessionManager) sm).setStoreDirectory(new File(storeDir));
return;
}
HashSessionManager hsm = new HashSessionManager();
hsm.setStoreDirectory(new File(storeDir));
SessionHandler sh = new SessionHandler();
sh.setSessionManager(hsm);
webApp.setSessionHandler(sh);
}
use of org.eclipse.jetty.server.session.SessionHandler in project neo4j by neo4j.
the class Jetty9WebServer method loadStaticContent.
private void loadStaticContent(SessionManager sm, String mountPoint) {
String contentLocation = staticContent.get(mountPoint);
try {
SessionHandler sessionHandler = new SessionHandler(sm);
sessionHandler.setServer(getJetty());
final WebAppContext staticContext = new WebAppContext();
staticContext.setServer(getJetty());
staticContext.setContextPath(mountPoint);
staticContext.setSessionHandler(sessionHandler);
staticContext.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
URL resourceLoc = getClass().getClassLoader().getResource(contentLocation);
if (resourceLoc != null) {
URL url = resourceLoc.toURI().toURL();
final Resource resource = Resource.newResource(url);
staticContext.setBaseResource(resource);
addFiltersTo(staticContext);
staticContext.addFilter(new FilterHolder(new NoCacheHtmlFilter()), "/*", EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD));
handlers.addHandler(staticContext);
} else {
log.warn("No static content available for Neo Server at %s, management console may not be available.", jettyAddress);
}
} catch (Exception e) {
log.error("Unknown error loading static content", e);
e.printStackTrace();
throw new RuntimeException(e);
}
}
Aggregations