Hi Yeah but do not use DataFormat but use your own POJO that just does what Camel does to invoke the real marshaller / unmarshaller logic.
You do not have to try shoehorn this into DataFormat that cannot work without Exchange. Use POJO and let Camel invoke your POJO as a "data format" On Thu, Jun 18, 2009 at 11:21 AM, Charles Moulliard <cmoulli...@gmail.com>wrote: > This is what I have done but unfortunately, Exchange is a required > parameter > in both methods of DataFormat ( > > http://camel.apache.org/maven/camel-core/apidocs/org/apache/camel/model/dataformat/DataFormatType.html > ): > > void *marshal< > http://camel.apache.org/maven/camel-core/apidocs/org/apache/camel/model/dataformat/DataFormatType.html#marshal%28org.apache.camel.Exchange,%20java.lang.Object,%20java.io.OutputStream%29 > > > *(Exchange< > http://camel.apache.org/maven/camel-core/apidocs/org/apache/camel/Exchange.html > > > exchange, > Object< > http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true > > > graph, > OutputStream< > http://java.sun.com/j2se/1.5.0/docs/api/java/io/OutputStream.html?is-external=true > > > stream) > Marshals the object to the given Stream. > > Object< > http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html?is-external=true > > > *unmarshal< > http://camel.apache.org/maven/camel-core/apidocs/org/apache/camel/model/dataformat/DataFormatType.html#unmarshal%28org.apache.camel.Exchange,%20java.io.InputStream%29 > > > *(Exchange< > http://camel.apache.org/maven/camel-core/apidocs/org/apache/camel/Exchange.html > > > exchange, > InputStream< > http://java.sun.com/j2se/1.5.0/docs/api/java/io/InputStream.html?is-external=true > > > stream) > Unmarshals the given stream into an object. > > > > On Thu, Jun 18, 2009 at 10:41 AM, Claus Ibsen <claus.ib...@gmail.com> > wrote: > > > Hi > > The Data Format abstraction in Camel is a thin layer. So you could create > > your own POJO layer you can invoke. > > And in the impl of the POJO layer you more or less do the same as Camel > > does, but without the Exchange as parameter. > > > > > > > > On Thu, Jun 18, 2009 at 9:58 AM, Charles Moulliard <cmoulli...@gmail.com > > >wrote: > > > > > Hi, > > > > > > I would like to know if it is possible for a camel bean to call an > > > unmarshall/marshall endpoint/process (I don't know if it must be > > > considerate > > > as an endpoint or process) from a Camel bean ? > > > > > > In a normal routing, we call unmarshall/marshall like this : > > > > > > <route> > > > <from uri="direct:start"/> > > > <marshal ref="myJaxb"/> > > > <to uri="direct:marshalled"/> > > > </route> > > > > > > What I would like to do is to declare marshal/unmarshal in a spring > > > DSL file (if it possible) and call it inside a bean ? > > > Why, because the payload to be marshalled/unmarshalled is part of an > > > object and I would like to keep this object during the pipeline route. > > > > > > ex > > > > > > <from uri=file://temp/data/> > > > <convertBodyTo type="java.io.String"/> > > > <bean ref="ServiceHelper" method="createRequest" /> // The Request > > > object is an object used by Hibernate and will contain the content of > > > the file. So this object cannot be unmarshalled/marshalled by its > > > content well > > > <bean ref="ServiceHelper" method="parseRequest" /> // Method who will > > > call the unmarshall/marshall endpoint / process defined in Spring DSL > > > file. This method send the string content to the endpoint > > > who will unmarshall by example the content into a collection of > > > Objects. The result is saved into the object Request > > > <bean ref=ServiceHelper" method="saveRequest"/> > > > > > > because it is not possible to do this without loosing the Request > object > > > > > > <from uri=file://temp/data/> > > > <convertBodyTo type="java.io.String"/> > > > <bean ref="ServiceHelper" method="createRequest" /> > > > <unmarshall ref="csbBindyDataFormat"/> > > > <bean ref=ServiceHelper" method="saveRequest"/> > > > > > > > > > Regards, > > > > > > Charles Moulliard > > > Senior Enterprise Architect > > > Apache Camel Committer > > > > > > ***************************** > > > blog : http://cmoulliard.blogspot.com > > > > > > > > > > > -- > > Claus Ibsen > > Apache Camel Committer > > > > Open Source Integration: http://fusesource.com > > Blog: http://davsclaus.blogspot.com/ > > Twitter: http://twitter.com/davsclaus > > > -- Claus Ibsen Apache Camel Committer Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus