2011-08-31 67 views
0

我需要修改代碼,Tomcat的server.xml
好吧,它只是一個XML文件,並且有很多方法可以解析它,但我想知道是否已經有專門用於server.xml(例如來自Apache)的API,並且不必編寫任何代碼來解析它。
那麼那裏?
注:解析server.xml會做的節目「下線」,即它是不是有訪問容器Tomcat server.xml解析器

回答

2

生成的XML XSD一個Valve或一些其它部件的一部分(使用IDEA或something) - >通過xsd(使用jaxb)生成jaxb表示不會花費很長時間

1

您可以使用Tomcat用於加載server.xml(即Commons Digester)的相同分析例程。通過這種方式,您可以重複使用常規Tomcat catalina.jar,並避免生成的代碼比過時的代碼複雜。

startup sequence文檔:

 b3) createStartDigester() 
      Configures a digester for the main server.xml elements like 
      org.apache.catalina.core.StandardServer (can change of course :) 
      org.apache.catalina.deploy.NamingResources 
       Stores naming resources in the J2EE JNDI tree 
      org.apache.catalina.LifecycleListener 
       implements events for start/stop of major components 
      org.apache.catalina.core.StandardService 
       The single entry for a set of connectors, 
       so that a container can listen to multiple connectors 
       ie, single entry 
      org.apache.coyote.tomcat5.CoyoteConnector 
       Connectors to listen for incoming requests only 
      It also adds the following rulesets to the digester 
       NamingRuleSet 
       EngineRuleSet 
       HostRuleSet 
       ContextRuleSet 
     b4) Load the server.xml and parse it using the digester 
      Parsing the server.xml using the digester is an automatic 
      XML-object mapping tool, that will create the objects defined in server.xml 
      Startup of the actual container has not started yet. 
0

它甚至有一個很好的做法去做,以編程方式?

+0

如果您正在製作安裝程序 – spy