Ok, at least two scenarios are possible:
1. You have a module A with PanelA and you want to inject someDAO bean,
which is defined inside module A (in the same module where class PanelA is
defined). Then you can use classic @SpringBean annotation, as I wrote in my
previous post.
2. You want to use PanelA class in another bundle B and injects someDAO2
bean which is defined inside module B. In such situation we are using a
diffrent annotation (similar to @SpringBean) which injects bean from current
bundle (bundle where class which uses PanelA is declared - in this example:
bundle B).

Of course a default behavior of @SpringBean annotation is up to your
implementation, it was only an example (in my previous post).
So you should decide if you want to inject a bean from AC where class is
defined or from AC where this class instance is used. Probably when you are
creating a reusable components (panels) then the second situation is more
often.

--
Daniel

On Tue, Jun 23, 2009 at 5:38 PM, Igor Vaynberg <[email protected]>wrote:

> isnt a big point of osgi to manage cross-bundle-dependencies?
>
> so if you inject panel A using panel A's context how does panel A ever
> see beans that are defined in module B?
>
> eg if panel A needs a sessionfactory which is defined in module B?
>
> -igor
>
> On Tue, Jun 23, 2009 at 5:36 AM, Daniel Stoch<[email protected]>
> wrote:
> > Hi,
> >
> > I think your problem is that in Wicket the whole Spring injection
> > mechanism is prepared for applications where there is only one
> > ApplicationContext (AC). This AC is hold in the Wicket application
> > instance. So when you are trying to use @SpringBean annotation Wicket
> > tries to inject a bean from this AC.
> > Inside OSGi there are many AC (each bundle has its own AC), so the
> > base Wicket injection mechanism does not work here for all ACs, only
> > for one which you are save in Wicket application instance. The best
> > solution here is to make adaptation of Wicket injection mechanism to
> > OSGi environment (as we did in our application platform). It is not so
> > easy, but it can be done :).
> >
> > It can work as follows (short draft):
> > When you are using @SpringBean to inject bean inside a class PanelA
> > then injection mechanism should injects a bean from ApplicationContext
> > of bundle where class PanelA is defined. So you must store somewhere
> > information about ApplicationContext in context of bundle class
> > loader. Then when you injecting a bean to PanelA: get a class PanelA
> > classloader find a proper AC for it and then inject a bean from this
> > AC.
> >
> > --
> > Daniel
>

Reply via email to