University of Cincinnati logo and link  
Dynamic Downloading
 
  UC ingot Take a deep breath.  Now we're ready to tackle dynamic downloading.
  • Dynamic downloading allows us to put the _Stub class in a download directory on the server, instead of copying it to each client that wants to use it.
    • Then, the client can download the stub dynamically.
    • Any time you update the server and update the stub, you can count on the client grabbing the stub from the download directory.  This saves you from sending a manual update to all of your users!
  • A few steps I took:
    • I created a download directory under /webapps/ROOT/ in Tomcat.  The book said to create one under /webapps/, but I eventually found that it wanted one under /webapps/ROOT/.
    • I placed ChatImpl_Stub.class and Chat.class in this directory.
    • I added the argument -Djava.rmi.server.codebase=http://localhost:8080/download/ to the list of arguments I passed the server on startup.
    • I removed the ChatImpl_Stub.class from the client directory to make sure it downloaded it dynamically.

    • I modified the policy files.  Ok, I cheated and gave both AllPermission because I was tired, but certainly you can restrict permission better than this.  
    • It didn't work.  So I pulled my hair out for a while and tried a number of things.  Then I thought that, since it is looking for chat.ChatImpl_Stub.class, perhaps I need to put the class files in a subdirectory of download called chat.  I did that, and sure enough it works.
    • Got it working, so now I can go back and fix my policy files.  I took away AllPermission when I had it working, and tweaked the files until I came up with this:
      • server.policy:

      • grant { 

         permission java.net.SocketPermission "*:1024-65535", "accept,connect,listen,resolve";
         permission java.net.SocketPermission "*:80", "accept,connect,listen,resolve";
         permission java.net.SocketPermission "*:8080", "accept,connect,listen,resolve";
        };

      • client.policy:

      • grant { 
         
         permission java.net.SocketPermission "*:1024-65535", "connect";
         permission java.net.SocketPermission "*:80", "connect";
         permission java.net.SocketPermission "*:8080", "connect";
        };
 Next Step: Parameter Passing