making root context (htroot) a WebAppContext

- this allows additional features, like servlet configuration via web.xml and many more things.
- currently the standard servlets are still configured in the code (so the supplied defaults/web.xml is not realy needed, yet),
  but could be expanded
- lookup for web.xml - 1. in /DATA/SETTINGS then in /defaults
pull/1/head
reger 11 years ago
parent f6099b730d
commit 37f2a82a5d

@ -84,6 +84,8 @@
<classpathentry kind="lib" path="lib/jetty-servlet-8.1.14.v20131031.jar"/>
<classpathentry kind="lib" path="lib/jetty-servlets-8.1.14.v20131031.jar"/>
<classpathentry kind="lib" path="lib/jetty-util-8.1.14.v20131031.jar"/>
<classpathentry kind="lib" path="lib/jetty-webapp-8.1.14.v20131031.jar"/>
<classpathentry kind="lib" path="lib/jetty-xml-8.1.14.v20131031.jar"/>
<classpathentry kind="lib" path="lib/servlet-api-3.0.jar"/>
<classpathentry kind="output" path="gen"/>
</classpath>

@ -74,6 +74,8 @@
<string>$JAVAROOT/lib/jetty-servlet-8.1.14.v20131031.jar</string>
<string>$JAVAROOT/lib/jetty-servlets-8.1.14.v20131031.jar</string>
<string>$JAVAROOT/lib/jetty-util-8.1.14.v20131031.jar</string>
<string>$JAVAROOT/lib/jetty-webapp-8.1.14.v20131031.jar</string>
<string>$JAVAROOT/lib/jetty-xml-8.1.14.v20131031.jar</string>
<string>$JAVAROOT/lib/jsch-0.1.50.jar</string>
<string>$JAVAROOT/lib/json-simple-1.1.1.jar</string>
<string>$JAVAROOT/lib/log4j-over-slf4j-1.7.2.jar</string>

@ -198,6 +198,8 @@
<pathelement location="${lib}/jetty-servlet-8.1.14.v20131031.jar" />
<pathelement location="${lib}/jetty-servlets-8.1.14.v20131031.jar" />
<pathelement location="${lib}/jetty-util-8.1.14.v20131031.jar" />
<pathelement location="${lib}/jetty-webapp-8.1.14.v20131031.jar" />
<pathelement location="${lib}/jetty-xml-8.1.14.v20131031.jar" />
<pathelement location="${lib}/jsch-0.1.50.jar" />
<pathelement location="${lib}/json-simple-1.1.1.jar" />
<pathelement location="${lib}/jsoup-1.6.3.jar" />
@ -653,7 +655,7 @@
<!--<arg value="-Xrunhprof"/>-->
<arg line="-start"/>
<jvmarg line="-Xms180m"/>
<jvmarg line="-Xmx600m"/>
<jvmarg line="-Xmx800m"/>
<!-- <arg line="-migratewords"/>-->
<!-- <arg line="-start ${user.dir}"/>-->
</java>

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>YaCy</display-name>
<description>Decentralized Web Search</description>
<!-- Standard YaCy Servlets -->
<!-- Default servlet for all YaCy output
-as this is mandatory the servlet activated automatically by the application
-no need to include this in this web.xml (provided only for completness)
<servlet>
<servlet-name>YaCyDefaultServlet</servlet-name>
<servlet-class>net.yacy.http.servlets.YaCyDefaultServlet</servlet-class>
</servlet>
-->
<!-- servlet to provide direct access to the embedded solr, also used for P2P searches -->
<servlet>
<servlet-name>SolrServlet</servlet-name>
<servlet-class>net.yacy.http.servlets.SolrServlet</servlet-class>
</servlet>
<!-- servlet to provide Google Search Appliance (GSA) formatted search results -->
<servlet>
<servlet-name>GSAServlet</servlet-name>
<servlet-class>net.yacy.http.servlets.GSAsearchServlet</servlet-class>
</servlet>
<!-- servlet to provide searchresults via proxy and needed for Augmented Browsing -->
<servlet>
<servlet-name>URLProxyServlet</servlet-name>
<servlet-class>net.yacy.http.servlets.YaCyProxyServlet</servlet-class>
</servlet>
<!-- mapping activated by the application
<servlet-mapping>
<servlet-name>SolrServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
-->
<servlet-mapping>
<servlet-name>SolrServlet</servlet-name>
<url-pattern>/solr/select</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>GSAServlet</servlet-name>
<url-pattern>/gsa/search</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>URLProxyServlet</servlet-name>
<url-pattern>/proxy.html</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>Index.html</welcome-file>
<welcome-file>Welcome.html</welcome-file>
</welcome-file-list>
</web-app>

