Re: Client with multiple codebases
Gregg Wonderly <[email protected]> Wed, 28 Nov 2007 12:08:56 -0600
| Newsgroups | gmane.comp.java.sun.jini |
|---|---|
| Message-ID | <[email protected]> |
Mark Brouwer wrote: > Calum Shaw-Mackay wrote: > >> Hi - >> >> I've got a Service with a ServiceUI - the Service Browser has it's own >> codebase(A). >> Part of the UI allows me to deploy an object into the service which >> has also has it's own, different, codebase(B). >> How do I push the object to the service with Codebase (B) without >> interfering with the Service Browsers codebase(A) - I don't want to >> use.... .... >> There is probably a really simple answer..... > In case the JVM running your ServiceUI browser has the > PreferredClassProvider installed you could define the objects in an > instance of PreferredClassLoader (or any other class loader that > implements ClassAnnotation) and create that class loader with a codebase > annotation you think is right. A URLClassLoader should also work as the > classes defined in that class loader have a codebase annotation that > equals the URLs with which it has been created. > > As I read the above I believe your ServiceUI could take care of the > class loader creation, it probably need some permissions that are beyond > the standard set of permissions but if you trust it I guess that won't > be a problem. This is certainly one way to do it. The primary issue is that you need to "know" what the codebase is. When your UIDescriptor specified factory is creating the Component that will be returned to the service browser, it can use ((URLClassLoader)getClass().getClassLoader()).getURLs() to find out what the codebase is for the client. If it sends stuff from that codebase, to the server, and PreferredClassProvider is active, everything will work just fine as long as the correct preferences are in your codebase jar (or the first jar if there are multiple). If, there is no PreferredClassProvider active, then you can't take advantage of PREFERRRED.LIST, but that might not be an issue. The other choice, is to use a MarshalledObject in your API so that you can have more control over how the codebase is created. 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]