Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Scout/Tutorial/3.10/UpdateWithF2"

(Add F2 Support)
(Replaced content with "{{ScoutPage|cat=Release 3.10}} see Scout/Tutorial/4.0/UpdateWithF2")
 
(57 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{{ScoutPage|cat=Release 3.10}}
 
{{ScoutPage|cat=Release 3.10}}
[[Scout/Concepts/F2 | F2]] is a simple update manager created by BSI. In this tutorial you learn how to update a scout client application with f2.
 
  
F2 has no dependencies to eclipse scout or any other library. However the installation of f2 is supported by the technology checkbox in Scout SDK.
+
see [[Scout/Tutorial/4.0/UpdateWithF2]]
 
+
==Prerequisites==
+
We assume that you already have {{ScoutLink|HowTo/3.9|Install Scout SDK|installed Scout}}. You also need to create a new Scout application that you will be updating with this tutorial. [[Scout/Tutorial/3.9/HelloWorld#Create_a_new_Scout_Project | Create a new Scout Project]] called org.eclipse.scout.helloworld. You also need to [[Scout/Tutorial/3.9/Deploy_to_Tomcat | deploy that application to tomcat]].
+
 
+
==Add F2 Support==
+
Adding F2 Support can be done by simply selecting the root node of the project in the Scout Explorer and checking the technology checkbox ''F2 Support'':
+
[[Image:addF2SupportToScoutApplication.jpg]] [[Image:addF2SupportToScoutApplicationUpdateManifests.jpg]]
+
 
+
Check all checkboxes to add f2 as a dependency to your Manifest files and include it in the client product files. Accept the license, wait until the update is installed and restart eclipse when asked.
+
 
+
==Add Automatic Update to Client==
+
Now you can add the code to update your client application automatically after startup, if an update is needed. You can do that by simply calling ''F2Updater.update'' with update strategy ''DoUpdate'' and a new ''EclipseUserAgent''. UpdateResult.UpdateSuccessful indicates that there was actually something updated and the update was successful. In development mode updating the application does not make sense. Therefore make sure there is never an update done in development mode.
+
 
+
Putting it all together leads to the following changes that need to be done in ''org.eclipse.scout.helloworld.ui.swing.SwingApplication.startSecure'':
+
 
+
...
+
  private Object startSecure(IApplicationContext context) throws Exception {
+
    try {
+
      NetActivator.install();
+
    }
+
    catch (Throwable t) {
+
      // no net handler found
+
      logger.warn("NetActivator is not available", t);
+
    }
+
    if (Platform.inDevelopmentMode()) {
+
      if (logger.isInfoEnabled()) {
+
        logger.info("No F2 update in development mode");
+
      }
+
    }
+
    else {
+
      // use f2 to update application
+
      UpdateResult result = F2Updater.update(UpdateStrategy.DoUpdate, null, new EclipseUserAgent(getProgressMonitor(), null));
+
      if (result == UpdateResult.UpdateSuccessful) {
+
        return EXIT_RESTART;
+
      }
+
    }
+
    return super.start(context);
+
  }
+
...
+
 
+
Update your SwingApplication accordingly.
+
 
+
==Creating an F2 Updatesite==
+
In order to update a client you need to create an updatesite, which contains the information about what has to be updated. The updatesite needs to be accessed over an URL. Therefore the easiest way is usually to deploy it to your servlet container (e.g. tomcat) where your server is located as a separate web application.
+
 
+
===Manual Creation===
+
For simplicity only the win32 case is described here. Assume that your application is called "example".
+
 
+
Export the eclipse client product to some temporary location with base folder "example_1.0.0"
+
Make sure that the application contains a jre, an *.exe and a *.ini file in /example_1.0.0/.
+
Compress/Zip the folder "example_1.0.0" to example_1.0.0.zip (including the folder "example_1.0.0" in the zip).
+
 
+
Create a new webapps directory:
+
/webapps/updatesite/
+
Copy the f2 plugin jar to
+
/webapps/updatesite/WEB-INF/lib/org.eclipse.update.f2_[version].jar
+
Copy the "example_1.0.0.zip" to
+
/webapps/updatesite/win32/example_1.0.0.zip
+
 
+
Rebuild the f2 update desciptor f2.txt with the command
+
java -jar /webapps/updatesite/WEB-INF/lib/org.eclipse.update.f2_[version].jar -create -site /webapps/updatesite -os win32 -name example -verbose
+
 
+
Now the updatesite is ready for use and the f2.txt contains all zip and delta files length, crc and hash.
+
 
+
===Build with Maven===
+
To create the updatesite with maven you can use the exec-maven-plugin.
+
 
+
<plugin>
+
        <groupId>org.codehaus.mojo</groupId>
+
        <artifactId>exec-maven-plugin</artifactId>
+
        <version>1.2.1</version>
+
        <executions>
+
            <execution>
+
                <id>default-cli</id>
+
                <goals>
+
                    <goal>exec</goal>
+
                </goals>
+
                <configuration>
+
                    <executable>java</executable>
+
                    <!-- optional -->
+
                    <workingDirectory>/tmp</workingDirectory>
+
                    <arguments>
+
                        <argument>-jar</argument>
+
                        <argument><path to f2>/org.eclipse.update.f2_[version].jar</argument>
+
                    </arguments>
+
                </configuration>                       
+
            </execution>
+
        </executions>
+
    </plugin>
+
 
+
== Triggering the update in the client ==
+
 
+
=== Initial client installation ===
+
The distribution of the initial client is not part of the f2 update.
+
 
+
The simplest way is to take the latest zip of your client application, say example_1.0.0.zip and copy it to the clients install location (C:/Program Files/example/example_1.0.0.zip). Unpack the zip at its location, so that the root example.exe is extracted to  C:/Program Files/example/example.exe
+
 
+
=== Automatic Client Update ===
+
From your plugin containing the eclipse IApplication add a dependency to org.eclipse.update.f2.
+
 
+
Somewhere in your application code where it best fits for you simply call: UpdateResult result = F2Updater.update();
+
 
+
Add the following entries to the config.ini of your product configuration
+
f2.url=http://hostname:port/updatesite
+
f2.name=example
+
 
+
Option: In order to use http basic auth add the config.ini parameters
+
f2.http.user=[user]
+
f2.http.pass=[pass]
+
 
+
=== Manual client update ===
+
It is also very simple to update the client manually (e.g. for testing). Copy the f2 plugin to some directory, say /temp/org.eclipse.update.f2_[version].jar and run the command
+
 
+
java -jar /temp/org.eclipse.update.f2_[version].jar -update -url http://hostname:port/updatesite -os win32 -arch x86 -name example -install "C:/Program Files/example" -verbose
+
 
+
-url is the url of the updatesite
+
-install is the root folder of the client installation
+
 
+
Option: In order to use http basic auth, add the command line parameters
+
-http.user [user]
+
-http.pass [pass]
+
 
+
Option: In order to log only errors, use -silent instead of -verbose
+
Basically logging is done using java.util.logging, so all therefore concepts hold.
+

Latest revision as of 11:41, 20 April 2014

The Scout documentation has been moved to https://eclipsescout.github.io/.

see Scout/Tutorial/4.0/UpdateWithF2

Back to the top