<?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: Calling Eclipse/OSGi Plug-in APIs from outside OSGi &#8211; part three</title>
	<atom:link href="http://www.macrobug.com/blog/2009/01/27/220/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.macrobug.com/blog/2009/01/27/220/</link>
	<description>Macrobug Blog</description>
	<lastBuildDate>Tue, 20 Jul 2010 21:22:49 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Adrian Taylor</title>
		<link>http://www.macrobug.com/blog/2009/01/27/220/comment-page-1/#comment-75752</link>
		<dc:creator>Adrian Taylor</dc:creator>
		<pubDate>Tue, 27 Jan 2009 17:14:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.macrobug.com/blog/2009/01/27/220/#comment-75752</guid>
		<description>So, upon consideration of Felix (and therefore presumably RFC132) here&#039;s how I&#039;d need to do it.

Summary of the problem: I have a simple Java &#039;library&#039; which wishes to use OSGi internally to load and use plug-ins. That library has an API which may be used by any number of driver &#039;applications&#039;, from a simple command-line tool up to arbitrarily complex existing Java web systems. (Not forgetting Eclipse GUIs).

If my understanding is correct of that &#039;embedding Felix&#039; page: with Felix, my &#039;library&#039; would NOT be an OSGi plug-in. It would be a normal Java JAR. That means the driver applications (except Eclipse) could access its APIs freely without any nasty class loading shenanigens. Great! Of course, to embed this into Eclipse, I&#039;d have to create an extra plug-in which wrapped this normal JAR. That&#039;s fine.

Within this JAR, it could create an embedded Felix OSGi framework to load the plug-ins it needs. It would do this using Felix.

That all sounds great, but I have three reservations.

Firstly, I&#039;m not familiar with any aspects of OSGi other than simple plug-in loading, and I appear to do that in an Eclipse-specific way. I use org.eclipse.core.runtime.Platform.getExtensionRegistry().getExtensionPoint(...).getConfigurationElements() and then IConfigurationElement.createExecutableExtension in order to instantiate the plug-ins I want. I suspect if I were to switch to another OSGi framework, I&#039;d have to learn to do things a different way since these are Eclipse-specific APIs, and OSGi in general seems much more focused around service provision. Still, I&#039;m sure there&#039;s a way, and it&#039;s my problem :-)

Secondly, the general advice I see from OSGi experts is &quot;make everything an OSGi bundle!&quot; In the above scenario, I&#039;d actually be taking something which is currently a bundle - my library - and making it a plain old Java library (POJL?) However, I think I&#039;ve come to the conclusion that there&#039;s no other way I can expose the APIs to people outside of OSGi, without using things like &#039;transloader&#039;, so that&#039;s no surprise.

Finally, though: this presents a problem when I want my system to be used as an Eclipse plug-in. It means that I&#039;d have an embedded plug-in system inside my plug-in, and I wouldn&#039;t be able to use any of Eclipse&#039;s extensive facilities to create and distribute those plug-in plug-ins. (For example, update sites, the update manager, maybe even PDE to create the plug-ins, etc.) That&#039;s unacceptable, and I&#039;d need to find a solution.

I&#039;m hoping that when I find the solution to the first point, and work out the generic OSGi APIs I should be using, it will transpire that there is some &#039;extension registry&#039; interface which is implemented by both Equinox (inside Eclipse) and Felix (outside Eclipse). The user of my library will have to pass some instance of this interface to the library when creating it. If they&#039;re working inside Eclipse, that&#039;s easy to obtain; if they&#039;re working outside, they&#039;ll have to initialise Felix themselves. Not ideal but not awful. I&#039;m not sure if it&#039;s even possible yet! (The plug-ins themselves could hopefully use Import-Package, and would therefore get the main &#039;library&#039; code from the Eclipse plug-in or the Felix &#039;system bundle&#039; depending on what was available).

In short: it looks like this could solve the problem, but I&#039;ll need to do some research into non-Equinox-specific ways of loading plug-ins and then find out if those ways can also be used within Equinox. And then find out what other problems pop up!

