Re: Another question about codebases and jar versions

Gregg Wonderly <[email protected]>
Newsgroups gmane.comp.java.sun.jini
Message-ID <[email protected]>
Logan, Patrick wrote:
> So I believe for my current purposes I can just ignore the context
> loader issues. I hope. Give me one thing to ignore.

I would suggest, that with Jini applications, that you always assert a context
class loader based on the classloader of the downloaded code for any leg of code
that transitions between code sources.

Just for some further information:

There have been numerous discussions on this list about context class loading
and Subjects in the AWT/Swing environment.  Because the event thread is not in
our control, we have to catch that thread in the component listeners, change the
subject/context class loader, and then interact with the application (downloaded
code) and then restore the old context back.

In a server, you have similar issues for inbound calls.  Data that is carried
into the call as primary level arguments will be made up of resolved classes.
But, if some of those classes then make calls which create instances of classes,
the server really needs to assert the context class loader so that downloadable
classes can be downloaded if needed.

There are numerous ways to handle these issues.  In Swing, I use a class that is
visible on http://swingutil.dev.java.net, called ComponentUpdateThread.  It has
the facilities to remember the active subject and context class loader, and then
assert those for you.  I also have classes named ContextActionListener,
ContextListSelectionListener etc which manage the context class loader etc.

On the server side, I sometimes baracade the client into an authenticated object
which has a facade of a java.lang.reflect.InvocationHandler which holds the
context class loader and the Subject needed to keep inbound calls confined into
the right environment.

Gregg Wonderly

--------------------------------------------------------------------------
Getting Started:     http://www.jini.org/wiki/Category:Getting_Started
Community Web Site:  http://jini.org
jini-users Archive:  http://archives.java.sun.com/archives/jini-users.html
Unsubscribing:       email "signoff JINI-USERS"  to [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.