X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=inline;f=src%2Fnet%2Fpterodactylus%2Fjsite%2Fcore%2FCoreListener.java;h=fb109d7696c7425cb2b3997605a3d10930b140b1;hb=7e16d0a3b4f15da04f665fc011f78af2bc93a13d;hp=5fe47f9b00cd3289e62ef82fc16c2c42040d3be3;hpb=98585bac12bf6597d824a0123f25915f4abf0331;p=jSite2.git diff --git a/src/net/pterodactylus/jsite/core/CoreListener.java b/src/net/pterodactylus/jsite/core/CoreListener.java index 5fe47f9..fb109d7 100644 --- a/src/net/pterodactylus/jsite/core/CoreListener.java +++ b/src/net/pterodactylus/jsite/core/CoreListener.java @@ -27,13 +27,90 @@ package net.pterodactylus.jsite.core; */ public interface CoreListener { + // + // project configuration + // + + /** + * Notifies a listener that loading the projects finished successfully. + * + * @param directory + * The directory the nodes were loaded from + */ + public void loadingProjectsDone(String directory); + /** * Notifies all listeners that loading the projects has failed. * * @param directory * The directory the projects were tried to load from + * @param throwable + * The exception that occured while saving, if any + */ + public void loadingProjectsFailed(String directory, Throwable throwable); + + /** + * Notifies a listener that the projects were successfully saved to the + * given directory. + * + * @param directory + * The directory the projects were saved to + */ + public void savingProjectsDone(String directory); + + /** + * Notifies a listener that saving the projects has failed. + * + * @param directory + * The directory the projects were to be saved to + * @param throwable + * The exception that occured when saving the projects, if any + */ + public void savingProjectsFailed(String directory, Throwable throwable); + + // + // node configuration + // + + /** + * Notifies a listener that the nodes were successfully loaded. + * + * @param directory + * The directory the nodes were loaded from + */ + public void loadingNodesDone(String directory); + + /** + * Notifies a listener that loading the nodes has failed. + * + * @param directory + * The directory the nodes were loaded from + * @param throwable + * The exception that occured while loading the nodes + */ + public void loadingNodesFailed(String directory, Throwable throwable); + + /** + * Notifies a listener that the nodes were successfully saved. + * + * @param directory + * The directory the nodes were saved to + */ + public void savingNodesDone(String directory); + + /** + * Notifies a listener that saving the nodes has failed. + * + * @param directory + * The directory the nodes were saved to + * @param throwable + * The exception that occured while saving the nodes */ - public void loadingProjectsFailed(String directory); + public void savingNodesFailed(String directory, Throwable throwable); + + // + // basic core functionality + // /** * Notifies all listeners that the core has loaded. @@ -41,8 +118,36 @@ public interface CoreListener { public void coreLoaded(); /** + * Notifies a listener that the core was stopped. + */ + public void coreStopped(); + + // + // node stuff + // + + /** + * Notifies a listener that a node was added to the core. + * + * @param node + * The node that was added. + */ + public void nodeAdded(Node node); + + /** + * Notifies a listener that a node was removed from the core. Before a node + * is removed, it will be disconnected (and + * {@link #nodeDisconnected(Node, Throwable)} will be called). + * + * @param node + * The node that was removed + */ + public void nodeRemoved(Node node); + + /** * Notifies all listeners that the core started connecting to the given - * node. + * node. Before a node is connected, it will be added (and + * {@link #nodeAdded(Node)} will be called). * * @param node * The node that is being connected @@ -62,7 +167,45 @@ public interface CoreListener { * * @param node * The node that was diconnected + * @param throwable + * The exception that caused the disconnect, or null + * if there was no exception + */ + public void nodeDisconnected(Node node, Throwable throwable); + + // + // request stuff + // + + /** + * Notifies a listener that a request was added to a node. + * + * @param node + * The node the request was added to + * @param request + * The request that was added + */ + public void requestAdded(Node node, Request request); + + /** + * Notifies a listener that a request made some progress. + * + * @param request + * The request that made the progress + * @param totalBlocks + * The total number of blocks + * @param requiredBlocks + * The number of required blocks + * @param successfulBlocks + * The number of successful blocks + * @param failedBlocks + * The number of failed blocks + * @param fatallyFailedBlocks + * The number of fatally failed blocks + * @param finalizedTotal + * true if the number of total blocks is + * finalized, false if it is not */ - public void nodeDisconnected(Node node); + public void requestProgressed(Request request, int totalBlocks, int requiredBlocks, int successfulBlocks, int failedBlocks, int fatallyFailedBlocks, boolean finalizedTotal); }