Get list of contexts in tomcat server -
I have several mini-wires that have modules for large applications running on the Tomcat 6.0 server. I'm doing this instead of putting all the modules in a war, because different establishments require different modules. I am starting to hit a roadblock, in which I have to know how other mini warriors are installed in the server. What is the procedure for getting a list of all installed war / references in the Tomcat 6.0 server?
i managed to solve this problem because since I will create "mini wars" The loader can share a lib in the tomcat at the level. This trick will be to use a ApplicationListener
(located in the normal class loader) which does the following:
Public class ApplicationListener ServletContextListener {Private Static Map & lt; String, ServletContext & gt; Reference = New Hashmap & lt; String, circlet contact & gt; (); Public Zero Concept Begins (ServletContextEvent Event) {ServletContext References = event.getServletContext (); If (context.getContextPath (.) Length ()> 0) contexts.put (context.getContextPath (), reference); Context.setAttribute ("myapps", application); }}
When a reference
is created, it registers in the static map as ServletContext
. This static map is then shared between all references via context
variable myapps
. Any time I need access to other references, I can do the following:
get ServletContext namecontext = (ServletContext) ServletContext.getAttribute ("myapps")) ("/ Nameapp ");
Hope it helps someone.
Comments
Post a Comment