1 package org
.argeo
.slc
.jms
;
3 import javax
.jms
.Destination
;
5 import org
.apache
.commons
.logging
.Log
;
6 import org
.apache
.commons
.logging
.LogFactory
;
7 import org
.argeo
.slc
.SlcException
;
8 import org
.argeo
.slc
.core
.test
.tree
.TreeTestResult
;
9 import org
.argeo
.slc
.msg
.test
.tree
.CloseTreeTestResultRequest
;
10 import org
.argeo
.slc
.msg
.test
.tree
.CreateTreeTestResultRequest
;
11 import org
.argeo
.slc
.msg
.test
.tree
.ResultPartRequest
;
12 import org
.argeo
.slc
.test
.TestResultListener
;
13 import org
.argeo
.slc
.test
.TestResultPart
;
14 import org
.springframework
.jms
.core
.JmsTemplate
;
16 public class JmsTreeTestResultListener
implements
17 TestResultListener
<TreeTestResult
> {
18 private final Log log
= LogFactory
.getLog(getClass());
20 private Boolean onlyOnClose
= false;
21 private JmsTemplate jmsTemplate
;
23 private Destination createDestination
;
24 private Destination addResultPartDestination
;
25 private Destination closeDestination
;
27 public void resultPartAdded(TreeTestResult testResult
,
28 TestResultPart testResultPart
) {
33 if (testResult
.getResultParts().size() == 1
34 && testResult
.getResultParts().values().iterator().next()
35 .getParts().size() == 1) {
36 CreateTreeTestResultRequest req
= new CreateTreeTestResultRequest(
39 if (log
.isDebugEnabled())
40 log
.debug("Send create result request for result "
41 + testResult
.getUuid());
43 jmsTemplate
.convertAndSend(createDestination
, req
);
45 ResultPartRequest req
= new ResultPartRequest(testResult
);
47 if (log
.isDebugEnabled())
48 log
.debug("Send result parts for result "
49 + testResult
.getUuid());
51 jmsTemplate
.convertAndSend(addResultPartDestination
, req
);
53 } catch (Exception e
) {
54 throw new SlcException("Could not notify to JMS", e
);
58 public void close(TreeTestResult testResult
) {
61 CreateTreeTestResultRequest req
= new CreateTreeTestResultRequest(
64 if (log
.isDebugEnabled())
65 log
.debug("Send create result request for result "
66 + testResult
.getUuid());
68 jmsTemplate
.convertAndSend(createDestination
, req
);
70 CloseTreeTestResultRequest req
= new CloseTreeTestResultRequest(
73 if (log
.isDebugEnabled())
74 log
.debug("Send close result request for result "
75 + testResult
.getUuid());
77 jmsTemplate
.convertAndSend(closeDestination
, req
);
80 } catch (Exception e
) {
81 throw new SlcException("Could not notify to JMS", e
);
85 public void setOnlyOnClose(Boolean onlyOnClose
) {
86 this.onlyOnClose
= onlyOnClose
;
89 public void setJmsTemplate(JmsTemplate jmsTemplate
) {
90 this.jmsTemplate
= jmsTemplate
;
93 public void setCreateDestination(Destination createDestination
) {
94 this.createDestination
= createDestination
;
97 public void setAddResultPartDestination(Destination addResultPartDestination
) {
98 this.addResultPartDestination
= addResultPartDestination
;
101 public void setCloseDestination(Destination closeDestination
) {
102 this.closeDestination
= closeDestination
;