0 Replies Latest reply: Sep 27, 2013 4:33 AM by SeitzD RSS

    search for updates during runtime

    SeitzD

      While the jws application is running it should look for new updates. If there are any, it displays a message like "There is a new version. Please restart the application to download the latest update". The problem is I don't know how to look for an update of the jws application. I've tried to use DownloadService2 (JNLP API Examples) but failed.

       

      This code should check for new updates and gets called periodically:

      BasicService bs = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService");
      System.out.println("Codebase: " + bs.getCodeBase());
      DownloadService2 service = (DownloadService2) ServiceManager.lookup("javax.jnlp.DownloadService2");
      
      ResourceSpec spec = new ResourceSpec(bs.getCodeBase()+".*", null, DownloadService2.JAR);
      ResourceSpec cacheResults[] = service.getCachedResources(spec);
      System.out.println(cacheResults.length);
      for (ResourceSpec resource : cacheResults) {
          System.out.println(resource.getUrl());
      }
      
      ResourceSpec updateResults[] = service.getUpdateAvailableResources(spec);
      System.out.println(updateResults.length);
      for (ResourceSpec resource : updateResults) {
          System.out.println(resource.getUrl());
      }
      
      
      

       

      The jar and the jnlp are hosted on a webserver and downloaded from there. If anything has changed in the code I upload a new jar unto the server. But service.getUpdateAvailableResource(spec) doesn't find any updates.