本文整理汇总了Java中org.mule.DefaultMuleMessage类的典型用法代码示例。如果您正苦于以下问题:Java DefaultMuleMessage类的具体用法?Java DefaultMuleMessage怎么用?Java DefaultMuleMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultMuleMessage类属于org.mule包,在下文中一共展示了DefaultMuleMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleMessage
import org.mule.DefaultMuleMessage; //导入依赖的package包/类
public void handleMessage(Message message) throws Fault
{
DefaultMuleMessage m = (DefaultMuleMessage)message.get("mule.message");
// String s = (String)m.getAdapter().getProperty("Content-type");
// if (StringUtils.isNotEmpty(s))
// message.put(Message.CONTENT_TYPE,s);
for (Object name : m.getAdapter().getPropertyNames())
if (((String)name).equalsIgnoreCase("content-type"))
{
String s = (String)m.getAdapter().getProperty((String)name,PropertyScope.INBOUND);
if (StringUtils.isNotBlank(s))
{
message.put(Message.CONTENT_TYPE,s);
break;
}
}
}
示例2: testSendToFileEndpoint
import org.mule.DefaultMuleMessage; //导入依赖的package包/类
/**
* Tests dispatching of a message to a file endpoint.
*/
@Test
public void testSendToFileEndpoint() {
/* Start the Mule transport service. */
mServiceUnderTest.start();
final MuleMessage theMuleMessage =
new DefaultMuleMessage(TEST_MESSAGE_PAYLOAD, mServiceUnderTest.getMuleContext());
/* Set name of file to be written to destination directory. */
theMuleMessage.setProperty("originalFilename", "testfile.txt", PropertyScope.INBOUND);
final MoverMessage<MuleMessage> theMessage = new MuleMoverMessage(theMuleMessage);
mServiceUnderTest.dispatch(theMessage, mOutboundFileEndpointUri);
delay(1000);
/* Verify outcome. */
final File[] theDestDirFiles = mTestDestinationDirectory.listFiles();
Assert.assertEquals("There should be one file in the destination directory", 1, theDestDirFiles.length);
}
示例3: performAndVerifyJmsTest
import org.mule.DefaultMuleMessage; //导入依赖的package包/类
private void performAndVerifyJmsTest() {
final String theJmsEndpointUri = "jms://queue:muletransportservice.queue";
final MuleMessage theMuleMessage =
new DefaultMuleMessage(TEST_MESSAGE_PAYLOAD, mServiceUnderTest.getMuleContext());
final MoverMessage<MuleMessage> theMessage = new MuleMoverMessage();
theMessage.setMessage(theMuleMessage);
mServiceUnderTest.dispatch(theMessage, theJmsEndpointUri);
delay(1000);
final MoverMessage<MuleMessage> theReceivedMessage = mServiceUnderTest.receive(theJmsEndpointUri, 5000);
/* Verify outcome. */
Assert.assertNotNull("A message should have been received", theReceivedMessage);
final MuleMessage theReceivedMuleMessage = theReceivedMessage.getMessage();
Assert.assertNotNull("The received message should contain a payload", theReceivedMessage.getMessage());
Assert.assertEquals("Payload of message should be unaltered", TEST_MESSAGE_PAYLOAD,
theReceivedMuleMessage.getPayload());
}
示例4: doSetup
import org.mule.DefaultMuleMessage; //导入依赖的package包/类
@Before
public void doSetup() throws Exception {
Banana banana = new Banana();
Kiwi kiwi = new Kiwi();
messageA = new DefaultMuleMessage(null, muleContext);
messageA.addOutboundAttachment("anInboundAttachment", banana, "application/vnd.mule.banana");
messageA = messageA.createInboundMessage();
messageA.addOutboundAttachment("anOutboundAttachment", kiwi, "application/vnd.mule.kiwi");
messageB = new DefaultMuleMessage(null, muleContext);
messageB.addOutboundAttachment("anInboundAttachment", banana, "application/vnd.mule.banana");
messageB = messageB.createInboundMessage();
messageB.addOutboundAttachment("anOutboundAttachment", kiwi, "application/vnd.mule.kiwi");
messageC = new DefaultMuleMessage(null, muleContext);
}
示例5: logNotFound
import org.mule.DefaultMuleMessage; //导入依赖的package包/类
void logNotFound(RequestLine requestLine, MuleContext muleContext) {
HttpResponse httpResponse = new HttpResponse();
httpResponse.setStatusLine(requestLine.getHttpVersion(), HttpConstants.SC_NOT_FOUND);
DefaultMuleMessage message = new DefaultMuleMessage(httpResponse, muleContext);
message.setInboundProperty(HttpConnector.HTTP_METHOD_PROPERTY, requestLine.getMethod());
try {
URI uri = new URI(requestLine.getUri());
message.setInboundProperty(HttpConnector.HTTP_REQUEST_PATH_PROPERTY, uri.getPath());
if (hasText(uri.getQuery())) {
message.setInboundProperty(HttpConnector.HTTP_QUERY_STRING, uri.getQuery());
}
} catch (URISyntaxException e) {
e.printStackTrace(); // we swallow this that should never happen
}
accessLogger.log(message);
}
示例6: visitAfter
import org.mule.DefaultMuleMessage; //导入依赖的package包/类
@Override
public void visitAfter(SAXElement saxElement, ExecutionContext executionContext) throws SmooksException, IOException {
try {
Object xmlElement = executionContext.getBeanContext().getBean(FRAGMENT_BEAN_ID);
MuleContext muleContext = (MuleContext) executionContext.getBeanContext().getBean(MULE_CONTEXT_BEAN_ID);
muleContext.getClient().send(sendToUri, new DefaultMuleMessage(xmlElement, muleContext));
} catch (Exception e) {
String message = String.format("XmlStreamSplitterComponent visitAfter() exception caught: %s", e.getMessage());
log.error(message, e);
throw new RuntimeException(message, e);
}
}
示例7: testMule
import org.mule.DefaultMuleMessage; //导入依赖的package包/类
@Test
public void testMule() throws Exception {
MuleContext muleContext = new DefaultMuleContextFactory().createMuleContext("mule/mule-standlone-config.xml");
muleContext.start();
MuleClient muleClient = new DefaultLocalMuleClient(muleContext);
Integer days = 5;
MuleMessage message = muleClient.send("vm://helloMule", new DefaultMuleMessage(days, muleContext));
assertNotNull(message.getPayload());
Boolean result = (Boolean) message.getPayload();
assertTrue(result);
}
示例8: testMuleMaster
import org.mule.DefaultMuleMessage; //导入依赖的package包/类
@Test
public void testMuleMaster() throws Exception {
MuleContext muleContext = new DefaultMuleContextFactory().createMuleContext("mule/mule-master/mule-master.xml");
muleContext.start();
MuleRegistry registry = muleContext.getRegistry();
RepositoryService repositoryService = (RepositoryService) registry.get("repositoryService");
repositoryService.createDeployment().addClasspathResource("mule/leaveWithMule.bpmn").deploy();
MuleClient muleClient = new DefaultLocalMuleClient(muleContext);
DefaultMuleMessage message = new DefaultMuleMessage("", muleContext);
Map<String, Object> variableMap = new HashMap<String, Object>();
variableMap.put("days", 5);
variableMap.put("processDefinitionKey", "leaveWithMule");
message.setProperty("createProcessParameters", variableMap , PropertyScope.OUTBOUND);
MuleMessage responseMessage = muleClient.send("vm://startLeaveProcess", message);
ProcessInstance processInstance = (ProcessInstance) responseMessage.getPayload();
assertFalse(processInstance.isEnded());
TaskService taskService = registry.get("taskService");
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
assertEquals("部门经理审批", task.getName());
muleContext.stop();
muleContext.dispose();
}
示例9: execute
import org.mule.DefaultMuleMessage; //导入依赖的package包/类
public void execute(ActivityExecution execution) throws Exception {
String endpointUrlValue = this.getStringFromField(this.endpointUrl, execution);
String languageValue = this.getStringFromField(this.language, execution);
String payloadExpressionValue = this.getStringFromField(this.payloadExpression, execution);
String resultVariableValue = this.getStringFromField(this.resultVariable, execution);
LocalMuleClient client = this.getMuleContext().getClient();
ScriptingEngines scriptingEngines = Context.getProcessEngineConfiguration().getScriptingEngines();
Object payload = scriptingEngines.evaluate(payloadExpressionValue, languageValue, execution);
MuleMessage message = new DefaultMuleMessage(payload, this.getMuleContext());
switch (this.mep) {
case REQUEST_RESPONSE:
MuleMessage resultMessage = client.send(endpointUrlValue, message);
Object result = resultMessage.getPayload();
if (resultVariableValue != null) {
execution.setVariable(resultVariableValue, result);
}
break;
case ONE_WAY:
client.dispatch(endpointUrlValue, message);
break;
default:
break;
}
this.leave(execution);
}
示例10: aggregate
import org.mule.DefaultMuleMessage; //导入依赖的package包/类
@Override
public MuleEvent aggregate(AggregationContext context) throws MuleException {
VerificaCreditoResponse resultado = new VerificaCreditoResponse();
resultado.setCredito(new Credito());
for (MuleEvent event : context.getEvents()) {
CreditoMappingStrategyFactory.mapCredito(event.getMessage().getPayload(), resultado.getCredito());
}
boolean aprovado = resultado.getCredito().isCasasBahia() && resultado.getCredito().isSerasa() && resultado.getCredito().isSpc();
resultado.getCredito().setAprovado(aprovado);
MuleMessage response = new DefaultMuleMessage((Object) resultado, context.getOriginalEvent().getMuleContext());
return new DefaultMuleEvent(response, context.getOriginalEvent(), context.getOriginalEvent().getSession());
}
示例11: doSetup
import org.mule.DefaultMuleMessage; //导入依赖的package包/类
@Before
public void doSetup() throws Exception {
messageA = new DefaultMuleMessage(null, muleContext);
messageA.setOutboundProperty("aKey", "aValue");
messageB = new DefaultMuleMessage(null, muleContext);
messageB.setOutboundProperty("aKey", "aValue");
messageC = new DefaultMuleMessage(null, muleContext);
messageC.setOutboundProperty("weird", "value");
}
示例12: doSetup
import org.mule.DefaultMuleMessage; //导入依赖的package包/类
@Before
public void doSetup() throws Exception {
message = new DefaultMuleMessage(null, muleContext);
new DefaultMuleEvent(message, MessageExchangePattern.ONE_WAY, getTestService());
message.setProperty("aPropertyKey", "aValue", PropertyScope.OUTBOUND);
message.setProperty("anInboundKey", "this is a Value", PropertyScope.INBOUND);
message.setProperty("anOutboundKey", "this is a Value", PropertyScope.OUTBOUND);
message.setProperty("anInvocationaKey", "aValue", PropertyScope.INVOCATION);
message.setProperty("aSessionKey", 3, PropertyScope.SESSION);
}
示例13: doSetup
import org.mule.DefaultMuleMessage; //导入依赖的package包/类
@Before
public void doSetup() throws Exception {
message = new DefaultMuleMessage(null, muleContext);
Banana banana = new Banana();
Orange orange = new Orange();
message.addOutboundAttachment("anInboundAttachment", banana, "application/vnd.mule.banana");
message = message.createInboundMessage();
message.addOutboundAttachment("anOutboundAttachment", orange, "application/vnd.mule.orange");
}
示例14: doSetup
import org.mule.DefaultMuleMessage; //导入依赖的package包/类
@Before
public void doSetup() throws Exception {
message = new DefaultMuleMessage(null, muleContext);
new DefaultMuleEvent(message, MessageExchangePattern.ONE_WAY, getTestService());
message.setProperty("anInboundKey", "aValue", PropertyScope.INBOUND);
message.setProperty("anOutboundKey", "aValue", PropertyScope.OUTBOUND);
message.setProperty("anInvocationaKey", "aValue", PropertyScope.INVOCATION);
message.setProperty("aSessionKey", "aValue", PropertyScope.SESSION);
}
示例15: doSetup
import org.mule.DefaultMuleMessage; //导入依赖的package包/类
@Before
public void doSetup() throws Exception {
message = new DefaultMuleMessage(null, muleContext);
banana = new Banana();
message.addOutboundAttachment("anAttachment", banana, "application/vnd.mule.banana");
message = message.createInboundMessage();
message.addOutboundAttachment("anOutboundAttachment", banana, "application/vnd.mule.banana");
}