start.config 简析

From jetty-start-8.1.0.RC5-sources\org\eclipse\jetty\start\start.config

# This file controls what file are to be put on classpath or command line.
#
# Format is as follows:
#
# Each line contains entry in the format:
#
# 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.
#
# ${name} is expanded to a start property
# $(name) is expanded to either a start property or a system property.
# The start property ${version} is defined as the version of the start.jar
#
# Files starting with "/" are considered absolute, all others are relative to
# 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 "<",">","<=",">=","==","!="
#
# CONTITIONS can be combined with AND OR or !, with AND being the assume
# operator for a list of CONDITIONS.
#
# Classpath operations are evaluated on the fly, so once a class or jar is
# added to the classpath, subsequent available conditions will see that class.
#
# The configuration file may be divided into sections with option names like:
# [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
# be used to pass in a list of tags, eg. :
#
# 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

# 把在java -jar start.jar这个执行命令定义的path变量的值加入到classpath中去

# 譬如运行 java -jar start.jar -Dpath=..\mylib

# ..\mylib是会被加入到classpath中去的

# 那么为什么是${path}.path,而不是简单的${path}?

# 首先,写成${path}.path,是因为jetty会做相应的解析

# if (subject.toLowerCase().endsWith(".path"))

#                    {

#                       // classpath (jetty.class.path?) to add to runtime classpath

#                       String cn = expand(subject.substring(0,subject.length() - 5));

#                        if (cn != null && cn.length() > 0)

#                        {

#                            debug("  PATH=" + cn);

#                            addClasspathPath(options,cn);

#                        }

#                        continue;

#                    }

# 输出是这样的:

# T ${path}.path                                     property path

#  PATH=..\mylib

# 其实,如果写出${path},效果是一样的,只不过处理起来稍有不同

# T ${path}                                     property path

#  CLASSPATH+=K:\dev\mylib

# add a property defined library directory
${lib}/** exists ${lib}

# 命令行如果设置了lib参数,就把lib下面所有的jar和zip加入到classpath

# 默认的是不设的

#==================================================

# jetty.home 的设置

#==================================================

# 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的查找

# 默认情况下,jetty.home先设置为当前目录,也就是运行java -jar start.jar的目录:

_jettyHome = System.getProperty("jetty.home",".");

先是判断这个文件的存在$(jetty.home)/start.jar

如果不存在,$(jetty.home)会被设置到当前目录

T jetty.home=.                                     ! exists $(jetty.home)/start.jar

  jetty.home=.

如果$(jetty.home)还没找到,就把$(jetty.home)设置到父目录

F jetty.home=..                                    ! exists $(jetty.home)/start.jar

设置到jetty-distribution/src/main/resources

F jetty.home=jetty-distribution/src/main/resources     ! exists $(jetty.home)/start.jar

设置到../jetty-distribution/src/main/resources

F jetty.home=../jetty-distribution/src/main/resources  ! exists $(jetty.home)/start.jar

设置回当前目录

F jetty.home=.                                     ! exists $(jetty.home)/start.jar

然后设置$(jetty.home)。在本例中,第一次判断之后,jetty.home就一直设置正确了

T jetty.home/=$(jetty.home)                        exists $(jetty.home)/start.jar

  jetty.home/=.==K:\dev\jetty-hightide-8.1.0.RC5

# jetty.home也可以通过命令行指定,譬如:

java -jar D:\dev\jetty-distribution-8.1.0.RC5\start.jar -Djetty.home=D:\dev\jetty-distribution-8.1.0.RC5\bin DEBUG=true --dry-run

#================================================================

# The main class to run
org.eclipse.jetty.xml.XmlConfiguration.class
${start.class}.class property start.class

你可以让start.jar运行你自己的类,譬如:

T org.eclipse.jetty.xml.XmlConfiguration.class

  CLASS=org.eclipse.jetty.xml.XmlConfiguration

T ${start.class}.class                             property start.class

  CLASS=test.Hello

java -jar D:\dev\jetty-distribution-8.1.0.RC5\start.jar -Djetty.home=D:\dev\jetty-distribution-8.1.0.RC5\ DEBUG=true -Dstart.class=test.Hello

输出:

WARNING: System properties and/or JVM args set.  Consider using --dry-run or --exec

main.class=test.Hello

test.Hello null

Hello!

D:\dev>

# 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

# Default OPTIONS if not specified on the command line
OPTIONS~=default,* ! property OPTIONS

# Add a resources directory if it is there
[All,resources,default]
$(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

[Server,All,xml,default]
$(jetty.home)/lib/jetty-xml-$(version).jar ! available org.eclipse.jetty.xml.XmlParser

[Server,All,server,default]
$(jetty.home)/lib/servlet-api-3.0.jar ! available javax.servlet.ServletContext
$(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

[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

[Server,All,webapp,default]
$(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

[Server,All,servlets,default]
$(jetty.home)/lib/jetty-servlets-$(version).jar ! available org.eclipse.jetty.servlets.WelcomeFilter

[All,rewrite]
$(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

[All,ajp]
$(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

[All,annotations]
$(jetty.home)/lib/jetty-annotations-$(version).jar ! available org.eclipse.jetty.annotations.AnnotationFinder
$(jetty.home)/lib/annotations/** exists $(jetty.home)/lib/jndi

[All,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

[All,Client,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

[All,websocket]
$(jetty.home)/lib/jetty-websocket-$(version).jar ! available org.eclipse.jetty.websocket.WebSocket

[Client]
$(jetty.home)/lib/jetty-http-$(version).jar ! available org.eclipse.jetty.http.HttpParser

[All,websocket]
$(jetty.home)/lib/jetty-websocket-$(version).jar ! available org.eclipse.jetty.websocket.WebSocket

[All,overlay,overlays]
$(jetty.home)/lib/jetty-overlay-deployer-$(version).jar ! available org.eclipse.jetty.overlay.OverlayedAppProvider


# Add ext if it exists
[Server,All,default,ext]
$(jetty.home)/lib/ext/**

# Add all other sub-directories in /lib/ as options in a dynamic way
[All,=$(jetty.home)/lib/**]

猜你喜欢

转载自dbcde.iteye.com/blog/1531020
今日推荐