2012-08-29 25 views
1

我想在轉換字符串輸入到URL列表的文檔中的轉換器示例,但它是拋出一個錯誤。Mule ESB 3變壓器不能轉換爲MessageProcessor

的例子是在這裏:http://www.mulesoft.org/documentation/display/MULE3USER/Transformer+Annotation#TransformerAnnotation-WorkingwithCollections

我對變壓器的代碼是複製粘貼,從他們的。

<custom-transformer class="com.test.transformer.StringToListTransformer" doc:name="StringToUrlList"/> 

注意到要求「註冊」的變壓器,我在文件的開頭後加入(後:

當我第一次做到了,我通過把在我的配置XML設置變壓器開放標籤):

<spring:bean id="stringToListTransformer" class="com.test.transformer.StringToListTransformer"/> 

然而,當我運行應用程序,我得到以下錯誤:

Exception in thread "main" org.mule.module.launcher.DeploymentInitException: IllegalStateException: Cannot convert value of type [com.test.transformer.StringToListTransformer] to required type [org.mule.api.processor.MessageProcessor] for property 'messageProcessors[3]': no matching editors or conversion strategy found 

回答

3

您不能使用@Transformer註解的類作爲custom-transformer,因爲它不是真實的org.mule.api.processor.MessageProcessor。只有真正的消息處理器可以直接在XML配置中使用並顯式調用。

正如doc for @Transformer說:

There is no mechanism in Mule 3.x to actually invoke a transformer which is being constructed from an annotated method.

如果您希望您的變壓器跳入在流,你需要使用:

<auto-transformer returnClass="java.util.List.class"/> 

假設它返回一個列表,沒有其他合適的優先登記變壓器。

否則,通過擴展org.mule.transformer.AbstractMessageTransformer創建一個真正的變壓器,然後與custom-transformer一起使用。

+0

謝謝,剛剛開始瓦特/騾子,我想我誤解了他們的步行通過的解析器。 – Paul

+0

斷開的鏈接 - 我認爲你想要:https://docs.mulesoft.com/mule-user-guide/v/3.8/transformer-annotation – kaybee99

+0

@ kaybee99謝謝你,修正它。 –

0

請使用Java組件,而不是Java變壓器..

+2

這不提供問題的答案。要批評或要求作者澄清,請在其帖子下方留言。如果[贏得](// meta.stackoverflow.com/q/146472/169503)足夠[聲望](// stackoverflow.com/help/whats-reputation),您將能夠[對任何帖子發表評論](/ /stackoverflow.com/help/privileges/comment)。 –

相關問題