Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] Recipe to get extension bundle classes on the class path

Hi Steven,

If you're writing a custom LogManager I'd definitely suggest placing the
code for your implementation on the classpath. e.g. SystemClassLoader. As I
gather you're aware, the LogManager sets the manager in its static
initializer so I'd suggest avoiding any initialization order dependencies
that count  on specific visibility via the context class loader being used
when the class is first loaded. Another good reason to use the
SystemClassLoader over a bundle in this case is that once the LogManager is
set it can't be unloaded (barring Reflection) until the VM is shutdown. In
this case your logging initializer would still have to call
LogManager.readConfiguration(...) to load your settings from the config
area.

That said, if you're in full control of your system and willing to live
with the consequences you should be able to set the LogManager via the
TCCL.
Try creating a regular bundle that contains your LogManager implementation
and in the Activator.start method set the System Properties (if not already
set) and then touch the LogManager class in some way to get it to load and
resolve.
ContextFinder will load classes from the first bundle on the stack which
should be your bundle that holds the implementation so it should just work.
If it doesn't I suspect that you'll have to carefully debug/walk the
LogManager static initializer to see what's going on.

Do either of these approaches work for you? Am I missing something?

-Simon



equinox-dev-bounces@xxxxxxxxxxx wrote on 06/04/2007 02:23:10 PM:

> I'm still struggling with the extension bundle and class path problems
> I wrote about a couple of weeks ago:
>
>   System and context class loaders
>
http://thread.gmane.org/gmane.comp.ide.eclipse.equinox.devel/1651/focus=1743

>     http://article.gmane.org/gmane.comp.ide.eclipse.equinox.devel/1743
>     http://article.gmane.org/gmane.comp.ide.eclipse.equinox.devel/1746
>     http://article.gmane.org/gmane.comp.ide.eclipse.equinox.devel/1747
>     http://article.gmane.org/gmane.comp.ide.eclipse.equinox.devel/1748
>
> My goal is to take some classes that I have packaged in a framework
> extension bundle and make them visible to a Java library that searches
> for classes both in the System Class Loader and the Thread Context
> Class Loader -- the java.util.logging library being my first example.
>
> According to Section 3.15.1 ("Illegal Manifest Headers for Extension
> Bundles") of the OSGi Core R4 specification, classes exported from a
> framework extension bundle must be exported by the System Bundle:
>
> ,----[ Section 3.15.1 ]
> | Both boot class path and framework extension bundles are permitted to
> | specify an Export-Package header. Any exported packages specified by a
> | framework extension bundle must be exported by the System Bundle when
> | the extension bundle is resolved.
> `----
>
> How does being "exported by the System Bundle" relate to which classes
> are visible to bundles that use ClassLoader.getSystemClassLoader() or
> Thread.currentThread().getContextClassLoader()?
>
> As the four articles mentioned above show, I'm in need of some recipe
> to coordinate all of these class loading options. Please advise.
>
> --
> Steven E. Harris
>
> _______________________________________________
> equinox-dev mailing list
> equinox-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/equinox-dev



Back to the top