01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.servicemix.tck;
18:
19: import javax.jbi.messaging.MessageExchange;
20: import javax.jbi.messaging.MessagingException;
21: import javax.jbi.messaging.NormalizedMessage;
22: import javax.xml.namespace.QName;
23:
24: import org.apache.servicemix.MessageExchangeListener;
25: import org.apache.servicemix.components.util.ComponentSupport;
26:
27: /**
28: * @version $Revision: 470478 $
29: */
30: public class ReceiverComponent extends ComponentSupport implements
31: MessageExchangeListener, Receiver {
32:
33: public static final QName SERVICE = new QName(
34: "http://servicemix.org/example/", "receiver");
35: public static final String ENDPOINT = "receiver";
36:
37: private MessageList messageList = new MessageList();
38:
39: public ReceiverComponent() {
40: this (SERVICE, ENDPOINT);
41: }
42:
43: public ReceiverComponent(QName service, String endpoint) {
44: super (service, endpoint);
45: }
46:
47: // MessageExchangeListener interface
48: //-------------------------------------------------------------------------
49: public void onMessageExchange(MessageExchange exchange)
50: throws MessagingException {
51: NormalizedMessage inMessage = getInMessage(exchange);
52: // Copy message to avoid possible closed stream exceptions
53: // when using StreamSource
54: NormalizedMessage copyMessage = exchange.createMessage();
55: getMessageTransformer().transform(exchange, inMessage,
56: copyMessage);
57: messageList.addMessage(copyMessage);
58: done(exchange);
59: }
60:
61: // Receiver interface
62: //-------------------------------------------------------------------------
63: public MessageList getMessageList() {
64: return messageList;
65: }
66: }
|