- Eclipse v3.2.1
- JDK 1.5.0_10
JNLP Tuning:
------------
It is possible to tune the JNLP files to improve performance in the loading of the jar files. For example, you can specify which jars are needed and which ones are optional. The point being that the application may not need to download all of the jars to get up and running.
There are two major components that I will list here. One is to specify which jar files need to be aggressively loaded versus ones that can be lazily loaded. The other technique is to list all of the contained packages in the related jar files so Java Web Start does not have to download all Jars just to find a class file or resource. The later will make for larger JNLP files and of course make them more complex, but could improve the initial download time for users to get up and running.
Both of these techniques should actually be combined to provide the greatest performance gains.
Regardless as to what techniques are used to improve the initial loading time of the jar files, once they are in the Java Web Start cache, the load time will be measured in seconds instead of minutes for subsequent launches of the application.
Example of lazy and eager loading
---------------------------------
A download hint of lazy or eager can be specified. Java Web Start will try to honor these hints, but if it cannot find a needed resource it may download all jars anyway until it finds what it is looking for.
<resources>
<jar href="plugins/mysql_connector_j_3.1.12.jar" download="eager" />
<jar href="plugins/org.apache.log4j_1.2.14.jar" download="lazy" />
</resources>
Example of Package and Part:
----------------------------
You can provide a hint to JWS as to what is contained within a jar by the use of the Package and Part within the JNLP.
Building upon the example under lazy and eager loading:
<resources>
<jar href="plugins/mysql_connector_j_3.1.12.jar" download="eager" part="mysqlcj" />
<jar href="plugins/org.apache.log4j_1.2.14.jar" download="lazy" part="log4j" />
<package part="mysqlcj" name="com.mysqlj.*" recursive="true" />
<package part="log4j" name="org.apache.log4j.*" recursive="true" />
</resources>
Part ties the package tags back to the jar tags.
The use of the recursive="true" attribute really can save a great deal of typing. Take for example the mySQL connector j example right above. It used a value of true on the recursive attribute, but if it were to use false, you would have to list out all of the possible packages contained in the jar even though they all began with com.mysql.
<package part="mysqlcj" name="com.mysqlj.jdbc.*" recursive="false" />
<package part="mysqlcj" name="com.mysqlj.jdbc.configs.*" recursive="false" />
<package part="mysqlcj" name="com.mysqlj.jdbc.integration.c3p0.*" recursive="false" />
<package part="mysqlcj" name="com.mysqlj.jdbc.integration.jboss.*" recursive="false" />
<package part="mysqlcj" name="com.mysqlj.jdbc.jdbc2.optional.*" recursive="false" />
<package part="mysqlcj" name="com.mysqlj.jdbc.log.*" recursive="false" />
<package part="mysqlcj" name="com.mysqlj.jdbc.profiler.*" recursive="false" />
<package part="mysqlcj" name="com.mysqlj.jdbc.util.*" recursive="false" />
References:
-----------
http://lopica.sourceforge.net/ref.html#package
http://lopica.sourceforge.net/ref.html#jar
No comments:
Post a Comment