405327 Merge branch jetty-9-modularstart

This commit is contained in:
Greg Wilkins 2013-04-29 15:19:41 +10:00
commit 7ce709519a
39 changed files with 335 additions and 214 deletions

View File

@ -100,7 +100,7 @@
<type>war</type>
<overWrite>true</overWrite>
<includes>**</includes>
<outputDirectory>${assembly-directory}/webapps</outputDirectory>
<outputDirectory>${assembly-directory}/webapps.demo</outputDirectory>
<destFileName>test.war</destFileName>
</artifactItem>
<artifactItem>
@ -110,7 +110,7 @@
<type>war</type>
<overWrite>true</overWrite>
<includes>**</includes>
<outputDirectory>${assembly-directory}/webapps</outputDirectory>
<outputDirectory>${assembly-directory}/webapps.demo</outputDirectory>
<destFileName>xref-proxy.war</destFileName>
</artifactItem>
<artifactItem>
@ -120,7 +120,7 @@
<type>war</type>
<overWrite>true</overWrite>
<includes>**</includes>
<outputDirectory>${assembly-directory}/webapps</outputDirectory>
<outputDirectory>${assembly-directory}/webapps.demo</outputDirectory>
<destFileName>async-rest.war</destFileName>
</artifactItem>
<artifactItem>

View File

@ -0,0 +1,21 @@
#===========================================================
# Configure JVM arguments.
#-----------------------------------------------------------
--exec
-Xmx2000m
-Xmn512m
-XX:+UseConcMarkSweepGC
-XX:ParallelCMSThreads=2
-XX:+CMSClassUnloadingEnabled
-XX:+UseCMSCompactAtFullCollection
-XX:CMSInitiatingOccupancyFraction=80
# -verbose:gc
# -XX:+PrintGCDateStamps
# -XX:+PrintGCTimeStamps
# -XX:+PrintGCDetails
# -XX:+PrintTenuringDistribution
# -XX:+PrintCommandLineFlags
# -XX:+DisableExplicitGC
# -Dorg.apache.jasper.compiler.disablejsr199=true

View File

@ -0,0 +1,16 @@
#===========================================================
# Default Server Options
# Use the core server jars with websocket on the classpath
# Add the contents of the resources directory to the classpath
# Add jars discovered in lib/ext to the classpath
# Include the core jetty configuration file
#-----------------------------------------------------------
OPTIONS=Server,websocket,resources,ext
threads.min=10
threads.max=200
threads.timeout=60000
#jetty.host=myhost.com
jetty.dump.start=false
jetty.dump.stop=false
etc/jetty.xml

View File

@ -0,0 +1,10 @@
#===========================================================
# JMX Management
# To enable remote JMX access uncomment jmxremote and
# enable --exec
#-----------------------------------------------------------
OPTIONS=jmx
# jetty.jmxrmihost=localhost
# jetty.jmxrmiport=1099
# -Dcom.sun.management.jmxremote
etc/jetty-jmx.xml

View File

@ -0,0 +1,5 @@
#===========================================================
# Java Server Pages
#-----------------------------------------------------------
OPTIONS=jsp

View File

@ -0,0 +1,7 @@
#===========================================================
# Server logging.
# The following configuration will redirect stderr and stdout
# to file which is rolled over daily.
#-----------------------------------------------------------
jetty.log.retain=90
etc/jetty-logging.xml

View File

@ -0,0 +1,13 @@
#===========================================================
# Enable SetUID
# The default user and group is 'jetty' and if you are
# starting as root you must change the run privledged to true
#-----------------------------------------------------------
OPTIONS=setuid
jetty.startServerAsPrivileged=false
jetty.username=jetty
jetty.groupname=jetty
jetty.umask=002
etc/jetty-setuid.xml

View File

@ -0,0 +1,12 @@
#===========================================================
# NPN Next Protocol Negotiation
#
# The SPDY and HTTP/2.0 connectors require NPN. The jar for
# NPN cannot be downloaded from eclipse. So the --download
# option is used to install the NPN jar if it does not already
# exist
#
#-----------------------------------------------------------
--exec
--download=http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.5.v20130313/npn-boot-1.1.5.v20130313.jar:lib/npn/npn-boot-1.1.5.v20130313.jar
-Xbootclasspath/p:lib/npn/npn-boot-1.1.5.v20130313.jar

