@Produce proxy...

Posted on

I've been using the @Produce annotation to help with development. It permits carving up routes and logic and eases the CamelBlueprintTestSupport single camel context problem. There is one issue that's a bit of an annoyance with it and maybe someone knows of an easy solution. It appears that Camel understands that if a basic Java object like a String is being passed then that is the body that the route should be using. If it isn't then it pass the BeanInvocationProxy. I've resorted to this hack in those instances to make it work but I'm wondering if there's a flag that might be set on the annotation (or should be added to the annotation) to indicate to Camel that it should do this under the covers.

@Override
public void configure() throws Exception {
from(MyRouut.DIRECT_FORMAT).bean(this,"realize")
.to("velocity:{{my.template.format}}?contentCache=false");

}

/**
 * Realize.
 *
 * @param e the e
 * @return the invoice
 */
//This hack is required to help Camel reflect on the bean invocation and return the body.
public Invoice realize(Invoice e)
{
    return e;
}