Skip to main content

Spring Beans xml :

<bean id="colorPicker" name="colorPicker"

class="com.xx.yy.zz.aa.ColorPicker" scope="singleton">

<property name="propA" ref="existingCodes"></property>

<property name="propB" ref="defaultCodes"></property>

</bean>

 

Method :

public boolean sampleMethod(String value) {

 

return true;

}

 

How do i invoke sampleMethod from dataweave code?

답변 2개
  1. 2020년 12월 30일 오후 3:25

    Hi Rajesh,

     

    Most of the information are already shared by Vishal,

     

    But Yes, You can access the Object in DataWeave of any class that is initiated by Spring module.

     

    Make sure , You inject the below class to Mule Spring registry

     

    Step 1:

    <spring:configname="colorPicker"doc:name="colorPicker"files="Bean.xml" />

    Step 2:

     

    Use dataWeave to access the object or use Invoke component as mentioned By Vishal

     

    If you have non-static function with the class initiated by Spring framework , Still you can access the Object only but you can not call function it seems

     

    For accessing the Object in dataWeave which is initiated by Spring, use the below one

     

    %dw 2.0

    output application/json

    ---

    app.registry.colorPicker

    Here ColorPicker is nothing but id of your class which is initiated by Spring framwork.

     

    or try calling function like below: But I am sure it will not work :

     

    %dw 2.0

    output application/json

    ---

    app.registry.defaultAnimal::functionaName(arg1)

     

    Make sure if you have different alternative ,Feel free to add with full details in the comment, I will add some point to your profile which will help you to get recognize in the MuleSoft community.

     

    Thanks,

    Manish Kumar Yadav

    MuleSoft Forum Moderator