View File

@ -0,0 +1,12 @@
#===========================================================
# SSL Context
# For use by HTTPS and SPDY
#-----------------------------------------------------------
jetty.keystore=etc/keystore
jetty.keystore.password=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4
jetty.keymanager.password=OBF:1u2u1wml1z7s1z7a1wnl1u2g
jetty.truststore=etc/keystore
jetty.truststore.password=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4
jetty.secure.port=8443
etc/jetty-ssl.xml

View File

@ -0,0 +1,6 @@
#===========================================================
# HTTP Connector
#-----------------------------------------------------------
jetty.port=8080
http.timeout=30000
etc/jetty-http.xml

View File

@ -0,0 +1,6 @@
#===========================================================
# HTTPS Connector
# Must be used with 200-ssl.ini
#-----------------------------------------------------------
jetty.https.port=8443
etc/jetty-https.xml

View File

@ -0,0 +1,9 @@
#===========================================================
# SPDY Connector
# Must be used with 200-ssl.ini and 200-npn.ini
#-----------------------------------------------------------
OPTIONS=spdy
jetty.spdy.port=8443
etc/jetty-spdy.xml

View File

@ -0,0 +1,8 @@
#===========================================================
# Annotations JNDI JAAS processing
#-----------------------------------------------------------
OPTIONS=plus
etc/jetty-plus.xml
OPTIONS=annotations
etc/jetty-annotations.xml

View File

@ -0,0 +1,9 @@
#===========================================================
# Request logger
# Will add a handler to log all HTTP requests to a standard
# request log format file.
#-----------------------------------------------------------
requestlog.retain=90
requestlog.append=true
requestlog.extended=true
etc/jetty-requestlog.xml

View File

@ -0,0 +1 @@
etc/jetty-debug.xml

View File

@ -0,0 +1 @@
etc/jetty-ipaccess.xml

View File

@ -0,0 +1,11 @@
#===========================================================
#-----------------------------------------------------------
lowresources.period=1050
lowresources.lowResourcesIdleTimeout=200
lowresources.monitorThreads=true
lowresources.maxConnections=0
lowresources.maxMemory=0
lowresources.maxLowResourcesTime=5000
etc/jetty-lowresources.xml

View File

@ -0,0 +1,4 @@
#===========================================================
#-----------------------------------------------------------
etc/jetty-stats.xml

View File

@ -0,0 +1,4 @@
#===========================================================
# Webapplication Deployer
#-----------------------------------------------------------
etc/jetty-deploy.xml

View File

