You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Charles Moulliard <cm...@gmail.com> on 2009/04/02 11:59:53 UTC

How spring beans are loaded by SMX Kernel ?

Hi,

I try to figure out how SMX Kernel + Spring DM + Felix + PAX works together
during the deployment of a WAR bundle using the command

install mvn:org.apache.camel/example/1.0-SNAPSHOT/war

For the simulation, let's say that we have a WAR bundle containing  under :
- META-INF/spring/ directory a service-osgi.xml spring config file. The
service-osgi.xml file contains local beans (that spring must instantiated)
and a reference (osgi:reference class="") to bean exposed as a service by
another OSGI bundle
- WEB-INF/web.xml.

Steps : command install --> PAX --> Felix --> Spring DM --> PAX Web --> ????

Question : When the bundle is installed and started, How can a Servlet have
access to the BundleContext class of Spring and can retrieve its local
spring beans or beans exposed as OSGI:service in another bundle ?

Regards,

Charles
SOA Architect

blog: http://cmoulliard.blogspot.com

Re: How spring beans are loaded by SMX Kernel ?

Posted by Charles Moulliard <cm...@gmail.com>.
I'm in discussion with Alin about Pax Web stuff. I have prepared a small
maven project including a service and wicket web bundles for testing
purposes.

BTW, I will have a look about spring-dm and how to register servlets. This
seems interesting.

On Thu, Apr 2, 2009 at 1:28 PM, Guillaume Nodet <gn...@gmail.com> wrote:

> I think there's no relationship between the processing that PAX Web
> and Spring DM do in this case.
> For the servlet to access the BundleContext, I would think the best
> way would be to have a bean defined in the spring xml config file that
> receives a reference to the BundleContext and store it in a static
> variable that could be accessed by the servlet.
> However you'd have no control over which object would be instanciated
> first.
> A better way may be to not use pax web extender and simply use your
> spring-dm files to create the servlet and expose them in the osgi
> registry (not using the WEB-INF/web.xml file), it should work better.
> Have you asked the Pax Web guys about that ? I'm sure they'll have better
> ideas.
>
> On Thu, Apr 2, 2009 at 11:59, Charles Moulliard <cm...@gmail.com>
> wrote:
> > Hi,
> >
> > I try to figure out how SMX Kernel + Spring DM + Felix + PAX works
> together
> > during the deployment of a WAR bundle using the command
> >
> > install mvn:org.apache.camel/example/1.0-SNAPSHOT/war
> >
> > For the simulation, let's say that we have a WAR bundle containing  under
> :
> > - META-INF/spring/ directory a service-osgi.xml spring config file. The
> > service-osgi.xml file contains local beans (that spring must
> instantiated)
> > and a reference (osgi:reference class="") to bean exposed as a service by
> > another OSGI bundle
> > - WEB-INF/web.xml.
> >
> > Steps : command install --> PAX --> Felix --> Spring DM --> PAX Web -->
> ????
> >
> > Question : When the bundle is installed and started, How can a Servlet
> have
> > access to the BundleContext class of Spring and can retrieve its local
> > spring beans or beans exposed as OSGI:service in another bundle ?
> >
> > Regards,
> >
> > Charles
> > SOA Architect
> >
> > blog: http://cmoulliard.blogspot.com
> >
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com
>

Re: How spring beans are loaded by SMX Kernel ?

Posted by Charles Moulliard <cm...@gmail.com>.
I have compared Spring DM Web support approach with PAX Web Extender &
extender whiteboard and they seems very similar. I wait the feedback of
Alin.

Nevertheless, in both cases, the Apache Wicket Filter servlet must be
modified to retrieve the ApplicationContext (which is in this case the
BundleContext)

The existing config must be transformed to something like this (in bold what
must be modified):

    <context-param>
        <param-name>contextClass</param-name>

<param-value>org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext</param-value>
    </context-param>

    <listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <filter>
        <filter-name>wicket.reportincident.web</filter-name>
        <filter-class>org.apache.wicket.protocol.http.*Osgi*
WicketFilter</filter-class>
        <init-param>
            <!-- <param-name>applicationFactoryClassName</param-name>

<param-value>org.apache.wicket.spring.SpringWebApplicationFactory</param-value>
-->

