414635 Modular start.d and jetty.base property

This commit is contained in:
Greg Wilkins 2013-08-08 17:53:33 +10:00
parent 1f3ec4b538
commit 21e7b67cc7
41 changed files with 662 additions and 629 deletions

View File

@ -39,14 +39,14 @@
<Call id="webappprovider" name="addAppProvider">
<Arg>
<New class="org.eclipse.jetty.deploy.providers.WebAppProvider">
<Set name="monitoredDirName"><Property name="jetty.home" default="." />/webapps</Set>
<Set name="monitoredDirName"><Property name="jetty.base" default="." />/webapps</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">
<!-- file of context configuration properties
<Set name="file"><SystemProperty name="jetty.home"/>/etc/some.properties</Set>
<Set name="file"><SystemProperty name="jetty.base"/>/etc/some.properties</Set>
-->
<!-- set a context configuration property
<Call name="put"><Arg>name</Arg><Arg>value</Arg></Call>
@ -56,7 +56,6 @@
</New>
</Arg>
</Call>
</New>
</Arg>
</Call>

View File

@ -13,7 +13,7 @@
<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="monitoredDirName"><Property name="jetty.base" 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>

View File

@ -0,0 +1,27 @@
#===========================================================
# Configure JVM arguments.
# If JVM args are include in an ini file then --exec is needed
# to start a new JVM from start.jar with the extra args.
# If you wish to avoid an extra JVM running, place JVM args
# on the normal command line and do not use --exec
#
# IF USED, THIS MODULE WILL INVOKE AN EXTRA JVM INSTANCE!!
#-----------------------------------------------------------
--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,17 @@
#===========================================================
# 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
#
#-----------------------------------------------------------
DEFINE=npn
OPTION=npn
--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,3 @@
# Add libraries from lib/ext to the classpath
OPTION=ext

View File

@ -0,0 +1,9 @@
#===========================================================
# JMX Management
#-----------------------------------------------------------
jetty.jmxrmihost=localhost
jetty.jmxrmiport=1099
--exec
-Dcom.sun.management.jmxremote

View File

@ -0,0 +1,3 @@
# Add the resources directory to the classpath
OPTION=resources

View File

@ -0,0 +1,19 @@
#===========================================================
# 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
#-----------------------------------------------------------
threads.min=10
threads.max=200
threads.timeout=60000
#jetty.host=myhost.com
jetty.dump.start=false
jetty.dump.stop=false
#jetty.logs=/var/log/jetty
OPTION=Server
etc/jetty.xml

View File

@ -0,0 +1,7 @@
#===========================================================
# JMX Management
#-----------------------------------------------------------
OPTION=jmx
etc/jetty-jmx.xml

View File

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

View File

@ -0,0 +1,9 @@
#===========================================================
# stderr/stdout 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,14 @@
#===========================================================
# Enable SetUID
# The default user and group is 'jetty' and if you are
# starting as root you must change the run privledged to true
#-----------------------------------------------------------
jetty.startServerAsPrivileged=false
jetty.username=jetty
jetty.groupname=jetty
jetty.umask=002
OPTION=setuid
etc/jetty-setuid.xml

View File

@ -0,0 +1,17 @@
#===========================================================
# SSL Context
# Create the keystore and trust store 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
DEFINE=ssl
OPTION=ssl
etc/jetty-ssl.xml

View File

@ -0,0 +1,5 @@
#===========================================================
# WebSocket Support
#-----------------------------------------------------------
OPTION=websocket

View File

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

View File

@ -0,0 +1,13 @@
#===========================================================
# HTTPS Connector
# Must be used with jetty-ssl.xml
#-----------------------------------------------------------
jetty.https.port=8443
DEFINE=https
OPTION=https
DEPEND=ssl
etc/jetty-https.xml

View File

@ -0,0 +1,10 @@
#===========================================================
# SPDY Connector
#-----------------------------------------------------------
jetty.spdy.port=8444
OPTION=spdy
DEPEND=npn,ssl
etc/jetty-spdy.xml

View File

@ -0,0 +1,9 @@
# ===========================================================
# Enable JAAS
# -----------------------------------------------------------
jaas.login.conf=etc/login.conf
OPTION=jaas
etc/jetty-jaas.xml

View File

@ -0,0 +1,5 @@
# ===========================================================
# Enable JNDI
# -----------------------------------------------------------
OPTION=jndi

View File

@ -0,0 +1,6 @@
# ===========================================================
# Enable additional webapp environment configurators
# -----------------------------------------------------------
OPTION=plus
etc/jetty-plus.xml

View File

@ -0,0 +1,11 @@
#===========================================================
# 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,9 @@
# ===========================================================
# Enable servlet 3.1 annotations
# -----------------------------------------------------------
OPTION=annotations
DEPEND=plus
etc/jetty-annotations.xml

View File

@ -0,0 +1,7 @@
#===========================================================
# WebSocket Annotations Support
#-----------------------------------------------------------
DEPEND=websocket
etc/jetty-websockets.xml

View File

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

View File

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

View File

@ -0,0 +1,13 @@
#===========================================================
# Low resource management
#-----------------------------------------------------------
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,6 @@
# ===========================================================
# Enable rewrite handler
# -----------------------------------------------------------
OPTION=rewrite
etc/jetty-rewrite.xml

View File

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

View File

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

View File

@ -6,54 +6,20 @@
# the start.d directory or rename it to not end with ".ini"
# ===========================================================
# ===========================================================
# Enable rewrite handler
# -----------------------------------------------------------
OPTIONS=rewrite
etc/jetty-rewrite.xml
# ===========================================================
# Add a deploy app provider to scan the webapps.demo directory
# -----------------------------------------------------------
etc/jetty-demo.xml
# ===========================================================
# Enable the Jetty HTTP client APIs for use by demo webapps
# -----------------------------------------------------------
OPTIONS=client
# ===========================================================
# Enable the test-realm login service for use by authentication
# demonstrations
# -----------------------------------------------------------
etc/test-realm.xml
# ===========================================================
# Enable JAAS test webapp
# -----------------------------------------------------------
OPTIONS=jaas
# The following options are explicitly configured for the demo
# in this file. Thus they cannot be used with the normal
# activation of them
jaas.login.conf=webapps.demo/test-jaas.d/login.conf
EXCLUDE=jaas,jndi,rewrite,client
OPTION=jaas,jndi,rewrite,client
etc/jetty-rewrite.xml
etc/jetty-jaas.xml
# ===========================================================
# Enable JNDI test webapp
# -----------------------------------------------------------
OPTIONS=jndi,jndi.demo
# Activate the demo options and configurations
OPTION=jndi.demo
etc/jetty-demo.xml
etc/test-realm.xml
# ===========================================================
# Enable additional webapp environment configurators
# -----------------------------------------------------------
# OPTIONS=plus
# etc/jetty-plus.xml
# ===========================================================
# Enable servlet 3.1 annotations
# -----------------------------------------------------------
# OPTIONS=annotations
# etc/jetty-annotations.xml
# ===========================================================
# Enable https listener
# -----------------------------------------------------------
etc/jetty-ssl.xml
etc/jetty-https.xml

