I have some problems regarding OSGi fragments and
. The example below illustrates my problem.
I have a third-party bundle
. I cannot modify
in any way. The bundle contains the following class:
If I call this method from bundle
for
, it will fail, since
is not on the classpath of bundle
.
Can I simply add a fragment
with a dependency to
to modify the classpath of bundle
? Or does this dependency only apply for classes within the fragment?
Long story short:
What are the semantics of
in OSGi, when executed in a class of the Host bundle? Does it include:
<ul>
<li>Q: The bundle classes? A: Yes.</li>
<li>Q: The classes contained in the fragment? A: Yes. <a href="http://olegz.wordpress.com/2008/11/05/osgi-and-classforname/" rel="nofollow">Source</a></li>
<li>Q: The imported packages and the packages exported from required bundles? A: Yes.</li>
<li><strong>Q: The imported packages and the packages exported from required bundles of all fragments? A: I don't know.</strong></li>
</ul>
Code:
Class.forName()
I have a third-party bundle
Code:
Foo
Code:
Foo
Code:
public class Serializer {
public String summarizeClass(String className) {
Class<?> myClass = Class.forName(className);
...
}
}
If I call this method from bundle
Code:
Bar
Code:
org.myPackage.MyClass
Code:
MyClass
Code:
Foo
Can I simply add a fragment
Code:
Foo.fragment
Code:
Bar
Code:
Foo
Long story short:
What are the semantics of
Code:
Class.forName()
<ul>
<li>Q: The bundle classes? A: Yes.</li>
<li>Q: The classes contained in the fragment? A: Yes. <a href="http://olegz.wordpress.com/2008/11/05/osgi-and-classforname/" rel="nofollow">Source</a></li>
<li>Q: The imported packages and the packages exported from required bundles? A: Yes.</li>
<li><strong>Q: The imported packages and the packages exported from required bundles of all fragments? A: I don't know.</strong></li>
</ul>