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
;
20 import java
.util
.UUID
;
22 import javax
.jms
.Destination
;
23 import javax
.jms
.JMSException
;
24 import javax
.jms
.Message
;
26 import org
.argeo
.slc
.msg
.ReferenceList
;
27 import org
.argeo
.slc
.runtime
.SlcAgent
;
28 import org
.argeo
.slc
.runtime
.SlcAgentFactory
;
29 import org
.springframework
.jms
.core
.JmsTemplate
;
30 import org
.springframework
.jms
.core
.MessagePostProcessor
;
32 public class JmsAgentProxyFactory
implements SlcAgentFactory
{
33 private Destination requestDestination
;
34 private Destination responseDestination
;
35 private Destination pingAllDestination
;
36 private JmsTemplate jmsTemplate
;
38 public SlcAgent
getAgent(String uuid
) {
39 return new JmsAgentProxy(uuid
, requestDestination
, responseDestination
,
43 public void pingAll(List
<String
> activeAgentIds
) {
44 ReferenceList referenceList
= new ReferenceList(activeAgentIds
);
45 jmsTemplate
.convertAndSend(pingAllDestination
, referenceList
,
46 new MessagePostProcessor() {
48 public Message
postProcessMessage(Message message
)
50 message
.setJMSCorrelationID(UUID
.randomUUID()
52 message
.setStringProperty(JmsAgent
.PROPERTY_QUERY
,
53 JmsAgent
.QUERY_PING_ALL
);
59 public void setRequestDestination(Destination requestDestination
) {
60 this.requestDestination
= requestDestination
;
63 public void setResponseDestination(Destination responseDestination
) {
64 this.responseDestination
= responseDestination
;
67 public void setJmsTemplate(JmsTemplate jmsTemplate
) {
68 this.jmsTemplate
= jmsTemplate
;
71 public void setPingAllDestination(Destination pingAllDestination
) {
72 this.pingAllDestination
= pingAllDestination
;