1 /* 2 * $Id: AbstractResponseRouter.java 11567 2008-04-11 13:08:05Z dirk.olmes $ 3 * -------------------------------------------------------------------------------------- 4 * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com 5 * 6 * The software in this package is published under the terms of the CPAL v1.0 7 * license, a copy of which has been included with this distribution in the 8 * LICENSE.txt file. 9 */ 10 11 package org.mule.routing.response; 12 13 import org.mule.api.MuleMessage; 14 import org.mule.api.routing.MessageInfoMapping; 15 import org.mule.api.routing.ResponseRouter; 16 import org.mule.routing.AbstractRouter; 17 import org.mule.routing.MuleMessageInfoMapping; 18 19 import org.apache.commons.logging.Log; 20 import org.apache.commons.logging.LogFactory; 21 22 /** 23 * <code>AbstractResponseRouter</code> is a base class for all Response Routers 24 */ 25 26 public abstract class AbstractResponseRouter extends AbstractRouter implements ResponseRouter 27 { 28 protected final Log logger = LogFactory.getLog(getClass()); 29 30 protected MessageInfoMapping messageInfoMapping = new MuleMessageInfoMapping(); 31 32 33 public MessageInfoMapping getMessageInfoMapping() 34 { 35 return messageInfoMapping; 36 } 37 38 public void setMessageInfoMapping(MessageInfoMapping messageInfoMapping) 39 { 40 this.messageInfoMapping = messageInfoMapping; 41 } 42 43 44 /** 45 * Extracts a 'Correlation Id' from a reply message. The correlation Id does not 46 * have to be the Message Correlation Id. It can be extracted from the message 47 * payload if desired. 48 * 49 * @param message a received reply message 50 * @return the correlation Id for this message 51 */ 52 protected Object getReplyAggregateIdentifier(MuleMessage message) 53 { 54 return messageInfoMapping.getCorrelationId(message); 55 } 56 57 /** 58 * Extracts a Group identifier from the current event. When an event is received 59 * with a group identifier not registered with this router, a new group is 60 * created. The id returned here can be a correlationId or some custom 61 * aggregation Id. This implementation uses the Unique Message Id of the 62 * MuleMessage being returned a 63 * 64 * @param message A response messages received on the response router endpoint 65 * @return an aggregation Id for this event 66 */ 67 protected Object getCallResponseAggregateIdentifier(MuleMessage message) 68 { 69 return messageInfoMapping.getMessageId(message); 70 } 71 }