You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by fachhoch <fa...@gmail.com> on 2011/06/15 17:12:13 UTC

modifying my app to use osgi

I like the osgi approach of modifying modules without   restarting the
server, I want to use this , and wondering  If I can integrate apache felix
in my exsisting app, I have a web application built with wicket , spring ,
hibernate , using pom , I have subprojects one for war and for jar  , please
suggest me are there any tutorials on integrating osgi into exisisting app ?
is this kind of pluggable ? 

-- 
View this message in context: http://old.nabble.com/modifying-my-app-to-use-osgi-tp31852339p31852339.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: modifying my app to use osgi

Posted by Caspar MacRae <ea...@gmail.com>.
It sounds like you don't really need an app server if it all runs in Jetty
=)  If that's the case why not migrate the entire app to run inside an OSGi
framework?

>From your original question it sounded like you wanted the benefits of OSGi
*throughout* your app, but if you just require an isolated plugin framework
for a small part of your app then Felix/Equinox will be the simplest to
embed (as you've probably seen googling "embed felix" turns up a lot of
results).

Most of the app server peeps have already migrated to OSGi, and then there's
Aries and Virgo, this might be an quicker path to achieve what you want.


On 15 June 2011 20:31, fachhoch <fa...@gmail.com> wrote:

>
> Thank you all for your replies , I did not find any example  on embedding
> karaf in my container , I use weblogic for deplyment and jetty for
> developemnt , please advice meif there are any examples for embedding karaf
> .(I did google but found nothing)
> Thanks a lot.
>
>
> Caspar MacRae-2 wrote:
> >
> > Hi fachhoch,
> >
> > A few months ago I converted a Wicket & Spring app running on Tomcat have
> > an
> > OSGi running on Karaf.  Basically the front-end Wicket stuff still thinks
> > it's talking to vanilla Spring, with Spring bridging to the OSGi
> registry.
> >
> > I couldn't get Hibernate to play nicely so first migrated to vanilla JPA,
> > then changed the provider to EclipseLink (this was a fair bit of work on
> > it's own, you might have better luck with Hibernate than I did).
> >
> > At this point you should be able to deploy your monolithic WAR (assuming
> > your Jar is packed into the War) to the OSGi container (using the pax war
> > handler).
> >
> > Then try to modularise (i.e. pull out a small Jar and convert to OSGi
> > bundle) a service at a time - by changing your Spring config it'll
> happily
> > pickup any OSGi services:
> >
> > <beans  xmlns="http://www.springframework.org/schema/beans"
> >                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >                 xmlns:util="http://www.springframework.org/schema/util"
> >                 xmlns:aop="http://www.springframework.org/schema/aop"
> >
> > xmlns:context="http://www.springframework.org/schema/context
> > "
> >                 xmlns:task="http://www.springframework.org/schema/task"
> >                 xmlns:osgi="http://www.springframework.org/schema/osgi"
> >                 xsi:schemaLocation="
> > http://www.springframework.org/schema/beans
> > http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
> >                         http://www.springframework.org/schema/util
> > http://www.springframework.org/schema/util/spring-util-2.5.xsd
> >                         http://www.springframework.org/schema/aop
> > http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
> >                         http://www.springframework.org/schema/task
> > http://www.springframework.org/schema/task/spring-task-3.0.xsd
> >                         http://www.springframework.org/schema/context
> > http://www.springframework.org/schema/context/spring-context-2.5.xsd
> >                         http://www.springframework.org/schema/osgi
> >
> > http://www.springframework.org/schema/osgi/spring-osgi.xsd">
> >
> >
> > Your service references are then defined with:
> >
> > <osgi:reference cardinality="0..1" interface="my.corp.SomeService" id="
> > SomeService" />
> >
> > The cardinality bit above is import as it allows Spring to rebind the
> > service when you deploy an update.
> >
> > This approach *should* allow you to migrate in a piecemeal manner, I'm
> not
> > certain you can mix the spring references as I didn't do it quite this
> way
> > -
> > so it might require a big bang migration of all services (this what I
> > did).
> >
> >
> > It wasn't a painless experience, but definitely worth it - we've a
> modular
> > app that supports dynamic updates of backend services, and it starts much
> > quicker.
> >
> > If you're using maven there's plenty of docs to help on the OSGi side; I
> > used Declarative Services (using felix SCR annotations) and Felix's
> > maven-bundle-plugin.  I found Felix is a bit too bare metal for
> production
> > use, Karaf uses an underlying framework (Felix/Equinox/..) but gives you
> a
> > lot of stuff out of the box (SSH access, XML features, service scripts
> and
> > a
> > really nice OSGi shell).
> >
> >
> > Good luck =)
> >
> > Caspar
> >
> >
> > On 15 June 2011 16:12, fachhoch <fa...@gmail.com> wrote:
> >
> >>
> >> I like the osgi approach of modifying modules without   restarting the
> >> server, I want to use this , and wondering  If I can integrate apache
> >> felix
> >> in my exsisting app, I have a web application built with wicket , spring
> >> ,
> >> hibernate , using pom , I have subprojects one for war and for jar  ,
> >> please
> >> suggest me are there any tutorials on integrating osgi into exisisting
> >> app
> >> ?
> >> is this kind of pluggable ?
> >>
> >> --
> >> View this message in context:
> >>
> http://old.nabble.com/modifying-my-app-to-use-osgi-tp31852339p31852339.html
> >> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> >> For additional commands, e-mail: users-help@felix.apache.org
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/modifying-my-app-to-use-osgi-tp31852339p31854354.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: modifying my app to use osgi

