camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Moulliard <>
Subject How can we share together util function with Camel
Date Thu, 09 Jul 2009 08:15:45 GMT

I try to figure out How we can share together util function with Camel that
we can use from DSL language (Spring, Java, ...).

Here is an example : For my project, I need to extract from CamelFileName
header property the last occurence of the folder (= parent folder) from the
file path. To get this information, I have created a bean = function

 public String getFolderName(@Header(value = "CamelFileParent") String
camelFileName, @Body File file) {

        LinkedList<String> folders = new LinkedList<String>();
        String parentFolder = "";

        if ( camelFileName != null ) {
            // Split path


            if ( folders != null ) {
            // Get last occurrence containing the parent folder
                parentFolder = folders.getLast();
        return parentFolder;

>From my route, I will call it to get the folderName like this

<from uri=""/>
<bean name="UtilHelper" method="getFolderName" />
<to uri=""/>


(1) What I propose is to have an UtilHelper class in Camel that every user
can have access to use methods that we share together ?

(2) It should be interesting that we can call this bean within setHeader
function like this

                <camel:setHeader headerName="messageType">
                    <camel:bean name="ServiceHelper"


Charles Moulliard
Senior Enterprise Architect
Apache Camel Committer

blog :

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message