Petals ESB Container

Improve classloading for components

Details

  • Type: Task Task
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 4.2.4
  • Fix Version/s: 5.0.0
  • Component/s: Classloader
  • Security Level: Public
  • Description:
    Hide

    The classloading for components and shared libraries should be implemented as follows (according to the JBI spec):

    • The JBI classloader contains jbi classes and optionally some container's specific classes
      • Normally they should be separated in two classloaders inheriting from each other, but for now it corresponds to the system classloader initialised by petals-bootstrap-launcher).
    • A component's classloader has all its shared libraries (in their declaration order) as parents (or if no shared libaries, the JBI classloader as parent).
    • A shared library has the JBI classloader as parent
    • Component or SLs can be parent-first or self-first, in the first case, the default, they first look at their parent and then at their own classes; in the second case, they first look at their own class, then at their parents.

    So there is a flat organisation of classloaders with the JBI classloader at the top, then inheriting from it, some SLs, then, for each components, they inherit from a set of SLs or if this set is empty, they directly inherit from the JBI classloader.

    The current classloading implementation has some shortcomings:

    • The parent JBI classloader is queried many times during the class resolution.
    • Classloaders acts as bottleneck (Java 7 introduced a per-class locking mechanism), and even more if the JBI classloader is so often queried.
    • The class hierarchy that implements it does not reflect properly the spec (there is only one object that takes care of dispatching to SLs classloader), so it introduces complex code in some places.
    • It seems that sometimes the spec is not respected (but it's hard to be completely sure because the code is complex because of previous point).
    • getResources is not implemented w.r.t. the JBI specs.
    • Code comments are not up-to-date.
    Show
    The classloading for components and shared libraries should be implemented as follows (according to the JBI spec):
    • The JBI classloader contains jbi classes and optionally some container's specific classes
      • Normally they should be separated in two classloaders inheriting from each other, but for now it corresponds to the system classloader initialised by petals-bootstrap-launcher).
    • A component's classloader has all its shared libraries (in their declaration order) as parents (or if no shared libaries, the JBI classloader as parent).
    • A shared library has the JBI classloader as parent
    • Component or SLs can be parent-first or self-first, in the first case, the default, they first look at their parent and then at their own classes; in the second case, they first look at their own class, then at their parents.
    So there is a flat organisation of classloaders with the JBI classloader at the top, then inheriting from it, some SLs, then, for each components, they inherit from a set of SLs or if this set is empty, they directly inherit from the JBI classloader. The current classloading implementation has some shortcomings:
    • The parent JBI classloader is queried many times during the class resolution.
    • Classloaders acts as bottleneck (Java 7 introduced a per-class locking mechanism), and even more if the JBI classloader is so often queried.
    • The class hierarchy that implements it does not reflect properly the spec (there is only one object that takes care of dispatching to SLs classloader), so it introduces complex code in some places.
    • It seems that sometimes the spec is not respected (but it's hard to be completely sure because the code is complex because of previous point).
    • getResources is not implemented w.r.t. the JBI specs.
    • Code comments are not up-to-date.
  • Environment:
    -

Activity

People

Dates

  • Created:
    Mon, 11 May 2015 - 11:34:19 +0200
    Updated:
    Fri, 3 Jul 2015 - 13:26:38 +0200
    Resolved:
    Fri, 3 Jul 2015 - 13:26:38 +0200