Posted by fachhoch <fa...@gmail.com>.
Thank you all for your replies , I did not find any example  on embedding
karaf in my container , I use weblogic for deplyment and jetty for
developemnt , please advice meif there are any examples for embedding karaf
.(I did google but found nothing) 
Thanks a lot.


Caspar MacRae-2 wrote:
> 
> Hi fachhoch,
> 
> A few months ago I converted a Wicket & Spring app running on Tomcat have
> an
> OSGi running on Karaf.  Basically the front-end Wicket stuff still thinks
> it's talking to vanilla Spring, with Spring bridging to the OSGi registry.
> 
> I couldn't get Hibernate to play nicely so first migrated to vanilla JPA,
> then changed the provider to EclipseLink (this was a fair bit of work on
> it's own, you might have better luck with Hibernate than I did).
> 
> At this point you should be able to deploy your monolithic WAR (assuming
> your Jar is packed into the War) to the OSGi container (using the pax war
> handler).
> 
> Then try to modularise (i.e. pull out a small Jar and convert to OSGi
> bundle) a service at a time - by changing your Spring config it'll happily
> pickup any OSGi services:
> 
> <beans  xmlns="http://www.springframework.org/schema/beans"
>                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>                 xmlns:util="http://www.springframework.org/schema/util"
>                 xmlns:aop="http://www.springframework.org/schema/aop"
>                
> xmlns:context="http://www.springframework.org/schema/context
> "
>                 xmlns:task="http://www.springframework.org/schema/task"
>                 xmlns:osgi="http://www.springframework.org/schema/osgi"
>                 xsi:schemaLocation="
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
>                         http://www.springframework.org/schema/util
> http://www.springframework.org/schema/util/spring-util-2.5.xsd
>                         http://www.springframework.org/schema/aop
> http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
>                         http://www.springframework.org/schema/task
> http://www.springframework.org/schema/task/spring-task-3.0.xsd
>                         http://www.springframework.org/schema/context
> http://www.springframework.org/schema/context/spring-context-2.5.xsd
>                         http://www.springframework.org/schema/osgi
> 
> http://www.springframework.org/schema/osgi/spring-osgi.xsd">
> 
> 
> Your service references are then defined with:
> 
> <osgi:reference cardinality="0..1" interface="my.corp.SomeService" id="
> SomeService" />
> 
> The cardinality bit above is import as it allows Spring to rebind the
> service when you deploy an update.
> 
> This approach *should* allow you to migrate in a piecemeal manner, I'm not
> certain you can mix the spring references as I didn't do it quite this way
> -
> so it might require a big bang migration of all services (this what I
> did).
> 
> 
> It wasn't a painless experience, but definitely worth it - we've a modular
> app that supports dynamic updates of backend services, and it starts much
> quicker.
> 
> If you're using maven there's plenty of docs to help on the OSGi side; I
> used Declarative Services (using felix SCR annotations) and Felix's
> maven-bundle-plugin.  I found Felix is a bit too bare metal for production
> use, Karaf uses an underlying framework (Felix/Equinox/..) but gives you a
> lot of stuff out of the box (SSH access, XML features, service scripts and
> a
> really nice OSGi shell).
> 
> 
> Good luck =)
> 
> Caspar
> 
> 
> On 15 June 2011 16:12, fachhoch <fa...@gmail.com> wrote:
> 
>>
>> I like the osgi approach of modifying modules without   restarting the
>> server, I want to use this , and wondering  If I can integrate apache
>> felix
>> in my exsisting app, I have a web application built with wicket , spring
>> ,
>> hibernate , using pom , I have subprojects one for war and for jar  ,
>> please
>> suggest me are there any tutorials on integrating osgi into exisisting
>> app
>> ?
>> is this kind of pluggable ?
>>
>> --
>> View this message in context:
>> http://old.nabble.com/modifying-my-app-to-use-osgi-tp31852339p31852339.html
>> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://old.nabble.com/modifying-my-app-to-use-osgi-tp31852339p31854354.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: modifying my app to use osgi

