felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniele Dellafiore <dani...@dellafiore.net>
Subject Re: spring-osgi and autowired
Date Wed, 06 Apr 2011 12:45:26 GMT
On Wed, Mar 30, 2011 at 6:57 PM, Allen Lau <allen.lau@gmail.com> wrote:

> I think what you want to do is achievable if you have some custom code to
> search through all the bundles imported and get the springA.xml and add it
> to your application context.
>
> I see that you are using Spring-DM, so in that case, if you are relying on
> the extender, why not expose your bundle A beans as services and then
> reference them from bundle B,C,D, etc.
>

I'd like to to that but what I need is that service exported from bundle B
are a single instance container-wide, while I need a different instance to
work for each bundle that import that beans.

So the first solution is the best: some code to load the beans from a
imported bundle.
I can export those as service only if I can have a new instance for every
application bundle that uses my library bundle beans. Is this possible?



>
>
> On Wed, Mar 30, 2011 at 5:37 AM, Daniele Dellafiore
> <daniele@dellafiore.net>wrote:
>
> > On Wed, Mar 30, 2011 at 2:23 PM, Daniele Dellafiore
> > <daniele@dellafiore.net>wrote:
> >
> > > Hi have bundle A with a springA.xml file that depends on beans from
> > bundle
> > > B springB.xml
> > > I've added a springA-osgi.xml with declared services and on bundle A
> > > activation everything works and I have
> > >
> > >
> > > | INFO  | tenderThread-114 | OsgiServiceFactoryBean           |
> > > r.support.OsgiServiceFactoryBean  301 | 42 -
> > org.springframework.osgi.core -
> > > 1.2.0 | Publishing service under classes
> > > [{in.laz.storage.mongo.StorageTemplate}]
> > > INFO  | tenderThread-114 | OsgiServiceFactoryBean           |
> > > r.support.OsgiServiceFactoryBean  301 | 42 -
> > org.springframework.osgi.core -
> > > 1.2.0 | Publishing service under classes [{com.mongodb.Mongo}]
> > >
> > > both of them (even if I really need to export the first as service,
> being
> > > the second injected in the first, anyway.
> > >
> > > Then bundleB have a StorageTemplate (first service) autowired into a
> > bean.
> > > That does not work:
> > > "No matching bean of type [in.laz.storage.mongo.StorageTemplate] found
> > for
> > > dependency"
> > >
> > > even if in springB,xml I import both springA and springA-osgi xml
> (which
> > I
> > > thiink should not be necessary).
> > >
> > > Two question here:
> > > 1. What am I possibly missing that's not making it work?
> > > 2. I'd like that every bundle that imports springA.xml create some new
> > > instances of the beans defined there, but I do not think that's what is
> > > happening: I thing that bundle A instance the beans and export them as
> > > services, and the same instance is eventually injected into the beans
> of
> > > bundle B. That's not what I want, I just want the spring beans
> definition
> > to
> > > stay in bundle A so I do not have to duplicate it in every other
> bundle,
> > how
> > > can I achieve that?
> > >
> >
> > sorry I sent it before was completed.
> > So basically I am failing doing a thing that's not what i really need to
> > do,
> > I just realised :)
> >
> > But I am not finding a way to just make a bundle read xml files from
> other
> > bundles, that should be supported, isn't it? I expect it to be even
> easier
> > than autowiring spring beans exported as osgi services, but if xml are
> not
> > exported... that won't work at all.
> >
> > Thanks for any hint.
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message