1 17 package org.apache.servicemix.components.pojo; 18 19 import javax.jbi.JBIException; 20 import javax.jbi.component.ComponentContext; 21 import javax.jbi.component.ComponentLifeCycle; 22 import javax.jbi.messaging.ExchangeStatus; 23 import javax.jbi.messaging.MessageExchange; 24 import javax.jbi.messaging.MessagingException; 25 import javax.jbi.messaging.NormalizedMessage; 26 import javax.management.ObjectName ; 27 import javax.xml.namespace.QName ; 28 29 import org.apache.commons.logging.Log; 30 import org.apache.commons.logging.LogFactory; 31 import org.apache.servicemix.MessageExchangeListener; 32 import org.apache.servicemix.tck.MessageList; 33 34 37 38 public class MyReceiver implements ComponentLifeCycle, MessageExchangeListener { 40 private static final Log log = LogFactory.getLog(MyReceiver.class); 41 42 private ComponentContext context; 43 private ObjectName extensionMBeanName; 44 private MessageList messageList = new MessageList(); 45 46 47 public ObjectName getExtensionMBeanName() { 50 return extensionMBeanName; 51 } 52 53 public void init(ComponentContext context) throws JBIException { 54 this.context = context; 55 56 context.activateEndpoint(new QName ("http://servicemix.org/cheese/", "receiver"), "receiver"); 58 } 59 60 public void shutDown() throws JBIException { 61 } 62 63 public void start() throws JBIException { 64 } 65 66 public void stop() throws JBIException { 67 } 68 69 public void onMessageExchange(MessageExchange exchange) throws MessagingException { 72 log.info("Received message " + exchange); 73 NormalizedMessage message = exchange.getMessage("in"); 74 getMessageList().addMessage(message); 75 exchange.setStatus(ExchangeStatus.DONE); 76 context.getDeliveryChannel().send(exchange); 77 } 78 79 public void setExtensionMBeanName(ObjectName extensionMBeanName) { 82 this.extensionMBeanName = extensionMBeanName; 83 } 84 85 public MessageList getMessageList() { 86 return messageList; 87 } 88 89 public void setMessageList(MessageList messageList) { 90 this.messageList = messageList; 91 } 92 } 93 | Popular Tags |