You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Meissa Sakho <mb...@gmail.com> on 2015/12/22 12:37:29 UTC
calling a spring bean inside an OSGI based project
Hi all,
I have created a restfull web service based on apache cxf with camel.
My endpoint is defined inside my blueprint configuration file like below:
<jaxrs:server id="bwService" address="/booking">
<jaxrs:serviceBeans>
<ref component-id="bookingService"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<bean class=
"com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider"/>
</jaxrs:providers>
</jaxrs:server>
<cxf:bus>
<cxf:features>
<cxf:logging />
</cxf:features>
</cxf:bus>
<bean id="bookingService" class="com.mycompany.BookingService"/>
I would like to Inject the Spring JdbcTemplate that I've defined in my
Spring configuration file to my BookingService business class.
My question is :
How can I a load and inject a Spring bean inside a OSGI based Bean?
Thank you in advance,
Meissa
Re: calling a spring bean inside an OSGI based project
Posted by Meissa Sakho <mb...@gmail.com>.
Matt,
I created the Datasource and the JdbcTemplate in blueprint and it works !
I can get rid off the Spring DM that I used to make all working.
Thank you very much (I owe you a beer :-)
Meissa
2016-01-06 16:01 GMT+01:00 Matt Sicker <bo...@gmail.com>:
> Can't you just create a JdbcTemplate in blueprint and specify the
> DataSource for it to use? I didn't think it required using Spring's
> ApplicationContext or anything. You could also expose it as a service
> (JdbcOperations).
>
> On 6 January 2016 at 02:22, Meissa Sakho <mb...@gmail.com> wrote:
>
> > Henryk,
> > I did not want to use Spring.
> > I just needed to call the Spring JdbcTemplate in my OSGI pure blueprint
> > beans.
> > The Spring JdbcTemplate provides database abstraction that we don't have
> > with others camel component (sql,jpa,jdbc).
> > Using Spring DM solves my problem, but that's not want I prefer.
> > So if you know a way to call a Spring Bean (JdbcTemplate) inside an pure
> > OSGI bean, i'll pay you a beer :-)
> > Thanks,
> > Meissa
> >
> > 2016-01-05 16:28 GMT+01:00 Henryk Konsek <he...@gmail.com>:
> >
> > > To use Spring, you have to stick to Spring DM configuration. Which is
> not
> > > maintained anymore. So using Spring in OSGi creates more problem than
> it
> > > solves.
> > >
> > > If you want to use Spring I recommend dropping OSGi on the behalf of
> the
> > > Spring Boot running as fat jar or WAR.
> > >
> > > Cheers!
> > >
> > > wt., 5.01.2016 o 11:54 użytkownik Meissa Sakho <mb...@gmail.com>
> > > napisał:
> > >
> > > > Hi Greg,
> > > > I've already reviewed this links above.
> > > > You can't define a spring bean inside yous OSGI configuration. It
> won't
> > > > work.
> > > > Let me first explain to you why I need to do it.
> > > > I need to use the Spring JdbcTemplate component because to leverage
> the
> > > > stored procedure abstraction.
> > > > I do that because either the JPA component,sql or jdbc component do
> not
> > > > provide this feature.
> > > > I've found another workaround so far.
> > > > But if you know a working solution for that (calling a spring bean
> > from a
> > > > blueprint), let me know.
> > > > Thans,
> > > > Meissa
> > > >
> > > > 2016-01-04 17:35 GMT+01:00 Greg Autric <ga...@redhat.com>:
> > > >
> > > > > hi Meissa,
> > > > >
> > > > >
> > > > > Blueprint configuration uses "almost" the same syntax and behavior
> > than
> > > > > Spring XML.
> > > > > IMHO, I dislike use a mix of spring conf and blueprint conf.
> > > > > Your spring configuration should work w/ few modifications into
> your
> > > > > blueprint [1].
> > > > >
> > > > > [1]
> > > > >
> > > >
> > >
> >
> http://fuseesb.blogspot.fr/2014/10/what-is-differences-between-camel.html
> > > > >
> > > > > an other useful link :
> > > > > http://camel.apache.org/using-osgi-blueprint-with-camel.html
> > > > >
> > > > > Greg AUTRIC
> > > > > JBoss Middleware Consultant
> > > > >
> > > > > email : gautric __at__ redhat __dot__ com
> > > > > twitter : @gautric_io
> > > > >
> > > > > Red Hat Global Services
> > > > > Red Hat France SARL sit: http://www.redhat.fr
> > > > > Le Linea, 1 rue du General Leclerc, 92047 Paris La Défense Cedex
> > > > > Sent from webmail
> > > > >
> > > > > ----- Mail original -----
> > > > > De: "Meissa Sakho" <mb...@gmail.com>
> > > > > À: users@camel.apache.org
> > > > > Envoyé: Mardi 22 Décembre 2015 12:37:29
> > > > > Objet: calling a spring bean inside an OSGI based project
> > > > >
> > > > > Hi all,
> > > > > I have created a restfull web service based on apache cxf with
> camel.
> > > > > My endpoint is defined inside my blueprint configuration file like
> > > below:
> > > > >
> > > > > <jaxrs:server id="bwService" address="/booking">
> > > > >
> > > > > <jaxrs:serviceBeans>
> > > > >
> > > > > <ref component-id="bookingService"/>
> > > > >
> > > > > </jaxrs:serviceBeans>
> > > > >
> > > > > <jaxrs:providers>
> > > > >
> > > > > <bean class=
> > > > > "com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider"/>
> > > > >
> > > > > </jaxrs:providers>
> > > > >
> > > > > </jaxrs:server>
> > > > >
> > > > > <cxf:bus>
> > > > >
> > > > > <cxf:features>
> > > > >
> > > > > <cxf:logging />
> > > > >
> > > > > </cxf:features>
> > > > >
> > > > > </cxf:bus>
> > > > >
> > > > > <bean id="bookingService"
> class="com.mycompany.BookingService"/>
> > > > >
> > > > >
> > > > > I would like to Inject the Spring JdbcTemplate that I've defined in
> > my
> > > > > Spring configuration file to my BookingService business class.
> > > > >
> > > > > My question is :
> > > > >
> > > > > How can I a load and inject a Spring bean inside a OSGI based Bean?
> > > > >
> > > > > Thank you in advance,
> > > > >
> > > > > Meissa
> > > > >
> > > >
> > > --
> > > Henryk Konsek
> > > http://about.me/hekonsek
> > >
> >
>
>
>
> --
> Matt Sicker <bo...@gmail.com>
>
Re: calling a spring bean inside an OSGI based project
Posted by Matt Sicker <bo...@gmail.com>.
Can't you just create a JdbcTemplate in blueprint and specify the
DataSource for it to use? I didn't think it required using Spring's
ApplicationContext or anything. You could also expose it as a service
(JdbcOperations).
On 6 January 2016 at 02:22, Meissa Sakho <mb...@gmail.com> wrote:
> Henryk,
> I did not want to use Spring.
> I just needed to call the Spring JdbcTemplate in my OSGI pure blueprint
> beans.
> The Spring JdbcTemplate provides database abstraction that we don't have
> with others camel component (sql,jpa,jdbc).
> Using Spring DM solves my problem, but that's not want I prefer.
> So if you know a way to call a Spring Bean (JdbcTemplate) inside an pure
> OSGI bean, i'll pay you a beer :-)
> Thanks,
> Meissa
>
> 2016-01-05 16:28 GMT+01:00 Henryk Konsek <he...@gmail.com>:
>
> > To use Spring, you have to stick to Spring DM configuration. Which is not
> > maintained anymore. So using Spring in OSGi creates more problem than it
> > solves.
> >
> > If you want to use Spring I recommend dropping OSGi on the behalf of the
> > Spring Boot running as fat jar or WAR.
> >
> > Cheers!
> >
> > wt., 5.01.2016 o 11:54 użytkownik Meissa Sakho <mb...@gmail.com>
> > napisał:
> >
> > > Hi Greg,
> > > I've already reviewed this links above.
> > > You can't define a spring bean inside yous OSGI configuration. It won't
> > > work.
> > > Let me first explain to you why I need to do it.
> > > I need to use the Spring JdbcTemplate component because to leverage the
> > > stored procedure abstraction.
> > > I do that because either the JPA component,sql or jdbc component do not
> > > provide this feature.
> > > I've found another workaround so far.
> > > But if you know a working solution for that (calling a spring bean
> from a
> > > blueprint), let me know.
> > > Thans,
> > > Meissa
> > >
> > > 2016-01-04 17:35 GMT+01:00 Greg Autric <ga...@redhat.com>:
> > >
> > > > hi Meissa,
> > > >
> > > >
> > > > Blueprint configuration uses "almost" the same syntax and behavior
> than
> > > > Spring XML.
> > > > IMHO, I dislike use a mix of spring conf and blueprint conf.
> > > > Your spring configuration should work w/ few modifications into your
> > > > blueprint [1].
> > > >
> > > > [1]
> > > >
> > >
> >
> http://fuseesb.blogspot.fr/2014/10/what-is-differences-between-camel.html
> > > >
> > > > an other useful link :
> > > > http://camel.apache.org/using-osgi-blueprint-with-camel.html
> > > >
> > > > Greg AUTRIC
> > > > JBoss Middleware Consultant
> > > >
> > > > email : gautric __at__ redhat __dot__ com
> > > > twitter : @gautric_io
> > > >
> > > > Red Hat Global Services
> > > > Red Hat France SARL sit: http://www.redhat.fr
> > > > Le Linea, 1 rue du General Leclerc, 92047 Paris La Défense Cedex
> > > > Sent from webmail
> > > >
> > > > ----- Mail original -----
> > > > De: "Meissa Sakho" <mb...@gmail.com>
> > > > À: users@camel.apache.org
> > > > Envoyé: Mardi 22 Décembre 2015 12:37:29
> > > > Objet: calling a spring bean inside an OSGI based project
> > > >
> > > > Hi all,
> > > > I have created a restfull web service based on apache cxf with camel.
> > > > My endpoint is defined inside my blueprint configuration file like
> > below:
> > > >
> > > > <jaxrs:server id="bwService" address="/booking">
> > > >
> > > > <jaxrs:serviceBeans>
> > > >
> > > > <ref component-id="bookingService"/>
> > > >
> > > > </jaxrs:serviceBeans>
> > > >
> > > > <jaxrs:providers>
> > > >
> > > > <bean class=
> > > > "com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider"/>
> > > >
> > > > </jaxrs:providers>
> > > >
> > > > </jaxrs:server>
> > > >
> > > > <cxf:bus>
> > > >
> > > > <cxf:features>
> > > >
> > > > <cxf:logging />
> > > >
> > > > </cxf:features>
> > > >
> > > > </cxf:bus>
> > > >
> > > > <bean id="bookingService" class="com.mycompany.BookingService"/>
> > > >
> > > >
> > > > I would like to Inject the Spring JdbcTemplate that I've defined in
> my
> > > > Spring configuration file to my BookingService business class.
> > > >
> > > > My question is :
> > > >
> > > > How can I a load and inject a Spring bean inside a OSGI based Bean?
> > > >
> > > > Thank you in advance,
> > > >
> > > > Meissa
> > > >
> > >
> > --
> > Henryk Konsek
> > http://about.me/hekonsek
> >
>
--
Matt Sicker <bo...@gmail.com>
Re: calling a spring bean inside an OSGI based project
Posted by Meissa Sakho <mb...@gmail.com>.
Henryk,
I did not want to use Spring.
I just needed to call the Spring JdbcTemplate in my OSGI pure blueprint
beans.
The Spring JdbcTemplate provides database abstraction that we don't have
with others camel component (sql,jpa,jdbc).
Using Spring DM solves my problem, but that's not want I prefer.
So if you know a way to call a Spring Bean (JdbcTemplate) inside an pure
OSGI bean, i'll pay you a beer :-)
Thanks,
Meissa
2016-01-05 16:28 GMT+01:00 Henryk Konsek <he...@gmail.com>:
> To use Spring, you have to stick to Spring DM configuration. Which is not
> maintained anymore. So using Spring in OSGi creates more problem than it
> solves.
>
> If you want to use Spring I recommend dropping OSGi on the behalf of the
> Spring Boot running as fat jar or WAR.
>
> Cheers!
>
> wt., 5.01.2016 o 11:54 użytkownik Meissa Sakho <mb...@gmail.com>
> napisał:
>
> > Hi Greg,
> > I've already reviewed this links above.
> > You can't define a spring bean inside yous OSGI configuration. It won't
> > work.
> > Let me first explain to you why I need to do it.
> > I need to use the Spring JdbcTemplate component because to leverage the
> > stored procedure abstraction.
> > I do that because either the JPA component,sql or jdbc component do not
> > provide this feature.
> > I've found another workaround so far.
> > But if you know a working solution for that (calling a spring bean from a
> > blueprint), let me know.
> > Thans,
> > Meissa
> >
> > 2016-01-04 17:35 GMT+01:00 Greg Autric <ga...@redhat.com>:
> >
> > > hi Meissa,
> > >
> > >
> > > Blueprint configuration uses "almost" the same syntax and behavior than
> > > Spring XML.
> > > IMHO, I dislike use a mix of spring conf and blueprint conf.
> > > Your spring configuration should work w/ few modifications into your
> > > blueprint [1].
> > >
> > > [1]
> > >
> >
> http://fuseesb.blogspot.fr/2014/10/what-is-differences-between-camel.html
> > >
> > > an other useful link :
> > > http://camel.apache.org/using-osgi-blueprint-with-camel.html
> > >
> > > Greg AUTRIC
> > > JBoss Middleware Consultant
> > >
> > > email : gautric __at__ redhat __dot__ com
> > > twitter : @gautric_io
> > >
> > > Red Hat Global Services
> > > Red Hat France SARL sit: http://www.redhat.fr
> > > Le Linea, 1 rue du General Leclerc, 92047 Paris La Défense Cedex
> > > Sent from webmail
> > >
> > > ----- Mail original -----
> > > De: "Meissa Sakho" <mb...@gmail.com>
> > > À: users@camel.apache.org
> > > Envoyé: Mardi 22 Décembre 2015 12:37:29
> > > Objet: calling a spring bean inside an OSGI based project
> > >
> > > Hi all,
> > > I have created a restfull web service based on apache cxf with camel.
> > > My endpoint is defined inside my blueprint configuration file like
> below:
> > >
> > > <jaxrs:server id="bwService" address="/booking">
> > >
> > > <jaxrs:serviceBeans>
> > >
> > > <ref component-id="bookingService"/>
> > >
> > > </jaxrs:serviceBeans>
> > >
> > > <jaxrs:providers>
> > >
> > > <bean class=
> > > "com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider"/>
> > >
> > > </jaxrs:providers>
> > >
> > > </jaxrs:server>
> > >
> > > <cxf:bus>
> > >
> > > <cxf:features>
> > >
> > > <cxf:logging />
> > >
> > > </cxf:features>
> > >
> > > </cxf:bus>
> > >
> > > <bean id="bookingService" class="com.mycompany.BookingService"/>
> > >
> > >
> > > I would like to Inject the Spring JdbcTemplate that I've defined in my
> > > Spring configuration file to my BookingService business class.
> > >
> > > My question is :
> > >
> > > How can I a load and inject a Spring bean inside a OSGI based Bean?
> > >
> > > Thank you in advance,
> > >
> > > Meissa
> > >
> >
> --
> Henryk Konsek
> http://about.me/hekonsek
>
Re: calling a spring bean inside an OSGI based project
Posted by Henryk Konsek <he...@gmail.com>.
To use Spring, you have to stick to Spring DM configuration. Which is not
maintained anymore. So using Spring in OSGi creates more problem than it
solves.
If you want to use Spring I recommend dropping OSGi on the behalf of the
Spring Boot running as fat jar or WAR.
Cheers!
wt., 5.01.2016 o 11:54 użytkownik Meissa Sakho <mb...@gmail.com> napisał:
> Hi Greg,
> I've already reviewed this links above.
> You can't define a spring bean inside yous OSGI configuration. It won't
> work.
> Let me first explain to you why I need to do it.
> I need to use the Spring JdbcTemplate component because to leverage the
> stored procedure abstraction.
> I do that because either the JPA component,sql or jdbc component do not
> provide this feature.
> I've found another workaround so far.
> But if you know a working solution for that (calling a spring bean from a
> blueprint), let me know.
> Thans,
> Meissa
>
> 2016-01-04 17:35 GMT+01:00 Greg Autric <ga...@redhat.com>:
>
> > hi Meissa,
> >
> >
> > Blueprint configuration uses "almost" the same syntax and behavior than
> > Spring XML.
> > IMHO, I dislike use a mix of spring conf and blueprint conf.
> > Your spring configuration should work w/ few modifications into your
> > blueprint [1].
> >
> > [1]
> >
> http://fuseesb.blogspot.fr/2014/10/what-is-differences-between-camel.html
> >
> > an other useful link :
> > http://camel.apache.org/using-osgi-blueprint-with-camel.html
> >
> > Greg AUTRIC
> > JBoss Middleware Consultant
> >
> > email : gautric __at__ redhat __dot__ com
> > twitter : @gautric_io
> >
> > Red Hat Global Services
> > Red Hat France SARL sit: http://www.redhat.fr
> > Le Linea, 1 rue du General Leclerc, 92047 Paris La Défense Cedex
> > Sent from webmail
> >
> > ----- Mail original -----
> > De: "Meissa Sakho" <mb...@gmail.com>
> > À: users@camel.apache.org
> > Envoyé: Mardi 22 Décembre 2015 12:37:29
> > Objet: calling a spring bean inside an OSGI based project
> >
> > Hi all,
> > I have created a restfull web service based on apache cxf with camel.
> > My endpoint is defined inside my blueprint configuration file like below:
> >
> > <jaxrs:server id="bwService" address="/booking">
> >
> > <jaxrs:serviceBeans>
> >
> > <ref component-id="bookingService"/>
> >
> > </jaxrs:serviceBeans>
> >
> > <jaxrs:providers>
> >
> > <bean class=
> > "com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider"/>
> >
> > </jaxrs:providers>
> >
> > </jaxrs:server>
> >
> > <cxf:bus>
> >
> > <cxf:features>
> >
> > <cxf:logging />
> >
> > </cxf:features>
> >
> > </cxf:bus>
> >
> > <bean id="bookingService" class="com.mycompany.BookingService"/>
> >
> >
> > I would like to Inject the Spring JdbcTemplate that I've defined in my
> > Spring configuration file to my BookingService business class.
> >
> > My question is :
> >
> > How can I a load and inject a Spring bean inside a OSGI based Bean?
> >
> > Thank you in advance,
> >
> > Meissa
> >
>
--
Henryk Konsek
http://about.me/hekonsek
Re: calling a spring bean inside an OSGI based project
Posted by Meissa Sakho <mb...@gmail.com>.
Hi Greg,
I've already reviewed this links above.
You can't define a spring bean inside yous OSGI configuration. It won't
work.
Let me first explain to you why I need to do it.
I need to use the Spring JdbcTemplate component because to leverage the
stored procedure abstraction.
I do that because either the JPA component,sql or jdbc component do not
provide this feature.
I've found another workaround so far.
But if you know a working solution for that (calling a spring bean from a
blueprint), let me know.
Thans,
Meissa
2016-01-04 17:35 GMT+01:00 Greg Autric <ga...@redhat.com>:
> hi Meissa,
>
>
> Blueprint configuration uses "almost" the same syntax and behavior than
> Spring XML.
> IMHO, I dislike use a mix of spring conf and blueprint conf.
> Your spring configuration should work w/ few modifications into your
> blueprint [1].
>
> [1]
> http://fuseesb.blogspot.fr/2014/10/what-is-differences-between-camel.html
>
> an other useful link :
> http://camel.apache.org/using-osgi-blueprint-with-camel.html
>
> Greg AUTRIC
> JBoss Middleware Consultant
>
> email : gautric __at__ redhat __dot__ com
> twitter : @gautric_io
>
> Red Hat Global Services
> Red Hat France SARL sit: http://www.redhat.fr
> Le Linea, 1 rue du General Leclerc, 92047 Paris La Défense Cedex
> Sent from webmail
>
> ----- Mail original -----
> De: "Meissa Sakho" <mb...@gmail.com>
> À: users@camel.apache.org
> Envoyé: Mardi 22 Décembre 2015 12:37:29
> Objet: calling a spring bean inside an OSGI based project
>
> Hi all,
> I have created a restfull web service based on apache cxf with camel.
> My endpoint is defined inside my blueprint configuration file like below:
>
> <jaxrs:server id="bwService" address="/booking">
>
> <jaxrs:serviceBeans>
>
> <ref component-id="bookingService"/>
>
> </jaxrs:serviceBeans>
>
> <jaxrs:providers>
>
> <bean class=
> "com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider"/>
>
> </jaxrs:providers>
>
> </jaxrs:server>
>
> <cxf:bus>
>
> <cxf:features>
>
> <cxf:logging />
>
> </cxf:features>
>
> </cxf:bus>
>
> <bean id="bookingService" class="com.mycompany.BookingService"/>
>
>
> I would like to Inject the Spring JdbcTemplate that I've defined in my
> Spring configuration file to my BookingService business class.
>
> My question is :
>
> How can I a load and inject a Spring bean inside a OSGI based Bean?
>
> Thank you in advance,
>
> Meissa
>
Re: calling a spring bean inside an OSGI based project
Posted by Greg Autric <ga...@redhat.com>.
hi Meissa,
Blueprint configuration uses "almost" the same syntax and behavior than Spring XML.
IMHO, I dislike use a mix of spring conf and blueprint conf.
Your spring configuration should work w/ few modifications into your blueprint [1].
[1] http://fuseesb.blogspot.fr/2014/10/what-is-differences-between-camel.html
an other useful link : http://camel.apache.org/using-osgi-blueprint-with-camel.html
Greg AUTRIC
JBoss Middleware Consultant
email : gautric __at__ redhat __dot__ com
twitter : @gautric_io
Red Hat Global Services
Red Hat France SARL sit: http://www.redhat.fr
Le Linea, 1 rue du General Leclerc, 92047 Paris La Défense Cedex
Sent from webmail
----- Mail original -----
De: "Meissa Sakho" <mb...@gmail.com>
À: users@camel.apache.org
Envoyé: Mardi 22 Décembre 2015 12:37:29
Objet: calling a spring bean inside an OSGI based project
Hi all,
I have created a restfull web service based on apache cxf with camel.
My endpoint is defined inside my blueprint configuration file like below:
<jaxrs:server id="bwService" address="/booking">
<jaxrs:serviceBeans>
<ref component-id="bookingService"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<bean class=
"com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider"/>
</jaxrs:providers>
</jaxrs:server>
<cxf:bus>
<cxf:features>
<cxf:logging />
</cxf:features>
</cxf:bus>
<bean id="bookingService" class="com.mycompany.BookingService"/>
I would like to Inject the Spring JdbcTemplate that I've defined in my
Spring configuration file to my BookingService business class.
My question is :
How can I a load and inject a Spring bean inside a OSGI based Bean?
Thank you in advance,
Meissa