Posted by Caspar MacRae <ea...@gmail.com>.
Hi fachhoch,

A few months ago I converted a Wicket & Spring app running on Tomcat have an
OSGi running on Karaf.  Basically the front-end Wicket stuff still thinks
it's talking to vanilla Spring, with Spring bridging to the OSGi registry.

I couldn't get Hibernate to play nicely so first migrated to vanilla JPA,
then changed the provider to EclipseLink (this was a fair bit of work on
it's own, you might have better luck with Hibernate than I did).

At this point you should be able to deploy your monolithic WAR (assuming
your Jar is packed into the War) to the OSGi container (using the pax war
handler).

Then try to modularise (i.e. pull out a small Jar and convert to OSGi
bundle) a service at a time - by changing your Spring config it'll happily
pickup any OSGi services:

<beans  xmlns="http://www.springframework.org/schema/beans"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:util="http://www.springframework.org/schema/util"
                xmlns:aop="http://www.springframework.org/schema/aop"
                xmlns:context="http://www.springframework.org/schema/context
"
                xmlns:task="http://www.springframework.org/schema/task"
                xmlns:osgi="http://www.springframework.org/schema/osgi"
                xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                        http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.5.xsd
                        http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
                        http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.0.xsd
                        http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
                        http://www.springframework.org/schema/osgi

http://www.springframework.org/schema/osgi/spring-osgi.xsd">


Your service references are then defined with:

<osgi:reference cardinality="0..1" interface="my.corp.SomeService" id="
SomeService" />

The cardinality bit above is import as it allows Spring to rebind the
service when you deploy an update.

This approach *should* allow you to migrate in a piecemeal manner, I'm not
certain you can mix the spring references as I didn't do it quite this way -
so it might require a big bang migration of all services (this what I did).


It wasn't a painless experience, but definitely worth it - we've a modular
app that supports dynamic updates of backend services, and it starts much
quicker.

If you're using maven there's plenty of docs to help on the OSGi side; I
used Declarative Services (using felix SCR annotations) and Felix's
maven-bundle-plugin.  I found Felix is a bit too bare metal for production
use, Karaf uses an underlying framework (Felix/Equinox/..) but gives you a
lot of stuff out of the box (SSH access, XML features, service scripts and a
really nice OSGi shell).


Good luck =)

