嵌入式的Web应用容器Jetty (第二篇)

它的根节点支持申明?? org.mortbay.jetty.Server???? 或 ??????org.mortbay.jetty.webapp.WebAppContext 两种:?

1、

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure id="Server" class="org.mortbay.jetty.Server">

	 <Property name="org.mortbay.util.URI.charset" default="UTF8"/>  
	<Set name="sessionIdManager">  
        <New class="org.mortbay.jetty.servlet.HashSessionIdManager">  
            <Set name="workerName">node1</Set>  
        </New>  
    </Set>  
	  <Set name="threadPool">
	    <New class="org.mortbay.thread.BoundedThreadPool">
	      <Set name="minThreads">10</Set>
	      <Set name="maxThreads">1000</Set>
	    </New>
	  </Set> 

	<Call name="addConnector"> 
		<Arg>
			<New class="org.mortbay.jetty.nio.SelectChannelConnector"> 
				<Set name="host">
					<SystemProperty name="jetty.host" />
				</Set>
				<Set name="port">
					<SystemProperty name="jetty.port" default="8180" />
				</Set> 
				<Set name="maxIdleTime">30000</Set>
				<Set name="acceptors">2</Set>
				<Set name="statsOn">false</Set>
				<Set name="confidentialPort">8443</Set>

				<Set name="lowResourcesConnections">5000</Set> 
				<Set name="lowResourcesMaxIdleTime">5000</Set>
			</New> 
		</Arg> 
	</Call>
 

<!-- 	<Set name="handler"> 
		<New id="Handlers" class="org.mortbay.jetty.handler.HandlerCollection">
			<Set name="handlers">
				<Array type="org.mortbay.jetty.Handler">
				   <Item>
		             <New id="ResourceHandler" class="org.mortbay.jetty.handler.ResourceHandler">
		               <Set name="resourceBase">./logs</Set>
		             </New>
		           </Item>				
					<Item>
						<New id="Contexts" class="org.mortbay.jetty.handler.ContextHandlerCollection" />
					</Item> 
					<Item>   
						<New id="DefaultHandler" class="org.mortbay.jetty.handler.DefaultHandler" /> 
					</Item>  
					<Item> 
						<New id="RequestLog" class="org.mortbay.jetty.handler.RequestLogHandler" /> 
					</Item> 
				</Array> 
			</Set> 
		</New> 
	</Set> -->
	
    <Set name="handler">  
        <New id="Handlers" class="org.mortbay.jetty.handler.HandlerCollection">  
            <Set name="handlers">  
                <Array type="org.mortbay.jetty.Handler">  
                    <Item>  
                        <New id="Contexts" class="org.mortbay.jetty.webapp.WebAppContext">  
                            <Set name="contextPath">/</Set>
                             <Set name="baseResource">
								<Call name="newClassPathResource" class="org.mortbay.resource.Resource" >
									 <Arg>test-webapp</Arg> 
								</Call>
							</Set> 
                            <Set name="resourceBase"><SystemProperty name="jetty.home" default="."/>/test-webapp</Set>
                            <Call name="addServlet">  
                                <Arg>org.mortbay.jetty.servlet.DefaultServlet</Arg>  
                                <Arg>/</Arg>  
                            </Call>
                        </New>  
                    </Item>  
                    
                 	<Item>
						<New id="Contexts" class="org.mortbay.jetty.handler.ContextHandlerCollection" />
					</Item> 
					<Item>   
						<New id="DefaultHandler" class="org.mortbay.jetty.handler.DefaultHandler" /> 
					</Item>  
					<Item> 
						<New id="RequestLog" class="org.mortbay.jetty.handler.RequestLogHandler" /> 
					</Item> 
                </Array>  
            </Set>  
        </New>  
    </Set>  
 	<Ref id="RequestLog">
      <Set name="requestLog">
        <New id="RequestLogImpl" class="org.mortbay.jetty.NCSARequestLog">
          <Set name="filename"><SystemProperty name="jetty.home" default="./logs"/>/request.log</Set>
          <Set name="append">false</Set>
        </New>
      </Set>
    </Ref>
    
<!--      <Call name="addLifeCycle">
      <Arg>
        <New class="org.mortbay.jetty.deployer.WebAppDeployer">
          <Set name="contexts"><Ref id="Contexts"/></Set>
          <Set name="webAppDir"><SystemProperty name="jetty.home" default="."/>/webapps</Set>
        </New>
      </Arg>
    </Call>  -->  

	<Set name="UserRealms">  
        <Array type="org.mortbay.jetty.security.UserRealm"/>  
    </Set>  
    
    <Set name="stopAtShutdown">true</Set>  
    <Set name="sendServerVersion">true</Set>  
    <Set name="gracefulShutdown">1000</Set> 
  
</Configure>

2、

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">

<Configure class="org.mortbay.jetty.webapp.WebAppContext">
    <New id="somewhere" class="org.mortbay.jetty.plus.naming.Resource">
        <Arg>jdbc/somewhere</Arg>
        <Arg>
            <New class="org.hsqldb.jdbc.jdbcDataSource">
                <Set name="Database">jdbc:hsqldb:hsql://localhost/somewhere</Set>
                <Set name="User">sa</Set>
                <Set name="Password"></Set>
            </New>
        </Arg>
    </New>
</Configure>


郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。