Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CXF and multiple servlet mappings

Currently we have a Java webapp with a Spring MVC DispatcherServlet and two CXFServlets. The DispatcherServlet is the default servlet (mapping /), one CXFServlet maps to /api/*, the other to /services/*.

What is bugging me, is that it seems impossible to have 1 CXFServlet that hosts 2 services, one on /api/v0 and one on /services/myService, without mapping /* to the CXFServlet. If this were possible, it would save the initialisation time, config hassle and memory requirements of another servlet instance.

So basically, my question is if anyone knows of a way to host 2 CXF services on 2 URLs in 1 CXFServlet, without a common base/root URL, preferably using the Spring namespaces config, without mapping /* to the CXFServlet?

like image 583
MikeN Avatar asked Jan 07 '13 23:01

MikeN


1 Answers

The invoke method of the CXF ServletController first calls HttpServletRequest#getPathInfo, which returns the part of the requested URL without the servlet's url-pattern. The result of this call is then used to match any defined service through a call to DestinationRegistry#getDestinationForPath. It is therefore currently impossible to have CXF match services using a path with the servlet part included — CXF never calls HttpServletRequest#getServletPath which would be needed for this.

Note that the base-address value that can be set in the servlet's initialisation parameters (<init-param>) will only affect any URLs that CXF displays, because the ServletController#getBaseURL method that uses this value is not used during service invocation.

like image 108
praseodym Avatar answered Nov 14 '22 04:11

praseodym