1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.kuali.student.common.ws; |
17 |
|
|
18 |
|
import java.util.Enumeration; |
19 |
|
import java.util.Properties; |
20 |
|
|
21 |
|
import javax.servlet.Servlet; |
22 |
|
import javax.servlet.ServletConfig; |
23 |
|
import javax.servlet.ServletContext; |
24 |
|
import javax.servlet.http.HttpServletRequest; |
25 |
|
import javax.servlet.http.HttpServletResponse; |
26 |
|
|
27 |
|
import org.apache.log4j.Logger; |
28 |
|
import org.springframework.beans.factory.BeanNameAware; |
29 |
|
import org.springframework.beans.factory.DisposableBean; |
30 |
|
import org.springframework.beans.factory.InitializingBean; |
31 |
|
import org.springframework.web.servlet.ModelAndView; |
32 |
|
import org.springframework.web.servlet.mvc.AbstractController; |
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
|
|
| 0% |
Uncovered Elements: 40 (40) |
Complexity: 12 |
Complexity Density: 0.46 |
|
40 |
|
public class ServletWrappingController extends AbstractController implements |
41 |
|
BeanNameAware, InitializingBean, DisposableBean { |
42 |
|
private Class<? extends Servlet> servletClass; |
43 |
|
private String servletName; |
44 |
|
private Properties initParameters = new Properties(); |
45 |
|
private String beanName; |
46 |
|
private Servlet servletInstance; |
47 |
|
|
48 |
|
private static org.apache.log4j.Logger log = Logger.getLogger(ServletWrappingController.class); |
49 |
|
|
50 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
51 |
0
|
public void setServletClass(Class<? extends Servlet> servletClass) {... |
52 |
0
|
log.info("setServletClass : " + servletClass); |
53 |
0
|
this.servletClass = servletClass; |
54 |
|
} |
55 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
56 |
0
|
public void setServletName(String servletName) {... |
57 |
0
|
log.info("setServletName : " + servletName); |
58 |
0
|
this.servletName = servletName; |
59 |
|
} |
60 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
61 |
0
|
public void setInitParameters(Properties initParameters) {... |
62 |
0
|
log.info("setInitParameters : " + initParameters); |
63 |
0
|
this.initParameters = initParameters; |
64 |
|
} |
65 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
66 |
0
|
public void setBeanName(String name) {... |
67 |
0
|
log.info("setBeanName : " + name); |
68 |
0
|
this.beanName = name; |
69 |
|
} |
70 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
71 |
0
|
public void setServletInstance(Servlet servletInstance) {... |
72 |
0
|
log.info("setServletInstance : " + servletInstance); |
73 |
0
|
this.servletInstance = servletInstance; |
74 |
|
} |
75 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 4 |
Complexity Density: 0.5 |
|
76 |
0
|
public void afterPropertiesSet() throws Exception {... |
77 |
0
|
log.info("afterPropertiesSet"); |
78 |
0
|
if (this.servletInstance == null) { |
79 |
0
|
throw new IllegalArgumentException("servletInstance is required"); |
80 |
|
} |
81 |
0
|
if (!Servlet.class.isAssignableFrom(servletInstance.getClass())) { |
82 |
0
|
throw new IllegalArgumentException("servletInstance [" |
83 |
|
+ this.servletClass.getName() |
84 |
|
+ "] needs to implement interface [javax.servlet.Servlet]"); |
85 |
|
} |
86 |
0
|
if (this.servletName == null) { |
87 |
0
|
this.servletName = this.beanName; |
88 |
|
} |
89 |
0
|
this.servletInstance.init(new DelegatingServletConfig()); |
90 |
|
} |
91 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.33 |
|
92 |
0
|
protected ModelAndView handleRequestInternal(HttpServletRequest request,... |
93 |
|
HttpServletResponse response) throws Exception { |
94 |
0
|
log.info("handleRequestInternal : " + servletName); |
95 |
0
|
try{ |
96 |
0
|
this.servletInstance.service(request, response); |
97 |
|
}catch(Exception e){ |
98 |
0
|
log.error(e.getMessage()); |
99 |
0
|
throw e; |
100 |
|
} |
101 |
|
|
102 |
0
|
return null; |
103 |
|
} |
104 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
105 |
0
|
public void destroy() {... |
106 |
0
|
log.info("destroy : " + servletName); |
107 |
0
|
this.servletInstance.destroy(); |
108 |
|
} |
109 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 4 |
Complexity Density: 1 |
|
110 |
|
private class DelegatingServletConfig implements ServletConfig { |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
111 |
0
|
public String getServletName() {... |
112 |
0
|
return servletName; |
113 |
|
} |
114 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
115 |
0
|
public ServletContext getServletContext() {... |
116 |
0
|
return getWebApplicationContext().getServletContext(); |
117 |
|
} |
118 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
119 |
0
|
public String getInitParameter(String paramName) {... |
120 |
0
|
return initParameters.getProperty(paramName); |
121 |
|
|
122 |
|
} |
123 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
124 |
0
|
public Enumeration<?> getInitParameterNames() {... |
125 |
0
|
return initParameters.keys(); |
126 |
|
} |
127 |
|
} |
128 |
|
} |