我需要修改代码,Tomcat的server.xml。
好吧,这只是一个XML文件,有很多方法可以解析它,但我想知道是否已经有专门针对server.xml的API (例如,来自Apache),并且不需要编写任何代码来解析它。
那有吗?
注意:解析server.xml的程序将“离线”解析它,即它不是Valve的一部分,也不是可以访问容器的其他组件的一部分
发布于 2011-09-01 04:07:19
用xml生成xsd (使用IDEA或something) ->用xsd生成jaxb表示(使用jaxb)不会花很长时间。
发布于 2011-09-01 05:53:16
您可以使用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.发布于 2016-04-06 01:22:15
以编程的方式来做这件事是不是一种好的做法?
https://stackoverflow.com/questions/7262711
复制相似问题