*  <init-param>
    <param-name>contextClass</param-name>
    <param-value>org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext</param-value>
  </init-param>*


        </init-param>
    </filter>

Obviously, the only integration proposed by Spring is Spring MVC. They
haven't created a kind of generic Helper Servlet that we could use to
integrate by example struts, tapestry, .... frameworks

Charles

On Thu, Apr 2, 2009 at 1:28 PM, Guillaume Nodet <gn...@gmail.com> wrote:

> I think there's no relationship between the processing that PAX Web
> and Spring DM do in this case.
> For the servlet to access the BundleContext, I would think the best
> way would be to have a bean defined in the spring xml config file that
> receives a reference to the BundleContext and store it in a static
> variable that could be accessed by the servlet.
> However you'd have no control over which object would be instanciated
> first.
> A better way may be to not use pax web extender and simply use your
> spring-dm files to create the servlet and expose them in the osgi
> registry (not using the WEB-INF/web.xml file), it should work better.
> Have you asked the Pax Web guys about that ? I'm sure they'll have better
> ideas.
>
> On Thu, Apr 2, 2009 at 11:59, Charles Moulliard <cm...@gmail.com>
> wrote:
> > Hi,
> >
> > I try to figure out how SMX Kernel + Spring DM + Felix + PAX works
> together
> > during the deployment of a WAR bundle using the command
> >
> > install mvn:org.apache.camel/example/1.0-SNAPSHOT/war
> >
> > For the simulation, let's say that we have a WAR bundle containing  under
> :
> > - META-INF/spring/ directory a service-osgi.xml spring config file. The
> > service-osgi.xml file contains local beans (that spring must
> instantiated)
> > and a reference (osgi:reference class="") to bean exposed as a service by
> > another OSGI bundle
> > - WEB-INF/web.xml.
> >
> > Steps : command install --> PAX --> Felix --> Spring DM --> PAX Web -->
> ????
> >
> > Question : When the bundle is installed and started, How can a Servlet
> have
> > access to the BundleContext class of Spring and can retrieve its local
> > spring beans or beans exposed as OSGI:service in another bundle ?
> >
> > Regards,
> >
> > Charles
> > SOA Architect
> >
> > blog: http://cmoulliard.blogspot.com
> >
>
>
>
> --
> Cheers,
> Guillaume Nodet
> ------------------------
> Blog: http://gnodet.blogspot.com/
> ------------------------
> Open Source SOA
> http://fusesource.com
>

Re: How spring beans are loaded by SMX Kernel ?

Posted by Guillaume Nodet <gn...@gmail.com>.
I think there's no relationship between the processing that PAX Web
and Spring DM do in this case.
For the servlet to access the BundleContext, I would think the best
way would be to have a bean defined in the spring xml config file that
receives a reference to the BundleContext and store it in a static
variable that could be accessed by the servlet.
However you'd have no control over which object would be instanciated first.
A better way may be to not use pax web extender and simply use your
spring-dm files to create the servlet and expose them in the osgi
registry (not using the WEB-INF/web.xml file), it should work better.
Have you asked the Pax Web guys about that ? I'm sure they'll have better ideas.

On Thu, Apr 2, 2009 at 11:59, Charles Moulliard <cm...@gmail.com> wrote:
> Hi,
>
> I try to figure out how SMX Kernel + Spring DM + Felix + PAX works together
> during the deployment of a WAR bundle using the command
>
> install mvn:org.apache.camel/example/1.0-SNAPSHOT/war
>
> For the simulation, let's say that we have a WAR bundle containing  under :
> - META-INF/spring/ directory a service-osgi.xml spring config file. The
> service-osgi.xml file contains local beans (that spring must instantiated)
> and a reference (osgi:reference class="") to bean exposed as a service by
> another OSGI bundle
> - WEB-INF/web.xml.
>
> Steps : command install --> PAX --> Felix --> Spring DM --> PAX Web --> ????
>
> Question : When the bundle is installed and started, How can a Servlet have
> access to the BundleContext class of Spring and can retrieve its local
> spring beans or beans exposed as OSGI:service in another bundle ?
>
> Regards,
>
> Charles
> SOA Architect
>
> blog: http://cmoulliard.blogspot.com
>



-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com