Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Programmatically add BuddyClass-Loading to a Bundle
Programmatically add BuddyClass-Loading to a Bundle [message #116575] Tue, 26 August 2008 21:26 Go to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

The following situation:

- org.hibernate.eclipse has
=> Eclipse-BuddyPolicy:registered

- at.bestsolution.soccer.core.datasource.teneo has
=> Eclipse-RegisterBuddy: org.hibernate.eclipse
=> Configures hibernate-eclipse and instructs it to use jdbc as Driver
e.g. org.apache.derby.jdbc.Driver

- org.apache.derby


Naturally the hibernate plugin could not create an instance of
org.apache.derby.jdbc.Driver. This could be fixed by adding
org.apache.derby as dependency to datasource.teneo but driver is defined
by user so if there's a mysql-bundle in the system he/she could specify it.

What do you suggest how can I fix this? Could I somehow programmtically
do something like "Eclipse-RegisterBuddy: org.hibernate.eclipse" does?
So that org.hibernate.eclipse can see it?

The only plugin in the system I control is datasource.teneo. Any ideas?

Tom

--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Programmatically add BuddyClass-Loading to a Bundle [message #116582 is a reply to message #116575] Wed, 27 August 2008 10:18 Go to previous messageGo to next message
Gunnar Wagenknecht is currently offline Gunnar WagenknechtFriend
Messages: 486
Registered: July 2009
Location: San Francisco ✈ Germany
Senior Member

Tom Schindl schrieb:
> The only plugin in the system I control is datasource.teneo. Any ideas?

Can you do the following in datasource.teneo?

Bundle dbDriverBundle = getBundle("bla");
java.sql.Driver driver = (java.sql.Driver) dbDriverBundle.loadClass("blah");

// user driver in Hibernate by specifying correct URL

AFAIK, a driver registers itself with the DriverManager. Does Hibernate
really want a driver instance or does it use the DriverManager?

Note, a DataSource might work too.

-Gunnar

--
Gunnar Wagenknecht
gunnar@wagenknecht.org
http://wagenknecht.org/
Re: Programmatically add BuddyClass-Loading to a Bundle [message #116589 is a reply to message #116582] Wed, 27 August 2008 11:53 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi Gunnar,

Teneo only wants a String "org.blabla.bla.Driver". I rethought the thing
yesterday in the evening and came to the solution that
datasource.teneo needs to provide an extension point where external
plugins register themselves against it and provide informations.

So what I have now is:

- hibernate.eclipse.
* Eclipse-BuddyPolicy:registered

- datasource.teneo
* Eclipse-RegisterBuddy: org.hibernate.eclipse
* Teneo-Extension-Point
=> hibernate-dialect

- datasource.teneo.derby
* Dependency on datasource.teneo
* Dependency on apache.derby
* Eclipse-RegisterBuddy: org.hibernate.eclipse

- apache.derby

I haven't tried it yet but this should solve the problem. This also
helps me to configure the Hibernate-Dialects available because I simply
have to query the extension point. People can now even contribute their
own Dialect.

Tom

Gunnar Wagenknecht schrieb:
> Tom Schindl schrieb:
>> The only plugin in the system I control is datasource.teneo. Any ideas?
>
> Can you do the following in datasource.teneo?
>
> Bundle dbDriverBundle = getBundle("bla");
> java.sql.Driver driver = (java.sql.Driver) dbDriverBundle.loadClass("blah");
>
> // user driver in Hibernate by specifying correct URL
>
> AFAIK, a driver registers itself with the DriverManager. Does Hibernate
> really want a driver instance or does it use the DriverManager?
>
> Note, a DataSource might work too.
>
> -Gunnar
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Programmatically add BuddyClass-Loading to a Bundle [message #116901 is a reply to message #116589] Mon, 01 September 2008 12:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: amottadelli_NO_SPAM.it.ibm.com

I'm curious about the reasons that make the people use "BuddyClass-Loading".
Please correct me if I'm wrong:
- usually frameworks and libraries designed to work in a J2EE
environment rely on thread context class loader to load "user" classes
- Equinox (or OSGi in general) cannot guarantee what is in the tccl
because this is out of its scope.
- Buddy class loading is an hack to work around this limitation
"forcing" the tccl looking up for the "correct" class loader in the call
stack.

In the (limited) scope of OSGi, buddy class loading is an elegant
solution to the problem, but the solution is outside the (current) scope
of OSGi.

Every application needs a thread or process model, so each application
environment is (or should) perfectly able to know and control what is in
the thread context class loader.

Regards,
Sandro
Re: Programmatically add BuddyClass-Loading to a Bundle [message #116940 is a reply to message #116901] Mon, 01 September 2008 17:13 Go to previous messageGo to next message
Gunnar Wagenknecht is currently offline Gunnar WagenknechtFriend
Messages: 486
Registered: July 2009
Location: San Francisco ✈ Germany
Senior Member

Alessandro Mottadelli schrieb:
> - usually frameworks and libraries designed to work in a J2EE
> environment rely on thread context class loader to load "user" classes

Yes. That's the problem. Designing a Java library just with a very
specific thread/execution model in mind is a poor design choice.

> - Equinox (or OSGi in general) cannot guarantee what is in the tccl
> because this is out of its scope.

Well, nobody can, not even the JVM or any other container.

> In the (limited) scope of OSGi, buddy class loading is an elegant
> solution to the problem, but the solution is outside the (current) scope
> of OSGi.

IMHO buddy class loading is neither elegant nor a solution to class
loading problem. Same is true for the TCCL. If you design *any* Java
code correctly, you don't need either one (whether the code runs in a
JavaEE container, inside a mobile phone or on the desktop).

-Gunnar

--
Gunnar Wagenknecht
gunnar@wagenknecht.org
http://wagenknecht.org/
Re: Programmatically add BuddyClass-Loading to a Bundle [message #116979 is a reply to message #116940] Tue, 02 September 2008 19:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: amottadelli_NO_SPAM.it.ibm.com

Gunnar Wagenknecht ha scritto:
> Alessandro Mottadelli schrieb:
>
>> - Equinox (or OSGi in general) cannot guarantee what is in the tccl
>> because this is out of its scope.
>
> Well, nobody can, not even the JVM or any other container.
>
Don't J2EE containers do that?
>> In the (limited) scope of OSGi, buddy class loading is an elegant
>> solution to the problem, but the solution is outside the (current) scope
>> of OSGi.
>
> IMHO buddy class loading is neither elegant nor a solution to class
> loading problem. Same is true for the TCCL. If you design *any* Java
> code correctly, you don't need either one (whether the code runs in a
> JavaEE container, inside a mobile phone or on the desktop).
>
Could you elaborate? What is in your opinion the best solution to have
custom code loaded by a java library?
> -Gunnar
>

Sandro
Re: Programmatically add BuddyClass-Loading to a Bundle [message #117028 is a reply to message #116979] Wed, 03 September 2008 12:02 Go to previous message
Gunnar Wagenknecht is currently offline Gunnar WagenknechtFriend
Messages: 486
Registered: July 2009
Location: San Francisco ✈ Germany
Senior Member

Alessandro Mottadelli schrieb:
> Could you elaborate? What is in your opinion the best solution to have
> custom code loaded by a java library?

IMHO it really depends on your use case. Personally, I made very good
experiences with OSGi services as well as Equinox extension points.

Of course, this means modifying (or wrapping) third party libraries in a
way that they make use of one of both. But this shouldn't be a problem
with open source libraries. Sometimes its as easy as adding a bit more
flexibility (eg.
http://code.google.com/p/google-web-toolkit/issues/detail?id =1888).

-Gunnar

--
Gunnar Wagenknecht
gunnar@wagenknecht.org
http://wagenknecht.org/
Previous Topic:Errors after Tomcat reload
Next Topic:p2.generator task
Goto Forum:
  


Current Time: Sat Nov 09 03:31:45 GMT 2024

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

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

Back to the top