@ -22,6 +22,11 @@
<location>htroot</location>
<encoding>UTF-8</encoding>
</source-folder>
<source-folder>
<label>YaCy</label>
<location>.</location>
<encoding>UTF-8</encoding>
</source-folder>
</folders>
<ide-actions>
<action name="build">
@ -78,7 +83,7 @@
<compilation-unit>
<package-root>source</package-root>
<package-root>htroot</package-root>
<classpath mode="compile">lib/J7Zip-modified.jar;lib/activation.jar;lib/apache-mime4j-0.6.jar;lib/arq-2.8.7.jar;lib/bcmail-jdk15-145.jar;lib/bcprov-jdk15-145.jar;lib/commons-codec-1.7.jar;lib/commons-compress-1.4.1.jar;lib/commons-fileupload-1.2.2.jar;lib/commons-io-2.1.jar;lib/commons-jxpath-1.3.jar;lib/commons-lang-2.6.jar;lib/commons-logging-1.1.3.jar;lib/fontbox-1.8.3.jar;lib/geronimo-stax-api_1.0_spec-1.0.1.jar;lib/guava-15.0.jar;lib/htmllexer.jar;lib/httpclient-4.3.1.jar;lib/httpcore-4.3.jar;lib/httpmime-4.3.1.jar;lib/icu4j-core.jar;lib/iri-0.8.jar;lib/jakarta-oro-2.0.8.jar;lib/jaudiotagger-2.0.4-20111207.115108-15.jar;lib/jcifs-1.3.17.jar;lib/jcl-over-slf4j-1.7.2.jar;lib/jempbox-1.8.3.jar;lib/jena-2.6.4.jar;lib/jetty-client-8.1.14.v20131031.jar;lib/jetty-continuation-8.1.14.v20131031.jar;lib/jetty-http-8.1.14.v20131031.jar;lib/jetty-io-8.1.14.v20131031.jar;lib/jetty-security-8.1.14.v20131031.jar;lib/jetty-server-8.1.14.v20131031.jar;lib/jetty-servlet-8.1.14.v20131031.jar;lib/jetty-servlets-8.1.14.v20131031.jar;lib/jetty-util-8.1.14.v20131031.jar;lib/jsch-0.1.50.jar;lib/json-simple-1.1.1.jar;lib/jsoup-1.6.3.jar;lib/log4j-over-slf4j-1.7.2.jar;lib/lucene-analyzers-common-4.6.0.jar;lib/lucene-analyzers-phonetic-4.6.0.jar;lib/lucene-classification-4.6.0.jar;lib/lucene-codecs-4.6.0.jar;lib/lucene-core-4.6.0.jar;lib/lucene-facet-4.6.0.jar;lib/lucene-grouping-4.6.0.jar;lib/lucene-highlighter-4.6.0.jar;lib/lucene-join-4.6.0.jar;lib/lucene-memory-4.6.0.jar;lib/lucene-misc-4.6.0.jar;lib/lucene-queries-4.6.0.jar;lib/lucene-queryparser-4.6.0.jar;lib/lucene-spatial-4.6.0.jar;lib/lucene-suggest-4.6.0.jar;lib/metadata-extractor-2.6.2.jar;lib/noggit-0.5.jar;lib/pdfbox-1.8.3.jar;lib/poi-3.9-20121203.jar;lib/poi-scratchpad-3.9-20121203.jar;lib/sax-2.0.1.jar;lib/servlet-api-3.0.jar;lib/slf4j-api-1.7.2.jar;lib/slf4j-jdk14-1.7.2.jar;lib/solr-core-4.6.0.jar;lib/solr-solrj-4.6.0.jar;lib/spatial4j-0.3.jar;lib/webcat-0.1-swf.jar;lib/wstx-asl-3.2.9.jar;lib/xercesImpl.jar;lib/xml-apis.jar;lib/zookeeper-3.4.5.jar</classpath>
<classpath mode="compile">lib/J7Zip-modified.jar;lib/activation.jar;lib/apache-mime4j-0.6.jar;lib/arq-2.8.7.jar;lib/bcmail-jdk15-145.jar;lib/bcprov-jdk15-145.jar;lib/commons-codec-1.7.jar;lib/commons-compress-1.4.1.jar;lib/commons-fileupload-1.2.2.jar;lib/commons-io-2.1.jar;lib/commons-jxpath-1.3.jar;lib/commons-lang-2.6.jar;lib/commons-logging-1.1.3.jar;lib/fontbox-1.8.3.jar;lib/geronimo-stax-api_1.0_spec-1.0.1.jar;lib/guava-15.0.jar;lib/htmllexer.jar;lib/httpclient-4.3.1.jar;lib/httpcore-4.3.jar;lib/httpmime-4.3.1.jar;lib/icu4j-core.jar;lib/iri-0.8.jar;lib/jakarta-oro-2.0.8.jar;lib/jaudiotagger-2.0.4-20111207.115108-15.jar;lib/jcifs-1.3.17.jar;lib/jcl-over-slf4j-1.7.2.jar;lib/jempbox-1.8.3.jar;lib/jena-2.6.4.jar;lib/jetty-client-8.1.14.v20131031.jar;lib/jetty-continuation-8.1.14.v20131031.jar;lib/jetty-http-8.1.14.v20131031.jar;lib/jetty-io-8.1.14.v20131031.jar;lib/jetty-security-8.1.14.v20131031.jar;lib/jetty-server-8.1.14.v20131031.jar;lib/jetty-servlet-8.1.14.v20131031.jar;lib/jetty-servlets-8.1.14.v20131031.jar;lib/jetty-util-8.1.14.v20131031.jar;lib/jetty-webapp-8.1.14.v20131031.jar;lib/jetty-xml-8.1.14.v20131031.jar;lib/jsch-0.1.50.jar;lib/json-simple-1.1.1.jar;lib/jsoup-1.6.3.jar;lib/log4j-over-slf4j-1.7.2.jar;lib/lucene-analyzers-common-4.6.0.jar;lib/lucene-analyzers-phonetic-4.6.0.jar;lib/lucene-classification-4.6.0.jar;lib/lucene-codecs-4.6.0.jar;lib/lucene-core-4.6.0.jar;lib/lucene-facet-4.6.0.jar;lib/lucene-grouping-4.6.0.jar;lib/lucene-highlighter-4.6.0.jar;lib/lucene-join-4.6.0.jar;lib/lucene-memory-4.6.0.jar;lib/lucene-misc-4.6.0.jar;lib/lucene-queries-4.6.0.jar;lib/lucene-queryparser-4.6.0.jar;lib/lucene-spatial-4.6.0.jar;lib/lucene-suggest-4.6.0.jar;lib/metadata-extractor-2.6.2.jar;lib/noggit-0.5.jar;lib/pdfbox-1.8.3.jar;lib/poi-3.9-20121203.jar;lib/poi-scratchpad-3.9-20121203.jar;lib/sax-2.0.1.jar;lib/servlet-api-3.0.jar;lib/slf4j-api-1.7.2.jar;lib/slf4j-jdk14-1.7.2.jar;lib/solr-core-4.6.0.jar;lib/solr-solrj-4.6.0.jar;lib/spatial4j-0.3.jar;lib/webcat-0.1-swf.jar;lib/wstx-asl-3.2.9.jar;lib/xercesImpl.jar;lib/xml-apis.jar;lib/zookeeper-3.4.5.jar</classpath>
<built-to>lib/yacycore.jar</built-to>
<source-level>1.6</source-level>
</compilation-unit>

