You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Meise, Christoph" <ch...@immobilienscout24.de> on 2010/09/02 16:17:10 UTC

Classpath resource endpoint?

Hi all,

We have several projects (B, C and D) which rely on testdata coming from project A. Up to now for example project B resolved project A and put the provided testdata into some defined spot (inputFileOrDirectoryName) which was on the eclipse classpath. Than in a testcase a route could be built like this one:

    new RouteBuilder() {
      @Override
      public void configure() throws Exception {
        from("file:" + inputFileOrDirectoryName + "?noop=true").to("log:before.transformation.log").to(
          "xslt:" + transformationFile).to("mock:checkpoint").to("log:after.transformation.log");
      }
    };

Basically it loaded an xml-file, transformed it and did some logging. Now the question arises whether there exists component that can load a resource from the classpath (using either a provided A.jar or the eclipse project A):
       ... from("classpath:" + inputFile).to("log:before.transformation.log").to( ...
I would be glad to receive any help on this issue even stating something like: "No, there is not". If there was nothing, would there be a wish provide it?

Kind Regards,
Christoph Meise
IT Systems&Services, Team SAT

Immobilien Scout GmbH
Andreasstraße 10 	
10243 Berlin 
Fon +49 (0)30 24301-1378
Fax +49 (0)30 24301-1110
christoph.meise@immobilienscout24.de

---------------------------------------------------------------
Immobilien Scout GmbH
Beirat: Dr. Martin Enderle (Vorsitzender)
Geschäftsführer: Dirk Hoffmann, Marc Stilke (Sprecher)
Handelsgericht: Amtsgericht Charlottenburg, HRB 69108
Sitz der Gesellschaft: Berlin
---------------------------------------------------------------

http://www.immobilienscout24.de
Der Marktführer: Deutschlands größter Immobilienmarkt

AW: Classpath resource endpoint?

Posted by "Meise, Christoph" <ch...@immobilienscout24.de>.
Thanks for your responses. Actually implementing what we needed took like half a day. What we now have is a component "classpath" which can take a file or directory as endpoint uri path and produce one message for each file found (thus consuming the file). Does that sound interesting to you? Actually to me this component looks like only a means for testing thus a little narrow. But we could provide it.

Kind Regards,
Christoph Meise

-----Ursprüngliche Nachricht-----
Von: Claus Ibsen [mailto:claus.ibsen@gmail.com] 
Gesendet: Freitag, 3. September 2010 06:39
An: users@camel.apache.org
Betreff: Re: Classpath resource endpoint?

If you projects are running in the same JVM then you can use intra-vm
communications such as: direct, seda components.

If you run your projects in separate JVMs then you need "remoting" to
share data between them. For example files, a shared database,
messaging, http, rmi etc.

And you can use placeholders in the uri so you can easily switch
endpoints, but keeping the route as is.
http://camel.apache.org/properties
http://camel.apache.org/how-do-i-use-spring-property-placeholder-with-camel-xml.html



On Thu, Sep 2, 2010 at 4:17 PM, Meise, Christoph
<ch...@immobilienscout24.de> wrote:
> Hi all,
>
> We have several projects (B, C and D) which rely on testdata coming from project A. Up to now for example project B resolved project A and put the provided testdata into some defined spot (inputFileOrDirectoryName) which was on the eclipse classpath. Than in a testcase a route could be built like this one:
>
>    new RouteBuilder() {
>      @Override
>      public void configure() throws Exception {
>        from("file:" + inputFileOrDirectoryName + "?noop=true").to("log:before.transformation.log").to(
>          "xslt:" + transformationFile).to("mock:checkpoint").to("log:after.transformation.log");
>      }
>    };
>
> Basically it loaded an xml-file, transformed it and did some logging. Now the question arises whether there exists component that can load a resource from the classpath (using either a provided A.jar or the eclipse project A):
>       ... from("classpath:" + inputFile).to("log:before.transformation.log").to( ...
> I would be glad to receive any help on this issue even stating something like: "No, there is not". If there was nothing, would there be a wish provide it?
>
> Kind Regards,
> Christoph Meise
> IT Systems&Services, Team SAT
>
> Immobilien Scout GmbH
> Andreasstraße 10
> 10243 Berlin
> Fon +49 (0)30 24301-1378
> Fax +49 (0)30 24301-1110
> christoph.meise@immobilienscout24.de
>
> ---------------------------------------------------------------
> Immobilien Scout GmbH
> Beirat: Dr. Martin Enderle (Vorsitzender)
> Geschäftsführer: Dirk Hoffmann, Marc Stilke (Sprecher)
> Handelsgericht: Amtsgericht Charlottenburg, HRB 69108
> Sitz der Gesellschaft: Berlin
> ---------------------------------------------------------------
>
> http://www.immobilienscout24.de
> Der Marktführer: Deutschlands größter Immobilienmarkt
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Classpath resource endpoint?

Posted by Claus Ibsen <cl...@gmail.com>.
If you projects are running in the same JVM then you can use intra-vm
communications such as: direct, seda components.

If you run your projects in separate JVMs then you need "remoting" to
share data between them. For example files, a shared database,
messaging, http, rmi etc.

And you can use placeholders in the uri so you can easily switch
endpoints, but keeping the route as is.
http://camel.apache.org/properties
http://camel.apache.org/how-do-i-use-spring-property-placeholder-with-camel-xml.html



On Thu, Sep 2, 2010 at 4:17 PM, Meise, Christoph
<ch...@immobilienscout24.de> wrote:
> Hi all,
>
> We have several projects (B, C and D) which rely on testdata coming from project A. Up to now for example project B resolved project A and put the provided testdata into some defined spot (inputFileOrDirectoryName) which was on the eclipse classpath. Than in a testcase a route could be built like this one:
>
>    new RouteBuilder() {
>      @Override
>      public void configure() throws Exception {
>        from("file:" + inputFileOrDirectoryName + "?noop=true").to("log:before.transformation.log").to(
>          "xslt:" + transformationFile).to("mock:checkpoint").to("log:after.transformation.log");
>      }
>    };
>
> Basically it loaded an xml-file, transformed it and did some logging. Now the question arises whether there exists component that can load a resource from the classpath (using either a provided A.jar or the eclipse project A):
>       ... from("classpath:" + inputFile).to("log:before.transformation.log").to( ...
> I would be glad to receive any help on this issue even stating something like: "No, there is not". If there was nothing, would there be a wish provide it?
>
> Kind Regards,
> Christoph Meise
> IT Systems&Services, Team SAT
>
> Immobilien Scout GmbH
> Andreasstraße 10
> 10243 Berlin
> Fon +49 (0)30 24301-1378
> Fax +49 (0)30 24301-1110
> christoph.meise@immobilienscout24.de
>
> ---------------------------------------------------------------
> Immobilien Scout GmbH
> Beirat: Dr. Martin Enderle (Vorsitzender)
> Geschäftsführer: Dirk Hoffmann, Marc Stilke (Sprecher)
> Handelsgericht: Amtsgericht Charlottenburg, HRB 69108
> Sitz der Gesellschaft: Berlin
> ---------------------------------------------------------------
>
> http://www.immobilienscout24.de
> Der Marktführer: Deutschlands größter Immobilienmarkt
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: Classpath resource endpoint?

Posted by Willem Jiang <wi...@gmail.com>.
I'm afraid we don't have a classpath component as you want.
If you just want to run unit test with an inputstream, you could define 
the route like this
   from("direct:test").to ...
And then using producerTemplate to send the inputstream  which you get 
from the classpath into the "direct:test" endpoint.

If you don't want to change the route, you could leverage 
camel-properties component[1] to replace the "file" endpoint into 
"direct" endpoint.

[1]https://cwiki.apache.org/CAMEL/properties.html

Willem

Meise, Christoph wrote:
> Hi all,
> 
> We have several projects (B, C and D) which rely on testdata coming from project A. Up to now for example project B resolved project A and put the provided testdata into some defined spot (inputFileOrDirectoryName) which was on the eclipse classpath. Than in a testcase a route could be built like this one:
> 
>     new RouteBuilder() {
>       @Override
>       public void configure() throws Exception {
>         from("file:" + inputFileOrDirectoryName + "?noop=true").to("log:before.transformation.log").to(
>           "xslt:" + transformationFile).to("mock:checkpoint").to("log:after.transformation.log");
>       }
>     };
> 
> Basically it loaded an xml-file, transformed it and did some logging. Now the question arises whether there exists component that can load a resource from the classpath (using either a provided A.jar or the eclipse project A):
>        ... from("classpath:" + inputFile).to("log:before.transformation.log").to( ...
> I would be glad to receive any help on this issue even stating something like: "No, there is not". If there was nothing, would there be a wish provide it?
> 
> Kind Regards,
> Christoph Meise
> IT Systems&Services, Team SAT
> 
> Immobilien Scout GmbH
> Andreasstraße 10 	
> 10243 Berlin 
> Fon +49 (0)30 24301-1378
> Fax +49 (0)30 24301-1110
> christoph.meise@immobilienscout24.de
> 
> ---------------------------------------------------------------
> Immobilien Scout GmbH
> Beirat: Dr. Martin Enderle (Vorsitzender)
> Geschäftsführer: Dirk Hoffmann, Marc Stilke (Sprecher)
> Handelsgericht: Amtsgericht Charlottenburg, HRB 69108
> Sitz der Gesellschaft: Berlin
> ---------------------------------------------------------------
> 
> http://www.immobilienscout24.de
> Der Marktführer: Deutschlands größter Immobilienmarkt
>