White Paper JNLP Version Based Downloading
Author:
Date:
Date:
Chandra Sekhar Annavajjala
09-16-2009
Table of Contents 1 INTRODUCTION.....................................................................................................................................3 1.1 1.2 1.3 1.4 1.5 1.6
PURPOSE.................................................................................................................................................3 TARGET AUDIENCE...................................................................................................................................3 DOCUMENT SCOPE....................................................................................................................................3 GLOSSARY...............................................................................................................................................3 DEPENDENCIES.........................................................................................................................................3 REVISION HISTORY...................................................................................................................................3
2 JNLP VERSION BASED DOWNLOADING.........................................................................................4 2.1 WHAT IS JNLP?.....................................................................................................................................4 2.2 BASIC DOWNLOADING...............................................................................................................................4 2.2.1 Advantages: .................................................................................................................................5 2.2.2 Disadvantages:-............................................................................................................................5 2.3 VERSION BASED DOWNLOAD.....................................................................................................................5 2.3.1 Advantages:- ................................................................................................................................7 2.3.2 Disadvantages:-............................................................................................................................7 2.4 VERSION BASED DOWNLOADING ANOTHER APPROACH...................................................................................8 2.4.1 Customized Version based downloading......................................................................................8 2.4.2 Advantages:-.................................................................................................................................8 2.4.3 Disadvantages:-............................................................................................................................8 3 APPENDICES............................................................................................................................................9 4 REFERENCES.........................................................................................................................................11
PROPOSAL
1Introduction 1.1 Purpose World wide the Swing/AWT based applications are running which needs to be downloaded from a server, to reduce the download time if the application jars get changed frequently and the jars are of big in size
1.2 Target Audience All Java/J2ee Developers/Technical Leads/Project Mangers who are working in the Swing/AWT based Application client environments, knowing javaweb start.
1.3 Document Scope How to implement a version based download for an Application Client Using jnlp.servlet.JNLPDownlaodServlet.
1.4 Glossary Term
Defin it ion
JNLP
Java Network Launching Protocol
FTCS
Flight Testing Computing System
Javaws
Java Web Start User Application Server
1.5 Dependencies NA.
1.6 Revision History Date
Name/Alias
Description
03-31-2009
Chandra Sekhar Annavajjala(
[email protected] )
Initial Draft
3
PROPOSAL 2JNLP Version Based Downloading 2.1 What is JNLP? JNLP is a protocol used to launch the Swing/AWT based application client for an application over the web, with the use of javaws (Java Web Start) into the client machine. The jar files needed for an application downloading will be listed in a file with extension .jnlp, when client request for .jnlp file then java web start (javaws) will request the server for those jar files and gets those jars downloaded into client machine and starts the application. Basically there are two types of downloading, 1. Basic Downloading 2. Version Based Downloading We propose a Customization of version based application downloading
2.2 Basic Downloading In this type of download, if the jar requested by javaws to server is available, then entire jar the jar will be sent as response to client. For example, if an application has a jar file named app.jar at server and that needs to be downloaded at client end, then JNLP file will have an entry of it and that will be served as it was requested. Request type 1: - http://yourserver.com:port/webcontext/client/app.jar
4
PROPOSAL
2.2.1 Advantages: 1. Easily manageable 2. Faster deployment 2.2.2 Disadvantages:1. Entire Jar files gets downloaded each time, which takes a lot of time of client if jar file size is big(10MB +) 2. If download is interrupted due to low internet bandwidth issues, the complete download needs to be done over again.
2.3 Version Based Download When application client is growing in size and it has frequent changes, then the basic download will take lot of time to download the client jars at the client machine. The version based download can be used in such cases. Versioning the application jars and serving them with an optimal download
5
PROPOSAL For example, if client machine has older version of application client jar with version 1.0, app__V1.0.jar and there are some changes in the jar and the new jar file is with version 1.1 i.e., app__V1.1.jar, then we can enable version based download by taking the following steps: a) Introducing a version file “version.xml” in the base folder of application jar in the web app. b) Including the “java.sample.jnlp.servlet.JNLPDownloadServlet” in “web.xml”. c) The application should be deployed with the two versions like app__V1.0.jar and app__V1.1.jar, As client request for app__V1.1.jar via jnlp file in a browser then the request will be sent as Request Type 2:http://yourserver.com:port/webcontext/client/app.jar?currentVersion=1.0&vers ion=1.1 If both resources app__V1.0.jar and app__V1.1.jar are available in server, then server creates jardiff (Difference of the latest with the older version) file app.jardiff and is sends back as response to the client. The jar diff file generation is done only for the first ‘type 2’ request for subsequent requests the same .jardiff file will be served. If app__V1.0.jar is not available, then it returns complete app__V1.1.jar as response. Javaws takes this app.jardiff and it merges with existing app__V1.0.jar and creates app__V1.1.jar App__v1.0.jar + app.jardiff = app__V1.1.jar
6
PROPOSAL
2.3.1 Advantages:1. Downloads only the difference of new file with old file, so downloading will be faster 2. Woks for any internet bandwidth 3. Saves Download time. 2.3.2 Disadvantages:1. If application jar is of heavy size (example 20 MB +) then server requires more Heap Memory to take the jar diff at runtime, even though the jar diff is done only for once. It may cause server crash.
7
PROPOSAL 2. Deployment is tough as it is required to deploy double size application archives (like app__V1.0.jar & app__V1.1.jar), it may fail to even deploy.
2.4 Version Based Downloading another Approach 2.4.1 Customized Version based downloading This approach is similar to approach in section 2.3 , but the jar diff for the jars app__V1.0.jar and app__V1.1.jar is created at the application build time and the difference file of those, app.jardiff is placed in context path of the application, and served when ever the request comes. Once the request comes as type 2 of section 2.3, then server responds back with jar diff file. This approach can be obtained by customizing JardiffHandler.java of jnlp package
2.4.2 Advantages:1. We can reduce application deployment time by keeping a dummy jar file for previous version (ex. app__V1.0 can be dummy as the diff is not happening in the runtime with app__V1.1 version file) 2. We can support some ‘n’ number of previous versions by keeping all dummy jars except for the latest (ex. If app__V1.5.jar is latest then we can keep dummy jar files for versions 1.0 to 1.4 and we can serve the version based download). 3. As the jar diff is done during build time and not runtime, the possibility of application running out of memory during the process is ruled out (not like Section 2.3).
2.4.3 Disadvantages:1. Application build process gets more complicated. 8
PROPOSAL 2. Need to maintain the previous version jar files for each build.
3Appendices Appendix 1: Basic download JNLP file - <jnlp spec="1.0+" codebase="http://application.host.com:portno/webcontext/client/"> -
Basic download Java Developer Connection <description /> - <security>
- <j2se version="1.5+" href="http://java.sun.com/products/autodl/j2se" initialheap-size="256M" max-heap-size="512M" java-vm-args="-ea -Xss1024K" /> <jar href="app.jar" /> - <argument>Development
Appendix 2: Version Based download JNLP file
Version.xml - <jnlp-versions> - - <pattern> app.jar
9
PROPOSAL 1.1 app__V1.1.jar - - <pattern> app.jar 1.0 app__V1.0.jar JNLP File
- <jnlp spec="1.0+" codebase="http://application.host.com:portno/webcontext/client/"> - Basic download Java Developer Connection <description /> - <security> - <j2se version="1.5+" href="http://java.sun.com/products/autodl/j2se" initialheap-size="256M" max-heap-size="512M" java-vm-args="-ea -Xss1024K" /> <jar href="app.jar" version = “1.1”/> - <argument>Development Folder Structure for Version Based Downloads
10
PROPOSAL
Web.xml
<servlet-mapping> <servlet-name>JnlpDownloadServlet *.jnlp <servlet-mapping> <servlet-name>JnlpDownloadServlet *.jar
<mime-mapping> <extension>jnlp <mime-type>application/x-java-jnlp-file <mime-mapping> <extension>jar <mime-type>application/x-java-archive <mime-mapping> <extension>jardiff <mime-type>application/x-java-archive-diff
4References Sun Microsystem
http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/overview.html
11