@ -26,6 +26,7 @@ package net.yacy.http;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.InetSocketAddress;
@ -57,9 +58,10 @@ import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.server.handler.IPAccessHandler;
import org.eclipse.jetty.server.nio.SelectChannelConnector;
import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.resource.Resource;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.webapp.WebAppContext;
/**
* class to embedded Jetty 8 http server into YaCy
@ -102,8 +104,31 @@ public class Jetty8HttpServerImpl implements YaCyHttpServer {
domainHandler.setAlternativeResolver(sb.peers);
// configure root context
ServletContextHandler htrootContext = new ServletContextHandler(ServletContextHandler.SESSIONS);
htrootContext.setContextPath("/");
// ServletContextHandler htrootContext = new ServletContextHandler(ServletContextHandler.SESSIONS);
WebAppContext htrootContext = new WebAppContext();
htrootContext.setContextPath("/");
try {
htrootContext.setBaseResource(Resource.newResource("htroot"));
// set web.xml to use
// make use of Jetty feature to define web.xml other as default WEB-INF/web.xml
// look in DATA/SETTINGS or use the one in DEFAULTS
Resource webxml = Resource.newResource(sb.dataPath + "/DATA/SETTINGS/web.xml");
if (webxml.exists()) {
htrootContext.setDescriptor(webxml.getName());
} else {
htrootContext.setDescriptor(sb.appPath + "/defaults/web.xml");
}
} catch (IOException ex) {
if (htrootContext.getBaseResource() == null) {
ConcurrentLog.severe("SERVER", "could not find directory: htroot ");
} else {
ConcurrentLog.warn("SERVER", "could not find: defaults/web.xml or DATA/SETTINGS/web.xml");
}
}
// as fundamental component leave this hardcoded, other servlets may be defined in web.xml only
ServletHolder sholder = new ServletHolder(YaCyDefaultServlet.class);
sholder.setInitParameter("resourceBase", "htroot");
//sholder.setInitParameter("welcomeFile", "index.html"); // default is index.html, welcome.html

Loading…
Cancel
Save