@ -1,5 +1,6 @@
#===========================================================
# Jetty start.jar arguments
#
# The contents of this file, together with the start.ini
# fragments found in start.d directory are used to build
# the classpath and command line on a call to
@ -23,199 +24,8 @@
#
#===========================================================
#===========================================================
# The --exec option should be used if any of the JVM options
# in this file are uncommented (eg -D* or -X*). Because a
# JVM cannot change it's own options, the --exec flag causes
# start.jar to fork a new JVM with the requested arguments.
#
# Alternately, a command line may be generated by running
#
# java -jar start.jar --exec-print
#
# and the results executed to start the jetty server.
# For example --exec can be avoided if jetty is started on unix with
#
# eval $(java -jar start.jar --exec-print)
#
#-----------------------------------------------------------
# --exec
#===========================================================
#===========================================================
# Configure Properties.
# The properties defined here may be used by the
# <Property name="myproperty"/> element in the XML files
# passed to start.jar.
# Alternately a file ending with ".properties" can be
# added that will include multiple properties.
# Properties, unlike SystemProperties, do not need --exec
# to be specified.
#-----------------------------------------------------------
# jetty.home=.
# jetty.logs=./logs
# jetty.host=0.0.0.0
#===========================================================
#===========================================================
# Configure JVM arguments.
# Must be used with --exec or --exec-print
#-----------------------------------------------------------
# -Dorg.apache.jasper.compiler.disablejsr199=true
# -Xmx2000m
# -Xmn512m
# -verbose:gc
# -XX:+PrintGCDateStamps
# -XX:+PrintGCTimeStamps
# -XX:+PrintGCDetails
# -XX:+PrintTenuringDistribution
# -XX:+PrintCommandLineFlags
# -XX:+DisableExplicitGC
# -XX:+UseConcMarkSweepGC
# -XX:ParallelCMSThreads=2
# -XX:+CMSClassUnloadingEnabled
# -XX:+UseCMSCompactAtFullCollection
# -XX:CMSInitiatingOccupancyFraction=80
#===========================================================
#===========================================================
# Default Server Options
# Use the core server jars with websocket on the classpath
# Add the contents of the resources directory to the classpath
# Add jars discovered in lib/ext to the classpath
# Include the core jetty configuration file
#-----------------------------------------------------------
OPTIONS=Server,websocket,resources,ext
etc/jetty.xml
#===========================================================
#===========================================================
# Enable SetUID
# The default user and group is 'jetty' and if you are
# starting as root you must change the run privledged to true
#-----------------------------------------------------------
# OPTIONS=setuid
# etc/jetty-setuid.xml
# jetty.startServerAsPrivileged=false
# jetty.username=jetty
# jetty.groupname=jetty
# jetty.umask=002
#===========================================================
#===========================================================
# Server logging.
# The following configuration will redirect stderr and stdout
# to file which is rolled over daily.
#-----------------------------------------------------------
# etc/jetty-logging.xml
#===========================================================
#===========================================================
# JMX Management
# To enable remote JMX access uncomment jmxremote and
# enable --exec or use --exec-print (see above)
#-----------------------------------------------------------
OPTIONS=jmx
# jetty.jmxrmihost=localhost
# jetty.jmxrmiport=1099
# -Dcom.sun.management.jmxremote
etc/jetty-jmx.xml
#===========================================================
#===========================================================
# Java Server Pages
#-----------------------------------------------------------
OPTIONS=jsp
#===========================================================
#===========================================================
# Annotations JNDI JAAS processing
#-----------------------------------------------------------
# OPTIONS=plus
# etc/jetty-plus.xml
# OPTIONS=annotations
# etc/jetty-annotations.xml
#===========================================================
#===========================================================
# HTTP Connector
#-----------------------------------------------------------
# jetty.port=8080
etc/jetty-http.xml
#===========================================================
#===========================================================
# SSL Context
# For use by HTTPS and SPDY
#-----------------------------------------------------------
# jetty.keystore=etc/keystore
# jetty.keystore.password=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4
# jetty.keymanager.password=OBF:1u2u1wml1z7s1z7a1wnl1u2g
# jetty.truststore=etc/keystore
# jetty.truststore.password=OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4
# jetty.secure.port=8443
# etc/jetty-ssl.xml
#===========================================================
#===========================================================
# HTTPS Connector
#-----------------------------------------------------------
# jetty.https.port=8443
# etc/jetty-https.xml
#===========================================================
#===========================================================
# SPDY Connector
#
# SPDY requires the NPN jar which must be separately downloaded:
#
# http://repo1.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.5.v20130313/npn-boot-1.1.5.v20130313.jar
#
# Which should be saved in lib/npn-boot-1.1.5.v20130313.jar
#
# To include the NPN jar on the boot path, you must either:
#
# a) enable --exec above and uncomment the -Xbootclass line
# below
#
# b) Add -Xbootclasspath/p:lib/npn-boot-1.1.5.v20130313.jar
# to the command line when running jetty.
#
#-----------------------------------------------------------
# OPTIONS=spdy
# -Xbootclasspath/p:lib/npn-boot-1.1.5.v20130313.jar
# jetty.spdy.port=8443
# etc/jetty-spdy.xml
#===========================================================
#===========================================================
# Webapplication Deployer
#-----------------------------------------------------------
etc/jetty-deploy.xml
#===========================================================
#===========================================================
# Request logger
# Will add a handler to log all HTTP requests to a standard
# request log format file.
#-----------------------------------------------------------
etc/jetty-requestlog.xml
#===========================================================
#===========================================================
# Additional configurations
# See headers of individual files for explanations
#-----------------------------------------------------------
# etc/jetty-stats.xml
# etc/jetty-debug.xml
# etc/jetty-ipaccess.xml
# etc/jetty-lowresources.xml
#===========================================================
#===========================================================
# Lookup additional ini files in start.d
#-----------------------------------------------------------
# The start.d directory contains the active start.ini fragments
start.d/
#===========================================================
# More start.ini fragments are in files named start.d/*.ini.disabled
# They may be enabled by moving, linking or copying to *.ini files.

