Re: Stub File
Wenbo Zhu <[email protected]>
| Newsgroups | gmane.comp.java.sun.rmi |
|---|---|
| Message-ID | <713043CE8B8E1348AF3C546DBE02C1B402655958@zcarhxm2.corp.nortel.com> |
A side question, if I understand correctly, pre-generated stub will implement all remote interfaces of the server implementation class (the input to rmic). So, with the dynamic proxy class, will this behavior change .. (when remote interface reference gets instantiated in client space)? - more importantly, is this something I can count on .. (part of spec)? Not sure if this is related to an old argument about why stub is generated against the sever implementation class rather than interface(s) ... - Wenbo -----Original Message----- From: Peter Jones - JavaSoft East [mailto:[email protected]] Sent: Wednesday, January 26, 2005 12:27 AM To: [email protected] Subject: Re: Stub File > In the API Documentation from RMI Tiger says that I don't need > pregenerated the stub file from the Remote Object class, but in my > application when i run the server(that is the remote object) the JVM > request the _stub file. > > What will be? > > Bellow the source code: [snip] > Servidor stub = (Servidor) UnicastRemoteObject.exportObject(this); Unfortunately, a pregenerated stub class is still required when you use that particular exportObject method, because its return type is java.rmi.server.RemoteStub (a class, which cannot be extended by a dynamic proxy class); changing that return type would have broken binary compatibility. See this footnote in the release notes[*]: http://java.sun.com/j2se/1.5.0/docs/guide/rmi/relnotes.html#callout Instead, use the UnicastRemoteObject.exportObject method that also has a port parameter; its return type is java.rmi.Remote, an interface, so a dynamic proxy instance can be returned (and is, if a pregenerated stub class is not available). Use zero for an anonymous port: Servidor stub = (Servidor) UnicastRemoteObject.exportObject(this, 0); -- Peter [*] or the documentation for the UnicastRemoteObject class: http://java.sun.com/j2se/1.5.0/docs/api/java/rmi/server/UnicastRemoteObject. html =========================================================================== To unsubscribe, send email to [email protected] and include in the body of the message "signoff RMI-USERS". For general help, send email to [email protected] and include in the body of the message "help". For a list of frequently asked RMI questions please refer to: http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html To view past RMI-USERS postings, please see: http://archives.java.sun.com/archives/rmi-users.html =========================================================================== To unsubscribe, send email to [email protected] and include in the body of the message "signoff RMI-USERS". For general help, send email to [email protected] and include in the body of the message "help". For a list of frequently asked RMI questions please refer to: http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html To view past RMI-USERS postings, please see: http://archives.java.sun.com/archives/rmi-users.html