Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-1924

BundleUtils.getBundleClassLoader() is utterly complicated.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.0.1
    • None
    • osgi
    • None
    • apache-karaf-2.1.2, openjdk-1.6.0b18

    Description

      I reviewed the code in

      org.apache.openjpa.persistence.osgi

      and could not find a point, why the code in BundleUtils.getBundleClassLoader() uses yet-another implmementation of a class loader (BundleDelegatingClassLoader) in order to acces the class laoder of the openjpa bundle.

      IMHO, BundleUtils.getBundleClassLoader() should simply read

      public static ClassLoader getBundleClassLoader() {

      if (runningUnderOSGi())

      { return BundleUtils.class.getClassLoader(); }

      else

      { return null; }

      }

      rendering the BundleDelegatindClassLoader class and the PersistenceActivator.getBundleClassLoader() method useless.

      Rationale: BundleUtils is a class, that lives inside the openjpa bundle and therefore has been loaded by the OSGi framework using a class loader, which knows the bundle's class and furthermore delegates to the imported packages from other bundles or the OSGi framework, aka the bundle class loader.

      Simplifying the code like suggested is not a big leap, but it helps to keep the code small and readable

      Best regards,

      Wolfgang

      Attachments

        Activity

          People

            Unassigned Unassigned
            wolfgang.glas@ev-i.at Wolfgang Glas
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: