Page Created :
SLING :
Updating the Sling Launcher
Updating the Sling Launcher has been created by Felix Meschberger (Jan 10, 2009). Content:Updating the Sling LauncherStatus: DRAFT 1 Problem ScopeA Sling instance is launched by the Sling launcher, which is a single JAR (standalone Java Application) or WAR (Web Application) file. This file cannot currently be updated without physical access to the system, stopping the system, replacing the file and restarting the system. It would be a good thing, if we could use existing administration API such as the Felix Web Console or the Felix (Remote) Shell to update this launcher. This concept is about how we could slightly restructure the launcher to enable just this functionality. 2 IdeaWe have a single JAR file, which contains the OSGi framework (Apache Felix), the OSGi core libraries and the actual launcher for the OSGi framework. This single JAR file the launcher JAR is contained as a JAR file in either the standalone Java Application JAR or the Web Application WAR file. The Standalone Java Application JAR File contains a single main class, which reads the command line and instantiates the actual launcher in the launcher JAR and waits for its termination. The Web Application WAR File contains a single servlet, which instantiates the actual launcher servlet in the launcher JAR and reacts to its termination. Both the main class and the servlet are very tiny and have the following tasks:
3 Launcher JAR updateSince the launcher JAR is a single JAR file, it may be updated. But it must also be possible to make sure the new code is actually being used after restart. To implement this requirement the main class or servlet follow this algorithm:
After the launcher terminates either by the stop or update method being called on the system bundle or by being requested from the main class or servlet, the class loader is just dropped and thus given to the garbage collector. It may be, that there will have to be some cleanup for the garbage collector to be operational. Notable areas are the Java VM JavaBeans cache and any caches of the Java Logging API. 4 Launcher support for stop and updateThe launcher JAR must have two basic features:
To implement these two features, the launcher JAR overwrites the stop and update methods of the Felix class, which implements the system bundle. The update(InputStream) method is overwritten to take the new launcher JAR file and place it such, that it can be used to restart. All method overwrites, start a separate thread which waits for the framework to terminate. When the framework has been terminated, the main class or servlet is notified. The main class or servlet provide the launcher with two Runnable instances: stopNotifier and updateNotifier. The stopNotifier is called if the framework has been stopped. The updateNotifier is called if the framework has been stopped for it to be restarted. The stopNotifier Runnable enables the main class or servlet to react to the situation that the framework has gone and take appropriate actions. The updateNotifier Runable enables the main class or servlet to drop the framework and classloader and restart the framework in a new class loader with a potentiall new launcher JAR. 5 PrototypeI will be creating a prototype implementation in my whiteboard |
Unsubscribe or edit your notifications preferences