Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package netbeans;
- import java.net.URL;
- import java.util.logging.Logger;
- import org.netbeans.api.autoupdate.UpdateUnitProvider;
- import org.netbeans.api.autoupdate.UpdateUnitProviderFactory;
- public class AutoUpdater {
- private static final Logger log = Logger.getLogger(AutoUpdater.class.getName());
- private final URL url;
- private final String name;
- private final String displayName;
- /**
- * Conveniently register an UpdateUnitProvider.
- *
- * @param url URL to Autoupdate Catalog. Where the updates.xml file and probably associated NBM (NetBeans Module) files are.
- * @param name name of provider, this name is used by Autoupdate infrastructure for manipulating of providers.
- * @param displayName display name of provider
- *
- * @see UpdateRestarter
- */
- public AutoUpdater(URL url, String name, String displayName) {
- this.url = url;
- this.name = name;
- this.displayName = displayName;
- }
- public void refresh() {
- try {
- log.info(String.format("Initiating autoupdate from %s", url));
- UpdateUnitProvider uup = UpdateUnitProviderFactory.getDefault().create(
- name,
- displayName,
- url
- );
- uup.refresh(null, true);
- } catch (Exception e) {
- log.severe(e.toString());
- }
- }
- }
Add Comment
Please, Sign In to add comment