View File

@ -12,8 +12,11 @@
# Each line in this file is prepended to the command line
# as arguments, which may be either:
# + A property like: name=value
# + Activation of an option: OPTION=option
+ The declaration of a new option: DEFINE=option
+ An option dependency: DEPEND=option,option
+ An option exclusion: EXCLUDE=option,option
# + A file of properties like: /etc/myjetty.properties
# + A classpath option like: OPTION=jmx
# + An XML configuration file like: etc/jetty-feature.xml
# + A start.jar option like: --dry-run
#
@ -23,231 +26,11 @@
# + A System Property like: -Dcom.sun.management.jmxremote
#
#-----------------------------------------------------------
#
# NOTE: The lines in this file may be uncommented to activate
# features. Alternately, the lines may be copied to a ini file
# in the start.d directory to enabled configuration without
# editing this file. See start.d/900-demo.ini for an example.
#
# Future releases will switch start.d style configuration for
# all features.
#===========================================================
#===========================================================
# Configure JVM arguments.
# If JVM args are include in an ini file then --exec is needed
# to start a new JVM from start.jar with the extra args.
# If you wish to avoid an extra JVM running, place JVM args
# on the normal command line and do not use --exec
#-----------------------------------------------------------
# --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
#===========================================================
# 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,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
#===========================================================
# Servlet 3.x Annotation Support
#-----------------------------------------------------------
OPTIONS=plus,annotations
etc/jetty-plus.xml
etc/jetty-annotations.xml
#===========================================================
# WebSocket Support
# To enable websocket server support (both apis)
# org.eclipse.jetty.websocket.api (API)
# javax.websocket (API)
#-----------------------------------------------------------
OPTIONS=websocket
etc/jetty-websockets.xml
#===========================================================
# 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
#===========================================================
# Java Server Pages
#-----------------------------------------------------------
OPTIONS=jsp
#===========================================================
# 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
#===========================================================
# stderr/stdout logging.
# The following configuration will redirect stderr and stdout
# to file which is rolled over daily.
#-----------------------------------------------------------
# jetty.log.retain=90
# etc/jetty-logging.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
# jetty.startServerAsPrivileged=false
# jetty.username=jetty
# jetty.groupname=jetty
# jetty.umask=002
# etc/jetty-setuid.xml
#===========================================================
# HTTP Connector
#-----------------------------------------------------------
jetty.port=8080
http.timeout=30000
etc/jetty-http.xml
#===========================================================
# SSL Context
# Create the keystore and trust store 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
# Must be used with jetty-ssl.xml
#-----------------------------------------------------------
# jetty.https.port=8443
# etc/jetty-https.xml
#===========================================================
# 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
#===========================================================
# SPDY Connector
# Requires SSL Context and NPN from above
#-----------------------------------------------------------
# OPTIONS=spdy
# jetty.spdy.port=8443
# etc/jetty-spdy.xml
#===========================================================
# Webapplication Deployer
#-----------------------------------------------------------
etc/jetty-deploy.xml
# ===========================================================
# Enable JAAS
# -----------------------------------------------------------
# OPTIONS=jaas
# jaas.login.conf=etc/login.conf
# etc/jetty-jaas.xml
# ===========================================================
# Enable JNDI
# -----------------------------------------------------------
# OPTIONS=jndi
# ===========================================================
# Enable additional webapp environment configurators
# -----------------------------------------------------------
# OPTIONS=plus
# etc/jetty-plus.xml
# ===========================================================
# Enable servlet 3.1 annotations
# -----------------------------------------------------------
# OPTIONS=annotations
# etc/jetty-annotations.xml
#===========================================================
# Other server features
#-----------------------------------------------------------
# etc/jetty-debug.xml
# etc/jetty-ipaccess.xml
# etc/jetty-stats.xml
#===========================================================
# Low resource managment
#-----------------------------------------------------------
# lowresources.period=1050
# lowresources.lowResourcesIdleTimeout=200
# lowresources.monitorThreads=true
# lowresources.maxConnections=0
# lowresources.maxMemory=0
# lowresources.maxLowResourcesTime=5000
# etc/jetty-lowresources.xml
#===========================================================
# The start.d directory contains the active start.ini fragments
start.d/
#-----------------------------------------------------------

View File

@ -7,10 +7,10 @@
<!-- and either jetty-https.xml or jetty-spdy.xml (but not both) -->
<!-- ============================================================= -->
<Configure id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory">
<Set name="KeyStorePath"><Property name="jetty.home" default="." />/<Property name="jetty.keystore" default="etc/keystore"/></Set>
<Set name="KeyStorePath"><Property name="jetty.base" default="." />/<Property name="jetty.keystore" default="etc/keystore"/></Set>
<Set name="KeyStorePassword"><Property name="jetty.keystore.password" default="OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4"/></Set>
<Set name="KeyManagerPassword"><Property name="jetty.keymanager.password" default="OBF:1u2u1wml1z7s1z7a1wnl1u2g"/></Set>
<Set name="TrustStorePath"><Property name="jetty.home" default="." />/<Property name="jetty.truststore" default="etc/keystore"/></Set>
<Set name="TrustStorePath"><Property name="jetty.base" default="." />/<Property name="jetty.truststore" default="etc/keystore"/></Set>
<Set name="TrustStorePassword"><Property name="jetty.truststore.password" default="OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4"/></Set>
<Set name="EndpointIdentificationAlgorithm"></Set>
<Set name="ExcludeCipherSuites">

View File

