本文整理汇总了Java中org.mule.api.MuleEventContext类的典型用法代码示例。如果您正苦于以下问题:Java MuleEventContext类的具体用法?Java MuleEventContext怎么用?Java MuleEventContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MuleEventContext类属于org.mule.api包,在下文中一共展示了MuleEventContext类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCall
import org.mule.api.MuleEventContext; //导入依赖的package包/类
public Object onCall(MuleEventContext eventContext) throws Exception
{
if (logger.isDebugEnabled())
{
logger.debug(eventContext);
}
// if http request
String requestPath = parseHttpRequestProperty(
eventContext.getMessage().getStringProperty(HttpConnector.HTTP_REQUEST_PROPERTY,
StringUtils.EMPTY));
if (requestPath.indexOf('?') > -1)
{
return generateWSDLOrXSD(eventContext, requestPath);
}
else
{
return sendToDestination(eventContext);
}
}
示例2: getMessageStream
import org.mule.api.MuleEventContext; //导入依赖的package包/类
/**
* Gets the stream representation of the current message.
*
* @param context the event context
* @return The inputstream for the current message
* @throws MuleException
*/
protected InputStream getMessageStream(MuleEventContext context) throws MuleException
{
InputStream is;
Object eventMsgPayload = context.transformMessage();
if (eventMsgPayload instanceof InputStream)
{
is = (InputStream) eventMsgPayload;
}
else
{
is = (InputStream) context.transformMessage(InputStream.class);
}
return is;
}
示例3: getWsdlUri
import org.mule.api.MuleEventContext; //导入依赖的package包/类
private String getWsdlUri(MuleEventContext eventContext, String reqPath)
{
EndpointURI epUri = eventContext.getEndpointURI();
String host = (String) eventContext.getMessage().getProperty("Host", epUri.getHost());
String ctx = (String) eventContext.getMessage().getProperty(HttpConnector.HTTP_REQUEST_PROPERTY);
return epUri.getScheme() + "://" + host + ctx;
}
示例4: setPayload
import org.mule.api.MuleEventContext; //导入依赖的package包/类
private void setPayload(MuleEventContext ctx, final MessageImpl m, Object payload)
throws TransformerException
{
if (payload instanceof InputStream)
{
m.put(Message.ENCODING, ctx.getEncoding());
m.setContent(InputStream.class, payload);
}
else if (payload instanceof Reader)
{
m.setContent(XMLStreamReader.class, StaxUtils.createXMLStreamReader((Reader) payload));
}
else if (payload instanceof byte[])
{
m.setContent(InputStream.class, new ByteArrayInputStream((byte[]) payload));
}
else if (payload instanceof StaxSource)
{
m.setContent(XMLStreamReader.class, ((StaxSource) payload).getXMLStreamReader());
}
else if (payload instanceof Source)
{
m.setContent(XMLStreamReader.class, StaxUtils.createXMLStreamReader((Source) payload));
}
else if (payload instanceof XMLStreamReader)
{
m.setContent(XMLStreamReader.class, (XMLStreamReader) payload);
}
else if (payload instanceof Document)
{
DOMSource source = new DOMSource((Node) payload);
m.setContent(XMLStreamReader.class, StaxUtils.createXMLStreamReader(source));
}
else
{
InputStream is = (InputStream) ctx.transformMessage(InputStream.class);
m.put(Message.ENCODING, ctx.getEncoding());
m.setContent(InputStream.class, is);
}
}
示例5: onCall
import org.mule.api.MuleEventContext; //导入依赖的package包/类
@Override
public Object onCall(MuleEventContext context) throws Exception
{
context.transformMessage();
return onCall(context.getMessage());
}
示例6: generateWSDLOrXSD
import org.mule.api.MuleEventContext; //导入依赖的package包/类
protected Object generateWSDLOrXSD(MuleEventContext eventContext, String req)
throws EndpointNotFoundException, IOException
{
// TODO: Is there a way to make this not so ugly?
String ctxUri = (String) eventContext.getMessage().getProperty(HttpConnector.HTTP_CONTEXT_PATH_PROPERTY);
String wsdlUri = getWsdlUri(eventContext, req);
String serviceUri = wsdlUri.substring(0, wsdlUri.indexOf('?'));
EndpointInfo ei = receiver.getServer().getEndpoint().getEndpointInfo();
if (serviceUri != null)
{
ei.setAddress(serviceUri);
if (ei.getExtensor(AddressType.class) != null)
{
ei.getExtensor(AddressType.class).setLocation(serviceUri);
}
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
String ct = null;
for (QueryHandler qh : bus.getExtension(QueryHandlerRegistry.class).getHandlers())
{
if (qh.isRecognizedQuery(wsdlUri, ctxUri, ei))
{
ct = qh.getResponseContentType(wsdlUri, ctxUri);
qh.writeResponse(wsdlUri, ctxUri, ei, out);
out.flush();
}
}
String msg;
if (ct == null)
{
ct = "text/plain";
msg = "No query handler found for URL.";
}
else
{
msg = out.toString();
}
MuleMessage result = new DefaultMuleMessage(msg);
result.setProperty(HttpConstants.HEADER_CONTENT_TYPE, ct);
return result;
}
示例7: onCall
import org.mule.api.MuleEventContext; //导入依赖的package包/类
/**
*
* @param eventContext
* @return
* @throws Exception
*/
@Override
public Object onCall(MuleEventContext eventContext) throws Exception {
InputStream is = eventContext.getMessage().getPayload(InputStream.class);
ExecutionContext smooksExecutionContext = smooks.createExecutionContext();
smooksExecutionContext.getBeanContext().addBean(MULE_CONTEXT_BEAN_ID, eventContext.getMuleContext());
smooks.filterSource(smooksExecutionContext, new StreamSource(is));
return EMPTY_STRING;
}
示例8: onCall
import org.mule.api.MuleEventContext; //导入依赖的package包/类
@Override
public Object onCall(MuleEventContext eventContext) throws Exception {
return tool.saySomething();
}