use of org.eclipse.jetty.webapp.WebAppContext in project ignite by apache.
the class WebSessionSelfTest method startServerWithLoginService.
/**
* Starts server with Login Service and create a realm file.
*
* @param port Port number.
* @param cfg Configuration.
* @param igniteInstanceName Ignite instance name.
* @param servlet Servlet.
* @return Server.
* @throws Exception In case of error.
*/
private Server startServerWithLoginService(int port, @Nullable String cfg, @Nullable String igniteInstanceName, HttpServlet servlet) throws Exception {
Server srv = new Server(port);
WebAppContext ctx = getWebContext(cfg, igniteInstanceName, keepBinary(), servlet);
HashLoginService hashLoginService = new HashLoginService();
hashLoginService.setName("Test Realm");
createRealm();
hashLoginService.setConfig("/tmp/realm.properties");
ctx.getSecurityHandler().setLoginService(hashLoginService);
srv.setHandler(ctx);
srv.start();
return srv;
}
use of org.eclipse.jetty.webapp.WebAppContext in project ignite by apache.
the class WebSessionSelfTest method getWebContext.
/**
* @param cfg Configuration.
* @param igniteInstanceName Ignite instance name.
* @param servlet Servlet.
* @return Servlet container web context for this test.
*/
protected WebAppContext getWebContext(@Nullable String cfg, @Nullable String igniteInstanceName, boolean keepBinaryFlag, HttpServlet servlet) {
final String path = keepBinaryFlag ? "modules/core/src/test/webapp" : "modules/web/src/test/webapp2";
WebAppContext ctx = new WebAppContext(U.resolveIgnitePath(path).getAbsolutePath(), "/ignitetest");
ctx.setInitParameter("IgniteConfigurationFilePath", cfg);
ctx.setInitParameter("IgniteWebSessionsGridName", igniteInstanceName);
ctx.setInitParameter("IgniteWebSessionsCacheName", getCacheName());
ctx.setInitParameter("IgniteWebSessionsMaximumRetriesOnFail", "100");
ctx.setInitParameter("IgniteWebSessionsKeepBinary", Boolean.toString(keepBinaryFlag));
ctx.addServlet(new ServletHolder(servlet), "/*");
return ctx;
}
use of org.eclipse.jetty.webapp.WebAppContext in project jena by apache.
the class JettyFuseki method buildServerWebapp.
private void buildServerWebapp(String contextPath, String jettyConfig) {
if (jettyConfig != null)
// --jetty-config=jetty-fuseki.xml
// for detailed configuration of the server using Jetty features.
configServer(jettyConfig);
else
defaultServerConfig(serverConfig.port, serverConfig.loopback);
WebAppContext webapp = createWebApp(contextPath);
if (false) /*enable symbolic links */
{
// See http://www.eclipse.org/jetty/documentation/current/serving-aliased-files.html
// Record what would be needed:
// 1 - Allow all symbolic links without checking
webapp.addAliasCheck(new ContextHandler.ApproveAliases());
// 2 - Check links are to valid resources. But default for Unix?
webapp.addAliasCheck(new AllowSymLinkAliasChecker());
}
servletContext = webapp.getServletContext();
server.setHandler(webapp);
// Replaced by Shiro.
if (jettyConfig == null && serverConfig.authConfigFile != null)
security(webapp, serverConfig.authConfigFile);
}
use of org.eclipse.jetty.webapp.WebAppContext in project lucene-solr by apache.
the class JettyWebappTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
System.setProperty("solr.solr.home", SolrJettyTestBase.legacyExampleCollection1SolrHome());
System.setProperty("tests.shardhandler.randomSeed", Long.toString(random().nextLong()));
System.setProperty("solr.tests.doContainerStreamCloseAssert", "false");
File dataDir = createTempDir().toFile();
dataDir.mkdirs();
System.setProperty("solr.data.dir", dataDir.getCanonicalPath());
String path = ExternalPaths.WEBAPP_HOME;
server = new Server(port);
// insecure: only use for tests!!!!
server.setSessionIdManager(new HashSessionIdManager(new Random(random().nextLong())));
new WebAppContext(server, path, context);
ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory());
connector.setIdleTimeout(1000 * 60 * 60);
connector.setSoLingerTime(-1);
connector.setPort(0);
server.setConnectors(new Connector[] { connector });
server.setStopAtShutdown(true);
server.start();
port = connector.getLocalPort();
}
use of org.eclipse.jetty.webapp.WebAppContext in project hbase by apache.
the class HMaster method putUpJettyServer.
// return the actual infoPort, -1 means disable info server.
private int putUpJettyServer() throws IOException {
if (!conf.getBoolean("hbase.master.infoserver.redirect", true)) {
return -1;
}
final int infoPort = conf.getInt("hbase.master.info.port.orig", HConstants.DEFAULT_MASTER_INFOPORT);
// -1 is for disabling info server, so no redirecting
if (infoPort < 0 || infoServer == null) {
return -1;
}
if (infoPort == infoServer.getPort()) {
return infoPort;
}
final String addr = conf.get("hbase.master.info.bindAddress", "0.0.0.0");
if (!Addressing.isLocalAddress(InetAddress.getByName(addr))) {
String msg = "Failed to start redirecting jetty server. Address " + addr + " does not belong to this host. Correct configuration parameter: " + "hbase.master.info.bindAddress";
LOG.error(msg);
throw new IOException(msg);
}
// TODO I'm pretty sure we could just add another binding to the InfoServer run by
// the RegionServer and have it run the RedirectServlet instead of standing up
// a second entire stack here.
masterJettyServer = new Server();
final ServerConnector connector = new ServerConnector(masterJettyServer);
connector.setHost(addr);
connector.setPort(infoPort);
masterJettyServer.addConnector(connector);
masterJettyServer.setStopAtShutdown(true);
final String redirectHostname = shouldUseThisHostnameInstead() ? useThisHostnameInstead : null;
final RedirectServlet redirect = new RedirectServlet(infoServer, redirectHostname);
final WebAppContext context = new WebAppContext(null, "/", null, null, null, null, WebAppContext.NO_SESSIONS);
context.addServlet(new ServletHolder(redirect), "/*");
context.setServer(masterJettyServer);
try {
masterJettyServer.start();
} catch (Exception e) {
throw new IOException("Failed to start redirecting jetty server", e);
}
return connector.getLocalPort();
}
Aggregations