You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Martin Stiborský <ma...@gmail.com> on 2012/09/26 12:41:31 UTC
Restlet component with OSGi/Blueprint
Hello,
I'd like to ask you for few things, I'm still missing some basic
points I guess, so maybe it will sound like trivial, sorry for that…
I need to use the restlet with Apache Camel. I need to create REST API
with Apache Camel to offer data and also I need to consume REST API,
from outside applications.
Problem is, that I'm not really sure how to use the Restlet component
inside Camel, with OSGi&Blueprint.
For example, where and how to configure the basic route, I mean, the
REST API you can call on "/rest/...", or where is the port configured.
Real example - I have a Camel bundle, there I have some basic route
with using of Restlet component, see Java code:
from("restlet:http://myapp.com:1551/rest/demo/{something}")
.process(new Processor() {
@Override
public void process(Exchange exchange) ..... skipped ...
As you can see, the path to the REST call (and the server where is the
app running) is hardcoded, that is not good…how to solve it? I know, I
can create (somehow) some preference file and load the server
path/rest api path it in the Java code and then use it, but is that
the correct way? Anyway, my next question is more serious for me :)
This route I've used above as example has own blueprint.xml of course,
and there is a Camel context create for it, and there is a
routeBuilder with reference to corresponding bean. And it works…But,
when I have another bundle, with another Camel context, then I have to
use another port for the restlet component, right? (Because of
different Camel context?) And here I'm again on the wrong way I
think…I don't know the best practices, yet, it's a little bit hard to
start.
Today, the "Camel in Action" book just arrived for me, I hope I'll
fill the most critical knowledge gaps soon, but in the mean time,
could you help me, guys?
Thanks!
--
S pozdravem
Martin Stiborský
Jabber: stibi@njs.netlab.cz
Re: Restlet component with OSGi/Blueprint
Posted by Willem jiang <wi...@gmail.com>.
You may also need to take a look at the camel-servlet component[1].
It's not an easy job to combine the Servlet, CamelContext within the OSGi platform.
[1]https://svn.apache.org/repos/asf/camel/trunk/components/camel-servlet
--
Willem Jiang
Red Hat, Inc.
FuseSource is now part of Red Hat
Web: http://www.fusesource.com | http://www.redhat.com
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang
Weibo: willemjiang
On Thursday, September 27, 2012 at 3:21 PM, Claus Ibsen wrote:
> The reslet framework have a number of extensions. You may need to use
> the servlet extension to hook into the servlet container
> http://wiki.restlet.org/docs_2.1/13-restlet/28-restlet/81-restlet.html
>
> How to configure that, I guess you need to dig in a bit.
>
> As we love contributions, feel free to help improve the docs. Or write
> a little cookbook page etc.
>
>
> On Wed, Sep 26, 2012 at 12:41 PM, Martin Stiborský
> <martin.stiborsky@gmail.com (mailto:martin.stiborsky@gmail.com)> wrote:
> > Hello,
> > I'd like to ask you for few things, I'm still missing some basic
> > points I guess, so maybe it will sound like trivial, sorry for that…
> >
> > I need to use the restlet with Apache Camel. I need to create REST API
> > with Apache Camel to offer data and also I need to consume REST API,
> > from outside applications.
> >
> > Problem is, that I'm not really sure how to use the Restlet component
> > inside Camel, with OSGi&Blueprint.
> >
> > For example, where and how to configure the basic route, I mean, the
> > REST API you can call on "/rest/...", or where is the port configured.
> > Real example - I have a Camel bundle, there I have some basic route
> > with using of Restlet component, see Java code:
> >
> > from("restlet:http://myapp.com:1551/rest/demo/{something}")
> > .process(new Processor() {
> >
> > @Override
> > public void process(Exchange exchange) ..... skipped ...
> >
> > As you can see, the path to the REST call (and the server where is the
> > app running) is hardcoded, that is not good…how to solve it? I know, I
> > can create (somehow) some preference file and load the server
> > path/rest api path it in the Java code and then use it, but is that
> > the correct way? Anyway, my next question is more serious for me :)
> >
> > This route I've used above as example has own blueprint.xml of course,
> > and there is a Camel context create for it, and there is a
> > routeBuilder with reference to corresponding bean. And it works…But,
> > when I have another bundle, with another Camel context, then I have to
> > use another port for the restlet component, right? (Because of
> > different Camel context?) And here I'm again on the wrong way I
> > think…I don't know the best practices, yet, it's a little bit hard to
> > start.
> >
> > Today, the "Camel in Action" book just arrived for me, I hope I'll
> > fill the most critical knowledge gaps soon, but in the mean time,
> > could you help me, guys?
> >
> > Thanks!
> >
> >
> >
> > --
> > S pozdravem
> > Martin Stiborský
> >
> > Jabber: stibi@njs.netlab.cz (mailto:stibi@njs.netlab.cz)
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Email: cibsen@redhat.com (mailto:cibsen@redhat.com)
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
Re: Restlet component with OSGi/Blueprint
Posted by Claus Ibsen <cl...@gmail.com>.
The reslet framework have a number of extensions. You may need to use
the servlet extension to hook into the servlet container
http://wiki.restlet.org/docs_2.1/13-restlet/28-restlet/81-restlet.html
How to configure that, I guess you need to dig in a bit.
As we love contributions, feel free to help improve the docs. Or write
a little cookbook page etc.
On Wed, Sep 26, 2012 at 12:41 PM, Martin Stiborský
<ma...@gmail.com> wrote:
> Hello,
> I'd like to ask you for few things, I'm still missing some basic
> points I guess, so maybe it will sound like trivial, sorry for that…
>
> I need to use the restlet with Apache Camel. I need to create REST API
> with Apache Camel to offer data and also I need to consume REST API,
> from outside applications.
>
> Problem is, that I'm not really sure how to use the Restlet component
> inside Camel, with OSGi&Blueprint.
>
> For example, where and how to configure the basic route, I mean, the
> REST API you can call on "/rest/...", or where is the port configured.
> Real example - I have a Camel bundle, there I have some basic route
> with using of Restlet component, see Java code:
>
> from("restlet:http://myapp.com:1551/rest/demo/{something}")
> .process(new Processor() {
>
> @Override
> public void process(Exchange exchange) ..... skipped ...
>
> As you can see, the path to the REST call (and the server where is the
> app running) is hardcoded, that is not good…how to solve it? I know, I
> can create (somehow) some preference file and load the server
> path/rest api path it in the Java code and then use it, but is that
> the correct way? Anyway, my next question is more serious for me :)
>
> This route I've used above as example has own blueprint.xml of course,
> and there is a Camel context create for it, and there is a
> routeBuilder with reference to corresponding bean. And it works…But,
> when I have another bundle, with another Camel context, then I have to
> use another port for the restlet component, right? (Because of
> different Camel context?) And here I'm again on the wrong way I
> think…I don't know the best practices, yet, it's a little bit hard to
> start.
>
> Today, the "Camel in Action" book just arrived for me, I hope I'll
> fill the most critical knowledge gaps soon, but in the mean time,
> could you help me, guys?
>
> Thanks!
>
>
>
> --
> S pozdravem
> Martin Stiborský
>
> Jabber: stibi@njs.netlab.cz
--
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Re: Restlet component with OSGi/Blueprint
Posted by Christian Müller <ch...@gmail.com>.
Use a properties placeholder like here [1].
You could also use the Camel provided properties component [2].
The FAQ entry [3] could be also useful for you.
[1]
https://svn.apache.org/repos/asf/camel/trunk/components/camel-blueprint/src/test/resources/test.xml
[2] http://camel.apache.org/using-propertyplaceholder.html
[3]
https://camel.apache.org/how-do-i-use-spring-property-placeholder-with-camel-xml.html
Best,
Christian
On Wed, Sep 26, 2012 at 12:41 PM, Martin Stiborský <
martin.stiborsky@gmail.com> wrote:
> Hello,
> I'd like to ask you for few things, I'm still missing some basic
> points I guess, so maybe it will sound like trivial, sorry for that…
>
> I need to use the restlet with Apache Camel. I need to create REST API
> with Apache Camel to offer data and also I need to consume REST API,
> from outside applications.
>
> Problem is, that I'm not really sure how to use the Restlet component
> inside Camel, with OSGi&Blueprint.
>
> For example, where and how to configure the basic route, I mean, the
> REST API you can call on "/rest/...", or where is the port configured.
> Real example - I have a Camel bundle, there I have some basic route
> with using of Restlet component, see Java code:
>
> from("restlet:http://myapp.com:1551/rest/demo/{something}")
> .process(new Processor() {
>
> @Override
> public void process(Exchange exchange)
> ..... skipped ...
>
> As you can see, the path to the REST call (and the server where is the
> app running) is hardcoded, that is not good…how to solve it? I know, I
> can create (somehow) some preference file and load the server
> path/rest api path it in the Java code and then use it, but is that
> the correct way? Anyway, my next question is more serious for me :)
>
> This route I've used above as example has own blueprint.xml of course,
> and there is a Camel context create for it, and there is a
> routeBuilder with reference to corresponding bean. And it works…But,
> when I have another bundle, with another Camel context, then I have to
> use another port for the restlet component, right? (Because of
> different Camel context?) And here I'm again on the wrong way I
> think…I don't know the best practices, yet, it's a little bit hard to
> start.
>
> Today, the "Camel in Action" book just arrived for me, I hope I'll
> fill the most critical knowledge gaps soon, but in the mean time,
> could you help me, guys?
>
> Thanks!
>
>
>
> --
> S pozdravem
> Martin Stiborský
>
> Jabber: stibi@njs.netlab.cz
>
--