- Split up Updater and Checker interfaces

- Update router after check
This commit is contained in:
zzz
2012-10-17 22:24:15 +00:00
parent 4db4010abf
commit b9d717b9f9
18 changed files with 178 additions and 102 deletions

View File

@@ -0,0 +1,26 @@
package net.i2p.update;
import java.net.URI;
import java.util.List;
/**
* Controls one or more types of updates.
* This must be registered with the UpdateManager.
*
* @since 0.9.4
*/
public interface Checker {
/**
* Check for updates.
* Should not block.
* If any are found, call back to UpdateManager.notifyUpdateAvailable().
*
* @param id plugin name or ignored
* @param maxTime how long you have
* @return active task or null if unable to check
*/
public UpdateTask check(UpdateType type, UpdateMethod method,
String id, String currentVersion, long maxTime);
}

View File

@@ -2,7 +2,7 @@ package net.i2p.update;
import java.io.File;
import java.net.URI;
import java.util.List;;
import java.util.List;
/**
* The central resource coordinating updates.
@@ -11,17 +11,20 @@ import java.util.List;;
* The UpdateManager starts and stops all updates,
* and controls notification to the user.
*
* @since 0.9.2
* @since 0.9.4
*/
public interface UpdateManager {
/**
* Call multiple times for each type/method pair.
* The UpdateManager will then call start()
* Call once for each type/method pair.
*/
public void register(Updater updater, UpdateType type, UpdateMethod method, int priority);
public void register(Checker checker, UpdateType type, UpdateMethod method, int priority);
public void unregister(Updater updater, UpdateType type, UpdateMethod method);
public void unregister(Checker checker, UpdateType type, UpdateMethod method);
public void start();

View File

@@ -3,7 +3,7 @@ package net.i2p.update;
/**
* Transport mechanism for getting something.
*
* @since 0.9.2
* @since 0.9.4
*/
public enum UpdateMethod {
METHOD_DUMMY,

View File

@@ -5,7 +5,7 @@ import java.net.URI;
/**
* A running check or download. Cannot be restarted.
*
* @since 0.9.2
* @since 0.9.4
*/
public interface UpdateTask {

View File

@@ -3,7 +3,7 @@ package net.i2p.update;
/**
* What to update
*
* @since 0.9.2
* @since 0.9.4
*/
public enum UpdateType {
TYPE_DUMMY,

View File

@@ -7,22 +7,10 @@ import java.util.List;
* Controls one or more types of updates.
* This must be registered with the UpdateManager.
*
* @since 0.9.2
* @since 0.9.4
*/
public interface Updater {
/**
* Check for updates.
* Should not block.
* If any are found, call back to UpdateManager.notifyUpdateAvailable().
*
* @param id plugin name or ignored
* @param maxTime how long you have
* @return active task or null if unable to check
*/
public UpdateTask check(UpdateType type, UpdateMethod method,
String id, String currentVersion, long maxTime);
/**
* Start a download and return a handle to the download task.
* Should not block.