On 6/21/10 16:41, Kelvin Chan wrote:
I just started with OSGi/Felix and went through a lot of reading over the
weekend regarding classloading/osgi/felix. I still don't have a clear idea of
how to incorporate an external library into my app.
I understand that OSGi do class loading through Import-Package, no
more linear class loading like in an traditional Java app. That means
if a bundle does not specify what packages it want to import, it will
not be available to that bundle. On the other hand, everything on
classpath, if specified by Import-Package, will be available to a
bundle. (did I get that right?)
A bundle can only see stuff it imports as long as there is someone else
exporting it. For class path packages, the system bundle (i.e., the
framework) will export everything in the JRE by default. If you have some
other non-JRE packages on the class path that you want bundles to be able to
import, then you must add them to the
org.osgi.framework.system.packages.extra property in the
conf/config.properties file.
Thanks for the quick reply.
It took me couple tries but eventually got it right. I used log4j as a test and
added It to the org.osgi.framework.system.packages.extra property as well as
the bundle manifest to get it going.
But I didn't quite understand the difference between
org.osgi.framework.system.packages.extra and org.osgi.framework.bootdelegation.
Do bundles get to see all package exported by either properties?
Will won't get to see anything except for what they specifically import.
This is true for packages coming from other bundles or the class path.
The exception to this rule is boot delegation. If you add packages to
the boot delegation property. This gives bundles access to the specified
packages from the class path without the bundles having to import them
at all. This is not a good thing and shouldn't be used in general.
The ultimate goal here is to reuse felix.jar as a host and import a 3rd party
jar so that one of the bundle can use it. (is this even the right approach?)
What's the best way to do this?
The best approach is to create a bundle out of the third-party JAR file and
install it into the framework along with your bundle. If this isn't possible (or
desired), then you can add it to the class path and export it from the system
bundle as described above.
Exporting 3rd party jar in config.properties isn't an ideal solution since it
breaks modularity and I won't be able to use OSGi's facility to resolve
dependencies.
Wouldn't it be nice if I can just build a bundle for a closed-source 3rd party
jar.
Luckily, as Ali points out, you don't need the source to create a
bundle, you just need to add the appropriate OSGi metadata to the JAR
file's manifest.
-> richard
Or open-source everything.
it's a good day for day dreaming
:)
kel
NOTICE: This communication is intended only for the use of the person or entity
named above and may contain information that is confidential or legally
privileged. If you are not the intended recipient named above or a person
responsible for delivering messages or communication to the intended recipient,
you are hereby notified that any use, distribution, or copying of this
communication or any of the information contained in it is strictly prohibited.
If you have this communication in error, please notify me immediately by
telephone and then destroy or delete this communication, or return it to me by
mail if requested. Thank you for your attention and cooperation.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]