View File

@ -0,0 +1,7 @@
This directory is scanned by the demo WebAppDeployer provider
created in the etc/jetty-demo.xml file and enabled by the
start.d/900-demo.ini file.
For normal deployment, use the webapps directory.

View File

@ -33,7 +33,7 @@
</Arg>
<Set name="host"><Property name="jetty.host" /></Set>
<Set name="port"><Property name="jetty.port" default="8080" /></Set>
<Set name="idleTimeout">30000</Set>
<Set name="idleTimeout"><Property name="http.timeout" default="30000"/></Set>
</New>
</Arg>
</Call>

View File

@ -10,12 +10,12 @@
<Arg>
<New class="org.eclipse.jetty.server.LowResourceMonitor">
<Arg name="server"><Ref refid='Server'/></Arg>
<Set name="period">1000</Set>
<Set name="lowResourcesIdleTimeout">200</Set>
<Set name="monitorThreads">true</Set>
<Set name="maxConnections">0</Set>
<Set name="maxMemory">0</Set>
<Set name="maxLowResourcesTime">5000</Set>
<Set name="period"><Property name="lowresources.period" default="1000"/></Set>
<Set name="lowResourcesIdleTimeout"><Property name="lowresources.lowResourcesIdleTimeout" default="200"/></Set>
<Set name="monitorThreads"><Property name="lowresources.monitorThreads" default="true"/></Set>
<Set name="maxConnections"><Property name="lowresources.maxConnections" default="0"/></Set>
<Set name="maxMemory"><Property name="lowresources.maxMemory" default="0"/></Set>
<Set name="maxLowResourcesTime"><Property name="lowresources.maxLowResourcesTime" default="5000"/></Set>
</New>
</Arg>
</Call>

View File

@ -17,9 +17,9 @@
<New id="RequestLogImpl" class="org.eclipse.jetty.server.AsyncNCSARequestLog">
<Set name="filename"><Property name="jetty.logs" default="./logs" />/yyyy_mm_dd.request.log</Set>
<Set name="filenameDateFormat">yyyy_MM_dd</Set>
<Set name="retainDays">90</Set>
<Set name="append">true</Set>
<Set name="extended">true</Set>
<Set name="retainDays"><Property name="requestlog.retain" default="90"/></Set>
<Set name="append"><Property name="requestlog.append" default="false"/></Set>
<Set name="extended"><Property name="requestlog.extended" default="false"/></Set>
<Set name="logCookies">false</Set>
<Set name="LogTimeZone">GMT</Set>
</New>

View File

@ -44,9 +44,9 @@
<!-- =========================================================== -->
<Arg name="threadpool">
<New id="threadpool" class="org.eclipse.jetty.util.thread.QueuedThreadPool">
<Arg name="minThreads" type="int">10</Arg>
<Arg name="maxThreads" type="int">200</Arg>
<Arg name="idleTimeout" type="int">60000</Arg>
<Arg name="minThreads" type="int"><Property name="threads.min" default="10"/></Arg>
<Arg name="maxThreads" type="int"><Property name="threads.max" default="200"/></Arg>
<Arg name="idleTimeout" type="int"><Property name="threads.timeout" default="60000"/></Arg>
<Set name="detailedDump">false</Set>
</New>
</Arg>

View File

