axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Amila Suriarachchi <amilasuriarach...@gmail.com>
Subject Re: [Axis2] Child first class loading
Date Sat, 16 May 2009 04:04:06 GMT
On Fri, May 15, 2009 at 8:05 PM, Andreas Veithen
<andreas.veithen@gmail.com>wrote:

> +1 for allowing parent last class loading, but -1 for making it the
> default. The reason is that I once worked on a larger project where we
> had to use parent last class loading (because we needed a newer
> version of some library that was exposed by the app server), and from
> that experience I know that using this policy leads to issues that are
> very hard to debug. If we make it the default, I expect that it will
> break many existing services that users have built.


I agree with you. Lets keep it as an option to configure since that may
cause
unexpected problems for existing systems.

>
>
> We should really make it configurable, with the parent first policy as
> default. The interesting question is at what level this should be
> configured. I would say that it should be an option in
> service.xml/module.xml, but that makes it probably a bit more
> difficult to implement.

Good suggestion.  I'll try to put it at service.xml/module.xml level. If it
really hard
then can only allow at axis2.xml

thanks,
Amila.

>
>
> Andreas
>
> On Fri, May 15, 2009 at 16:14, Amila Suriarachchi
> <amilasuriarachchi@gmail.com> wrote:
> > hi all,
> >
> > 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;
> >     }
> >
> > I have attach the patch here[1].
> >
> > I tested this with a sample service and it worked fine. Will do some
> tests
> > with the modules as well.
> >
> > I think this should be the default behaviour to axis2 since it allows
> people
> > to use their own classes at the service/module level.
> >
> > Any thoughts?
> >
> > thanks,
> > Amila.
> >
> >
> > [1] https://issues.apache.org/jira/browse/AXIS2-4349
> >
> >
> >
> > --
> > Amila Suriarachchi
> > WSO2 Inc.
> > blog: http://amilachinthaka.blogspot.com/
> >
>



-- 
Amila Suriarachchi
WSO2 Inc.
blog: http://amilachinthaka.blogspot.com/

Mime
View raw message