Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
CXFServletControllerAdapter |
|
| 1.0;1 |
1 | /* | |
2 | * Copyright 2007-2008 The Kuali Foundation | |
3 | * | |
4 | * Licensed under the Educational Community License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.opensource.org/licenses/ecl2.php | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | package org.kuali.rice.ksb.messaging.servlet; | |
17 | ||
18 | import javax.servlet.http.HttpServletRequest; | |
19 | import javax.servlet.http.HttpServletResponse; | |
20 | ||
21 | import org.apache.cxf.BusFactory; | |
22 | import org.apache.cxf.transport.servlet.ServletController; | |
23 | import org.kuali.rice.ksb.messaging.ServiceInfo; | |
24 | import org.kuali.rice.ksb.service.KSBServiceLocator; | |
25 | import org.springframework.web.servlet.ModelAndView; | |
26 | import org.springframework.web.servlet.mvc.Controller; | |
27 | ||
28 | /** | |
29 | * An adapter for the {@link ServletController} so that it conforms to Springs MVC {@link Controller} interface. | |
30 | * | |
31 | * | |
32 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
33 | * | |
34 | */ | |
35 | public class CXFServletControllerAdapter | |
36 | implements Controller{ | |
37 | ||
38 | private ServiceInfo serviceInfo; | |
39 | private ServletController controller; | |
40 | ||
41 | 0 | public CXFServletControllerAdapter(ServiceInfo serviceInfo){ |
42 | 0 | this.serviceInfo = serviceInfo; |
43 | 0 | } |
44 | ||
45 | /** | |
46 | * This method invokes the cxf servlet controller | |
47 | * | |
48 | * @see org.springframework.web.servlet.mvc.Controller#handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) | |
49 | */ | |
50 | public ModelAndView handleRequest(HttpServletRequest request, | |
51 | HttpServletResponse response) throws Exception { | |
52 | ||
53 | try { | |
54 | 0 | BusFactory.setThreadDefaultBus(KSBServiceLocator.getCXFBus()); |
55 | 0 | controller.invoke(request, response); |
56 | 0 | } finally { |
57 | 0 | BusFactory.setThreadDefaultBus(null); |
58 | 0 | } |
59 | ||
60 | 0 | return null; |
61 | } | |
62 | ||
63 | public void setController(ServletController controller){ | |
64 | 0 | this.controller = controller; |
65 | 0 | } |
66 | } |