本文整理了Java中org.switchyard.Message.getContext()
方法的一些代码示例,展示了Message.getContext()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getContext()
方法的具体详情如下:
包路径:org.switchyard.Message
类名称:Message
方法名:getContext
[英]Retrieves the message context.
[中]检索消息上下文。
代码示例来源:origin: jboss-switchyard/core
@Override
public Context getContext(Message message) {
if (_message != null && _message == message) {
return getContext();
}
return message.getContext();
}
代码示例来源:origin: org.switchyard.components/switchyard-component-bean
/**
* {@inheritDoc}
*/
@Override
public Context getContext() {
return getMessage().getContext();
}
代码示例来源:origin: jboss-switchyard/components
/**
* {@inheritDoc}
*/
@Override
public Context getContext() {
return getMessage().getContext();
}
代码示例来源:origin: org.switchyard/switchyard-bus-camel
@Override
public Context getContext(Message message) {
if (_exchange.getIn() == message) {
return getContext();
}
return message.getContext();
}
代码示例来源:origin: org.switchyard/switchyard-runtime
@Override
public Context getContext(Message message) {
if (_message != null && _message == message) {
return getContext();
}
return message.getContext();
}
代码示例来源:origin: jboss-switchyard/core
@Override
public Context getContext(Message message) {
if (_exchange.getIn() == message) {
return getContext();
}
return message.getContext();
}
代码示例来源:origin: org.switchyard.components/switchyard-component-common-knowledge
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);
}
代码示例来源:origin: jboss-switchyard/components
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);
}
代码示例来源:origin: org.switchyard/switchyard-api
/**
* 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());
}
代码示例来源:origin: jboss-switchyard/core
/**
* 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());
}
代码示例来源:origin: org.switchyard/switchyard-runtime
@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);
}
代码示例来源:origin: jboss-switchyard/core
@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);
}
代码示例来源:origin: jboss-switchyard/core
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());
}
}
代码示例来源:origin: org.switchyard/switchyard-runtime
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());
}
}
代码示例来源:origin: org.switchyard/switchyard-runtime
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());
}
}
}
代码示例来源:origin: jboss-switchyard/core
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());
}
}
}
代码示例来源:origin: org.switchyard/switchyard-runtime
@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);
}
代码示例来源:origin: jboss-switchyard/core
@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);
}
代码示例来源:origin: jboss-switchyard/core
@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));
}
代码示例来源:origin: jboss-switchyard/core
@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));
}
内容来源于网络,如有侵权,请联系作者删除!