@ -50,6 +50,8 @@ import java.util.Locale;
import java.util.Properties;
import java.util.Set;
import javax.naming.OperationNotSupportedException;
/*-------------------------------------------*/
/**
* <p>
@ -175,6 +177,12 @@ public class Main
stop(port,key,timeout);
return null;
}
if (arg.startsWith("--download="))
{
download(arg);
continue;
}
if ("--version".equals(arg) || "-v".equals(arg) || "--info".equals(arg))
{
@ -302,6 +310,121 @@ public class Main
return xmls;
}
private void download(String arg)
{
try
{
String[] split = arg.split(":",3);
if (split.length!=3 || "http".equalsIgnoreCase(split[0]) || !split[1].startsWith("//"))
throw new IllegalArgumentException("Not --download=<http uri>:<location>");
String location=split[2];
if (File.separatorChar!='/')
location.replaceAll("/",File.separator);
File file = new File(location);
if (Config.isDebug())
System.err.println("Download to "+file.getAbsolutePath()+(file.exists()?" Exists!":""));
if (file.exists())
return;
String[] parse = split[1].split("/",4);
String host=parse[2];
String uri="/"+split[1].substring(3+host.length());
try (Socket socket = new Socket(host,80))
{
String request="GET "+uri+" HTTP/1.0\r\n"+
"Host: "+host+"\r\n"+
"User-Agent: jetty-start.jar\r\n"+
"\r\n";
socket.getOutputStream().write(request.getBytes("ISO-8859-1"));
socket.getOutputStream().flush();
InputStream in = socket.getInputStream();
int state=0;
loop: while (state>=0)
{
char c = (char)in.read();
switch (state)
{
case 0:
c=Character.toLowerCase(c);
if (c==' ')
state=1;
else if (c!='h' && c!='t' && c!='p' && c!='/' && c!='.' && !Character.isDigit(c))
break loop;
break;
case 1:
if (c==' ')
state=2;
else if (c!='2' && c!='0')
break loop;
break;
case 2:
if (c=='\r')
state=3;
else if (c=='\n')
state=4;
break;
case 3:
if (c=='\n')
state=4;
else if (c=='\r')
state=-1;
break;
case 4:
if (c=='\r')
state=5;
else if (c=='\n')
state=-1;
else
state=2;
break;
case 5:
if (c=='\n')
state=-1;
else
state=2;
break;
}
}
if (state>=0)
throw new IOException("Bad HTTP response: "+state);
System.err.println("DOWNLOAD: "+uri+" from "+host+" to "+location);
if (!file.getParentFile().exists())
file.getParentFile().mkdirs();
byte[] buf=new byte[8192];
try (OutputStream out = new FileOutputStream(file))
{
while(!socket.isInputShutdown())
{
int len = in.read(buf);
if (len>0)
out.write(buf,0,len);
if (len<0)
break;
}
}
}
}
catch(Exception e)
{
System.err.println("ERROR: processing "+arg+"\n"+e);
e.printStackTrace();
usageExit(EXIT_USAGE);
}
}
private void usage()
{
String usageResource = "org/eclipse/jetty/start/usage.txt";

View File

@ -45,6 +45,10 @@ Command Line Options:
and additional .ini files in jetty.home/start.d/
will NOT be read. A --ini option with no file indicates that
start.ini should not be read.
--download=<http-uri>:location
If the file does not exist at the given location, then
download it from the given http URI
System Properties:
These are set with a command line like "java -Dname=value ..." and are

View File

@ -0,0 +1,21 @@
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
<!-- =============================================================== -->
<!-- Create the demo deployment provider -->
<!-- =============================================================== -->
<Configure id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager">
<Call id="webappprovider" name="addAppProvider">
<Arg>
<New class="org.eclipse.jetty.deploy.providers.WebAppProvider">
<Set name="monitoredDirName"><Property name="jetty.home" default="." />/webapps.demo</Set>
<Set name="defaultsDescriptor"><Property name="jetty.home" default="." />/etc/webdefault.xml</Set>
<Set name="scanInterval">1</Set>
<Set name="extractWars">true</Set>
<Set name="configurationManager">
<New class="org.eclipse.jetty.deploy.PropertiesConfigurationManager"/>
</Set>
</New>
</Arg>
</Call>
</Configure>

View File

@ -1,3 +1,4 @@
# Enabled services and configuration needed by the test webapp
OPTIONS=client
etc/test-realm.xml
etc/jetty-demo.xml

View File

@ -19,15 +19,15 @@ detected.
<!-- + war OR resourceBase -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<Set name="contextPath">/test</Set>
<Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/test.war</Set>
<Set name="war"><Property name="jetty.webapps" default="."/>/test.war</Set>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- Optional context configuration -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<Set name="extractWAR">true</Set>
<Set name="copyWebDir">false</Set>
<Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
<Set name="overrideDescriptor"><SystemProperty name="jetty.home" default="."/>/webapps/test.d/override-web.xml</Set>
<Set name="defaultsDescriptor"><Property name="jetty.home" default="."/>/etc/webdefault.xml</Set>
<Set name="overrideDescriptor"><Property name="jetty.webapps" default="."/>/test.d/override-web.xml</Set>
<!-- Allow directory symbolic links -->
<Call name="addAliasCheck">