You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Romain Manni-Bucau <rm...@gmail.com> on 2011/05/12 17:55:17 UTC
a bit of stax
Hi all,
i worked a bit around stax (thanks to claus for its advices).
You can find what i've done here:
http://code.google.com/p/rmannibucau/source/browse/camel/camel-stax/
The test show what can be done with it:
http://code.google.com/p/rmannibucau/source/browse/camel/camel-stax/src/test/java/org/apache/camel/stax/test/StAXRouteTest.java
- validation using sax (just need a converter)
- parsing using a sax contenthandler and a stax stream reader (a simple
component)
- parsing of sub tree to get jaxb objects using a stax event reader for
the whole tree and jaxb for the sub objects
- Romain
Re: a bit of stax
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi,
thank you Richard and Claus for your feedbacks.
I modified the classloading stuff, the NPE catch and added the XMLUtil class
to get the tag name.
I added support for input stream as input (adding some converters) but the
problem is that camel already have a lot of converters and you can load back
the whole file very fast if you don't take care.
- Romain
2011/5/13 Claus Ibsen <cl...@gmail.com>
> Hi
>
> Yeah it does look very cool. Good work.
>
> Would be great if the StaxComponent could also cater for non file
> based inputs. You may have the message body as a Source already. But
> that can always be improved.
>
> And yes as Richard mention the class loading should use the
> ClassResolver. You can get it from the CamelContext. exchange -> camel
> context -> class resolver.
>
> And the stuff that finds the annotations. We may have some common code
> for that. Or later refactor that into a util class.
>
> Anyway keep it up.
>
>
> On Fri, May 13, 2011 at 1:29 AM, Richard Kettelerij
> <ri...@gmail.com> wrote:
> > Hi Romain,
> >
> > Nice work. I've taken a look at your component. A few minor suggestions
> for
> > improvement, in case you want to contribute it to Apache:
> >
> > - The component currently uses getContextClassLoader().loadClass() for
> > classloading. Camel actually has a abstraction to make this portable
> across
> > various runtime environments. You can just replace it with
> > org.apache.camel.spi.ClassResolver().resolveClass().
> >
> > - Avoid catching the NullPointException in the
> StAXJAXBIteratorExpression.
> >
> > - Do you plan to add a DSL method for the StAXJAXBIteratorExpression
> > (requires patching camel-core)? So you can write for example
> > "split(stax(Record.class))" in your route.
> >
> > Regards,
> > Richard
> >
> > On Thu, May 12, 2011 at 5:55 PM, Romain Manni-Bucau
> > <rm...@gmail.com>wrote:
> >
> >> Hi all,
> >>
> >> i worked a bit around stax (thanks to claus for its advices).
> >>
> >> You can find what i've done here:
> >> http://code.google.com/p/rmannibucau/source/browse/camel/camel-stax/
> >>
> >> The test show what can be done with it:
> >>
> >>
> http://code.google.com/p/rmannibucau/source/browse/camel/camel-stax/src/test/java/org/apache/camel/stax/test/StAXRouteTest.java
> >>
> >> - validation using sax (just need a converter)
> >> - parsing using a sax contenthandler and a stax stream reader (a
> simple
> >> component)
> >> - parsing of sub tree to get jaxb objects using a stax event reader
> for
> >> the whole tree and jaxb for the sub objects
> >>
> >>
> >> - Romain
> >>
> >
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> CamelOne 2011: http://fusesource.com/camelone2011/
> Twitter: davsclaus
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>
Re: a bit of stax
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Yeah it does look very cool. Good work.
Would be great if the StaxComponent could also cater for non file
based inputs. You may have the message body as a Source already. But
that can always be improved.
And yes as Richard mention the class loading should use the
ClassResolver. You can get it from the CamelContext. exchange -> camel
context -> class resolver.
And the stuff that finds the annotations. We may have some common code
for that. Or later refactor that into a util class.
Anyway keep it up.
On Fri, May 13, 2011 at 1:29 AM, Richard Kettelerij
<ri...@gmail.com> wrote:
> Hi Romain,
>
> Nice work. I've taken a look at your component. A few minor suggestions for
> improvement, in case you want to contribute it to Apache:
>
> - The component currently uses getContextClassLoader().loadClass() for
> classloading. Camel actually has a abstraction to make this portable across
> various runtime environments. You can just replace it with
> org.apache.camel.spi.ClassResolver().resolveClass().
>
> - Avoid catching the NullPointException in the StAXJAXBIteratorExpression.
>
> - Do you plan to add a DSL method for the StAXJAXBIteratorExpression
> (requires patching camel-core)? So you can write for example
> "split(stax(Record.class))" in your route.
>
> Regards,
> Richard
>
> On Thu, May 12, 2011 at 5:55 PM, Romain Manni-Bucau
> <rm...@gmail.com>wrote:
>
>> Hi all,
>>
>> i worked a bit around stax (thanks to claus for its advices).
>>
>> You can find what i've done here:
>> http://code.google.com/p/rmannibucau/source/browse/camel/camel-stax/
>>
>> The test show what can be done with it:
>>
>> http://code.google.com/p/rmannibucau/source/browse/camel/camel-stax/src/test/java/org/apache/camel/stax/test/StAXRouteTest.java
>>
>> - validation using sax (just need a converter)
>> - parsing using a sax contenthandler and a stax stream reader (a simple
>> component)
>> - parsing of sub tree to get jaxb objects using a stax event reader for
>> the whole tree and jaxb for the sub objects
>>
>>
>> - Romain
>>
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
CamelOne 2011: http://fusesource.com/camelone2011/
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: a bit of stax
Posted by Richard Kettelerij <ri...@gmail.com>.
Hi Romain,
Nice work. I've taken a look at your component. A few minor suggestions for
improvement, in case you want to contribute it to Apache:
- The component currently uses getContextClassLoader().loadClass() for
classloading. Camel actually has a abstraction to make this portable across
various runtime environments. You can just replace it with
org.apache.camel.spi.ClassResolver().resolveClass().
- Avoid catching the NullPointException in the StAXJAXBIteratorExpression.
- Do you plan to add a DSL method for the StAXJAXBIteratorExpression
(requires patching camel-core)? So you can write for example
"split(stax(Record.class))" in your route.
Regards,
Richard
On Thu, May 12, 2011 at 5:55 PM, Romain Manni-Bucau
<rm...@gmail.com>wrote:
> Hi all,
>
> i worked a bit around stax (thanks to claus for its advices).
>
> You can find what i've done here:
> http://code.google.com/p/rmannibucau/source/browse/camel/camel-stax/
>
> The test show what can be done with it:
>
> http://code.google.com/p/rmannibucau/source/browse/camel/camel-stax/src/test/java/org/apache/camel/stax/test/StAXRouteTest.java
>
> - validation using sax (just need a converter)
> - parsing using a sax contenthandler and a stax stream reader (a simple
> component)
> - parsing of sub tree to get jaxb objects using a stax event reader for
> the whole tree and jaxb for the sub objects
>
>
> - Romain
>