1 package org.hardcode.juf.sample; 2 3 import java.io.File; 4 import java.io.IOException; 5 import java.net.MalformedURLException; 6 import java.net.URL; 7 import java.util.HashMap; 8 9 import org.hardcode.juf.InstallException; 10 import org.hardcode.juf.Installer; 11 import org.hardcode.juf.JUpdateUtilities; 12 import org.hardcode.juf.NoServerFileException; 13 import org.hardcode.juf.ProgressListener; 14 import org.hardcode.juf.status.Status; 15 import org.hardcode.juf.status.UpdateInfo; 16 17 /*** 18 * 19 */ 20 public class SampleUpdate implements Installer{ 21 22 /*** 23 * @throws InstallException 24 * @see org.hardcode.juf.Installer#install(java.util.HashMap, org.hardcode.jupdate.status.UpdateInfo, org.hardcode.jupdate.ProgressListener) 25 */ 26 public UpdateInfo install(HashMap clientStatus, UpdateInfo status, ProgressListener listener) throws InstallException { 27 JUpdateUtilities jup = new JUpdateUtilities(); 28 Status componentStatus = jup.getComponentStatus(status, "sample-component"); 29 30 if (componentStatus == null){ 31 componentStatus = new Status(); 32 componentStatus.setComponentName("sample-component"); 33 componentStatus.setVersion(1); 34 status.addStatus(componentStatus); 35 }else{ 36 componentStatus.setVersion(componentStatus.getVersion() + 1); 37 } 38 39 try { 40 jup.download(new URL("http://localhost:8080/jupdate-1.0.jar"), new File("jubajadaopdate-1.0.jar")); 41 } catch (NoServerFileException e) { 42 throw new InstallException(e); 43 } catch (MalformedURLException e) { 44 throw new InstallException(e); 45 } catch (IOException e) { 46 throw new InstallException(e); 47 } 48 49 return status; 50 } 51 52 }