JUpdater
Encyclopedia
JUpdater is a project which aims to create a utility that allows developers to quickly implement version checks into Java
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

 programs. The utility ensures that the user can always be notified of new versions, and easily upgrade to the latest version from within the program, without having to do anything. The utility only downloads the files that are out of date, saving bandwidth.

JUpdater is split into two parts. A small Java client, which can easily be implemented into existing programs. And a PHP
PHP
PHP is a general-purpose server-side scripting language originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document...

 server part, which keeps track of the versions and provides the client with all the info it requires. The project is still in its youth, it's functional but expect a bug or two. Any program that is to be updated via JUpdater has to be contained in a jar file
JAR (file format)
In software, JAR is an archive file format typically used to aggregate many Java class files and associated metadata and resources into one file to distribute application software or libraries on the Java platform.JAR files are built on the ZIP file format and have the .jar file extension...

.

Client

A small bundle of classes, a JUpdater client, has to be added to programs so that they can compare their versions with a central server. The client requires JRE 1.5 or greater.

The client provides three main operations.
  1. Update a specified jar file by comparing all files' MD5
    MD5
    The MD5 Message-Digest Algorithm is a widely used cryptographic hash function that produces a 128-bit hash value. Specified in RFC 1321, MD5 has been employed in a wide variety of security applications, and is also commonly used to check data integrity...

     checksums, this is done in several steps described below.
  2. Check if a new version is available on the server by using the Implementation-Version attribute in the jar manifest
    Manifest file
    On the Java platform, a Manifest file is a specific file contained within a JAR archive. It is used to define extension and package-related data. It is a metadata file that contains name-value pairs organized in different sections. If a JAR file is intended to be used as an executable file, the...

    .
  3. Check if a new version is available and get the corresponding changelog by using the Implementation-Version attribute.


An interface
Interface (computer science)
In the field of computer science, an interface is a tool and concept that refers to a point of interaction between components, and is applicable at the level of both hardware and software...

 can optionally be implemented in order to listen to the update process. This information can then for instance be displayed in a GUI
Gui
Gui or guee is a generic term to refer to grilled dishes in Korean cuisine. These most commonly have meat or fish as their primary ingredient, but may in some cases also comprise grilled vegetables or other vegetarian ingredients. The term derives from the verb, "gupda" in Korean, which literally...

 for the user.

Server

JUpdater requires a central server that contains information about the latest version. The clients connect to the server in order to check if there are new versions and to download the changes and changelog. The server requires PHP 4.3 or greater and MySQL
MySQL
MySQL officially, but also commonly "My Sequel") is a relational database management system that runs as a server providing multi-user access to a number of databases. It is named after developer Michael Widenius' daughter, My...

 4.0 or greater.

How updating works

Here's an in depth description of what actually happens behind the scenes when performing a complete update check.
  1. The JUpdater instance's updateJar method is called with the name of the jar file to update and the relevant program name.
  2. The client opens a connection to the server and sends the program name (via HTTP Post).
  3. The server establishes a session and responds with the session id and the server's jar URL for that program. From this point on the client and server are in a session and the server therefor remembers what program the client wants to update during all further requests connected to that specific update.
  4. The client stores the server's response and sends a request for the file list of the server's jar file via XML-RPC
    XML-RPC
    XML-RPC is a remote procedure call protocol which uses XML to encode its calls and HTTP as a transport mechanism. "XML-RPC" also refers generically to the use of XML for remote procedure call, independently of the specific protocol...

    . The server responds with a list (taken from the server's database).
  5. The client calculates MD5 checksums
    MD5
    The MD5 Message-Digest Algorithm is a widely used cryptographic hash function that produces a 128-bit hash value. Specified in RFC 1321, MD5 has been employed in a wide variety of security applications, and is also commonly used to check data integrity...

    for all local files that it can find (looking in the file list from the server), the rest are given a checksum of 0. The client then sends the result to the server (via XML-RPC).
  6. The server checks all MD5 checksums against the entries in the database and returns a list of all the files for which the checksums did not match (i.e. a list of all files that are out of date). The following array is sent back for each file that is out of date: [filename, size, correct md5] (all of those things are read from the database).
  7. If nothing is out of date then the client stops here, otherwise it continues.
  8. The client requests a changelog from the server (via XML-RPC). The server responds with all changes (as entered by the administrator) made between the client's versions and the latest version.
  9. The client displays the changes and asks the listener with shouldStartDownloading if it should download the files.
  10. If false is returned from the method then the client stops here, otherwise it continues.
  11. The client starts downloading the out of date files one by one into a temporary storage. For each file the client calculates the MD5 checksum and make sure that it matches, otherwise it tries again (until it's out of tries).
  12. The client begins to patch once all out of date files are downloaded. It copies the current jar's up to date files into a new jar file and then writes the downloaded files into that jar. Once all is done without errors it replaces the old jar with the up to date jar, hence completing the update.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK