English 中文(简体)
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, expecting for all such files in all jars to be returned, other libraries use ServiceLoader).

I want OSGi s dynamic loading, ability for handling several versions of the same library, and service framework.

So what are my alternatives? I know of JPF, looking for something less xmlish.

最佳回答

I had this problem with having a java mail bundle separate from my java activation bundle. You have the following options to get 1 bundle to see files (ie. not java resources but things like xml files) in META-INF of other bundles.

1) Merge the bundles together. This is often icky to deal with or just not impossible for the project.

2) Have the bundles that need to share resources be bundle fragments of the bundle that needs to read up the resources. Bundle fragments are defined by the OSGi spec and allow separate bundles to share resources as though they were merged together.

问题回答

Have you tried googling for each library + osgi? A quick glance shows some others experiences and (it would seem) successes.

Sorry for the "just google it answer" but since I don t actively use these libraries in my OSGi app I can only suggest how I ve handled this for some of my libraries ... which was google.

This is not really a good answer, but I don t want this buried in comments.

I want OSGi s dynamic loading, ability for handling several versions of the same library, and service framework.

There are other service frameworks, but to get dynamic loading and several versions of the same class there is nothing else by OSGi that I know of.

Also, now that OSGi seems to finally gain some traction, the pressure on libraries to "play nice" is rising. SpringSource for example maintains a growing collection of OSGified libraries. The package you need may already be there.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签