Uploaded image for project: 'Axis2'
  1. Axis2
  2. AXIS2-4349

Child first class loading

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 1.5.5, 1.6.0
    • None
    • None

    Description

      Currently Axis2 follows the parent first class loading for service and module loading.

      The reason for this is it uses DeploymentClassLoader loader which is extended from the ClassLoader class.

      The loadClass method of the ClassLoader class looks like this.

      protected synchronized Class<?> loadClass(String name, boolean resolve)
      throws ClassNotFoundException
      {
      // First, check if the class has already been loaded
      Class c = findLoadedClass(name);
      if (c == null) {
      try {
      if (parent != null)

      { c = parent.loadClass(name, false); }

      else

      { c = findBootstrapClass0(name); }

      } catch (ClassNotFoundException e)

      { // If still not found, then invoke findClass in order // to find the class. c = findClass(name); }

      }
      if (resolve)

      { resolveClass(c); }

      return c;
      }

      it first check for parent class loader classes and then for its classes. So we can add child first class loading simply reversing this order in a override loadClass method as follows.

      protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {

      Class c = findLoadedClass(name);
      if (c == null) {
      try

      { c = findClass(name); }

      catch (Exception e)

      { c = super.loadClass(name, resolve); }

      }
      return c;
      }

      Attachments

        1. child_first_class_loading.patch
          0.7 kB
          Amila Chinthaka Suriarachchi
        2. classloaderpatch.txt
          20 kB
          Amila Chinthaka Suriarachchi

        Issue Links

          Activity

            People

              Unassigned Unassigned
              amilachinthaka Amila Chinthaka Suriarachchi
              Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: