Warning: A non-numeric value encountered in /home/ricston2/public_html/blogarchive/wp-content/themes/Divi/functions.php on line 5766

I have a component that is being hosted as a service in Mule and I want to set one of its properties from within config. Specifically, I want to be able to set the value of this property to another class.

This is slightly trickier than you’d expect. If I just wanted to assign a simple value to a property, then I could use elements to do so. However, I need to be sure that the class I have in mind is constructed and passed to my service properly.

Consider this class:

public class ProductUpdateServiceComponent {
	OrderMotionConvertorInterface orderMotionConvertor;

	public OrderMotionInterface getOrderMotion() {
		return orderMotion;
	}

	public void setOrderMotion(OrderMotionInterface orderMotion) {
		this.orderMotion = orderMotion;
	}

(Some details have been left out)

As you can see here, I have a Java interface called OrderMotionConvertorInterface that will be implemented by other classes. The fact that I have getter and setter methods means that I can set the value of this property from within my config. If I try to set the value of this property to something like 'com.ricston.tests.AConvertor', then a string value containing this FQCN is passed to the service which is not what I want. I want an AConvertor to be constructed and passed to this property.

The easy way to do this is to use Spring beans and to join them up together. In my Mule XML, I need the following:




	
		
	

This shows two Spring beans wired together through the use of the element. In this manner, the convertor is constructed and passed to my service. My service then looks like this:


	
		
	
	
		
	

By referring to a , I can hook my service up to the Spring bean rather than to a new class of its own.