Guest User

Untitled

a guest
Jan 22nd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. package netbeans;
  2.  
  3. import java.net.URL;
  4. import java.util.logging.Logger;
  5. import org.netbeans.api.autoupdate.UpdateUnitProvider;
  6. import org.netbeans.api.autoupdate.UpdateUnitProviderFactory;
  7.  
  8. public class AutoUpdater {
  9.  
  10. private static final Logger log = Logger.getLogger(AutoUpdater.class.getName());
  11.  
  12. private final URL url;
  13.  
  14. private final String name;
  15.  
  16. private final String displayName;
  17.  
  18. /**
  19. * Conveniently register an UpdateUnitProvider.
  20. *
  21. * @param url URL to Autoupdate Catalog. Where the updates.xml file and probably associated NBM (NetBeans Module) files are.
  22. * @param name name of provider, this name is used by Autoupdate infrastructure for manipulating of providers.
  23. * @param displayName display name of provider
  24. *
  25. * @see UpdateRestarter
  26. */
  27. public AutoUpdater(URL url, String name, String displayName) {
  28. this.url = url;
  29. this.name = name;
  30. this.displayName = displayName;
  31. }
  32.  
  33. public void refresh() {
  34. try {
  35. log.info(String.format("Initiating autoupdate from %s", url));
  36. UpdateUnitProvider uup = UpdateUnitProviderFactory.getDefault().create(
  37. name,
  38. displayName,
  39. url
  40. );
  41. uup.refresh(null, true);
  42.  
  43. } catch (Exception e) {
  44. log.severe(e.toString());
  45. }
  46. }
  47. }
Add Comment
Please, Sign In to add comment