@ -45,6 +45,8 @@ import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
import org.omg.CORBA._PolicyStub;
/**
* <p>
* It allows an application to be started with the command <code>"java -jar start.jar"</code>.
@ -184,14 +186,14 @@ public class Config
private static final String _version;
private static boolean DEBUG = false;
private static final Map<String, String> __properties = new HashMap<String, String>();
private final Map<String, String> _properties = new HashMap<String, String>();
private final Map<String, Classpath> _classpaths = new HashMap<String, Classpath>();
private final List<String> _xml = new ArrayList<String>();
private String _classname = null;
private int argCount = 0;
private final Set<String> _activeOptions = new TreeSet<String>(new Comparator<String>()
private final Set<String> _options = new TreeSet<String>(new Comparator<String>()
{
// Make sure "*" is always at the end of the list
public int compare(String o1, String o2)
@ -208,17 +210,24 @@ public class Config
}
});
public Classpath defineOption(String option)
{
Classpath cp = _classpaths.get(option);
if (cp == null)
{
cp = new Classpath();
_classpaths.put(option,cp);
}
return cp;
}
private boolean addClasspathComponent(List<String> sections, String component)
{
for (String section : sections)
{
Classpath cp = _classpaths.get(section);
if (cp == null)
cp = new Classpath();
Classpath cp = defineOption(section);
boolean added = cp.addComponent(component);
_classpaths.put(section,cp);
if (!added)
{
// First failure means all failed.
@ -234,10 +243,6 @@ public class Config
for (String section : sections)
{
Classpath cp = _classpaths.get(section);
if (cp == null)
{
cp = new Classpath();
}
if (!cp.addClasspath(path))
{
// First failure means all failed.
@ -385,7 +390,7 @@ public class Config
*/
public Classpath getActiveClasspath()
{
return getCombinedClasspath(_activeOptions);
return getCombinedClasspath(_options);
}
/**
@ -408,7 +413,7 @@ public class Config
Classpath otherCp = _classpaths.get(optionId);
if (otherCp == null)
{
throw new IllegalArgumentException("No such OPTIONS: " + optionId);
throw new IllegalArgumentException("No such OPTION: " + optionId);
}
cp.overlay(otherCp);
}
@ -421,12 +426,12 @@ public class Config
return _classname;
}
public static void clearProperties()
public void clearProperties()
{
__properties.clear();
_properties.clear();
}
public static Properties getProperties()
public Properties getProperties()
{
Properties properties = new Properties();
// Add System Properties First
@ -436,30 +441,30 @@ public class Config
properties.put(name, System.getProperty(name));
}
// Add Config Properties Next (overwriting any System Properties that exist)
for (String key : __properties.keySet()) {
properties.put(key,__properties.get(key));
for (String key : _properties.keySet()) {
properties.put(key,_properties.get(key));
}
return properties;
}
public static String getProperty(String name)
public String getProperty(String name)
{
if ("version".equalsIgnoreCase(name)) {
return _version;
}
// Search Config Properties First
if (__properties.containsKey(name)) {
return __properties.get(name);
if (_properties.containsKey(name)) {
return _properties.get(name);
}
// Return what exists in System.Properties otherwise.
return System.getProperty(name);
}
public static String getProperty(String name, String defaultValue)
public String getProperty(String name, String defaultValue)
{
// Search Config Properties First
if (__properties.containsKey(name))
return __properties.get(name);
if (_properties.containsKey(name))
return _properties.get(name);
// Return what exists in System.Properties otherwise.
return System.getProperty(name, defaultValue);
}
@ -956,31 +961,46 @@ public class Config
}
if (name.equals("OPTIONS"))
{
_activeOptions.clear();
_options.clear();
String ids[] = value.split(",");
for (String id : ids)
addOption(id);
}
if (name.equals("jetty.base"))
{
File base=new File(value);
try
{
addActiveOption(id);
value=base.getCanonicalPath();
}
catch(Exception e)
{
e.printStackTrace();
}
}
__properties.put(name,value);
_properties.put(name,value);
}
public void addActiveOption(String option)
public void addOption(String option)
{
_activeOptions.add(option);
__properties.put("OPTIONS",join(_activeOptions,","));
_options.add(option);
_properties.put("OPTIONS",join(_options,","));
}
public Set<String> getKnownOptions()
{
return _classpaths.keySet();
}
public Set<String> getActiveOptions()
public Set<String> getOptions()
{
return _activeOptions;
return _options;
}
public void removeActiveOption(String option)
public void removeOption(String option)
{
_activeOptions.remove(option);
__properties.put("OPTIONS",join(_activeOptions,","));
_options.remove(option);
_properties.put("OPTIONS",join(_options,","));
}
private String join(Collection<?> coll, String delim)
@ -999,4 +1019,37 @@ public class Config
return buf.toString();
}
public String getJettyHome()
{
return getProperty("jetty.home");
}
public String getJettyBase()
{
return getProperty("jetty.base");
}
public File getFileBaseHomeAbs(String filename)
{
File file;
String base = getJettyBase();
if (base!=null)
{
file=new File(base,filename);
if (file.exists())
return file;
}
file=new File(getJettyHome(),filename);
if (file.exists())
return file;
file=new File(filename);
if (file.exists())
return file;
return null;
}
}

View File

@ -51,8 +51,6 @@ import java.util.Locale;
import java.util.Properties;
import java.util.Set;
import javax.naming.OperationNotSupportedException;
/*-------------------------------------------*/
/**
* <p>
@ -82,19 +80,17 @@ public class Main
private boolean _dryRun = false;
private boolean _exec = false;
private final Config _config = new Config();
private final Set<String> _sysProps = new HashSet<String>();
private final List<String> _jvmArgs = new ArrayList<String>();
private final Set<String> _sysProps = new HashSet<>();
private final List<String> _jvmArgs = new ArrayList<>();
private final List<File> _iniFiles = new ArrayList<>();
private String _startConfig = null;
private String _jettyHome;
public static void main(String[] args)
{
try
{
Main main = new Main();
List<String> arguments = main.expandCommandLine(args);
List<String> xmls = main.processCommandLine(arguments);
List<String> xmls = main.processCommandLine(args);
if (xmls != null)
main.start(xmls);
}
@ -106,64 +102,36 @@ public class Main
Main() throws IOException
{
_jettyHome = System.getProperty("jetty.home",".");
_jettyHome = new File(_jettyHome).getCanonicalPath();
String jetty_home=new File(System.getProperty("jetty.home",".")).getCanonicalPath();
_config.setProperty("jetty.home",jetty_home);
}
public List<String> expandCommandLine(String[] args) throws Exception
Config getConfig()
{
List<String> arguments = new ArrayList<String>();
// add the command line args and look for start.ini args
boolean ini = false;
for (String arg : args)
{
return _config;
}
public List<String> processCommandLine(String[] args) throws Exception
{
String source="";
// Handle default ini args
ArrayList<String> arguments = new ArrayList<>(Arrays.asList(args));
boolean ini=false;
for(String arg : arguments)
if (arg.startsWith("--ini=") || arg.equals("--ini"))
{
ini = true;
if (arg.length() > 6)
{
arguments.addAll(loadStartIni(new File(arg.substring(6))));
}
}
else if (arg.startsWith("--config="))
{
_startConfig = arg.substring(9);
}
else
{
arguments.add(arg);
}
}
// if no non-option inis, add the start.ini and start.d
if (!ini)
{
arguments.addAll(0,parseStartIniFiles());
}
return arguments;
}
List<String> parseStartIniFiles()
{
List<String> ini_args = new ArrayList<String>();
File start_ini = new File(_jettyHome,"start.ini");
if (start_ini.exists())
ini_args.addAll(loadStartIni(start_ini));
return ini_args;
}
public List<String> processCommandLine(List<String> arguments) throws Exception
{
arguments.add("--ini=start.ini");
// The XML Configuration Files to initialize with
List<String> xmls = new ArrayList<String>();
// Process the arguments
int startup = 0;
for (String arg : arguments)
// Process the arguments in for loop so list of args can be extended.
for (int i=0;i<arguments.size();i++)
{
String arg=arguments.get(i);
if ("--help".equals(arg) || "-?".equals(arg))
{
_showUsage = true;
@ -172,9 +140,9 @@ public class Main
if ("--stop".equals(arg))
{
int port = Integer.parseInt(Config.getProperty("STOP.PORT","-1"));
String key = Config.getProperty("STOP.KEY",null);
int timeout = Integer.parseInt(Config.getProperty("STOP.WAIT","0"));
int port = Integer.parseInt(_config.getProperty("STOP.PORT","-1"));
String key = _config.getProperty("STOP.KEY",null);
int timeout = Integer.parseInt(_config.getProperty("STOP.WAIT","0"));
stop(port,key,timeout);
return null;
}
@ -215,6 +183,28 @@ public class Main
continue;
}
if (arg.startsWith("--ini=") || arg.equals("--ini"))
{
ini = true;
if (arg.length() > 6)
{
String name=arg.substring(6);
File file=_config.getFileBaseHomeAbs(name);
arguments.addAll(i+1,loadStartIni(file,name));
}
continue;
}
if (arg.startsWith("--config="))
{
_startConfig = arg.substring(9);
continue;
}
// Special internal indicator that jetty was started by the jetty.sh Daemon
if ("--daemon".equals(arg))
{
@ -278,17 +268,58 @@ public class Main
switch (assign.length)
{
case 2:
if ("OPTIONS".equals(assign[0]))
if ("_SRC_".equals(assign[0]))
{
source=assign[1].trim();
}
else if ("DEFINE".equals(assign[0]))
{
String opts[] = assign[1].split(",");
for (String opt : opts)
_config.addActiveOption(opt.trim());
_config.defineOption(opt.trim());
}
else if ("DEPEND".equals(assign[0]))
{
String opts[] = assign[1].split(",");
for (String opt : opts)
{
opt=opt.trim();
if (!_config.getOptions().contains(opt))
{
System.err.printf("Missing Dependency: %s DEPEND %s%n",path(source),opt );
usageExit(ERR_LOGGING);
}
}
}
else if ("EXCLUDE".equals(assign[0]))
{
String opts[] = assign[1].split(",");
for (String opt : opts)
{
opt=opt.trim();
if (_config.getOptions().contains(opt))
{
System.err.printf("Excluded Dependency: %s EXCLUDE %s%n",path(source),opt );
usageExit(ERR_LOGGING);
}
}
}
else if ("OPTION".equals(assign[0]))
{
String opts[] = assign[1].split(",");
for (String opt : opts)
_config.addOption(opt.trim());
}
else if ("OPTIONS".equals(assign[0]))
{
this._config.setProperty(assign[0],assign[1]);
}
else
{
this._config.setProperty(assign[0],assign[1]);
}
break;
case 1:
this._config.setProperty(assign[0],null);
break;
@ -398,15 +429,7 @@ public class Main
}
else if (info.equals("@CONFIGS"))
{
File etc = new File(System.getProperty("jetty.home","."),"etc");
if (!etc.exists() || !etc.isDirectory())
{
System.out.print(indent);
System.out.println("Unable to find/list " + etc);
continue;
}
File configs[] = etc.listFiles(new FileFilter()
FileFilter filter =new FileFilter()
{
public boolean accept(File path)
{
@ -418,35 +441,55 @@ public class Main
String name = path.getName().toLowerCase(Locale.ENGLISH);
return (name.startsWith("jetty") && name.endsWith(".xml"));
}
});
};
// list home etc
File etc = new File(_config.getJettyHome(),"etc");
if (!etc.exists() || !etc.isDirectory())
{
System.out.print(indent);
System.out.println("Unable to find/list " + etc);
continue;
}
List<File> configFiles = new ArrayList<File>();
File[] configs = etc.listFiles(filter);
configFiles.addAll(Arrays.asList(configs));
// list base etc
if (!_config.getJettyHome().equals(_config.getJettyBase()))
{
etc = new File(_config.getJettyBase(),"etc");
if (etc.exists() && etc.isDirectory())
{
configs = etc.listFiles(filter);
configFiles.addAll(Arrays.asList(configs));
}
}
Collections.sort(configFiles);
for (File configFile : configFiles)
{
System.out.print(indent);
System.out.print("etc/");
System.out.println(configFile.getName());
}
System.out.printf("%s%s%n",indent,path(configFile));
}
else if (info.equals("@STARTINI"))
{
List<String> ini = parseStartIniFiles();
if (ini != null && ini.size() > 0)
for (File file : _iniFiles)
{
for (String a : ini)
String path=path(file);
System.out.printf("%s%s:%n",indent,path);
try (FileReader reader=new FileReader(file); BufferedReader in = new BufferedReader(reader);)
{
System.out.print(indent);
System.out.println(a);
String arg;
while ((arg = in.readLine()) != null)
{
arg = arg.trim();
if (arg.length() == 0 || arg.startsWith("#"))
continue;
System.out.printf("%s %s%n",indent,arg);
}
}
}
else
{
System.out.print(indent);
System.out.println("none");
}
}
}
else
@ -466,6 +509,29 @@ public class Main
System.exit(EXIT_USAGE);
}
String path(String path)
{
if (path==null)
return path;
if (path.startsWith(_config.getJettyHome()))
path = "${jetty.home}" + path.substring(_config.getJettyHome().length());
if (_config.getJettyBase()!=null && path.startsWith(_config.getJettyBase()))
path = "${jetty.base}" + path.substring(_config.getJettyBase().length());
return path;
}
String path(File file)
{
try
{
return path(file.getCanonicalPath());
}
catch (IOException e)
{
}
return path(file.getAbsolutePath());
}
public void invokeMain(ClassLoader classloader, String classname, List<String> args) throws IllegalAccessException, InvocationTargetException,
NoSuchMethodException, ClassNotFoundException
{
@ -550,12 +616,13 @@ public class Main
{
System.err.println("java.class.path=" + System.getProperty("java.class.path"));
System.err.println("jetty.home=" + System.getProperty("jetty.home"));
System.err.println("jetty.base=" + System.getProperty("jetty.base"));
System.err.println("java.home=" + System.getProperty("java.home"));
System.err.println("java.io.tmpdir=" + System.getProperty("java.io.tmpdir"));
System.err.println("java.class.path=" + classpath);
System.err.println("classloader=" + cl);
System.err.println("classloader.parent=" + cl.getParent());
System.err.println("properties=" + Config.getProperties());
System.err.println("properties=" + _config.getProperties());
}
// Show the usage information and return
@ -689,23 +756,20 @@ public class Main
return xmlFilename;
}
File xml = new File(xmlFilename);
if (xml.exists() && xml.isFile())
{
// Look for the file as absolute, jetty-base or jetty-home
File xml = _config.getFileBaseHomeAbs(xmlFilename);
if (xml!=null && xml.isFile())
return xml.getAbsolutePath();
}
xml = new File(_jettyHome,fixPath(xmlFilename));
if (xml.exists() && xml.isFile())
{
// Try corrected / for \
xml = _config.getFileBaseHomeAbs(fixPath(xmlFilename));
if (xml!=null && xml.isFile())
return xml.getAbsolutePath();
}
xml = new File(_jettyHome,fixPath("etc/" + xmlFilename));
if (xml.exists() && xml.isFile())
{
// Try in etc
xml = _config.getFileBaseHomeAbs("etc/"+xmlFilename);
if (xml!=null && xml.isFile())
return xml.getAbsolutePath();
}
throw new FileNotFoundException("Unable to find XML Config: " + xmlFilename);
}
@ -718,7 +782,9 @@ public class Main
{
cmd.addArg(x);
}
cmd.addRawArg("-Djetty.home=" + _jettyHome);
cmd.addRawArg("-Djetty.home=" + _config.getJettyHome());
if (_config.getJettyBase()!=null)
cmd.addRawArg("-Djetty.base=" + _config.getJettyBase());
// Special Stop/Shutdown properties
ensureSystemPropertySet("STOP.PORT");
@ -736,7 +802,7 @@ public class Main
cmd.addRawArg(_config.getMainClassname());
// Check if we need to pass properties as a file
Properties properties = Config.getProperties();
Properties properties = _config.getProperties();
if (properties.size() > 0)
{
File prop_file = File.createTempFile("start",".properties");
@ -748,7 +814,7 @@ public class Main
for (String xml : xmls)
{
cmd.addRawArg(xml);
cmd.addRawArg(xml);
}
return cmd;
}
@ -767,7 +833,7 @@ public class Main
return; // done
}
Properties props = Config.getProperties();
Properties props = _config.getProperties();
if (props.containsKey(key))
{
String val = props.getProperty(key,null);
@ -841,7 +907,8 @@ public class Main
System.out.println("Note: If using multiple options (eg: 'Server,servlet,webapp,jms,jmx') "
+ "then overlapping entries will not be repeated in the eventual classpath.");
System.out.println();
System.out.printf("${jetty.home} = %s%n",_jettyHome);
System.out.printf("${jetty.home} = %s%n",_config.getJettyHome());
System.out.printf("${jetty.base} = %s%n",_config.getJettyBase());
System.out.println();
for (String sectionId : sectionIds)
@ -876,14 +943,7 @@ public class Main
int i = 0;
for (File element : sectionCP.getElements())
{
String elementPath = element.getAbsolutePath();
if (elementPath.startsWith(_jettyHome))
{
elementPath = "${jetty.home}" + elementPath.substring(_jettyHome.length());
}
System.out.printf("%2d: %20s | %s\n",i++,getVersion(element),elementPath);
}
System.out.printf("%2d: %20s | %s\n",i++,getVersion(element),path(element));
System.out.println();
}
@ -894,7 +954,7 @@ public class Main
// Iterate through active classpath, and fetch Implementation Version from each entry (if present)
// to dump to end user.
System.out.println("Active Options: " + _config.getActiveOptions());
System.out.println("Active Options: " + _config.getOptions());
if (classpath.count() == 0)
{
@ -908,14 +968,7 @@ public class Main
int i = 0;
for (File element : classpath.getElements())
{
String elementPath = element.getAbsolutePath();
if (elementPath.startsWith(_jettyHome))
{
elementPath = "${jetty.home}" + elementPath.substring(_jettyHome.length());
}
System.out.printf("%2d: %20s | %s\n",i++,getVersion(element),elementPath);
}
System.out.printf("%2d: %20s | %s\n",i++,getVersion(element),path(element));
}
private String fixPath(String path)
@ -1003,13 +1056,6 @@ public class Main
// parse the config
_config.parse(cfgstream);
_jettyHome = Config.getProperty("jetty.home",_jettyHome);
if (_jettyHome != null)
{
_jettyHome = new File(_jettyHome).getCanonicalPath();
System.setProperty("jetty.home",_jettyHome);
}
// Collect the configured xml configurations.
List<String> ret = new ArrayList<String>();
ret.addAll(xmls); // add command line provided xmls first.
@ -1145,17 +1191,22 @@ public class Main
/**
* Convert a start.ini format file into an argument list.
*/
List<String> loadStartIni(File ini)
List<String> loadStartIni(File ini,String name)
{
if (!ini.exists())
if (ini==null || !ini.exists() || ini.isDirectory() || !ini.canRead())
{
System.err.println("Warning - can't find ini file: " + ini);
System.err.println("Warning - bad ini file: " + name);
// No start.ini found, skip load.
return Collections.emptyList();
}
ini=ini.getAbsoluteFile();
if (!_iniFiles.contains(ini))
_iniFiles.add(ini);
List<String> args = new ArrayList<String>();
args.add("_SRC_="+name);
FileReader reader = null;
BufferedReader buf = null;
try
@ -1176,11 +1227,8 @@ public class Main
{
try
{
File start_d = new File(arg);
if (!start_d.exists() || !start_d.isDirectory())
start_d = new File(_jettyHome,arg);
if (start_d.isDirectory())
File start_d = _config.getFileBaseHomeAbs(arg);
if (start_d!=null && start_d.isDirectory())
{
File[] inis = start_d.listFiles(new FilenameFilter()
{
@ -1193,8 +1241,9 @@ public class Main
Arrays.sort(inis);
for (File i : inis)
args.addAll(loadStartIni(i));
args.addAll(loadStartIni(i,i.getAbsolutePath()));
args.add("_SRC_="+name);
continue;
}
}

View File

@ -4,18 +4,18 @@
#
# Each line contains entry in the format:
#
# SUBJECT [ [!] CONDITION [AND|OR] ]*
# SUBJECT [ [!] CONDITION [AND|OR] ]*
#
# where SUBJECT:
# ends with ".class" is the Main class to run.
# ends with ".xml" is a configuration file for the command line
# ends with "/" is a directory from which to add all jar and zip files.
# ends with "/*" is a directory from which to add all unconsidered jar and zip files.
# ends with "/**" is a directory from which to recursively add all unconsidered jar and zip files.
# Containing = are used to assign system properties.
# Containing ~= are used to assign start properties.
# Containing /= are used to assign a canonical path.
# all other subjects are treated as files to be added to the classpath.
# ends with ".class" is the Main class to run.
# ends with ".xml" is a configuration file for the command line
# ends with "/" is a directory from which to add all jar and zip files.
# ends with "/*" is a directory from which to add all unconsidered jar and zip files.
# ends with "/**" is a directory from which to recursively add all unconsidered jar and zip files.
# Containing = are used to assign system properties.
# Containing ~= are used to assign start properties.
# Containing /= are used to assign a canonical path.
# all other subjects are treated as files to be added to the classpath.
#
# ${name} is expanded to a start property
# $(name) is expanded to either a start property or a system property.
@ -25,15 +25,15 @@
# the home directory.
#
# CONDITION is one of:
# always
# never
# available classname # true if class on classpath
# property name # true if set as start property
# system name # true if set as system property
# exists file # true if file/dir exists
# java OPERATOR version # java version compared to literal
# nargs OPERATOR number # number of command line args compared to literal
# OPERATOR := one of "<",">","<=",">=","==","!="
# always
# never
# available classname # true if class on classpath
# property name # true if set as start property
# system name # true if set as system property
# exists file # true if file/dir exists
# java OPERATOR version # java version compared to literal
# nargs OPERATOR number # number of command line args compared to literal
# OPERATOR := one of "<",">","<=",">=","==","!="
#
# CONTITIONS can be combined with AND OR or !, with AND being the assume
# operator for a list of CONDITIONS.
@ -45,123 +45,135 @@
# [ssl,default]
#
# Clauses after a section header will only be included if they match one of the tags in the
# options property. By default options are set to "default,*" or the OPTIONS property may
# options property. By default options are set to "default,*" or the OPTIONS property may
# be used to pass in a list of tags, eg. :
#
# java -jar start.jar OPTIONS=jetty,jsp,ssl
# java -jar start.jar OPTIONS=jetty,jsp,ssl
#
# The tag '*' is always appended to the options, so any section with the * tag is always
# applied.
#
# add a property defined classpath
${path}.path property path
${path}.path property path
# add a property defined library directory
${lib}/** exists ${lib}
${lib}/** exists ${lib}
# Try different settings of jetty.home until the start.jar is found.
jetty.home=. ! exists $(jetty.home)/start.jar
jetty.home=.. ! exists $(jetty.home)/start.jar
jetty.home=jetty-distribution/src/main/resources ! exists $(jetty.home)/start.jar
jetty.home=../jetty-distribution/src/main/resources ! exists $(jetty.home)/start.jar
jetty.home=. ! exists $(jetty.home)/start.jar
jetty.home/=$(jetty.home) exists $(jetty.home)/start.jar
jetty.home=. ! exists $(jetty.home)/start.jar
jetty.home=.. ! exists $(jetty.home)/start.jar
jetty.home=jetty-distribution/src/main/resources ! exists $(jetty.home)/start.jar
jetty.home=../jetty-distribution/src/main/resources ! exists $(jetty.home)/start.jar
jetty.home=. ! exists $(jetty.home)/start.jar
jetty.home/=$(jetty.home) exists $(jetty.home)/start.jar
# Set the jetty.base property
jetty.base=$(jetty.base) system jetty.base
# The main class to run
org.eclipse.jetty.xml.XmlConfiguration.class
${start.class}.class property start.class
${start.class}.class property start.class
# The default configuration files
$(jetty.home)/etc/jetty.xml nargs == 0
./jetty-server/src/main/config/etc/jetty.xml nargs == 0 AND ! exists $(jetty.home)/etc/jetty.xml
$(jetty.base)/etc/jetty.xml nargs == 0 AND property jetty.base
$(jetty.home)/etc/jetty.xml nargs == 0
./jetty-server/src/main/config/etc/jetty.xml nargs == 0 AND ! exists $(jetty.home)/etc/jetty.xml
# Default OPTIONS if not specified on the command line
OPTIONS~=default,* ! property OPTIONS
OPTIONS~=default,* ! property OPTIONS
# Add a resources directory if it is there
[All,resources,default]
$(jetty.base)/resources/ property jetty.base
$(jetty.home)/resources/
# Add jetty modules
[*]
$(jetty.home)/lib/jetty-util-$(version).jar ! available org.eclipse.jetty.util.StringUtil
$(jetty.home)/lib/jetty-io-$(version).jar ! available org.eclipse.jetty.io.Buffer
$(jetty.home)/lib/jetty-util-$(version).jar ! available org.eclipse.jetty.util.StringUtil
$(jetty.home)/lib/jetty-io-$(version).jar ! available org.eclipse.jetty.io.Buffer
[Server,All,xml,default]
$(jetty.home)/lib/jetty-xml-$(version).jar ! available org.eclipse.jetty.xml.XmlParser
$(jetty.home)/lib/jetty-xml-$(version).jar ! available org.eclipse.jetty.xml.XmlParser
[Server,All,server,default]
$(jetty.home)/lib/servlet-api-3.1.jar ! available javax.servlet.ServletContext
$(jetty.home)/lib/jetty-schemas-3.1.jar
$(jetty.home)/lib/jetty-http-$(version).jar ! available org.eclipse.jetty.http.HttpParser
$(jetty.home)/lib/jetty-continuation-$(version).jar ! available org.eclipse.jetty.continuation.Continuation
$(jetty.home)/lib/jetty-server-$(version).jar ! available org.eclipse.jetty.server.Server
$(jetty.home)/lib/servlet-api-3.1.jar ! available javax.servlet.ServletContext
$(jetty.home)/lib/jetty-schemas-3.1.jar
$(jetty.home)/lib/jetty-http-$(version).jar ! available org.eclipse.jetty.http.HttpParser
$(jetty.home)/lib/jetty-continuation-$(version).jar ! available org.eclipse.jetty.continuation.Continuation
$(jetty.home)/lib/jetty-server-$(version).jar ! available org.eclipse.jetty.server.Server
[Server,All,security,default]
$(jetty.home)/lib/jetty-security-$(version).jar ! available org.eclipse.jetty.security.LoginService
$(jetty.home)/lib/jetty-security-$(version).jar ! available org.eclipse.jetty.security.LoginService
[Server,All,servlet,default]
$(jetty.home)/lib/servlet-api-3.0.jar ! available javax.servlet.ServletContext
$(jetty.home)/lib/jetty-servlet-$(version).jar ! available org.eclipse.jetty.servlet.ServletHandler
$(jetty.home)/lib/servlet-api-3.0.jar ! available javax.servlet.ServletContext
$(jetty.home)/lib/jetty-servlet-$(version).jar ! available org.eclipse.jetty.servlet.ServletHandler
[servlets]
$(jetty.home)/lib/jetty-servlets-$(version).jar ! available org.eclipse.jetty.servlets.MultiPartFilter
$(jetty.home)/lib/jetty-servlets-$(version).jar ! available org.eclipse.jetty.servlets.MultiPartFilter
[Server,All,webapp,default]
$(jetty.home)/lib/jetty-webapp-$(version).jar ! available org.eclipse.jetty.webapp.WebAppContext
$(jetty.home)/lib/jetty-webapp-$(version).jar ! available org.eclipse.jetty.webapp.WebAppContext
[Server,All,deploy,default]
$(jetty.home)/lib/jetty-deploy-$(version).jar ! available org.eclipse.jetty.deploy.ContextDeployer
$(jetty.home)/lib/jetty-deploy-$(version).jar ! available org.eclipse.jetty.deploy.ContextDeployer
[All,rewrite]
$(jetty.home)/lib/jetty-rewrite-$(version).jar ! available org.eclipse.jetty.rewrite.handler.RewriteHandler
$(jetty.home)/lib/jetty-rewrite-$(version).jar ! available org.eclipse.jetty.rewrite.handler.RewriteHandler
[All,jmx]
$(jetty.home)/lib/jetty-jmx-$(version).jar ! available org.eclipse.jetty.jmx.MBeanContainer
$(jetty.home)/lib/jetty-jmx-$(version).jar ! available org.eclipse.jetty.jmx.MBeanContainer
[All,ajp]
$(jetty.home)/lib/jetty-ajp-$(version).jar ! available org.eclipse.jetty.ajp.Ajp13Connection
$(jetty.home)/lib/jetty-ajp-$(version).jar ! available org.eclipse.jetty.ajp.Ajp13Connection
[All,plus,jndi]
$(jetty.home)/lib/jetty-jndi-${version}.jar ! available org.eclipse.jetty.jndi.ContextFactory
$(jetty.home)/lib/jetty-plus-${version}.jar ! available org.eclipse.jetty.plus.jndi.NamingEntry
$(jetty.home)/lib/jndi/** exists $(jetty.home)/lib/jndi
$(jetty.home)/lib/jetty-jndi-${version}.jar ! available org.eclipse.jetty.jndi.ContextFactory
$(jetty.home)/lib/jetty-plus-${version}.jar ! available org.eclipse.jetty.plus.jndi.NamingEntry
$(jetty.home)/lib/jndi/** exists $(jetty.home)/lib/jndi
[All,jaas]
$(jetty.home)/lib/jetty-jaas-${version}.jar ! available org.eclipse.jetty.jaas.JAASLoginService
$(jetty.home)/lib/jetty-jaas-${version}.jar ! available org.eclipse.jetty.jaas.JAASLoginService
[All,annotations]
$(jetty.home)/lib/jetty-annotations-$(version).jar ! available org.eclipse.jetty.annotations.AnnotationParser
$(jetty.home)/lib/annotations/** exists $(jetty.home)/lib/annotations
$(jetty.home)/lib/jetty-annotations-$(version).jar ! available org.eclipse.jetty.annotations.AnnotationParser
$(jetty.home)/lib/annotations/** exists $(jetty.home)/lib/annotations
[All,setuid]
$(jetty.home)/lib/jetty-setuid-$(version).jar ! available org.eclipse.jetty.setuid.SetUID
$(jetty.home)/lib/setuid/**
$(jetty.home)/lib/jetty-setuid-$(version).jar ! available org.eclipse.jetty.setuid.SetUID
$(jetty.home)/lib/setuid/**
[All,policy]
$(jetty.home)/lib/jetty-policy-$(version).jar ! available org.eclipse.jetty.policy.JettyPolicy
$(jetty.home)/lib/jetty-policy-$(version).jar ! available org.eclipse.jetty.policy.JettyPolicy
[All,client]
$(jetty.home)/lib/jetty-http-$(version).jar ! available org.eclipse.jetty.http.HttpParser
$(jetty.home)/lib/jetty-client-$(version).jar ! available org.eclipse.jetty.client.HttpClient
$(jetty.home)/lib/jetty-http-$(version).jar ! available org.eclipse.jetty.http.HttpParser
$(jetty.home)/lib/jetty-client-$(version).jar ! available org.eclipse.jetty.client.HttpClient
[All,proxy]
$(jetty.home)/lib/jetty-proxy-$(version).jar ! available org.eclipse.jetty.proxy.ConnectHandler
$(jetty.home)/lib/jetty-proxy-$(version).jar ! available org.eclipse.jetty.proxy.ConnectHandler
$(jetty.home)/lib/jetty-http-$(version).jar ! available org.eclipse.jetty.http.HttpParser
$(jetty.home)/lib/jetty-client-$(version).jar ! available org.eclipse.jetty.client.HttpClient
$(jetty.home)/lib/jetty-client-$(version).jar ! available org.eclipse.jetty.client.HttpClient
[All,websocket]
$(jetty.home)/lib/websocket/**
[All,overlay,overlays]
$(jetty.home)/lib/jetty-overlay-deployer-$(version).jar ! available org.eclipse.jetty.overlay.OverlayedAppProvider
$(jetty.home)/lib/jetty-overlay-deployer-$(version).jar ! available org.eclipse.jetty.overlay.OverlayedAppProvider
# Add ext if it exists
[Server,All,default,ext]
[Server,All,default,ext]
$(jetty.base)/lib/ext/** property jetty.base
$(jetty.home)/lib/ext/**
# Add all other sub-directories in /lib/ as options in a dynamic way
[All,=$(jetty.home)/lib/**]
[All,=$(jetty.base)/lib/**]
[All,=$(jetty.home)/lib/**]
# Set property jetty.base and jetty.log as jetty.home if not set
jetty.base=${jetty.home} ! property jetty.base
jetty.logs=${jetty.base}/logs ! property jetty.logs

View File

@ -76,13 +76,20 @@ System Properties:
com.sun.management.jmxremote
Enable remote JMX management in Sun JVMS.
Properties:
These are set with a command line like "java -jar start.jar name=value"
and only affect the start mechanism. Some of these are defined in the
default start.config and will not be available if another configuration
file is used. NOTE: Not all properties are listed here:
jetty.home=[directory]
Set the home directory of the jetty distribtion.
jetty.base=[directory]
Set the jetty configuration directory. This is where the etc, webapps and start
files will be looked for. If not found in jetty.base, they are looked for in
jetty.home.
path=[directory]
An additional class path element to add to the started class path. Typically
this is used to add directories of classes and/or resources
@ -120,8 +127,8 @@ Properties:
Available Configurations:
By convention, configuration files are kept in $JETTY_HOME/etc.
The known configuration files are:
By convention, configuration files are kept in ${jetty.base}/etc or
${jetty.home}/etc The known configuration files are:
@CONFIGS@
@ -135,6 +142,6 @@ Defaults:
If --ini options are provided on the command line, then start.ini will NOT be read.
The current start.ini arguments are:
The current start.ini files are:
@STARTINI@

View File

@ -100,7 +100,6 @@ public class ConfigTest
@Before
public void reset()
{
Config.clearProperties();
}
/*
@ -115,7 +114,7 @@ public class ConfigTest
Config cfg = new Config();
cfg.parse(buf);
Assert.assertEquals(getTestResourcesDir().getCanonicalPath(),Config.getProperty("test.resources.dir"));
Assert.assertEquals(getTestResourcesDir().getCanonicalPath(),cfg.getProperty("test.resources.dir"));
}
/*
@ -131,8 +130,8 @@ public class ConfigTest
Config options = new Config();
options.parse(buf);
Assert.assertEquals("foo",Config.getProperty("test.jetty.start.text"));
Assert.assertEquals("Eatagramovabits",Config.getProperty("test.jetty.start.quote"));
Assert.assertEquals("foo",options.getProperty("test.jetty.start.text"));
Assert.assertEquals("Eatagramovabits",options.getProperty("test.jetty.start.quote"));
}
/*

View File

@ -30,9 +30,11 @@ import java.io.IOException;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.Vector;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
@ -52,42 +54,19 @@ public class MainTest
System.setProperty("jetty.home",testJettyHome.getAbsolutePath());
}
@Test
public void testLoadStartIni() throws IOException
{
Main main = new Main();
List<String> args = main.parseStartIniFiles();
assertEquals("Expected 5 uncommented lines in start.ini",9,args.size());
assertEquals("First uncommented line in start.ini doesn't match expected result","OPTIONS=Server,jsp,resources,websocket,ext",args.get(0));
assertEquals("Last uncommented line in start.ini doesn't match expected result","etc/jetty-contexts.xml",args.get(8));
}
@Test
public void testExpandCommandLine() throws Exception
{
Main main = new Main();
List<String> args = main.expandCommandLine(new String[] {});
assertEquals("start.ini OPTIONS","OPTIONS=Server,jsp,resources,websocket,ext",args.get(0));
assertEquals("start.d/jmx OPTIONS","OPTIONS=jmx",args.get(2));
assertEquals("start.d/jmx XML","etc/jetty-jmx.xml",args.get(3));
assertEquals("start.d/websocket OPTIONS","OPTIONS=websocket",args.get(4));
}
@Test
public void testProcessCommandLine() throws Exception
{
Main main = new Main();
List<String> args = main.expandCommandLine(new String[] {});
List<String> xmls = main.processCommandLine(args);
List<String> xmls = main.processCommandLine(new String[] {});
System.err.println(args);
System.err.println(xmls);
assertEquals("etc/jetty.xml",xmls.get(0));
assertEquals("etc/jetty-jmx.xml",xmls.get(1));
assertEquals("start.d","etc/jetty-testrealm.xml",xmls.get(2));
assertEquals("start.d","etc/jetty-contexts.xml",xmls.get(5));
Set<String> options = main.getConfig().getOptions();
assertThat(options,Matchers.contains("Server","ext","jmx","jsp","newOption","resources","websocket"));
}
@Test

View File

@ -9,7 +9,7 @@
#===========================================================
#-----------------------------------------------------------
OPTIONS=jmx
OPTION=jmx
#-----------------------------------------------------------

View File

@ -9,5 +9,6 @@
#===========================================================
#-----------------------------------------------------------
OPTIONS=websocket
DEPEND=Server
OPTION=websocket
#-----------------------------------------------------------

View File

@ -6,71 +6,13 @@
#===========================================================
#===========================================================
# If the arguements in this file include JVM arguments
# (eg -Xmx512m) or JVM System properties (eg com.sun.???),
# then these will not take affect unless the --exec
# parameter is included or if the output from --dry-run
# is executed like:
# eval $(java -jar start.jar --dry-run)
#
# Below are some recommended options for Sun's JRE
#-----------------------------------------------------------
# --exec
# -Dorg.apache.jasper.compiler.disablejsr199=true
# -Dcom.sun.management.jmxremote
# -Dorg.eclipse.jetty.util.log.IGNORED=true
# -Dorg.eclipse.jetty.util.log.stderr.DEBUG=true
# -Dorg.eclipse.jetty.util.log.stderr.SOURCE=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
#-----------------------------------------------------------
#===========================================================
# Start classpath OPTIONS.
# These control what classes are on the classpath
# for a full listing do
# java -jar start.jar --list-options
#
# Enable classpath OPTIONS. Each options represents one or more jars
# to be added to the classpath. The options can be listed with --help
# or --list-options.
# By convention, options starting with a capital letter (eg Server)
# are aggregations of other available options.
# Directories in $JETTY_HOME/lib can be added as dynamic OPTIONS by
# convention. E.g. put some logging jars in $JETTY_HOME/lib/logging
# and make them available in the classpath by adding a "logging" OPTION
# like so: OPTIONS=Server,jsp,logging
#-----------------------------------------------------------
OPTIONS=Server,jsp,resources,websocket,ext
#-----------------------------------------------------------
#===========================================================
# Configuration files.
# For a full list of available configuration files do
# java -jar start.jar --help
#-----------------------------------------------------------
etc/jetty.xml
start.d/
# etc/jetty-ssl.xml
# etc/jetty-requestlog.xml
etc/jetty-deploy.xml
#etc/jetty-overlay.xml
etc/jetty-webapps.xml
etc/jetty-contexts.xml
#===========================================================
DEFINE=newOption
OPTION=newOption
DEPEND=newOption