Can the Java / Scala / etc code tell Tomcat when to run it?
I have my webapp data in a database that can be accessed in different ways from different places There is no common code to do this for both So I want to know the env I use at runtime In fact, the running code actually depends on whether it runs inside Tomcat or not, so I want to detect it at run time What should I do@ H_ 403_ 4@
resolvent
Solution
I agree with kbrasee that this is not a good situation, so I will take it away as much as possible if I can
That is, assuming that you have no choice and need to do so, they will perform this operation in the Liferay implementation Look at the serverdetector class
You will notice_ The detect method (near the bottom) looks for the identified class if it runs on a given server They're at Tomcat_ BOOTSTRAP_ Class and Tomcat_ EMBEDDED_ The top of the class constant defines the class
We encountered a problem in detecting embedded Tomcat in GlassFish I'm not sure if it has been fixed in the version I linked, but it may not be a problem for you