@Override public Context getContext(Message message) { if (_message != null && _message == message) { return getContext(); } return message.getContext(); }
/** * {@inheritDoc} */ @Override public Context getContext() { return getMessage().getContext(); }
/** * {@inheritDoc} */ @Override public Context getContext() { return getMessage().getContext(); }
@Override public Context getContext(Message message) { if (_exchange.getIn() == message) { return getContext(); } return message.getContext(); }
@Override public Context getContext(Message message) { if (_message != null && _message == message) { return getContext(); } return message.getContext(); }
@Override public Context getContext(Message message) { if (_exchange.getIn() == message) { return getContext(); } return message.getContext(); }
private static Object run(Message message, Expression expression, Map<String, Object> expressionVariables) { Map<String, Object> variables = new HashMap<String, Object>(); if (expressionVariables != null) { variables.putAll(expressionVariables); } // these always take precedence! variables.put(CONTEXT, new ContextMap(message.getContext(), Scope.MESSAGE)); variables.put(MESSAGE, message); return expression.run(variables); }
private static Object run(Message message, Expression expression, Map<String, Object> expressionVariables) { Map<String, Object> variables = new HashMap<String, Object>(); if (expressionVariables != null) { variables.putAll(expressionVariables); } // these always take precedence! variables.put(CONTEXT, new ContextMap(message.getContext(), Scope.MESSAGE)); variables.put(MESSAGE, message); return expression.run(variables); }
/** * Associate this instance with the supplied message context. * @param message associate the transform to this message */ public void associateWith(Message message) { message.getContext().setProperty(TransformSequence.class.getName(), this) .addLabels(BehaviorLabel.TRANSIENT.label()); }
/** * Associate this instance with the supplied message context. * @param message associate the transform to this message */ public void associateWith(Message message) { message.getContext().setProperty(TransformSequence.class.getName(), this) .addLabels(BehaviorLabel.TRANSIENT.label()); }
@Override public synchronized void sendFault(Message message) { assertMessageOK(message); // You can't send a fault before you send a message if (_phase == null) { throw RuntimeMessages.MESSAGES.sendFaultNotAllowed(); } _phase = ExchangePhase.OUT; _state = ExchangeState.FAULT; initFaultContentType(); // set relatesTo header on OUT context message.getContext().setProperty(RELATES_TO, _message.getContext().getPropertyValue(MESSAGE_ID)) .addLabels(BehaviorLabel.TRANSIENT.label()); sendInternal(message); }
@Override public synchronized void sendFault(Message message) { assertMessageOK(message); // You can't send a fault before you send a message if (_phase == null) { throw RuntimeMessages.MESSAGES.sendFaultNotAllowed(); } _phase = ExchangePhase.OUT; _state = ExchangeState.FAULT; initFaultContentType(); // set relatesTo header on OUT context message.getContext().setProperty(RELATES_TO, _message.getContext().getPropertyValue(MESSAGE_ID)) .addLabels(BehaviorLabel.TRANSIENT.label()); sendInternal(message); }
private void initContentType(Message message) { QName exchangeInputType = _contract.getConsumerOperation().getInputType(); if (exchangeInputType != null) { message.getContext().setProperty(Exchange.CONTENT_TYPE, exchangeInputType, Scope.MESSAGE) .addLabels(BehaviorLabel.TRANSIENT.label()); } }
private void initContentType(Message message) { QName exchangeInputType = _contract.getConsumerOperation().getInputType(); if (exchangeInputType != null) { message.getContext().setProperty(Exchange.CONTENT_TYPE, exchangeInputType, Scope.MESSAGE) .addLabels(BehaviorLabel.TRANSIENT.label()); } }
private void initFaultContentType() { if (_contract.getProviderOperation() != null) { QName serviceOperationFaultType = _contract.getProviderOperation().getFaultType(); if (serviceOperationFaultType != null) { _message.getContext().setProperty(Exchange.FAULT_TYPE, serviceOperationFaultType, Scope.MESSAGE) .addLabels(BehaviorLabel.TRANSIENT.label()); } } }
private void initFaultContentType() { if (_contract.getProviderOperation() != null) { QName serviceOperationFaultType = _contract.getProviderOperation().getFaultType(); if (serviceOperationFaultType != null) { _message.getContext().setProperty(Exchange.FAULT_TYPE, serviceOperationFaultType, Scope.MESSAGE) .addLabels(BehaviorLabel.TRANSIENT.label()); } } }
@Override public synchronized void send(Message message) { assertMessageOK(message); // Set exchange phase if (_phase == null) { _phase = ExchangePhase.IN; initContentType(message); } else if (_phase.equals(ExchangePhase.IN)) { _phase = ExchangePhase.OUT; initContentType(message); // set relatesTo header on OUT context Object propertyValue = _message.getContext().getPropertyValue(MESSAGE_ID); message.getContext().setProperty(RELATES_TO, propertyValue) .addLabels(BehaviorLabel.TRANSIENT.label()); } else { throw RuntimeMessages.MESSAGES.sendMessageNotAllowed(_phase.toString()); } sendInternal(message); }
@Override public synchronized void send(Message message) { assertMessageOK(message); // Set exchange phase if (_phase == null) { _phase = ExchangePhase.IN; initContentType(message); } else if (_phase.equals(ExchangePhase.IN)) { _phase = ExchangePhase.OUT; initContentType(message); // set relatesTo header on OUT context Object propertyValue = _message.getContext().getPropertyValue(MESSAGE_ID); message.getContext().setProperty(RELATES_TO, propertyValue) .addLabels(BehaviorLabel.TRANSIENT.label()); } else { throw RuntimeMessages.MESSAGES.sendMessageNotAllowed(_phase.toString()); } sendInternal(message); }
@Test public void testRelatesToSetOnReply() { ServiceReference service = _domain.createInOutService( new QName("ReplyTest"), new MockHandler().forwardInToOut()); MockHandler replyHandler = new MockHandler(); Exchange exchange = service.createExchange(replyHandler); Message message = exchange.createMessage(); exchange.send(message); String requestId = message.getContext().getPropertyValue(Exchange.MESSAGE_ID); String replyId = exchange.getMessage().getContext().getPropertyValue(Exchange.MESSAGE_ID); String replyRelatesTo = exchange.getMessage().getContext().getPropertyValue(Exchange.RELATES_TO); Assert.assertEquals(requestId, replyRelatesTo); Assert.assertFalse(requestId.equals(replyId)); }
@Test public void testMessageIdSetOnSend() { ServiceReference service = _domain.createInOnlyService(new QName("IdTest")); Exchange exchange = service.createExchange(); exchange.send(exchange.createMessage()); Assert.assertNotNull(exchange.getMessage().getContext().getProperty(Exchange.MESSAGE_ID)); }