本文整理了Java中org.switchyard.Message.setContent()
方法的一些代码示例,展示了Message.setContent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.setContent()
方法的具体详情如下:
包路径:org.switchyard.Message
类名称:Message
方法名:setContent
[英]Assigns the specified content to the body of this message.
[中]将指定的内容分配给此邮件的正文。
代码示例来源:origin: org.switchyard.components/switchyard-component-bean
/**
* {@inheritDoc}
*/
@Override
public Message setContent(Object content) {
return getMessage().setContent(content);
}
代码示例来源:origin: jboss-switchyard/components
/**
* {@inheritDoc}
*/
@Override
public Message setContent(Object content) {
return getMessage().setContent(content);
}
代码示例来源:origin: org.switchyard.components/switchyard-component-bean
@Override
public ReferenceInvocation invoke(Object content) throws Exception {
_inMessage.setContent(content);
return invoke();
}
代码示例来源:origin: jboss-switchyard/components
@Override
public ReferenceInvocation invoke(Object content) throws Exception {
_inMessage.setContent(content);
return invoke();
}
代码示例来源:origin: jboss-switchyard/components
/**
* {@inheritDoc}
*/
@Override
public org.switchyard.Message compose(MappedRecordBindingData source, Exchange exchange) throws Exception {
final org.switchyard.Message message = exchange.createMessage();
getContextMapper().mapFrom(source, exchange.getContext(message));
Map<Object,Object> m = new HashMap<Object,Object>();
m.putAll(source.getRecord());
message.setContent(m);
return message;
}
代码示例来源:origin: jboss-switchyard/core
@Override
public Message transform(Message message) {
try {
Object result = _mapper.readValue(message.getContent(Reader.class), _clazz);
if (_clazz.isInstance(result)) {
message.setContent(result);
return message;
} else {
throw TransformMessages.MESSAGES.transformationResultWrongType(result.getClass().toString());
}
} catch (JsonParseException e) {
throw TransformMessages.MESSAGES.unexpectedJSONParseException(e);
} catch (JsonMappingException e) {
throw TransformMessages.MESSAGES.unexpectedJSONMappingException(e);
} catch (IOException e) {
throw TransformMessages.MESSAGES.unexpectedIOExceptionCheckTransformer(e);
}
}
}
代码示例来源:origin: jboss-switchyard/components
/**
* {@inheritDoc}
*/
@Override
public org.switchyard.Message compose(IndexedRecordBindingData source, Exchange exchange) throws Exception {
final org.switchyard.Message message = exchange.createMessage();
getContextMapper().mapFrom(source, exchange.getContext(message));
List<Object> l = new ArrayList<Object>();
l.addAll(source.getRecord());
message.setContent(l);
return message;
}
代码示例来源:origin: jboss-switchyard/components
/**
* {@inheritDoc}
*/
@Override
public Message compose(StreamableRecordBindingData source, Exchange exchange) throws Exception {
final org.switchyard.Message message = exchange.createMessage();
getContextMapper().mapFrom(source, exchange.getContext(message));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
source.getRecord().write(baos);
message.setContent(new ByteArrayInputStream(baos.toByteArray()));
return message;
}
代码示例来源:origin: jboss-switchyard/core
@Override
public void handleMessage(Exchange exchange) throws HandlerException {
Message fault = exchange.createMessage();
fault.setContent(new Exception("testFaultTransformSequence"));
exchange.sendFault(fault);
}
};
代码示例来源:origin: jboss-switchyard/core
@Test
public void testContent() throws Exception {
final String message = "Hello There!";
_message.setContent(message);
Assert.assertEquals(message, _message.getContent());
// the following tests to make sure casting to same type works
String content = _message.getContent(String.class);
Assert.assertEquals(message, content);
}
代码示例来源:origin: jboss-switchyard/release
@Override
public org.switchyard.Message compose(JMSBindingData source, Exchange exchange) throws Exception {
org.switchyard.Message msg = super.compose(source, exchange);
msg.setContent(msg.getContent(String.class) + "test");
return msg;
}
代码示例来源:origin: jboss-switchyard/components
/**
* {@inheritDoc}
*/
@Override
public Message compose(HttpBindingData source, Exchange exchange) throws Exception {
final Message message = exchange.createMessage();
getContextMapper().mapFrom(source, exchange.getContext(message));
QName msgType = getMessageType(exchange);
message.setContent(source.getBody());
Object content;
if ((msgType != null) && (QNameUtil.isJavaMessageType(msgType))) {
// Hack - the getContent() call triggers a conversion from native content type and the result is set as the new body
message.setContent(message.getContent(QNameUtil.toJavaMessageType(msgType)));
}
return message;
}
代码示例来源:origin: org.switchyard.components/switchyard-component-http
/**
* {@inheritDoc}
*/
@Override
public Message compose(HttpBindingData source, Exchange exchange) throws Exception {
final Message message = exchange.createMessage();
getContextMapper().mapFrom(source, exchange.getContext(message));
QName msgType = getMessageType(exchange);
message.setContent(source.getBody());
Object content;
if ((msgType != null) && (QNameUtil.isJavaMessageType(msgType))) {
// Hack - the getContent() call triggers a conversion from native content type and the result is set as the new body
message.setContent(message.getContent(QNameUtil.toJavaMessageType(msgType)));
}
return message;
}
代码示例来源:origin: jboss-switchyard/core
public void handleMessage(Exchange exchange) {
Assert.assertEquals(
exchange.getMessage().getContent(),
inMsgContent);
Message outMsg = exchange.createMessage();
outMsg.setContent(outMsgContent);
try {
exchange.send(outMsg);
}
catch (Exception ex) {
Assert.fail(ex.toString());
}
}
};
代码示例来源:origin: org.switchyard.components/switchyard-component-resteasy
/**
* {@inheritDoc}
*/
@Override
public Message compose(RESTEasyBindingData source, Exchange exchange) throws Exception {
final Message message = exchange.createMessage();
getContextMapper().mapFrom(source, exchange.getContext(message));
Object content = null;
if (source.getParameters().length > 0) {
content = source.getParameters()[0];
}
message.setContent(content);
return message;
}
代码示例来源:origin: jboss-switchyard/release
@Override
public JMSBindingData decompose(Exchange exchange, JMSBindingData target) throws Exception {
exchange.getMessage().setContent(exchange.getMessage().getContent(String.class)+"test");
return super.decompose(exchange, target);
}
代码示例来源:origin: jboss-switchyard/components
/**
* {@inheritDoc}
*/
@Override
public Message compose(RESTEasyBindingData source, Exchange exchange) throws Exception {
final Message message = exchange.createMessage();
getContextMapper().mapFrom(source, exchange.getContext(message));
Object content = null;
if (source.getParameters().length > 0) {
content = source.getParameters()[0];
}
message.setContent(content);
if (source.getParameters().length > 1) {
RestEasyLogger.ROOT_LOGGER.defaultRESTEasyMessageComposerDoesnTHandleMultipleInputParameters();
}
return message;
}
代码示例来源:origin: jboss-switchyard/core
@Test
public void testStreamContent() throws Exception {
String contentAsString = "abc-InputStream-xyz";
MockHandler provider = new MockHandler();
_domain.getTransformerRegistry().addTransformer(new StreamTransformer());
ServiceReference service = _domain.createInOnlyService(new QName("StreamTest"), provider);
InputStream contentAsStream = new ByteArrayInputStream(contentAsString.getBytes());
Exchange ex = service.createExchange();
Message msg = ex.createMessage();
msg.setContent(contentAsStream);
ex.send(msg);
Message rcvdMsg = provider.getMessages().poll().getMessage();
Assert.assertTrue(rcvdMsg.getContent(InputStream.class).available() > 0);
}
代码示例来源:origin: jboss-switchyard/core
@Test
public void testReaderContent() throws Exception {
String contentAsString = "abc-Reader-xyz";
MockHandler provider = new MockHandler();
_domain.getTransformerRegistry().addTransformer(new ReaderTransformer());
ServiceReference service = _domain.createInOnlyService(new QName("ReaderTest"), provider);
StringReader contentAsReader = new StringReader(contentAsString);
Exchange ex = service.createExchange();
Message msg = ex.createMessage();
msg.setContent(contentAsReader);
ex.send(msg);
Message rcvdMsg = provider.getMessages().poll().getMessage();
Assert.assertTrue(rcvdMsg.getContent(Reader.class).read() != -1);
}
}
代码示例来源:origin: org.switchyard/switchyard-test
/**
* Send an IN_ONLY message to the target Service.
* @param messagePayload The message payload.
* @throws InvocationFaultException if the message exchange produces a fault
*/
public void sendInOnly(Object messagePayload) throws InvocationFaultException {
ExchangeHandlerProxy exchangeHandlerProxy = _exchangeHandlerProxy;
ResponseCatcher responseCatcher = null;
if (exchangeHandlerProxy == null) {
responseCatcher = new ResponseCatcher();
exchangeHandlerProxy = createHandlerProxy(responseCatcher);
}
Exchange exchange = createExchange(ExchangePattern.IN_ONLY, exchangeHandlerProxy._exchangeHandlerProxy);
Message message = exchange.createMessage().setContent(messagePayload);
setProperties(exchange, message);
addAttachments(message);
exchange.send(message);
if (exchange.getState().equals(ExchangeState.FAULT)) {
throw new InvocationFaultException(exchange.getMessage());
}
}
内容来源于网络,如有侵权,请联系作者删除!