Hi I want to change tomcat-server.xml of embedded tomcat in Virgo programatically. What are the possible options for that?
Is there a way/ API through which I can change the tomcat server.xml through coding?
We just need to know if there is a way for parsing + modification through the configurations APIs of Apache/tomcat (if there is any)
Embedded Tomcat typically doesn't use tomcat-server.xml, because the embedded Tomcat is a JavaBean and it is configured using POJO properties on the Tomcat bean. Which is basically what tomcat-server.xml is for - it's a set of specifications for configuring the Tomcat startup.
So the answer to your question depends on how Virgo configures Tomcat. I've never heard of Virgo, myself, though.
An IDE is no substitute for an Intelligent Developer.
Joined: Apr 24, 2012
In general how can I get the control to change the connector attributes from tomcat server.xml like port timeout etc through API.
Are there any exposed API if I have the handle to read the server.xml.
My moto is to chnage the server.xml programatically which will allow me to call APIs like setPort() or setConnectionTimeout() etc which will change the setting for tomcat server. This can be static or dynamic in whichever way it is possible.
If it works for standalone tomcat , possibly it will work for Virgo Tomcat Server as well which is nothibg but the OSGi implementation of Equinox giving a support for tomcat through embedding it in Virgo.
Please let me know if there is a way to get the handle of the tomcat server or some of the configuration related classes of tomcat and which can be changed programatically.
Server.xml is digested and processed when Tomcat starts up and ignored until the next startup, so changing it for the purpose of dynamically modifying Tomcat is futile - that's why you're not supposed to put Context elements in server.xml.
Once Tomcat is running, an embedded Tomcat is a JavaBean and you dynamically modify it using the bean methods. This, of course, supposes that you own the bean.
For external dynamic controls, there are several interfaces, including JMX, JSR-77, JSR-88 (and their successors), the Tomcat management webapps (if installed).