如何在Mule Studio中为Java组件提供属性Bean?

时间:2014-03-20 13:48:07

标签: java spring components mule esb

在Mule Studio 3.5中,直接在XML和Flow中,我有以下声明:

<component class="fr.esb.bo.GenerateReportFileComponent" doc:name="BOreport">           
            <spring:property name="boServices" ref="boServices"/>
</component>

当我用这个启动Mule时,我收到以下错误

org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'spring:property'. One of '{"http://www.mulesoft.org/schema/mule/core":annotations, "http://www.mulesoft.org/schema/mule/core":abstract-interceptor, "http://www.mulesoft.org/schema/mule/core":interceptor-stack, "http://www.mulesoft.org/schema/mule/core":abstract-entry-point-resolver-set, "http://www.mulesoft.org/schema/mule/core":abstract-entry-point-resolver, "http://www.mulesoft.org/schema/mule/core":abstract-object-factory, "http://www.mulesoft.org/schema/mule/core":abstract-lifecycle-adapter-factory, "http://www.mulesoft.org/schema/mule/core":binding}' is expected.

我明白了,但是如何将boServices bean提供给我的组件? 使用定制变压器,效果很好。

1 个答案:

答案 0 :(得分:6)

将您的类定义为Spring bean:

<spring:beans>
  <spring:bean id="restaurantWaiter" scope="prototype" class="com.foo.RestaurantWaiter">
    <spring:property name="kitchenService">
        <spring:ref local="kitchenService"/>
    </spring:property>
  </spring:bean>
</spring:beans>

<component>
  <spring-object bean="restaurantWaiter"/>
</component>

解释here