<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How to invoke Spring beans in other osgi bundle</title>
	<atom:link href="http://blog.esofthead.com/how-to-invoke-spring-beans-in-other-osgi-bundle/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.esofthead.com/how-to-invoke-spring-beans-in-other-osgi-bundle/</link>
	<description>The official blog of eSoftHead Company</description>
	<lastBuildDate>Wed, 14 Jul 2010 00:47:10 -0400</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: admin</title>
		<link>http://blog.esofthead.com/how-to-invoke-spring-beans-in-other-osgi-bundle/comment-page-1/#comment-55</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Thu, 07 May 2009 10:47:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.esofthead.com/how-to-invoke-spring-beans-in-other-osgi-bundle/#comment-55</guid>
		<description>Thanks Costin, 

The above solution is raised when we need to call spring bean service from a normal java class (a legacy application that it is not managed by Spring). 

The above code sample does a trick and it does not impact the time of initiating Activator because the static method getAuthenticationService is called after Activator start and Spring extender resolves dependencies (We control such flow in our calling function) - and we also handle the possible failures in calling method (in case we can not create the Spring context). 

One thing makes me feel uncomfortable is create the static variable bundleContext (it is a trick to set bundleContext later when create OsgiBundleXmlApplicationContext). Later our implementation, base on the fact that Spring DM registers Spring bean as Osgi service, we use the white board pattern to track whether some Osgi service (Spring bean) is resolved by Spring extender and we catch it.</description>
		<content:encoded><![CDATA[<p>Thanks Costin, </p>
<p>The above solution is raised when we need to call spring bean service from a normal java class (a legacy application that it is not managed by Spring). </p>
<p>The above code sample does a trick and it does not impact the time of initiating Activator because the static method getAuthenticationService is called after Activator start and Spring extender resolves dependencies (We control such flow in our calling function) &#8211; and we also handle the possible failures in calling method (in case we can not create the Spring context). </p>
<p>One thing makes me feel uncomfortable is create the static variable bundleContext (it is a trick to set bundleContext later when create OsgiBundleXmlApplicationContext). Later our implementation, base on the fact that Spring DM registers Spring bean as Osgi service, we use the white board pattern to track whether some Osgi service (Spring bean) is resolved by Spring extender and we catch it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Costin Leau</title>
		<link>http://blog.esofthead.com/how-to-invoke-spring-beans-in-other-osgi-bundle/comment-page-1/#comment-54</link>
		<dc:creator>Costin Leau</dc:creator>
		<pubDate>Thu, 07 May 2009 05:48:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.esofthead.com/how-to-invoke-spring-beans-in-other-osgi-bundle/#comment-54</guid>
		<description>The activator should return as fast as possible since otherwise the entire OSGi platform waits for it. Moreover, why would you want to get a hold of the bean in the activator? Any work done with it, will slow down the OSGi platform even more.

While the solution proposed above works, it has several nasty side effects. There are other alternatives such as:

- wrapping the context creation in a separate thread so the activator returns fast
- lookup the ApplicationContext (as Spring DM publishes as a service upon completion) and then use it  - of course, also within a separate thread

In all cases though you would have to pay attention to all possible outcomes, such as the context failing and thus not being published or Activator/OSGi platform shutdown.
It&#039;s considerably much more easier to leave the Spring DM extender to deal with these issues and simply make your own application IoC&#039;ed rather then using dependency lookup.

Hope this helps,</description>
		<content:encoded><![CDATA[<p>The activator should return as fast as possible since otherwise the entire OSGi platform waits for it. Moreover, why would you want to get a hold of the bean in the activator? Any work done with it, will slow down the OSGi platform even more.</p>
<p>While the solution proposed above works, it has several nasty side effects. There are other alternatives such as:</p>
<p>- wrapping the context creation in a separate thread so the activator returns fast<br />
- lookup the ApplicationContext (as Spring DM publishes as a service upon completion) and then use it  &#8211; of course, also within a separate thread</p>
<p>In all cases though you would have to pay attention to all possible outcomes, such as the context failing and thus not being published or Activator/OSGi platform shutdown.<br />
It&#8217;s considerably much more easier to leave the Spring DM extender to deal with these issues and simply make your own application IoC&#8217;ed rather then using dependency lookup.</p>
<p>Hope this helps,</p>
]]></content:encoded>
	</item>
</channel>
</rss>
