Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] Hibernate and classloaders

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
> files.
>
>
>
> 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,
Alin Dreghiciu

>
>
>
> Emmanuel
> _______________________________________________
>  equinox-dev mailing list
>  equinox-dev@xxxxxxxxxxx
>  https://dev.eclipse.org/mailman/listinfo/equinox-dev
>
>


Back to the top