替换变量前jetty.xml如下:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<!-- =============================================================== -->
<!-- Configure the Jetty Server -->
<!-- -->
<!-- Documentation of this file format can be found at: -->
<!-- http://wiki.eclipse.org/Jetty/Reference/jetty.xml_syntax -->
<!-- -->
<!-- Additional configuration files are available in JETTY_HOME/etc -->
<!-- and can be mixed in. For example: -->
<!-- java -jar start.jar etc/jetty.xml etc/jetty-ssl.xml -->
<!-- -->
<!-- See start.ini file for the default configuraton files -->
<!-- =============================================================== -->
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- =========================================================== -->
<!-- Server Thread Pool -->
<!-- =========================================================== -->
<Set name="ThreadPool">
<!-- Default queued blocking threadpool -->
<New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
<Set name="minThreads">10</Set>
<Set name="maxThreads">250</Set>
</New>
</Set>
<!-- =========================================================== -->
<!-- Set connectors -->
<!-- =========================================================== -->
<!-- -->
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<Set name="host"><Property name="jetty.host" /></Set>
<Set name="port"><Property name="jetty.port" default="@tutorial1.appserver.port@"/></Set>
<!-- added by benni, to retrieve the client remote address in the webapp -->
<Set name="forwarded">true</Set>
<Set name="forwardedHostHeader">ignore</Set>
<Set name="forwardedServerHeader">ignore</Set>
<Set name="maxIdleTime">600000</Set>
<Set name="Acceptors">2</Set>
<Set name="acceptQueueSize">256</Set>
<Set name="statsOn">false</Set>
<Set name="confidentialPort">8443</Set>
<Set name="lowResourcesConnections">2000</Set>
<Set name="lowResourcesMaxIdleTime">5000</Set>
<!-- modify 2011-04-08 for http status 413-->
<Set name="requestHeaderSize">8192</Set>
<Set name="responseHeaderSize">8192</Set>
</New>
</Arg>
</Call>
<!-- =========================================================== -->
<!-- Set handler Collection Structure -->
<!-- =========================================================== -->
<Set name="handler">
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
<Set name="handlers">
<Array type="org.eclipse.jetty.server.Handler">
<Item>
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
</Item>
<Item>
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
</Item>
</Array>
</Set>
</New>
</Set>
<!-- =========================================================== -->
<!-- extra options -->
<!-- =========================================================== -->
<Set name="stopAtShutdown">true</Set>
<Set name="sendServerVersion">false</Set>
<Set name="sendDateHeader">true</Set>
<Set name="gracefulShutdown">1000</Set>
<!-- =========================================================== -->
<!-- Configure deployment steps for every web app -->
<!-- =========================================================== -->
<Call name="setAttribute">
<Arg>org.eclipse.jetty.webapp.configuration</Arg>
<Arg>
<Array type="java.lang.String">
<Item>org.eclipse.jetty.webapp.WebInfConfiguration</Item>
<Item>org.eclipse.jetty.webapp.WebXmlConfiguration</Item>
<Item>org.eclipse.jetty.webapp.MetaInfConfiguration</Item>
<Item>org.eclipse.jetty.webapp.FragmentConfiguration</Item>
<Item>org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Item>
<Item>org.eclipse.jetty.webapp.TagLibConfiguration</Item>
</Array>
</Arg>
</Call>
<Call name="setAttribute">
<Arg>org.eclipse.jetty.webapp.systemClasses</Arg>
<Arg>
<Array type="java.lang.String">
<!-- jetty default config , can see WebAppContext.__dftSystemClasses -->
<Item>java.</Item>
<Item>javax.</Item>
<Item>org.xml.</Item>
<Item>org.w3c.</Item>
<Item>org.apache.commons.logging.</Item>
<Item>org.eclipse.jetty.continuation.</Item>
<Item>org.eclipse.jetty.jndi.</Item>
<Item>org.eclipse.jetty.plus.jaas.</Item>
<Item>org.eclipse.jetty.websocket.</Item>
<Item>org.eclipse.jetty.servlet.DefaultServlet</Item>
<!-- add by ljh , custom jai for sealed -->
<!--for jai_code.jar , jai_codec.jar -->
<Item>com.sun.media.jai.</Item>
<!--for jai_imageio.jar -->
<Item>com.sun.media.imageio.</Item>
<Item>com.sun.media.imageioimpl.</Item>
<Item>jj2000.j2k.</Item>
</Array>
</Arg>
</Call>
<Call class="java.lang.System" name="setProperty">
<Arg>org.eclipse.jetty.server.Request.maxFormContentSize</Arg>
<Arg>2097152</Arg>
</Call>
<!-- =========================================================== -->
<!-- Configure the deployment manager -->
<!-- -->
<!-- Sets up 2 monitored dir app providers that are configured -->
<!-- to behave in a similaraly to the legacy ContextDeployer -->
<!-- and WebAppDeployer from previous versions of Jetty. -->
<!-- =========================================================== -->
<Call name="addBean">
<Arg>
<New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager">
<Set name="contexts">
<Ref id="Contexts" />
</Set>
<Call name="setContextAttribute">
<Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
<Arg>.*/jsp-api-[^/]*\.jar$|.*/jsp-[^/]*\.jar$</Arg>
</Call>
<!-- Providers of Apps via WAR file existence.
Configured to behave similar to the legacy WebAppDeployer -->
<Call name="addAppProvider">
<Arg>
<New class="org.eclipse.jetty.deploy.providers.WebAppProvider">
<Set name="monitoredDir">@tutorial1.jettyserverhome@/webapps</Set>
<Set name="scanInterval">0</Set>
<Set name="extractWars"><Property name="jetty.extractWars" default="false"/></Set>
<Set name="defaultsDescriptor">@tutorial1.jettyserverhome@/conf/webdefault.xml</Set>
</New>
</Arg>
</Call>
</New>
</Arg>
</Call>
</Configure>
替换变量前base_env.bat如下:
SET JAVA_HOME=@tutorial1.javahome@
set DEPLOY_HOME=@tutorial1.deployhome@
set OUTPUT_HOME=@tutorial1.output@
set JETTY_HOME=@tutorial1.jettyhome@
set JETTY_SERVER_HOME=@tutorial1.jettyserverhome@
set PRODUCTION=@tutorial1.production@
set LOG_DIR=%OUTPUT_HOME%\logs
set JAVA_MEM_OPTS= -Xms128m -Xmx512m -XX:PermSize=128m
set JAVA_OPTS_EXT= -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Dapplication.codeset=GBK -Dmonitor.enable=true -Dmonitor.exclog.enable=true -Dmonitor.biz.interval=120 -Dmonitor.debug=false -Djava.util.logging.config.file="%DEPLOY_HOME%\conf\general\logging.properties"
set DATABASE_OPTS= -Ddatabase.codeset=ISO-8859-1 -Ddatabase.logging=false
set URI_ENCODE= -Dorg.eclipse.jetty.util.URI.charset=GBK
set JAVA_DEBUG_OPT= -server -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=@tutorial1.debug.port@,server=y,suspend=n
set JAVA_OPTS= %JAVA_MEM_OPTS% %DATABASE_OPTS% %JAVA_OPTS_EXT% %JAVA_DEBUG_OPT% %URI_ENCODE%
jettyctl.bat如下:
@echo off
@if not "%ECHO%" == "" echo %ECHO%
@if "%OS%" == "Windows_NT" setlocal
set ENV_PATH=.\
if "%OS%" == "Windows_NT" set ENV_PATH=%~dp0%
call %ENV_PATH%\base_env.bat
REM copy file to jetty server.
RMDIR "%JETTY_SERVER_HOME%" /S /Q
MKDIR "%JETTY_SERVER_HOME%"
MKDIR "%JETTY_SERVER_HOME%\logs"
MKDIR "%JETTY_SERVER_HOME%\tmp"
MKDIR "%JETTY_SERVER_HOME%\webapps"
REM create output/logs for jetty_stdout.log
MKDIR "%OUTPUT_HOME%/logs"
REM jetty args
set JETTY_PROS= -Djetty.logs="%JETTY_SERVER_HOME%\logs" -Djetty.home="%JETTY_HOME%" -Djava.io.tmpdir="%JETTY_SERVER_HOME%\tmp"
set JETTY_ARGS= --ini="%JETTY_SERVER_HOME%\conf\start.ini"
for %%a in ("%DEPLOY_HOME%\..\*.war") do (
if exist "%JETTY_SERVER_HOME%\webapps\tutorial1.war" (
DEL /F /S /Q "%JETTY_SERVER_HOME%\webapps\tutorial1.war"
echo "remove duplicate tutorial1.war"
)
COPY "%%a" "%JETTY_SERVER_HOME%\webapps\tutorial1.war" /Y
)
XCOPY "%DEPLOY_HOME%\conf\jetty" "%JETTY_SERVER_HOME%" /Y /S /Q
REM cls screen
rem CLS
"%JAVA_HOME%\bin\java" %JAVA_OPTS% %JETTY_PROS% -jar %JETTY_HOME%\start.jar %JETTY_ARGS%