Re: Using an interface between two dl'ed applications
Calum Shaw-Mackay <[email protected]> Mon, 19 Jan 2009 13:49:16 +0000
| Newsgroups | gmane.comp.java.sun.jini |
|---|---|
| Message-ID | <[email protected]> |
Okay to make things clearer System 'A' is a container of sorts, Object 'B' is a component that Object C (the caller) wishes to utilise and conenct with at runtime Both the component and the caller are deployed into system A via a JINI service call (lets call it 'deploy()'), they are deployed separately in two separate deploy() calls The component 'B' implements an interface that the caller 'C' is aware of and has a compile time dependency on. To call the component, the caller obtains the component through a call to the container. For the sake of security and transparency, the container returns a dynamic proxy (j.l.r.proxy) that implements the required interface (it extracts this interface from the full definition of the component 'B', before sending it back to the caller 'C'. The point that I'm making is that both 'B' and 'C' were created in separate calls, and potentially separate classloaders, meaning that the definition of the interface used by 'B' and that used by 'C' will be marked as being different because the class is not sourced from a the same single classloader when used/linked to by 'B' and 'C' To be clear, this is not cross JVM as such - both B and C are in the same JVM, but are deployed via separate remote calls into the JVM.... this can be of course solved by placing the interface on the classpath of the container, but this is not a desirable way for me to go Calum On 19 Jan 2009, at 13:33, Niclas Hedhman wrote: > On Mon, Jan 19, 2009 at 11:55 AM, Calum Shaw-Mackay > <[email protected]> wrote: >> Given a system 'A' that allows objects 'B' and 'C' to be deployed >> to it, >> where 'C' has an interface dependency on 'B'. Also 'B' and 'C" are >> independently deployed, with potentially different codebases, but >> with the >> same interface definition (compiled) in each. >> >> When 'C' requests access to 'B' via a dynamic proxy generated from >> the >> Interface declared in 'B's codebase, I get a >> ClassNotFoundException, I'm >> assuming that this is because B's classes are being declared in a >> different >> classloader to 'C's. > > Are you talking a java.lang.reflect.Proxy, bytecode generated one or > something else? > I am not sure what you mean by "declared in different classloader to > C's". Is it in the same JVM? Otherwise, why do you mention it? (I know > you are not a novice... :-) ) > > If we are talking j.l.r.Proxy, is the InvocationHandler in B > serializable and its classes available to C? In JRMP, there is > explicit support for j.l.r.Proxy since it is not straight forward. The > Proxy from B should be reconstructed at JRMP level from the interface > classes and invocationhandler instance received from B using the RMI > Classloader in C for B's codebase. > > > Cheers > Niclas > -- > http://www.qi4j.org - New Energy for Java -------------------------------------------------------------------------- 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]