version based java application downloading

13
White Paper JNLP Version Based Downloading Chandra Sekhar Annavajjala 09-16-2009 Author Date: Date:

Upload: girijasekhar

Post on 12-Nov-2014

162 views

Category:

Documents


0 download

DESCRIPTION

This document gives a customized way of version based application download in JNLP

TRANSCRIPT

Page 1: Version Based Java Application Downloading

White Paper

JNLP Version Based Downloading

Chandra Sekhar Annavajjala

09-16-2009

Author:

Date:

Date:

Page 2: Version Based Java Application Downloading

Table of Contents

1 INTRODUCTION.................................................................................................................................3

1.1 PURPOSE........................................................................................................................................31.2 TARGET AUDIENCE........................................................................................................................31.3 DOCUMENT SCOPE.........................................................................................................................31.4 GLOSSARY.....................................................................................................................................31.5 DEPENDENCIES...............................................................................................................................31.6 REVISION HISTORY........................................................................................................................3

2 JNLP VERSION BASED DOWNLOADING....................................................................................4

2.1 WHAT IS JNLP?.............................................................................................................................42.2 BASIC DOWNLOADING...................................................................................................................4

2.2.1 Advantages:..............................................................................................................................52.2.2 Disadvantages:-........................................................................................................................5

2.3 VERSION BASED DOWNLOAD........................................................................................................52.3.1 Advantages:-.............................................................................................................................62.3.2 Disadvantages:-........................................................................................................................6

2.4 VERSION BASED DOWNLOADING ANOTHER APPROACH...............................................................72.4.1 Customized Version based downloading..................................................................................72.4.2 Advantages:-.............................................................................................................................72.4.3 Disadvantages:-........................................................................................................................7

3 APPENDICES.......................................................................................................................................8

4 References.............................................................................................................................................10

Page 3: Version Based Java Application Downloading

PROPOSAL

1 Introduction

1.1 PurposeWorld 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 AudienceAll Java/J2ee Developers/Technical Leads/Project Mangers who are working in the Swing/AWT based Application client environments, knowing javaweb start.

1.3 Document ScopeHow to implement a version based download for an Application Client Using jnlp.servlet.JNLPDownlaodServlet.

1.4 GlossaryTerm Definition

JNLP Java Network Launching Protocol

FTCS Flight Testing Computing System

Javaws Java Web Start

User

Application Server

1.5 DependenciesNA.

1.6 Revision History

Date Name/Alias Description

03-31-2009 Chandra Sekhar Annavajjala( [email protected] )

Initial Draft

3

Page 4: Version Based Java Application Downloading

PROPOSAL

2 JNLP 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 Downloading2. 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

Page 5: Version Based Java Application Downloading

PROPOSAL

2.2.1Advantages:

1. Easily manageable2. Faster deployment

2.2.2Disadvantages:-

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

Page 6: Version Based Java Application Downloading

PROPOSALFor 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&version=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

Page 7: Version Based Java Application Downloading

PROPOSAL

2.3.1Advantages:-

1. Downloads only the difference of new file with old file, so downloading will be faster

2. Woks for any internet bandwidth3. Saves Download time.

2.3.2Disadvantages:-

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

Page 8: Version Based Java Application Downloading

PROPOSAL2. 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.1Customized 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.2Advantages:-

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.3Disadvantages:-

1. Application build process gets more complicated.

8

Page 9: Version Based Java Application Downloading

PROPOSAL2. Need to maintain the previous version jar files for each build.

3 Appendices

Appendix 1: Basic download JNLP file

  <?xml version="1.0" encoding="UTF-8" ?> - <jnlp spec="1.0+"

codebase="http://application.host.com:portno/webcontext/client/">- <information>  <title>Basic download</title>   <vendor>Java Developer Connection</vendor>   <homepage href="/jdc" />   <description />   </information>

- <security>  <all-permissions />   </security>

- <resources>  <j2se version="1.5+" href="http://java.sun.com/products/autodl/j2se" initial-heap-

size="256M" max-heap-size="512M" java-vm-args="-ea -Xss1024K" />   <jar href="app.jar" />   </resources>

- <application-desc main-class="LoadApplication">  <argument>Development</argument>   </application-desc>  </jnlp>

Appendix 2: Version Based download JNLP file

Version.xml

- <jnlp-versions>- <resource>- <pattern>  <name>app.jar</name>   <version-id>1.1</version-id>   </pattern>

9

Page 10: Version Based Java Application Downloading

PROPOSAL  <file>app__V1.1.jar</file>   </resource>

- <resource>- <pattern>  <name>app.jar</name>   <version-id>1.0</version-id>   </pattern>

  <file>app__V1.0.jar</file>   </resource></jnlp-versions>

JNLP File

  <?xml version="1.0" encoding="UTF-8" ?> - <jnlp spec="1.0+"

codebase="http://application.host.com:portno/webcontext/client/">- <information>  <title>Basic download</title>   <vendor>Java Developer Connection</vendor>   <homepage href="/jdc" />   <description />   </information>

- <security>  <all-permissions />   </security>

- <resources>  <j2se version="1.5+" href="http://java.sun.com/products/autodl/j2se" initial-heap-

size="256M" max-heap-size="512M" java-vm-args="-ea -Xss1024K" /> <!—we will mention the version for jar file in version based jnlp file -->  <jar href="app.jar" version = “1.1”/>   </resources>

- <application-desc main-class="LoadApplication">  <argument>Development</argument>   </application-desc>  </jnlp>

Folder Structure for Version Based Downloads

10

Page 11: Version Based Java Application Downloading

PROPOSALWeb.xml

<servlet-mapping> <servlet-name>JnlpDownloadServlet</servlet-name> <url-pattern>*.jnlp</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>JnlpDownloadServlet</servlet-name> <url-pattern>*.jar</url-pattern> </servlet-mapping>

<mime-mapping> <extension>jnlp</extension> <mime-type>application/x-java-jnlp-file</mime-type> </mime-mapping>

<mime-mapping> <extension>jar</extension> <mime-type>application/x-java-archive</mime-type>

</mime-mapping><mime-mapping>

<extension>jardiff</extension><mime-type>application/x-java-archive-diff</mime-type>

</mime-mapping>

4 References

Sun Microsystem

http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/overview.html

11