Caspar


On 15 June 2011 16:12, fachhoch <fa...@gmail.com> wrote:

>
> I like the osgi approach of modifying modules without   restarting the
> server, I want to use this , and wondering  If I can integrate apache felix
> in my exsisting app, I have a web application built with wicket , spring ,
> hibernate , using pom , I have subprojects one for war and for jar  ,
> please
> suggest me are there any tutorials on integrating osgi into exisisting app
> ?
> is this kind of pluggable ?
>
> --
> View this message in context:
> http://old.nabble.com/modifying-my-app-to-use-osgi-tp31852339p31852339.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: modifying my app to use osgi

Posted by Donald Whytock <dw...@gmail.com>.
It can be made sort of pluggable.  There are jars that have OSGi
activators and manifests that handle all the OSGi-specific
functionality and are otherwise ignored when the jar's used outside of
OSGi.

A couple things you need to pay attention to:

- Thread control.  Just because you stop a bundle doesn't mean threads
that bundle started will be stopped as well.  So your thread
management needs to be sensitive to changes in the bundle state.

- Classloader.  Each bundle has its own classloader, and can have a
problem seeing class definitions outside itself unless specifically
made visible through the manifests.  Full classpaths aren't
sufficient; they need to be exposed.  And for the sake of passing
objects between bundles you may be relying on interfaces more than
usual.

Don

On Wed, Jun 15, 2011 at 11:24 AM, Achim Nierbeck
<bc...@googlemail.com> wrote:
> Hi,
>
> I suggest take a look at Apache Karaf it contains pretty much what you need.
> It uses Felix/Equinox as base OSGi Framework, you are free of choice
> if you want to use spring/spring-dm or Blueprint. You are able to deploy
> std. or OSGi wars out of the box because of Pax Web.
> You might even consider using Pax Wicket for your Wicket (OSGi-fied)
> application.
> So rather building all from scratch use something that is already
> there and working :-)
>
> regards, Achim
>
>
> 2011/6/15 fachhoch <fa...@gmail.com>:
>>
>> I like the osgi approach of modifying modules without   restarting the
>> server, I want to use this , and wondering  If I can integrate apache felix
>> in my exsisting app, I have a web application built with wicket , spring ,
>> hibernate , using pom , I have subprojects one for war and for jar  , please
>> suggest me are there any tutorials on integrating osgi into exisisting app ?
>> is this kind of pluggable ?
>>
>> --
>> View this message in context: http://old.nabble.com/modifying-my-app-to-use-osgi-tp31852339p31852339.html
>> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>
>
>
>
> --
> --
> *Achim Nierbeck*
>
>
> Apache Karaf <http://karaf.apache.org/> Committer & PMC
> OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/>
> Committer & Project Lead
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: modifying my app to use osgi

Posted by Achim Nierbeck <bc...@googlemail.com>.
Hi,

I suggest take a look at Apache Karaf it contains pretty much what you need.
It uses Felix/Equinox as base OSGi Framework, you are free of choice
if you want to use spring/spring-dm or Blueprint. You are able to deploy
std. or OSGi wars out of the box because of Pax Web.
You might even consider using Pax Wicket for your Wicket (OSGi-fied)
application.
So rather building all from scratch use something that is already
there and working :-)

regards, Achim


2011/6/15 fachhoch <fa...@gmail.com>:
>
> I like the osgi approach of modifying modules without   restarting the
> server, I want to use this , and wondering  If I can integrate apache felix
> in my exsisting app, I have a web application built with wicket , spring ,
> hibernate , using pom , I have subprojects one for war and for jar  , please
> suggest me are there any tutorials on integrating osgi into exisisting app ?
> is this kind of pluggable ?
>
> --
> View this message in context: http://old.nabble.com/modifying-my-app-to-use-osgi-tp31852339p31852339.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>



-- 
--
*Achim Nierbeck*


Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/>
Committer & Project Lead

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org