Skip to main content



      Home
Home » Eclipse Projects » Equinox » Custom priority ClassLoader extention ?
Custom priority ClassLoader extention ? [message #74151] Sat, 07 October 2006 11:50 Go to next message
Eclipse UserFriend
What is involved in providing an Equinox extension to allow a plugin to
provide its own ClassLoader implementation has higher precedence than
the default class loader.

Obviously it would be necessary to provide two piece of data in the
MANIFEST.MF, the location of where the custom ClassLoader implementation
(and its supporting classes) can be found and the name of the class.

Bundle-ClassLoader: classloader.jar!com.enterprise.MyClassLoaderImpl;
priority="first"


The reason for this request is that the ATF project are already forcing
the issue to allow loading of the correct JAR file from the xulrunner
distribution location.

The xulrunner project already provides two compatible counterpart JAR
files as part of an xulrunner installation. It would be less
maintainence to have a single Eclipse plugin that was able to resolve
the location of the counterpart JAR files directly from within the
xulrunner installation.

At the moment it is necessary to re-release an updated version of the
Eclipse connecting plugin whenever any part of the interfaces change.
The users of extra new functionality are already doing Class.forName()
existance checking to confirm the interface class is present to make use
of for a certain feature.


Please feel free to point out any obvious holes I maybe digging for
myself with this approach.

RFC

Darryl
Re: Custom priority ClassLoader extention ? [message #74187 is a reply to message #74151] Sat, 07 October 2006 17:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alex_blewitt.yahoo.com

What are you trying to achieve by doing this? If the two Jars are compatible, what is the difference between them? How do you determine which of the two Jars to select? Could other approaches, such as having two fragments with one Jar each help solve the problem?

Alex.
Re: Custom priority ClassLoader extention ? [message #74205 is a reply to message #74187] Sun, 08 October 2006 07:44 Go to previous messageGo to next message
Eclipse UserFriend
Alex Blewitt wrote:
> What are you trying to achieve by doing this? If the two Jars are compatible, what is the difference between them? How do you determine which of the two Jars to select? Could other approaches, such as having two fragments with one Jar each help solve the problem?
>
> Alex.

The Java interface JAR file for Mozilla are distributed with Xulrunner.
There is a one-to-one relationship between the JAR and xulrunner
because those JARs are built and distributed with Xulrunner so always
contain the correct feature set and interfaces that exact version of
Mozilla provides through Java.

mozilla$ find dist -name "Mozilla*.jar" -or -name "javaxpcom*jar"
../dist/sdk/lib/MozillaInterfaces.jar
../dist/sdk/lib/MozillaInterfaces-src.jar
../dist/bin/javaxpcom-src.jar
../dist/bin/javaxpcom.jar


> what is the difference between them?

Well for each successive version of Mozilla/Xulrunner the Xulrunner
developers may choose to add new interfaces that are available over Java.

The version lifecycles of the vendor provided Xulrunner package are
independant of Eclipse version lifecycles. A user may choose to upgrade
his Xulrunner from a vendor (RedHat, etc...) update.


> How do you determine which of the two Jars to select?

This is essentially the point of why a custom ClassLoader is necessary,
with Equinox as it stands it is not in a position to determine this but
a custom provided class would be.

The way the process currently works with Mozilla/Xulrunner is a mixture of:

* Utilizing $HOME/.gre.d/*.conf, /etc/gre.d/*.conf, /etc/gre*conf files
* Looking in the Windows registry for gre.conf information (on windows)
* Looking in specific configuration files (on Mac OS X)
* Utilizing environment variables MOZILLA_FIVE_HOME (in the case of
SWTs native Mozilla embeded widget)
* Automatic searching of the well known locations that popular
distributions use (/usr/lib/mozilla-*, /usr/lib64/mozilla-*, etc..)


This location process is _ALREADY_ being performed by the respective
Eclipse components.

This location process is necessary since Xulrunner is distributed
independently of Eclipse. As in Xulrunner itself is not an eclipse
plugin and a large free standing application. There are moves to
address this situation by some eclipse users (easyeclipse to name an
example). But some Linux users might object to installing two copies of
xulrunner on their system, one within eclipse and one provided by their
vendor. The easyeclipse solution makes most sense to me for users on
the windows getting functionality without installation headache.

Once the location process has completed and a valid libxpcom.{so,dll}
library has been found and loaded and native methods called upon it,
then the counterpart javaxpcom.jar and MozillaInterfaces.jar should be
picked up and used directly from the xulrunner distribution if available.


The purpose of the request/thread to get away from distributing
counterpart Java interface JAR separately from the Xulrunner
distribution as an eclipse plugin.

It would be possible to create an eclipse plugin that contributed the
JARs to the Eclipse platform by way of dynamic location resolution and
then optionally provide a fallback version from its own.



A custom class loader solution then leads into another scenario that
could be implemented as well as (I have not previously discussed in this
thread so as to not cloud the issue).

This feature request would also allow a single plugin version to
successively include fallback JAR files like:

myjavalib-1.7.12-release.jar
myjavalib-1.8.0.4-release.jar
myjavalib-1.8.1-devel.jar

In this scenario we could distribute a copy of the JAR which correctly
married up with the version of Mozilla it was working against at
runtime. So my custom ClassLoader when operating in a fallback scenario
would pick the correct JAR file to introduce to the ClassLoader.

This way version 1.8.1 of the plugin actually supports interfaces of
1.7.12 and 1.8.0.4 and 1.8.1 etc... so the user doesn't have to worry
exactly which version of Mozilla he has installed to get things working.
Any new functionality added in 1.8.1 would simply not be available
because the interface would not be available when trying to instate it
through XPCOM.


To not cloud the issue let me restate the main goal would be dynamic
resolution.


Darryl
Re: Custom priority ClassLoader extention ? [message #74238 is a reply to message #74205] Sun, 08 October 2006 12:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alex_blewitt.yahoo.com

You should be able to do something similar with having pairs of Jars into plugins, and then have those plugins separately versioned. The dependent code would then only need have an import-package, and your bundles could be set up in such a way that if the co-dependent DLL didn't exist, you could prevent the bundle for starting.

Trying to package everything into a single bundle and then rolling your own version control seems like the wrong way to go, from an Eclipse perspective.

Alex.
Re: Custom priority ClassLoader extention ? [message #74256 is a reply to message #74238] Sun, 08 October 2006 22:30 Go to previous messageGo to next message
Eclipse UserFriend
Alex Blewitt wrote:
> You should be able to do something similar with having pairs of Jars into plugins, and then have those plugins separately versioned. The dependent code would then only need have an import-package, and your bundles could be set up in such a way that if the co-dependent DLL didn't exist, you could prevent the bundle for starting.

I dont fully understand what you as stating. Can you cite an example of
an open source project using the method you describe.

The actual JAR I want to load will not be packaged inside the Bundle
distribution, it needs to be loaded from some other place outside the
Bundle install location. Just like libxpcom.so and xpcom.dll are loaded
from some other place outside the Bundle install location.

There is one advantage to having the Bundle started even when no DLLs
are found, that is to provide high quality error report and installation
problem diagnostic. If the Bundle just didn't start this can leave the
user pretty clueless as to why.



> Trying to package everything into a single bundle and then rolling your own version control seems like the wrong way to go, from an Eclipse perspective.

This is just my point. The versioning control of xulrunner is "beyond
the scope of Eclipse" since the Mozilla/Xulrunner package is distributed
externally and independently of Eclipse by the operating system vendor
or directly from the Mozilla website.

The end result of what I'm proposing that we only ever need 1 version of
the plugin if the JARs can be picked up dynamically.


Darryl
Re: Custom priority ClassLoader extention ? [message #74272 is a reply to message #74256] Mon, 09 October 2006 06:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: alex_blewitt.yahoo.com

Rather than replacing the classloader, you might like to see if you can coerce the Fragment mechanism to attach your external code to a XUL-type bundle.

Alternatively, have you looked at the ClassLoadingHook in the org.eclipse.osgi.baseadaptor.hooks package (in the org.eclipse.osgi bundle)? You can override the BaseClassLoader there, but I'm still not sure that's the right way to go.

Alex.
Re: Custom priority ClassLoader extention ? [message #74365 is a reply to message #74151] Tue, 10 October 2006 08:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jeff_mcaffer.REMOVE.ca.ibm.com

I'm not sure I follow the whole issue but is section 20.4 of the Eclipse
RCP book (http://eclipsercp.org) of any use here? See
http://www.eclipse.org/orbit/documents/RCP_Chapter20.pdf

Otherwise, there is a whole adaptor layer below the framework that
allows you to mess with classloader implementation etc. See
http://wiki.eclipse.org/index.php/Adaptor_Hooks

Jeff

Darryl L. Miles wrote:
>
>
> What is involved in providing an Equinox extension to allow a plugin to
> provide its own ClassLoader implementation has higher precedence than
> the default class loader.
>
> Obviously it would be necessary to provide two piece of data in the
> MANIFEST.MF, the location of where the custom ClassLoader implementation
> (and its supporting classes) can be found and the name of the class.
>
> Bundle-ClassLoader: classloader.jar!com.enterprise.MyClassLoaderImpl;
> priority="first"
>
>
> The reason for this request is that the ATF project are already forcing
> the issue to allow loading of the correct JAR file from the xulrunner
> distribution location.
>
> The xulrunner project already provides two compatible counterpart JAR
> files as part of an xulrunner installation. It would be less
> maintainence to have a single Eclipse plugin that was able to resolve
> the location of the counterpart JAR files directly from within the
> xulrunner installation.
>
> At the moment it is necessary to re-release an updated version of the
> Eclipse connecting plugin whenever any part of the interfaces change.
> The users of extra new functionality are already doing Class.forName()
> existance checking to confirm the interface class is present to make use
> of for a certain feature.
>
>
> Please feel free to point out any obvious holes I maybe digging for
> myself with this approach.
>
> RFC
>
> Darryl
Re: Custom priority ClassLoader extention ? [message #74610 is a reply to message #74365] Tue, 10 October 2006 11:28 Go to previous messageGo to next message
Eclipse UserFriend
Jeff McAffer wrote:
> I'm not sure I follow the whole issue but is section 20.4 of the Eclipse
> RCP book (http://eclipsercp.org) of any use here? See
> http://www.eclipse.org/orbit/documents/RCP_Chapter20.pdf

Thanks for the pointer. The crux for those who have not read the PDF is
the use of:

Bundle-Classpath: external:$JDBC_HOME$/drivers/jdbc.jar

This is approach is fine, but I would need to be able to set the value
of JDBC_HOME via code, not from an inherited value since startup. I
guess this wouldn't work as its a chicken and egg situation.

This is why having my own ClassLoader attacks this problem nicely, I can
have auto-configuration on first use, and still provide some classes to
perform fault diagnostic on why my ClassLoader couldn't find the
expected JAR to load.


> Otherwise, there is a whole adaptor layer below the framework that
> allows you to mess with classloader implementation etc. See
> http://wiki.eclipse.org/index.php/Adaptor_Hooks

Now this looks promising org.eclipse.osgi.baseadaptor.hooks for a
Class Loading Hook, EclipseClassLoadingHook. I shall investigate some
more this week.

Any body know of an OSS project which is using it ?

Darryl
Re: Custom priority ClassLoader extention ? [message #74645 is a reply to message #74610] Tue, 10 October 2006 11:40 Go to previous message
Eclipse UserFriend
Originally posted by: jeff_mcaffer.REMOVE.ca.ibm.com

the $JDBC_HOME thing needs to be set as a system property. So you can
set it in config.ini or on the command line. I actually don't remember
when we look for the property but suspect it is when we go to actually
create the classloader. This will be, generally speaking, either when
you start the bundle or first try to load something from the bundle.

As for who is using the classloading hooks, there are several people we
have heard of but its hard to list them. Of course, we use them
ourselves to implement the Eclipse Adaptor. I believe the Aspect folks
(in the Equinox incubator) are using them as well. Various of the IBM
Eclipse based products use them to exploit classloading optimizations
available in the IBM VMs, ...

Jeff


Darryl L. Miles wrote:
> Jeff McAffer wrote:
>> I'm not sure I follow the whole issue but is section 20.4 of the
>> Eclipse RCP book (http://eclipsercp.org) of any use here? See
>> http://www.eclipse.org/orbit/documents/RCP_Chapter20.pdf
>
> Thanks for the pointer. The crux for those who have not read the PDF is
> the use of:
>
> Bundle-Classpath: external:$JDBC_HOME$/drivers/jdbc.jar
>
> This is approach is fine, but I would need to be able to set the value
> of JDBC_HOME via code, not from an inherited value since startup. I
> guess this wouldn't work as its a chicken and egg situation.
>
> This is why having my own ClassLoader attacks this problem nicely, I can
> have auto-configuration on first use, and still provide some classes to
> perform fault diagnostic on why my ClassLoader couldn't find the
> expected JAR to load.
>
>
>> Otherwise, there is a whole adaptor layer below the framework that
>> allows you to mess with classloader implementation etc. See
>> http://wiki.eclipse.org/index.php/Adaptor_Hooks
>
> Now this looks promising org.eclipse.osgi.baseadaptor.hooks for a
> Class Loading Hook, EclipseClassLoadingHook. I shall investigate some
> more this week.
>
> Any body know of an OSS project which is using it ?
>
> Darryl
Previous Topic:Bundle-Classpath: filters on ws, os, arch, is this possible ?
Next Topic:How does Eclipse decide which of the 2 Fragments of a Plugin to load ???
Goto Forum:
  


Current Time: Thu Jul 17 08:36:43 EDT 2025

Powered by FUDForum. Page generated in 0.09811 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top