ThreadContextClassLoader

From APIDesign

(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
-
[[Java]] provides way to associate a special class loader with each of executing threads. This is handy, as often the executing class needs access to more than its own classes. However it is also acompanied with problems. Especially in a [[modular system]]s. When it is not easy to control thread management, it is hard to make sure the [[ThreadContextClassLoader]] is specified properly.
+
[[Java]] provides way to associate a special class loader with each of executing threads. This is handy, as often the executing class needs access to more than classes visible by its own classloader. However it is also accompanied with problems. Especially in [[modular system]]s. When it is not easy to control thread management (e.g. application can create and destroy threads on the fly), it is hard to make sure the [[ThreadContextClassLoader]] is specified properly.
Things get even more complicated as each [[NetBeans Runtime Container|modular runtime container]] may have different idea what [[ThreadContextClassLoader]] shall do. I know what I am talking about, I have spend last month trying to reimplement [[Netbinox]] [[OSGi]] container to provide [[ThreadContextClassLoader]] which is friendly to [[NetBeans]] modules as well as bundles comming from [[Equinox]] world.
Things get even more complicated as each [[NetBeans Runtime Container|modular runtime container]] may have different idea what [[ThreadContextClassLoader]] shall do. I know what I am talking about, I have spend last month trying to reimplement [[Netbinox]] [[OSGi]] container to provide [[ThreadContextClassLoader]] which is friendly to [[NetBeans]] modules as well as bundles comming from [[Equinox]] world.
 +
 +
=== [[Equinox]] Way ===
 +
 +
The need for enhanced [[ThreadContextClassLoader]] is clear as can be seen summary about [[eclipse:Context_Class_Loader_Enhancements|class loader enhancements]]. It summarizes the need as well as the solution taken by [[Equinox]] guys. Everything is built around '''buddies''' - e.g. each module can define its own '''buddy''' loading policy and let others to register is '''buddies'''.
 +
 +
=== [[NetBeans]] Way ===

Revision as of 16:00, 6 November 2010

Java provides way to associate a special class loader with each of executing threads. This is handy, as often the executing class needs access to more than classes visible by its own classloader. However it is also accompanied with problems. Especially in modular systems. When it is not easy to control thread management (e.g. application can create and destroy threads on the fly), it is hard to make sure the ThreadContextClassLoader is specified properly.

Things get even more complicated as each modular runtime container may have different idea what ThreadContextClassLoader shall do. I know what I am talking about, I have spend last month trying to reimplement Netbinox OSGi container to provide ThreadContextClassLoader which is friendly to NetBeans modules as well as bundles comming from Equinox world.

Equinox Way

The need for enhanced ThreadContextClassLoader is clear as can be seen summary about class loader enhancements. It summarizes the need as well as the solution taken by Equinox guys. Everything is built around buddies - e.g. each module can define its own buddy loading policy and let others to register is buddies.

NetBeans Way

Personal tools
buy