1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
package org.kuali.rice.ksb.messaging.bam.service.impl; |
18 |
|
|
19 |
|
import org.apache.log4j.Logger; |
20 |
|
import org.kuali.rice.core.api.config.property.Config; |
21 |
|
import org.kuali.rice.core.api.config.property.ConfigContext; |
22 |
|
import org.kuali.rice.core.api.reflect.ObjectDefinition; |
23 |
|
import org.kuali.rice.ksb.messaging.ServiceInfo; |
24 |
|
import org.kuali.rice.ksb.messaging.bam.BAMParam; |
25 |
|
import org.kuali.rice.ksb.messaging.bam.BAMTargetEntry; |
26 |
|
import org.kuali.rice.ksb.messaging.bam.dao.BAMDAO; |
27 |
|
import org.kuali.rice.ksb.messaging.bam.service.BAMService; |
28 |
|
|
29 |
|
import javax.xml.namespace.QName; |
30 |
|
import java.lang.reflect.Method; |
31 |
|
import java.sql.Timestamp; |
32 |
|
import java.util.List; |
33 |
|
|
34 |
|
|
|
|
| 0% |
Uncovered Elements: 94 (94) |
Complexity: 28 |
Complexity Density: 0.45 |
|
35 |
|
public class BAMServiceImpl implements BAMService { |
36 |
|
|
37 |
|
private static final Logger LOG = Logger.getLogger(BAMServiceImpl.class); |
38 |
|
|
39 |
|
private BAMDAO dao; |
40 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.33 |
|
41 |
0
|
public BAMTargetEntry recordClientInvocation(ServiceInfo serviceDefinition, Object target, Method method, Object[] params) {... |
42 |
0
|
if (isEnabled()) { |
43 |
0
|
try { |
44 |
0
|
LOG.debug("A call was received... for service: " + serviceDefinition.getQname().toString() + " method: " + method.getName()); |
45 |
0
|
BAMTargetEntry bamTargetEntry = getBAMTargetEntry(Boolean.FALSE, serviceDefinition, target, method, params); |
46 |
0
|
this.dao.save(bamTargetEntry); |
47 |
0
|
return bamTargetEntry; |
48 |
|
} catch (Throwable t) { |
49 |
0
|
LOG.error("BAM Failed to record client invocation", t); |
50 |
0
|
return null; |
51 |
|
} |
52 |
|
} |
53 |
0
|
return null; |
54 |
|
} |
55 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
|
56 |
0
|
public BAMTargetEntry recordServerInvocation(Object target, ServiceInfo entry, Method method, Object[] params) {... |
57 |
0
|
if (isEnabled()) { |
58 |
0
|
try { |
59 |
0
|
LOG.debug("A call was received... for service: " + target.getClass().getName() + " method: " + method.getName()); |
60 |
0
|
BAMTargetEntry bamTargetEntry = getBAMTargetEntry(Boolean.TRUE, entry, target, method, params); |
61 |
0
|
this.dao.save(bamTargetEntry); |
62 |
0
|
return bamTargetEntry; |
63 |
|
} catch (Throwable t) { |
64 |
0
|
LOG.error("BAM Failed to record server invocation", t); |
65 |
|
} |
66 |
|
} |
67 |
0
|
return null; |
68 |
|
} |
69 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
70 |
0
|
public BAMTargetEntry recordClientInvocationError(Throwable throwable, BAMTargetEntry bamTargetEntry) {... |
71 |
0
|
if (bamTargetEntry != null) { |
72 |
0
|
try { |
73 |
0
|
setThrowableOnBAMTargetEntry(throwable, bamTargetEntry); |
74 |
0
|
this.dao.save(bamTargetEntry); |
75 |
0
|
return bamTargetEntry; |
76 |
|
} catch (Exception e) { |
77 |
0
|
LOG.error("BAM Failed to record client invocation error", e); |
78 |
|
} |
79 |
|
} |
80 |
0
|
return null; |
81 |
|
} |
82 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
83 |
0
|
public BAMTargetEntry recordServerInvocationError(Throwable throwable, BAMTargetEntry bamTargetEntry) {... |
84 |
0
|
if (bamTargetEntry != null) { |
85 |
0
|
try { |
86 |
0
|
setThrowableOnBAMTargetEntry(throwable, bamTargetEntry); |
87 |
0
|
this.dao.save(bamTargetEntry); |
88 |
0
|
return bamTargetEntry; |
89 |
|
} catch (Exception e) { |
90 |
0
|
LOG.error("BAM Failed to record service invocation error", e); |
91 |
|
} |
92 |
|
} |
93 |
0
|
return null; |
94 |
|
} |
95 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
96 |
0
|
private void setThrowableOnBAMTargetEntry(Throwable throwable, BAMTargetEntry bamTargetEntry) {... |
97 |
0
|
if (throwable != null) { |
98 |
0
|
bamTargetEntry.setExceptionMessage(throwable.getMessage()); |
99 |
0
|
bamTargetEntry.setExceptionToString(makeStringfit(throwable.toString())); |
100 |
|
} |
101 |
|
} |
102 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
|
103 |
0
|
private BAMTargetEntry getBAMTargetEntry(Boolean serverInd, ServiceInfo entry, Object target, Method method, Object[] params) {... |
104 |
0
|
BAMTargetEntry bamEntry = new BAMTargetEntry(); |
105 |
0
|
bamEntry.setServerInvocation(serverInd); |
106 |
0
|
bamEntry.setServiceName(entry.getQname().toString()); |
107 |
0
|
bamEntry.setServiceURL(entry.getEndpointUrl()); |
108 |
0
|
bamEntry.setTargetToString(makeStringfit(target.toString())); |
109 |
0
|
bamEntry.setMethodName(method.getName()); |
110 |
0
|
bamEntry.setThreadName(Thread.currentThread().getName()); |
111 |
0
|
bamEntry.setCallDate(new Timestamp(System.currentTimeMillis())); |
112 |
0
|
setBamParams(params, bamEntry); |
113 |
0
|
return bamEntry; |
114 |
|
} |
115 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
116 |
0
|
private void setBamParams(Object[] params, BAMTargetEntry bamEntry) {... |
117 |
0
|
if (params == null) { |
118 |
0
|
return; |
119 |
|
} |
120 |
0
|
for (int i = 0; i < params.length; i++) { |
121 |
0
|
BAMParam bamParam = new BAMParam(); |
122 |
0
|
bamParam.setBamTargetEntry(bamEntry); |
123 |
0
|
bamParam.setParam(params[i].toString()); |
124 |
0
|
bamEntry.addBamParam(bamParam); |
125 |
|
} |
126 |
|
} |
127 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
128 |
0
|
private String makeStringfit(String string) {... |
129 |
0
|
if (string.length() > 1999) { |
130 |
0
|
return string.substring(0, 1999); |
131 |
|
} |
132 |
0
|
return string; |
133 |
|
} |
134 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
135 |
0
|
public boolean isEnabled() {... |
136 |
0
|
return Boolean.valueOf(ConfigContext.getCurrentContextConfig().getProperty(Config.BAM_ENABLED)); |
137 |
|
} |
138 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
139 |
0
|
public BAMDAO getDao() {... |
140 |
0
|
return this.dao; |
141 |
|
} |
142 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
143 |
0
|
public void setDao(BAMDAO dao) {... |
144 |
0
|
this.dao = dao; |
145 |
|
} |
146 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
147 |
0
|
public List<BAMTargetEntry> getCallsForService(QName serviceName) {... |
148 |
0
|
return getDao().getCallsForService(serviceName); |
149 |
|
} |
150 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
151 |
0
|
public List<BAMTargetEntry> getCallsForRemotedClasses(ObjectDefinition objDef) {... |
152 |
0
|
return getDao().getCallsForRemotedClasses(objDef); |
153 |
|
} |
154 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
155 |
0
|
public void clearBAMTables() {... |
156 |
0
|
getDao().clearBAMTables(); |
157 |
|
} |
158 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
159 |
0
|
public List<BAMTargetEntry> getCallsForService(QName serviceName, String methodName) {... |
160 |
0
|
return getDao().getCallsForService(serviceName, methodName); |
161 |
|
} |
162 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
163 |
0
|
public List<BAMTargetEntry> getCallsForRemotedClasses(ObjectDefinition objDef, String methodName) {... |
164 |
0
|
return getDao().getCallsForRemotedClasses(objDef, methodName); |
165 |
|
} |
166 |
|
} |