2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
4 * Licensed under the Apache 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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org
.argeo
.slc
.jms
;
19 import java
.util
.List
;
21 import javax
.jms
.Destination
;
23 import org
.apache
.commons
.logging
.Log
;
24 import org
.apache
.commons
.logging
.LogFactory
;
25 import org
.argeo
.slc
.UnsupportedException
;
26 import org
.argeo
.slc
.execution
.ExecutionProcess
;
27 import org
.argeo
.slc
.msg
.process
.SlcExecutionStatusRequest
;
28 import org
.argeo
.slc
.msg
.process
.SlcExecutionStepsRequest
;
29 import org
.argeo
.slc
.process
.SlcExecution
;
30 import org
.argeo
.slc
.process
.SlcExecutionNotifier
;
31 import org
.argeo
.slc
.process
.SlcExecutionStep
;
32 import org
.springframework
.jms
.JmsException
;
33 import org
.springframework
.jms
.core
.JmsTemplate
;
35 @SuppressWarnings("deprecation")
36 public class JmsSlcExecutionNotifier
implements SlcExecutionNotifier
{
37 private final static Log log
= LogFactory
38 .getLog(JmsSlcExecutionNotifier
.class);
40 private JmsTemplate jmsTemplate
;
42 private Destination executionEventDestination
;
44 // private Destination updateStatusDestination;
46 public void updateStatus(ExecutionProcess slcExecution
, String oldStatus
,
48 SlcExecutionStatusRequest req
= new SlcExecutionStatusRequest(
49 slcExecution
.getUuid(), newStatus
);
53 public void addSteps(ExecutionProcess slcExecution
,
54 List
<SlcExecutionStep
> additionalSteps
) {
55 SlcExecutionStepsRequest req
= new SlcExecutionStepsRequest(
56 slcExecution
.getUuid(), additionalSteps
);
60 public void newExecution(SlcExecution slcExecution
) {
61 throw new UnsupportedException();
64 public void updateExecution(SlcExecution slcExecution
) {
65 throw new UnsupportedException();
68 public void setJmsTemplate(JmsTemplate jmsTemplate
) {
69 this.jmsTemplate
= jmsTemplate
;
72 public void setExecutionEventDestination(
73 Destination executionEventDestination
) {
74 this.executionEventDestination
= executionEventDestination
;
77 protected void convertAndSend(Object req
) {
79 jmsTemplate
.convertAndSend(executionEventDestination
, req
);
80 } catch (JmsException e
) {
81 log
.warn("Send request " + req
.getClass() + " to server: "
83 if (log
.isTraceEnabled())
84 log
.debug("Original error.", e
);