You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Ricardo Garcia <th...@gmail.com> on 2023/07/31 21:03:38 UTC
Fwd: loading routes from external xml files
Hi, I am migrating to camel 4, as part of a broader migration to all
jakarta API instead of javax API
In camel 3 I could load routes from multiple external xml files:
try (DirectoryStream<Path> ds = Files.newDirectoryStream(routesDir, "*.xml"
);
DefaultResourceResolvers.FileResolver resolver = new
DefaultResourceResolvers.FileResolver()) {
resolver.setCamelContext(camelContext);
for(Path file : ds)
try {
log.debug("Loading routes in {}", file);
Resource resource = resolver.resolve(file.toUri().toString());
camelContext.getRoutesLoader().loadRoutes(resource);
} catch(Exception ex) {
log.error("Cannot load routes in " + file, ex);
}
}
But in camel 4 RC2, "getRoutesLoader()" does not exist in
DefaultCamelContext, nor in ExtendedCamelContext... so how should we do it
then?
Thanks
--
Chipu
Re: loading routes from external xml files
Posted by Ricardo Garcia <th...@gmail.com>.
@ski n
Simply:
camelContext.getRoutesLoader() ->
org.apache.camel.support.
PluginHelper.getRoutesLoader(camelContext)
On Tue, Aug 1, 2023 at 8:34 AM ski n <ra...@gmail.com> wrote:
> OK, good to know as I use this functionality also heavily. Some
> questions/remarks about this:
>
> 1. What's the reason that it was (re)moved? Is there a new concept behind
> the PluginHelper?
> 2. Maybe good to add this to the migration guide (
> https://camel.apache.org/manual/camel-4-migration-guide.html).
> 3. @chipu. Would be nice if you can post your new solution here?
>
> --
>
> Raymond
>
> On Tue, Aug 1, 2023 at 7:56 AM Claus Ibsen <cl...@gmail.com> wrote:
>
> > Hi
> >
> > You can use org.apache.camel.support.PluginHelper
> >
> > On Mon, Jul 31, 2023 at 11:04 PM Ricardo Garcia <th...@gmail.com>
> > wrote:
> >
> > > Hi, I am migrating to camel 4, as part of a broader migration to all
> > > jakarta API instead of javax API
> > > In camel 3 I could load routes from multiple external xml files:
> > >
> > > try (DirectoryStream<Path> ds = Files.newDirectoryStream(routesDir,
> > "*.xml"
> > > );
> > > DefaultResourceResolvers.FileResolver resolver = new
> > > DefaultResourceResolvers.FileResolver()) {
> > > resolver.setCamelContext(camelContext);
> > > for(Path file : ds)
> > > try {
> > > log.debug("Loading routes in {}", file);
> > > Resource resource = resolver.resolve(file.toUri().toString());
> > > camelContext.getRoutesLoader().loadRoutes(resource);
> > > } catch(Exception ex) {
> > > log.error("Cannot load routes in " + file, ex);
> > > }
> > > }
> > > But in camel 4 RC2, "getRoutesLoader()" does not exist in
> > > DefaultCamelContext, nor in ExtendedCamelContext... so how should we do
> > it
> > > then?
> > > Thanks
> > >
> > > --
> > > Chipu
> > >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2
> >
>
--
Chipu
Re: loading routes from external xml files
Posted by ski n <ra...@gmail.com>.
OK, good to know as I use this functionality also heavily. Some
questions/remarks about this:
1. What's the reason that it was (re)moved? Is there a new concept behind
the PluginHelper?
2. Maybe good to add this to the migration guide (
https://camel.apache.org/manual/camel-4-migration-guide.html).
3. @chipu. Would be nice if you can post your new solution here?
--
Raymond
On Tue, Aug 1, 2023 at 7:56 AM Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> You can use org.apache.camel.support.PluginHelper
>
> On Mon, Jul 31, 2023 at 11:04 PM Ricardo Garcia <th...@gmail.com>
> wrote:
>
> > Hi, I am migrating to camel 4, as part of a broader migration to all
> > jakarta API instead of javax API
> > In camel 3 I could load routes from multiple external xml files:
> >
> > try (DirectoryStream<Path> ds = Files.newDirectoryStream(routesDir,
> "*.xml"
> > );
> > DefaultResourceResolvers.FileResolver resolver = new
> > DefaultResourceResolvers.FileResolver()) {
> > resolver.setCamelContext(camelContext);
> > for(Path file : ds)
> > try {
> > log.debug("Loading routes in {}", file);
> > Resource resource = resolver.resolve(file.toUri().toString());
> > camelContext.getRoutesLoader().loadRoutes(resource);
> > } catch(Exception ex) {
> > log.error("Cannot load routes in " + file, ex);
> > }
> > }
> > But in camel 4 RC2, "getRoutesLoader()" does not exist in
> > DefaultCamelContext, nor in ExtendedCamelContext... so how should we do
> it
> > then?
> > Thanks
> >
> > --
> > Chipu
> >
>
>
> --
> Claus Ibsen
> -----------------
> @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>
Re: loading routes from external xml files
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
You can use org.apache.camel.support.PluginHelper
On Mon, Jul 31, 2023 at 11:04 PM Ricardo Garcia <th...@gmail.com> wrote:
> Hi, I am migrating to camel 4, as part of a broader migration to all
> jakarta API instead of javax API
> In camel 3 I could load routes from multiple external xml files:
>
> try (DirectoryStream<Path> ds = Files.newDirectoryStream(routesDir, "*.xml"
> );
> DefaultResourceResolvers.FileResolver resolver = new
> DefaultResourceResolvers.FileResolver()) {
> resolver.setCamelContext(camelContext);
> for(Path file : ds)
> try {
> log.debug("Loading routes in {}", file);
> Resource resource = resolver.resolve(file.toUri().toString());
> camelContext.getRoutesLoader().loadRoutes(resource);
> } catch(Exception ex) {
> log.error("Cannot load routes in " + file, ex);
> }
> }
> But in camel 4 RC2, "getRoutesLoader()" does not exist in
> DefaultCamelContext, nor in ExtendedCamelContext... so how should we do it
> then?
> Thanks
>
> --
> Chipu
>
--
Claus Ibsen
-----------------
@davsclaus
Camel in Action 2: https://www.manning.com/ibsen2