简体   繁体   English

Mule REST组件返回类型

[英]Mule REST Component Return type

I am trying to implement the REST component in Mule Flow and I was able to expose REST services also and the response is coming back to client also. 我正在尝试在Mule Flow中实现REST组件,我也能够公开REST服务,并且响应也会回到客户端。 But When I put Mule Java Component to access the properties of the REST component response, I am not able to do that. 但是,当我使用Mule Java Component访问REST组件响应的属性时,我无法做到这一点。 Below is the code of my Mule message processor, 下面是我的Mule消息处理器的代码,

public class RestResponseProcessor implements Callable{

@Override
public Object onCall(MuleEventContext eventContext) throws Exception {
    Object messagePayload = eventContext.getMessage().getPayload();
    System.out.println("Message payload class is  " + messagePayload.getClass());
    org.mule.module.jersey.JerseyResourcesComponent jerseyResponse = (org.mule.module.jersey.JerseyResourcesComponent) messagePayload;
    System.out.println("jerseyResponse.getClass() is  " + jerseyResponse.getClass());
    return eventContext;
}

}

The output for the first sysout is Message payload class is class org.mule.module.jersey.JerseyResourcesComponent$2 but when I trying to cast it org.mule.module.jersey.JerseyResourcesComponent object, it is giving classCastException, java.lang.ClassCastException: org.mule.module.jersey.JerseyResourcesComponent$2 cannot be cast to org.mule.module.jersey.JerseyResourcesComponent What does this $2 means after the class name and what can be the possible solution to this. 第一个sysout的输出是Message payload class is class org.mule.module.jersey.JerseyResourcesComponent$2但是当我试图将它转换为org.mule.module.jersey.JerseyResourcesComponent对象时,它给出了classCastException, java.lang.ClassCastException: org.mule.module.jersey.JerseyResourcesComponent$2 cannot be cast to org.mule.module.jersey.JerseyResourcesComponent这个$ 2在类名后面意味着什么,以及可能的解决方案。

Basically I am trying to route my message based on the REST component response before sending the response to client. 基本上我试图在将响应发送到客户端之前基于REST组件响应来路由我的消息。

Hope I am clear with my question. 希望我对我的问题很清楚。

I got the answer from Mule forum. 我从Mule论坛得到了答案。

$2 is an anonymous class of type org.mule.api.transport.OutputHandler created by the Jersey component. $ 2是由泽西组件创建的org.mule.api.transport.OutputHandler类型的匿名类。

I tried using "Byte Array To String" and it worked. 我尝试使用“字节数组到字符串”,它工作。 It solved my purpose. 它解决了我的目的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM