Bug 242465 - jarList driver extension option doesn't support plugins-as-jars
Summary: jarList driver extension option doesn't support plugins-as-jars
Status: RESOLVED FIXED
Alias: None
Product: Data Tools
Classification: Tools
Component: DataTools (show other bugs)
Version: 1.6.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.7M4   Edit
Assignee: Brian Fitzpatrick CLA
QA Contact:
URL:
Whiteboard:
Keywords: plan
Depends on:
Blocks:
 
Reported: 2008-07-29 16:28 EDT by Cameron Bateman CLA
Modified: 2008-12-10 18:28 EST (History)
3 users (show)

See Also:


Attachments
possible patch (1.78 KB, patch)
2008-07-30 13:25 EDT, Brian Fitzpatrick CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Cameron Bateman CLA 2008-07-29 16:28:06 EDT
While trying to use the feature described here:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=140816

which is intended to allow jars bundled in plugins to be used as JDBC drivers, we discovered that it doesn't work if the plugin is bundled as a JAR.  That is, if the relative path must ultimately point into a JAR archive rather than a sub-directory of the eclipse/plugins dir.
Comment 1 Konstantin Komissarchik CLA 2008-07-29 16:36:36 EDT
It would be ideal if the extension point could allow pointing at the plugin jar itself (allowing distribution of jdbc jars as proper osgi bundles). That was the first thing we tried. That didn't work. Then we tried a jdbc driver jar inside a jarred plugin. That didn't work either. It seems like the only thing that works is a jdbc driver jar in an exploded plugin directory. Distributing exploded plugins is not optimal for a variety of reasons, so we'd like to see this issue resolved soon.
Comment 2 Brian Fitzpatrick CLA 2008-07-29 17:41:46 EDT
This is a good thought and one that we can explore for the "Galileo" or 1.7/2.0 for the June 2009 release
Comment 3 Brian Fitzpatrick CLA 2008-07-29 18:20:53 EDT
Ok... So forgive my lack of OSGI awareness... Do you have an example of how I would set up something along the lines of distributing JDBC jar(s) as an OSGI bundle? If you look at Derby, there's an example there of how we take the Orbit bundle (which I believe is a binary wrapper of the plug-in) for Derby 10.1, is that what you're looking for? We do that in the driver property provider class (hunt for the plug-in, use the path to the plug-in jar).
Comment 4 Konstantin Komissarchik CLA 2008-07-29 18:51:31 EDT
> Ok... So forgive my lack of OSGI awareness... Do you have an example of how I
> would set up something along the lines of distributing JDBC jar(s) as an OSGI
> bundle? 

You just need to add the various OSGi properties (such as bundle id and version) to the manifest of the jar and can be used as a plain jar or as an OSGi bundle.

> If you look at Derby, there's an example there of how we take the Orbit
> bundle (which I believe is a binary wrapper of the plug-in) for Derby 10.1, is
> that what you're looking for? We do that in the driver property provider class
> (hunt for the plug-in, use the path to the plug-in jar).

Could you provide some more details on this? I am not following. In our code we have something like the following, which works if the plugin containing the jdbc driver jar is in exploded form.

<driverTemplate
   createDefault="true"
   emptyJarListIsOK="false"
   id="oracle.dbtools.dtp.connectivity.db.genericDriverTemplate"
   jarList="[oracle.dbtools.dtp.jdbc.driver]/lib/ojdbc14.jar"
   name="Oracle Database 10g Driver"
   parentCategory="org.eclipse.datatools.enablement.oracle.10.driverCategory" > 

If I look at the Derby plugin, I see this:

<driverTemplate
   createDefault="false"
   defaultDefinitionName="%DERBY_EMBEDDED_DRIVER_DEFAULT_INSTANCE_NAME"
   emptyJarListIsOK="false"
   id="org.eclipse.datatools.connectivity.db.derby.genericDriverTemplate"
   jarList="derby.jar"
   name="%DERBY_EMBEDDED_DRIVER_TEMPLATE_NAME"
parentCategory="org.eclipse.datatools.connectivity.db.derby.10_0.driverCategory"
valuesProvider="org.eclipse.datatools.connectivity.apache.internal.derby.driver.DerbyDriverValuesProvider101">

I did not find derby.jar as specified in jarList in that plugin. Are you saying there is some magic in the valuesProvider that takes care of locating the jar?

Ideally the following use of the existing syntax should work for jdbc drivers packaged as OSGi bundles:

<driverTemplate
   createDefault="true"
   emptyJarListIsOK="false"
   id="oracle.dbtools.dtp.connectivity.db.genericDriverTemplate"
   jarList="[oracle.dbtools.dtp.jdbc.driver]"
   name="Oracle Database 10g Driver"
   parentCategory="org.eclipse.datatools.enablement.oracle.10.driverCategory" > 

Comment 5 Konstantin Komissarchik CLA 2008-07-29 19:04:59 EDT
Answering my own question...

> I did not find derby.jar as specified in jarList in that plugin. Are you saying
> there is some magic in the valuesProvider that takes care of locating the jar?

Looking at the valuesProvider code it looks like it is dynamically computing the value for the jarList attribute. Presumably the value in plugin.xml (plain derby.jar) is never actually used.
Comment 6 Brian Fitzpatrick CLA 2008-07-30 09:17:32 EDT
Well, that's not exactly true. The "derby.jar" value that's in the jarlist of the driver template IS used, but only if the values provider doesn't find one of the various plug-ins that it's looking for.

The values provider gives you a ton more control (like in the Derby case) to look for things like jarred plug-ins. If you grab the derby plug-in from Orbit:

http://download.eclipse.org/tools/orbit/downloads/drops/R20080611105805/bundles/org.apache.derby_10.1.2.1_v200803061811.jar

I believe this is jarred as you would want for OSGI.

So if you do something similar, you can save the user a bunch of trouble. The values provider class gets called every time the workbench starts. So if you drop the derby plug-in into the workspace and restart (and no Derby default driver definition was already there), it'll create a default driver for derby with the corrected paths to the plug-in...
Comment 7 Brian Fitzpatrick CLA 2008-07-30 10:09:24 EDT
I do like the idea of having a simple [plugin] syntax (with no path) to indicate that it should just use the plug-in jar. But that would only apply to fully jarred plug-ins I'm guessing. So you'd still have to do the path thing with unjarred plug-ins.
Comment 8 Brian Fitzpatrick CLA 2008-07-30 13:25:49 EDT
Created attachment 108765 [details]
possible patch

Hi there...

So here's a possibility for how your simple [plugin] case might work. It works for the jarred Derby Orbit plug-in and for the Apache Derby Core plugin that has the derby.jar split out (i.e. non jarred). 

Let me know if it works for you. Hopefully will simplify things.

--Fitz
Comment 9 Brian Fitzpatrick CLA 2008-08-07 19:41:48 EDT
Any thoughts on this fix?
Comment 10 Brian Fitzpatrick CLA 2008-08-19 17:03:53 EDT
Larry, can you review this patch?
Comment 11 Larry Dunnell CLA 2008-08-21 16:23:35 EDT
Brian, the patch looks good.
Comment 12 Brian Fitzpatrick CLA 2008-12-10 18:28:50 EST
Delivered as tag v200812110730