English 中文(简体)
I want to load my OSGI jar files from a database or other source
原标题:
  • 时间:2009-11-30 00:01:13
  •  标签:
  • osgi

Do i need to supply a custom ClassLoader ? Thinking out loud this does not appear to be the right approach because inside the classloader one does not know the required version.

最佳回答

Given that the loading mechanism essentially works with an URL, I would suggest to try a custom URL handler. Logically you will need to load and activate it before loading any bundles using this handler, otherwise I think it should work.

See the "URL Handlers Service Specification", R4 OSGi Core Specification.

Glassfish is using this approach to install webapp bundles btw.

问题回答

A simple solution is to create your own bootstrap bundle that will provision all other bundles from a database (or other location). OSGi allows you to install bundles from an arbitrary InputStream so it should be reasonably easy to plug this into whatever source you want (e.g. JDBC).

See BundleContext.installBundle() method for more details.

You should not be looking for a "callback" through which the framework would notify you "when it needs to load a required dependency" since automatic dependency management (ala Maven) is not part of the core OSGi functionality (although can be achieved by using services like OBR).

Have a look at the PAX URL project: http://wiki.ops4j.org/display/paxurl/Documentation

That demonstrates the separation of concerns of loading an OSGi bundle from how it is stored. In theory, I don t see any major impediment to using a database as the bundle store, though I also don t see any obvious advantages.

To your point on the bundle versions, you need some mechanism to identify which bundles (and versions) to load. You would store the bundles in the database with version information, otherwise how would you store different versions of the same bundle?

You could always download them from database (or whatever) into some local location and then install them dynamically into the OSGi Framework. All you need to give to the framework is the filesystem path of the bundle. Of course, you will have to write all the glue code for this yourself. On the other hand, if you are using Eclipse P2, you might have some more flexibility thanks to the automated provisioning.





相关问题
OSGi - How mature is this technology?

I have a requirement where I need to share some web resources (jsp, html, js, images, css etc.) across different Spring based Struts 2 applications. And seems like OSGi can be used to achieve this? ...

OSGi unit testing without step that packages bundles

I have checked a few testing solution for OSGI including PAX and had a quick look at the abstract TestCase within Spring DM but they both appear to require one to jar up and bundle associated bundles. ...

Is there a way to secure access to bundles in OSGi?

I have an application consisting of several OSGi bundles. I would like to enforce that some of them only provide other bundles access to their services if a valid token (e. g. a license key) has been ...

• 如何限制方案资源+JV/OSGi的权利?

我想建立一个网站,让人们能够解决方案拟定任务,并最终上载解决办法(无论用哪一种证书-语言),以便核实并与其他人分享。

When to use ServiceTracker vs ServiceReference

I am just starting with OSGi programming and have come across two ways to listener for services being activated. The first way, from an EclipseRCP book, uses ServiceReference: String filter="(...

osgi-like framework without the import/export restrictions?

I like OSGi, but the import/export restrictions and the lack of context class loader creates havoc when trying to use 3rd party libraries (e.g., some libraries try to find file.xml in META-INF, ...

热门标签