2 Replies Latest reply on Mar 8, 2012 4:07 AM by sekaijin

    How to get a resource from a bundle when it is created via blueprint?

    sekaijin

      Hi

       

      I have a bundle created  using the camel-archetype-archetype blueprint.

      my project contains only two elements

      class road builder and a property file.

       

      the blueprint définition is

       

       

      the RouteBuilder in fr.phe.transfo is simply derived from the class of Camel RouteBuilder that implemented the method "configure"

      In constructor method I try to read my file myProperties.properties

      package fr.phe.transfo;

       

      import java.net.URL;

       

      public class RouteBuilder extends org.apache.camel.builder.RouteBuilder {

       

            

           public RouteBuilder() {

                super();

                URL url = getClass().getClassLoader().getResource("myProperties.properties");

                //...

           }

       

           public void configure() {

                // do some things with the properties

                from("file:src/data?noop=true")

                .to("file:target/messages");

           }

      }

       

      the package is correct and contains the properties file.

       

      I tried

      getClass().getClassLoeader().getRessource("myfile")

      Thread.getCurrentThread().getClassLoeader().getRessource("myfile");

      BundleDelegatingClassLoader.getSystemResource("myfile"); //:(

       

      all these methods cause a NullPointerException.

       

      I think I need to get the bundle context to search in the bundle, the resource.

      But I do not know how.

       

      How to get a resource from a bundle when it is created via blueprint?

       

      A+JYT

      PS: Sorry for my approximative english.