µ±Ç°Î»ÖÃ: > Linux·þÎñÆ÷ > Tomcat >

Tomcatѧϰ֮Engine

ʱ¼ä:2014-12-30 13:21À´Ô´:linux.it.net.cn ×÷Õß:IT
Enginetomcat engineÊÇÒ»¸öÍêÕûµÄServletÈÝÆ÷£¬ÆäÏÂÃæÓµÓжà¸öÐéÄâÖ÷»ú£¬ËüµÄÔðÈξÍÊǽ«Óû§ÇëÇó·ÖÅä¸øÒ»¸öÐéÄâÉÏ»ú´¦Àí¡£½Ó¿ÚEngine´ú±íÒ»¸öServletÒýÇ棬ÆäʵÏÖÀàÊÇStandardEngine£¬ÏÈÀ´¿´¿´¹¹Ôì·½·¨

 

[html] view plaincopyprint?
  1. public StandardEngine() {  
  2.   
  3.     super();  
  4.     pipeline.setBasic(new StandardEngineValve());  
  5.     /* Set the jmvRoute using the system property jvmRoute */  
  6.     try {  
  7.         setJvmRoute(System.getProperty("jvmRoute"));  
  8.     } catch(Exception ex) {  
  9.         log.warn(sm.getString("standardEngine.jvmRouteFail"));  
  10.     }  
  11.     // By default, the engine will hold the reloading thread  
  12.     backgroundProcessorDelay = 10;  
  13.   
  14. }  
Õâ¸ö·½·¨ÔÚDigester½âÎöServer.xmlʱ»áµ÷Óã¬ËüÊ×ÏÈÉèÖÃÒ»¸ö»ù±¾·§ÃÅ£¬È»ºóÉèÖÃJVMRoute£¬Õâ¸öÔÚclusterÖлáÓõ½£¬È»ºóΪbackgroundProcessorDelay¸³³õÖµ£¬backgroundProcessorDelayµÄº¬ÒåÔÚÇ°ÃæÓн²¹ý¡£

 

À´¿´¿´Õâ¸ö»ù±¾·§ÃÅ(StandardEngineValve)×öÁËÄÄЩÊÂ,ÕâÀïÃæ×îÖØÒªµÄÊÇËüµÄinvoke·½·¨

 

[html] view plaincopyprint?
  1. public final void invoke(Request request, Response response)  
  2.        throws IOException, ServletException {  
  3.   
  4.        // Select the Host to be used for this Request  
  5.        Host host = request.getHost();  
  6.        if (host == null) {  
  7.            response.sendError  
  8.                (HttpServletResponse.SC_BAD_REQUEST,  
  9.                 sm.getString("standardEngine.noHost",   
  10.                              request.getServerName()));  
  11.            return;  
  12.        }  
  13.        if (request.isAsyncSupported()) {  
  14.            request.setAsyncSupported(host.getPipeline().isAsyncSupported());  
  15.        }  
  16.   
  17.        // Ask this Host to process this request  
  18.        host.getPipeline().getFirst().invoke(request, response);  
  19.   
  20.    }  
Ö»×öÁËÁ½¼þÊ£º

 

(1)Ñ¡ÔñÒ»¸öÖ÷»úÀ´´¦ÀíÓû§ÇëÇó

(2)Èç¹ûÇëÇóÊÇÒì²½µÄ£¬ÉèÖÃÒì²½±ê־λ

ÖÁÓÚÒýÇæµÄ³õʼ»¯ºÍÆô¶¯ºÜ¼òµ¥£¬Ç°ÃæÓн²¹ýServiceµÄ³õʼ»¯»áÏȳõʼ»¯ÈÝÆ÷£¬ÔÙ³õʼ»¯Á¬½ÓÆ÷¡£¶ÔÈÝÆ÷µÄ³õʼ»¯Ê×ÏȾͻá³õʼ»¯¶¥¼¶ÈÝÆ÷£¬Ò²¾ÍÊÇengine,ÒýÇæµÄÆô¶¯Ò²ÊÇÔÚServiceµÄÆô¶¯ÖÐÍê³ÉµÄ¡£¶ÔÓÚÈÝÆ÷µÄÕû¸ö³õʼ»¯ºÍÆô¶¯¹ý³Ìµ½Ê±»áµ¥¶À·ÖÎö¡£

À´¿´¿´engineµÄÅäÖÃ

 

[html] view plaincopyprint?
  1. <Engine name="Catalina" defaultHost="localhost">  
  2.       <Realm className="org.apache.catalina.realm.LockOutRealm">  
  3.         <Realm className="org.apache.catalina.realm.UserDatabaseRealm"  
  4.                resourceName="UserDatabase"/>  
  5.       </Realm>  
  6.   
  7.       <Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true">  
  8.         <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"    
  9.                prefix="localhost_access_log." suffix=".txt"  
  10.                pattern="%h %l %u %t "%r" %s %b" resolveHosts="false"/>  
  11.   
  12.       </Host>  
  13. </Engine>  
nameÊôÐÔÊÇÒýÇæµÄÂß¼­Ãû³Æ£¬ÔÚÈÕÖ¾ºÍ´íÎóÏûÏ¢ÖлáÓõ½£¬ÔÚͬһ̨·þÎñÆ÷ÉÏÓжà¸öServiceʱ£¬name±ØÐëΨһ¡£

 

defaultHostÖ¸¶¨Ä¬ÈÏÖ÷»ú£¬Èç¹ûûÓзÖÅäÄĸöÖ÷»úÀ´Ö´ÐÐÓû§ÇëÇó£¬ÓÉÕâ¸öÖµËùÖ¸¶¨µÄÖ÷»úÀ´´¦Àí£¬Õâ¸öÖµ±ØÐëºÍ<Host>ÔªËØÖеÄÆäÖÐÒ»¸öÏàͬ¡£

EngineÀïÃæ³ýÁË¿ÉÒÔÖ¸¶¨ÊôÐÔÖ®Í⣬»¹¿ÉÒÔÓÐÆäËü×é¼þ£¬±ÈÈ磺log,listener,filter,realmµÈ,ºóÃæ»áµ¥¶À·ÖÎö.

(ÔðÈα༭£ºIT)
------·Ö¸ôÏß----------------------------
À¸Ä¿Áбí
ÍƼöÄÚÈÝ