[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [equinox-dev] Hibernate and classloaders
- From: "Alin Dreghiciu" <adreghiciu@xxxxxxxxx>
- Date: Fri, 28 Mar 2008 09:55:37 +0800
- Delivered-to: firstname.lastname@example.org
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=OKx1IjVP8VQfKgHdO8S8JXdk8ke7KSPGwI2Z66bXDGqy4UAM4skwhQk9iVbpEZp19ppKPsZVTY/1GxViXKx595KtFas6LMhpuIJ23CmoXJz8RSId9ibZmNx+sEVZapQR5QnqObQgDQQH3IYuQKvR508DR+8zYRxbge8B7Lc1xVM=
On Fri, Mar 28, 2008 at 12:01 AM, Emmanuel Potvin <epotvin@xxxxxxxxxxx> wrote:
> My question is about classloaders. Hibernate is just an example.
> How can I change temporarily the classpath of an object? In this case, I
> pass a string to a configurator class containing « /hibernate.cfg.xml ». The
> configurator open the file and configure hibernate. The problem is : the
> hibernate.cfg.xml file (and any entity classes) are in my current bundle,
> but the configurator run as in his proper bundle, so it don't see any of my
> I know that the httpservice use string for resource registering. I want the
> same thing.
If you want the same thing than you will have to:
1. from your hibernate bundle register a HibernateService with a
method like, lets say, registerMappings(String hbmLocaton)
2. the above service should implement ServiceFactory (read more about
on the core osgi specs)
3. in getService(...) implementation you will get the Bundle that
contains the class that made the call to the service so you are now
able to do Bundle.getResource or Bundle.getEntry to find the url of
your hbm file
4. on ungetService(...) ou can deconfgure (undo) what you have done above.
I don't know if this is workable for our use case but at least this is
how HttpService implementations works.
Hope it helps,
> equinox-dev mailing list