Re: [Skunkworks] Java RMI / Network Programming

The devil is in the details for these sort of problem: It is a complex problem because: 1. Files like pdf, doc, ... are files containing information that only the application that uses that file understands. Let's call it File Format. Unless the File Format is open (so that you know how to read the file data) then you will have to read the file through it's application. If the application (e.g. M$ Word) does not provide an API to stream a .doc file contents to the application then your other option is to open the network connection, stream the entire file and create a copy of it in the local system, then open that local file. 1.1. If for example you would like changes to the .doc file to be saved in the server, then you need to program the locking, unlocking stuff in the application that opens the file (in this case M$ Word) and the application needs to provide you with those mechanisms. If you did the local file way (as described above) then you have to take care of a problem where saving the file changes might result in a conflict. You can intergrate your network communication tool with a tool like SVN, so that SVN can pull the file for you and it will help you manage file conflict resolution. 2. If the file is not on a shared folder then you need a program running on the server to listen to client requests. With what you are planning to do, you might open a security hole through this server application. o_O --- On Wed, 4/15/09, Duggan Kim <mdkimani@gmail.com> wrote: From: Duggan Kim <mdkimani@gmail.com> Subject: [Skunkworks] Java RMI / Network Programming To: skunkworks@lists.my.co.ke Date: Wednesday, April 15, 2009, 5:49 PM I am writing a java based peer to peer application that requires remote files (pdf, text, .doc etc) in the server to be opened(run) in the client, the same way you would open a shared file in a different machine from your machine. How do I create a URL to the remote file considering that the file is not necessary contained in a shared folder, or how do you open the file via a remote File object reference? Any ideas would be appreciated. Thank you, Duggan Kimani. _______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks Other services @ http://my.co.ke

Hi Guys, Thank you for the responses. I would just like to shed a little more light on the problem. I am currently able to get a reference to the file from my server, but even through this reference, the details in the file object are only usable within the server, e.g the path has the value like C:\docs\hello.pdf. This path is not usable within the client. I can create an input stream and output stream between the client and server using sockets and copy paste the file, but this is a very slow process. The server and client communicate via RMI, but to open a file, I am using: Process p = Runtime.getRuntime().exec("cmd /c start '+ path); the path provided by the server cannot be used by the client to open the right file. How else can this be done? Thank you, Duggan Kim On 4/16/09, wesley kiriinya <kiriinya2000@yahoo.com> wrote:
The devil is in the details for these sort of problem:
It is a complex problem because:
1. Files like pdf, doc, ... are files containing information that only the application that uses that file understands. Let's call it File Format. Unless the File Format is open (so that you know how to read the file data) then you will have to read the file through it's application. If the application (e.g. M$ Word) does not provide an API to stream a .doc file contents to the application then your other option is to open the network connection, stream the entire file and create a copy of it in the local system, then open that local file.
1.1. If for example you would like changes to the .doc file to be saved in the server, then you need to program the locking, unlocking stuff in the application that opens the file (in this case M$ Word) and the application needs to provide you with those mechanisms. If you did the local file way (as described above) then you have to take care of a problem where saving the file changes might result in a conflict. You can intergrate your network communication tool with a tool like SVN, so that SVN can pull the file for you and it will help you manage file conflict resolution.
2. If the file is not on a shared folder then you need a program running on the server to listen to client requests. With what you are planning to do, you might open a security hole through this server application.
o_O
--- On Wed, 4/15/09, Duggan Kim <mdkimani@gmail.com> wrote:
From: Duggan Kim <mdkimani@gmail.com> Subject: [Skunkworks] Java RMI / Network Programming To: skunkworks@lists.my.co.ke Date: Wednesday, April 15, 2009, 5:49 PM
I am writing a java based peer to peer application that requires remote files (pdf, text, .doc etc) in the server to be opened(run) in the client, the same way you would open a shared file in a different machine from your machine. How do I create a URL to the remote file considering that the file is not necessary contained in a shared folder, or how do you open the file via a remote File object reference?
Any ideas would be appreciated.
Thank you,
Duggan Kimani. _______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks Other services @ http://my.co.ke

On Thu, Apr 16, 2009 at 4:41 PM, Duggan Kim <mdkimani@gmail.com> wrote:
process. The server and client communicate via RMI, but to open a file, I am using:
Process p = Runtime.getRuntime().exec("cmd /c start '+ path);
the path provided by the server cannot be used by the client to open the right file. How else can this be done?
The client should not be trying to open a file directly on the server -- you need the server to return the file to your client as a binary stream. Secondly, using RMI is a very bad idea for various reasons -- insecure (you are executing arbitrary code on the remote computer), non-portable (the code above wont work on non-windows computers), slow (rmi socket negotiation is slow...), and RMI will probably not work over firewalls. RMI was fashionable in the 90s when the predominantly used communication protocols were com/dcom/corba... I suggest you dont use this and try something that works over standard protocols (e.g. http) Jxta (mentioned in an earlier email) or do a googel search for "p2p framework" to get you started.

Well, Thank you. I think I will look into using JXTA. But am still curious about the same implementation using RMI. Duggan On 4/16/09, ashok+skunkworks@parliaments.info <ashok+skunkworks@parliaments.info> wrote:
On Thu, Apr 16, 2009 at 4:41 PM, Duggan Kim <mdkimani@gmail.com> wrote:
process. The server and client communicate via RMI, but to open a file, I am using:
Process p = Runtime.getRuntime().exec("cmd /c start '+ path);
the path provided by the server cannot be used by the client to open the right file. How else can this be done?
The client should not be trying to open a file directly on the server -- you need the server to return the file to your client as a binary stream.
Secondly, using RMI is a very bad idea for various reasons -- insecure (you are executing arbitrary code on the remote computer), non-portable (the code above wont work on non-windows computers), slow (rmi socket negotiation is slow...), and RMI will probably not work over firewalls. RMI was fashionable in the 90s when the predominantly used communication protocols were com/dcom/corba... I suggest you dont use this and try something that works over standard protocols (e.g. http) Jxta (mentioned in an earlier email) or do a googel search for "p2p framework" to get you started. _______________________________________________ Skunkworks mailing list Skunkworks@lists.my.co.ke http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks Other services @ http://my.co.ke Other lists ------------- Skunkworks announce: http://lists.my.co.ke/cgi-bin/mailman/listinfo/skunkworks-announce Science - http://lists.my.co.ke/cgi-bin/mailman/listinfo/science kazi - http://lists.my.co.ke/cgi-bin/mailman/admin/kazi/general
participants (3)
-
ashok+skunkworks@parliaments.info
-
Duggan Kim
-
wesley kiriinya