1 16 package org.apache.axis.ime.internal; 17 18 import org.apache.axis.MessageContext; 19 import org.apache.axis.components.logger.LogFactory; 20 import org.apache.axis.ime.MessageExchangeCorrelator; 21 import org.apache.axis.ime.MessageExchangeEventListener; 22 import org.apache.axis.ime.event.MessageFaultEvent; 23 import org.apache.axis.ime.event.MessageReceiveEvent; 24 import org.apache.axis.ime.internal.util.KeyedBuffer; 25 import org.apache.commons.logging.Log; 26 27 31 public class FirstComeFirstServeDispatchPolicy 32 implements ReceivedMessageDispatchPolicy { 33 34 protected static Log log = 35 LogFactory.getLog(FirstComeFirstServeDispatchPolicy.class.getName()); 36 37 protected KeyedBuffer RECEIVE_REQUESTS; 38 protected KeyedBuffer RECEIVE; 39 40 public FirstComeFirstServeDispatchPolicy( 41 KeyedBuffer RECEIVE, 42 KeyedBuffer RECEIVE_REQUESTS) { 43 this.RECEIVE = RECEIVE; 44 this.RECEIVE_REQUESTS = RECEIVE_REQUESTS; 45 } 46 47 public void dispatch( 48 MessageExchangeSendContext context) { 49 50 if (log.isDebugEnabled()) { 51 log.debug("Enter: FirstComeFirstServeDispatchPolicy::dispatch"); 52 } 53 54 60 MessageExchangeReceiveContext receiveContext = null; 61 MessageExchangeCorrelator correlator = 62 context.getMessageExchangeCorrelator(); 63 receiveContext = (MessageExchangeReceiveContext)RECEIVE_REQUESTS.get(correlator); 64 if (receiveContext == null) { 65 receiveContext = (MessageExchangeReceiveContext)RECEIVE_REQUESTS.get(SimpleMessageExchangeCorrelator.NULL_CORRELATOR); 66 } 67 if (receiveContext == null) 68 RECEIVE.put(correlator,context); 69 else { 70 MessageExchangeEventListener eventListener = 71 receiveContext.getMessageExchangeEventListener(); 72 MessageContext msgContext = 73 context.getMessageContext(); 74 try { 75 MessageReceiveEvent receiveEvent = 76 new org.apache.axis.ime.event.MessageReceiveEvent( 77 correlator, 78 receiveContext, 79 context.getMessageContext()); 80 eventListener.onEvent(receiveEvent); 81 } catch (Exception exception) { 82 if (eventListener != null) { 83 MessageFaultEvent faultEvent = new MessageFaultEvent( 84 correlator, 85 exception); 86 eventListener.onEvent(faultEvent); 87 } 88 } 89 } 90 if (log.isDebugEnabled()) { 91 log.debug("Exit: FirstComeFirstServeDispatchPolicy::dispatch"); 92 } 93 94 } 95 96 } 97 | Popular Tags |