Thanks again Peter for the useful comment.</description>
		<content:encoded><![CDATA[<p>So, upon consideration of Felix (and therefore presumably RFC132) here&#8217;s how I&#8217;d need to do it.</p>
<p>Summary of the problem: I have a simple Java &#8216;library&#8217; which wishes to use OSGi internally to load and use plug-ins. That library has an API which may be used by any number of driver &#8216;applications&#8217;, from a simple command-line tool up to arbitrarily complex existing Java web systems. (Not forgetting Eclipse GUIs).</p>
<p>If my understanding is correct of that &#8216;embedding Felix&#8217; page: with Felix, my &#8216;library&#8217; would NOT be an OSGi plug-in. It would be a normal Java JAR. That means the driver applications (except Eclipse) could access its APIs freely without any nasty class loading shenanigens. Great! Of course, to embed this into Eclipse, I&#8217;d have to create an extra plug-in which wrapped this normal JAR. That&#8217;s fine.</p>
<p>Within this JAR, it could create an embedded Felix OSGi framework to load the plug-ins it needs. It would do this using Felix.</p>
<p>That all sounds great, but I have three reservations.</p>
<p>Firstly, I&#8217;m not familiar with any aspects of OSGi other than simple plug-in loading, and I appear to do that in an Eclipse-specific way. I use org.eclipse.core.runtime.Platform.getExtensionRegistry().getExtensionPoint(&#8230;).getConfigurationElements() and then IConfigurationElement.createExecutableExtension in order to instantiate the plug-ins I want. I suspect if I were to switch to another OSGi framework, I&#8217;d have to learn to do things a different way since these are Eclipse-specific APIs, and OSGi in general seems much more focused around service provision. Still, I&#8217;m sure there&#8217;s a way, and it&#8217;s my problem :-)</p>
<p>Secondly, the general advice I see from OSGi experts is &#8220;make everything an OSGi bundle!&#8221; In the above scenario, I&#8217;d actually be taking something which is currently a bundle &#8211; my library &#8211; and making it a plain old Java library (POJL?) However, I think I&#8217;ve come to the conclusion that there&#8217;s no other way I can expose the APIs to people outside of OSGi, without using things like &#8216;transloader&#8217;, so that&#8217;s no surprise.</p>
<p>Finally, though: this presents a problem when I want my system to be used as an Eclipse plug-in. It means that I&#8217;d have an embedded plug-in system inside my plug-in, and I wouldn&#8217;t be able to use any of Eclipse&#8217;s extensive facilities to create and distribute those plug-in plug-ins. (For example, update sites, the update manager, maybe even PDE to create the plug-ins, etc.) That&#8217;s unacceptable, and I&#8217;d need to find a solution.</p>
<p>I&#8217;m hoping that when I find the solution to the first point, and work out the generic OSGi APIs I should be using, it will transpire that there is some &#8216;extension registry&#8217; interface which is implemented by both Equinox (inside Eclipse) and Felix (outside Eclipse). The user of my library will have to pass some instance of this interface to the library when creating it. If they&#8217;re working inside Eclipse, that&#8217;s easy to obtain; if they&#8217;re working outside, they&#8217;ll have to initialise Felix themselves. Not ideal but not awful. I&#8217;m not sure if it&#8217;s even possible yet! (The plug-ins themselves could hopefully use Import-Package, and would therefore get the main &#8216;library&#8217; code from the Eclipse plug-in or the Felix &#8217;system bundle&#8217; depending on what was available).</p>
<p>In short: it looks like this could solve the problem, but I&#8217;ll need to do some research into non-Equinox-specific ways of loading plug-ins and then find out if those ways can also be used within Equinox. And then find out what other problems pop up!</p>
<p>Thanks again Peter for the useful comment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adrian Taylor</title>
		<link>http://www.macrobug.com/blog/2009/01/27/220/comment-page-1/#comment-75751</link>
		<dc:creator>Adrian Taylor</dc:creator>
		<pubDate>Tue, 27 Jan 2009 16:33:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.macrobug.com/blog/2009/01/27/220/#comment-75751</guid>
		<description>Thanks Peter!

Another interesting link, linked from the Felix page, is this:
http://code.google.com/p/transloader/
This was written for the exact purpose I am describing. It takes a tree of objects loaded by one ClassLoader and makes a copy which will work in another ClassLoader. Remarkable!

Meanwhile I&#039;ll have a look into RFC 132 and Felix.</description>
		<content:encoded><![CDATA[<p>Thanks Peter!</p>
<p>Another interesting link, linked from the Felix page, is this:<br />
<a href="http://code.google.com/p/transloader/" rel="nofollow">http://code.google.com/p/transloader/</a><br />
This was written for the exact purpose I am describing. It takes a tree of objects loaded by one ClassLoader and makes a copy which will work in another ClassLoader. Remarkable!</p>
<p>Meanwhile I&#8217;ll have a look into RFC 132 and Felix.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Kriens</title>
		<link>http://www.macrobug.com/blog/2009/01/27/220/comment-page-1/#comment-75750</link>
		<dc:creator>Peter Kriens</dc:creator>
		<pubDate>Tue, 27 Jan 2009 16:12:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.macrobug.com/blog/2009/01/27/220/#comment-75750</guid>
		<description>The OSGi is developing RFC 132, which is addressing this issue. 

http://www.osgi.org/Specifications/Drafts

Also take a look at the embedding felix pages on the Felix website.

http://felix.apache.org/site/launching-and-embedding-apache-felix.html

The felix model was the role model for the OSGi RFC 132 specification.</description>
		<content:encoded><![CDATA[<p>The OSGi is developing RFC 132, which is addressing this issue. </p>
<p><a href="http://www.osgi.org/Specifications/Drafts" rel="nofollow">http://www.osgi.org/Specifications/Drafts</a></p>
<p>Also take a look at the embedding felix pages on the Felix website.</p>
<p><a href="http://felix.apache.org/site/launching-and-embedding-apache-felix.html" rel="nofollow">http://felix.apache.org/site/launching-and-embedding-apache-felix.html</a></p>
<p>The felix model was the role model for the OSGi RFC 132 specification.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
