码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2014-11-25 11:03:12      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:style   http   io   ar   os   sp   strong   on   log   

它的根节点支持申明?? 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>


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

标签:style   http   io   ar   os   sp   strong   on   log   

原文地址:http://my.oschina.net/frankies/blog/348403

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!