I'm just getting started with mule and cant figure out how I can possibly pass a part of my request header as a parameter/argument to the Java component.
My Java Component is as follows
public String processHeader(String in)
{
//process header
System.out.print(" Header" + in);
}
Ive been able to access processHeader
in the following manner from the flow
<component>
<method-entry-point-resolver>
<include-entry-point method="processHeader" />
</method-entry-point-resolver>
<singleton-object class="my.test.mule.Processor" />
</component>
Accessing the above using http://localhost:8080/test
. Prints Header test
I'm able to dump the contents of the header using the following
<logger level="INFO" doc:name="Logger" message="#[headers:INBOUND:*]"/>
But I cant seem to figure out how to pass the message
as an argument to processHeader
nor can I find any relevant examples. Any help would be appreciated.
Btw, I'm using Mule 3.5
if that matters.
implement Callable interface for your java component. When default methods are overridden, you will get eventContext as parameter inside which you can find mule message which in turn gives you access to headers and payload. sample is here:
import org.mule.api.MuleEventContext;
import org.mule.api.lifecycle.Callable;
import org.mule.api.transport.PropertyScope;
public class Test implements Callable {
@Override
public Object onCall(MuleEventContext eventContext) throws Exception {
eventContext.getMessage().getProperty("header1", PropertyScope.INBOUND);
return null;
}
}