Re: AW: AW: Using a Java Space from an OSGi bundle

Mark Brouwer <[email protected]> Fri, 14 Sep 2007 10:24:47 +0200
Newsgroups gmane.comp.java.sun.javaspaces
Message-ID <[email protected]>
Wellmann, Harald wrote:
> Great, setting the context class loader did solve my problem. It's a bit
> awkward, but if wrap my space in an adapter class that handles the class
> loader twiddling in each method, then it's an adequate workaround.
>
> I found an article about the ContextFinder in Eclipse/Equinox, which
> you'd expect to do something of this sort behind the scenes, but
> unfortunately it doesn't...

Hi Harald,

You might want to have a look at the Cheiron Utils project that provides
a class that can wrap your JavaSpace05 proxy that will set/restore the
proper thread context class loader and security context (if this is
relevant to you), see
http://www.cheiron.org/utils/release/v0.2/api/org/cheiron/util/proxy/ProxyWrapper.html

In your case you have to do something like this

   JavaSpace05 space = <obtain your JavaSpace proxy>;
   space = (JavaSpace05) ProxyWrapper.wrap(space, null, loader);

Where null indicates the current security context to be used and loader
the context class loader you want to have effective upon invocations.
This class has been written to correct 'wrong' environments as present
in many application servers (especially in the past) and the AWT event
queue.

Download source/binary (ALv2) from http://www.cheiron.org/utils/
--
Mark

===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff JAVASPACES-USERS".  For general help, send email to
[email protected] and include in the body of the message "help".

To view past JAVASPACES-USERS postings, please see:
http://archives.java.sun.com/archives/javaspaces-users.html