From 52608018e26c1d6bffc3c8561cae9500c141a636 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 23 May 2009 15:41:06 +0200 Subject: [PATCH] Remove request and insert manager and all related classes. --- src/net/pterodactylus/jsite/core/CoreImpl.java | 117 +----- src/net/pterodactylus/jsite/core/Insert.java | 108 ------ .../pterodactylus/jsite/core/InsertListener.java | 81 ---- .../jsite/core/InsertListenerSupport.java | 111 ------ .../pterodactylus/jsite/core/InsertManager.java | 119 ------ src/net/pterodactylus/jsite/core/Request.java | 408 --------------------- .../pterodactylus/jsite/core/RequestListener.java | 73 ---- .../jsite/core/RequestListenerManager.java | 98 ----- .../pterodactylus/jsite/core/RequestManager.java | 222 ----------- 9 files changed, 1 insertion(+), 1336 deletions(-) delete mode 100644 src/net/pterodactylus/jsite/core/Insert.java delete mode 100644 src/net/pterodactylus/jsite/core/InsertListener.java delete mode 100644 src/net/pterodactylus/jsite/core/InsertListenerSupport.java delete mode 100644 src/net/pterodactylus/jsite/core/InsertManager.java delete mode 100644 src/net/pterodactylus/jsite/core/Request.java delete mode 100644 src/net/pterodactylus/jsite/core/RequestListener.java delete mode 100644 src/net/pterodactylus/jsite/core/RequestListenerManager.java delete mode 100644 src/net/pterodactylus/jsite/core/RequestManager.java diff --git a/src/net/pterodactylus/jsite/core/CoreImpl.java b/src/net/pterodactylus/jsite/core/CoreImpl.java index 6787cef..2b795ed 100644 --- a/src/net/pterodactylus/jsite/core/CoreImpl.java +++ b/src/net/pterodactylus/jsite/core/CoreImpl.java @@ -34,7 +34,7 @@ import net.pterodactylus.util.logging.Logging; * * @author David ‘Bombe’ Roden <bombe@freenetproject.org> */ -public class CoreImpl implements Core, NodeListener, RequestListener, InsertListener { +public class CoreImpl implements Core, NodeListener { /** The logger. */ private static final Logger logger = Logging.getLogger(CoreImpl.class.getName()); @@ -52,14 +52,6 @@ public class CoreImpl implements Core, NodeListener, RequestListener, InsertList /** The node manager. */ private NodeManager nodeManager; - /** The request manager. */ - /* TODO - remove */ - @SuppressWarnings("unused") - private RequestManager requestManager; - - /** The insert manager. */ - private InsertManager insertManager; - // // LISTENER MANAGEMENT // @@ -123,26 +115,6 @@ public class CoreImpl implements Core, NodeListener, RequestListener, InsertList } /** - * Sets the request manager to use. - * - * @param requestManager - * The request manager to use - */ - public void setRequestManager(RequestManager requestManager) { - this.requestManager = requestManager; - } - - /** - * Sets the insert manager to use. - * - * @param insertManager - * The insert manager to use - */ - public void setInsertManager(InsertManager insertManager) { - this.insertManager = insertManager; - } - - /** * {@inheritDoc} */ public List getNodes() { @@ -254,7 +226,6 @@ public class CoreImpl implements Core, NodeListener, RequestListener, InsertList */ public void insertProject(Node node, Project project) { logger.log(Level.FINEST, "insertProject(node=" + node + ", project=" + project + ")"); - insertManager.insertProject(project, node); } /** @@ -336,90 +307,4 @@ public class CoreImpl implements Core, NodeListener, RequestListener, InsertList coreListenerSupport.fireNodeDisconnected(node, throwable); } - // - // INTERFACE RequestListener - // - - /** - * {@inheritDoc} - */ - public void requestAdded(Request request) { - /* TODO - find project and process request */ - } - - /** - * @see net.pterodactylus.jsite.core.RequestListener#requestProgressed(Request) - */ - public void requestProgressed(Request request) { - /* TODO - find project and process request */ - } - - /** - * @see net.pterodactylus.jsite.core.RequestListener#requestRemoved(net.pterodactylus.jsite.core.Request) - */ - public void requestRemoved(Request request) { - /* TODO - find project and process request */ - } - - /** - * @see net.pterodactylus.jsite.core.RequestListener#requestGeneratedURI(net.pterodactylus.jsite.core.Request, - * java.lang.String) - */ - public void requestGeneratedURI(Request request, String uri) { - /* TODO - find project and process request */ - } - - /** - * @see net.pterodactylus.jsite.core.RequestListener#requestFinished(net.pterodactylus.jsite.core.Request) - */ - public void requestFinished(Request request) { - /* TODO - find project and process request */ - } - - // - // INTERFACE InsertListener - // - - /** - * {@inheritDoc} - */ - public void insertAdded(Insert insert) { - /* TODO */ - } - - /** - * {@inheritDoc} - */ - public void insertRemoved(Insert insert) { - /* TODO */ - } - - /** - * {@inheritDoc} - */ - public void insertStarted(Insert insert) { - /* TODO */ - } - - /** - * {@inheritDoc} - */ - public void insertProgressed(Insert insert) { - /* TODO */ - } - - /** - * {@inheritDoc} - */ - public void insertGeneratedURI(Insert insert, String uri) { - /* TODO */ - } - - /** - * {@inheritDoc} - */ - public void insertFinished(Insert insert) { - /* TODO */ - } - } diff --git a/src/net/pterodactylus/jsite/core/Insert.java b/src/net/pterodactylus/jsite/core/Insert.java deleted file mode 100644 index ba61be2..0000000 --- a/src/net/pterodactylus/jsite/core/Insert.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * jSite2 - Insert.java - Copyright © 2008 David Roden - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package net.pterodactylus.jsite.core; - -/** - * Represents a currently running or past insert. - * - * @author David ‘Bombe’ Roden <bombe@freenetproject.org> - */ -public class Insert extends Request { - - /** The project that was inserted. */ - private final Project project; - - /** The start time of the insert. */ - private final long startTime; - - /** The end time of the insert. */ - private long endTime; - - /** - * Creates a new insert that starts now. - * - * @param project - * The project that is inserted - * @param node - * The node the project is inserted to - * @param identifier - * The identifier of the insert request - */ - public Insert(Project project, Node node, String identifier) { - this(project, node, identifier, System.currentTimeMillis()); - } - - /** - * Creates a new insert. - * - * @param project - * The project that is inserted - * @param node - * The node the project is inserted to - * @param identifier - * The identifier of the insert request - * @param startTime - * The time the insert was started - */ - public Insert(Project project, Node node, String identifier, long startTime) { - super(node, identifier); - this.project = project; - this.startTime = startTime; - } - - /** - * Returns the project that is inserted. - * - * @return The inserted project - */ - public Project getProject() { - return project; - } - - /** - * Returns the start time of the insert. - * - * @return The start time of the insert - */ - public long getStartTime() { - return startTime; - } - - /** - * Returns the end time of the insert. If the insert has not yet finished, - * -1 is returned. - * - * @return The end time of the insert, or -1 if the insert is - * still running - */ - public long getEndTime() { - return endTime; - } - - /** - * Sets the end time of the insert. - * - * @param endTime - * The end time of the insert - */ - public void setEndTime(long endTime) { - this.endTime = endTime; - } - -} diff --git a/src/net/pterodactylus/jsite/core/InsertListener.java b/src/net/pterodactylus/jsite/core/InsertListener.java deleted file mode 100644 index d4751c0..0000000 --- a/src/net/pterodactylus/jsite/core/InsertListener.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * jSite2 - InsertListener.java - Copyright © 2008 David Roden - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package net.pterodactylus.jsite.core; - -import java.util.EventListener; - -/** - * Interface for objects that want to be notified on events emitted by the - * {@link InsertManager}. - * - * @author David ‘Bombe’ Roden <bombe@freenetproject.org> - */ -public interface InsertListener extends EventListener { - - /** - * Notifies a listener that an insert was added. - * - * @param insert - * The insert that was added - */ - public void insertAdded(Insert insert); - - /** - * Notifies a listener that an insert was removed. - * - * @param insert - * The insert that was removed - */ - public void insertRemoved(Insert insert); - - /** - * Notifies a listener that an insert was started. - * - * @param insert - * The insert that was started - */ - public void insertStarted(Insert insert); - - /** - * Notifies a listener that an insert made some progress. - * - * @param insert - * The insert that made some progress - */ - public void insertProgressed(Insert insert); - - /** - * Notifies listeners that an insert generated a URI. - * - * @param insert - * The insert that generated a URI - * @param uri - * The generated URI - */ - public void insertGeneratedURI(Insert insert, String uri); - - /** - * Notifies a listener that an insert has finished. - * - * @param insert - * The insert that has finished - */ - public void insertFinished(Insert insert); - -} diff --git a/src/net/pterodactylus/jsite/core/InsertListenerSupport.java b/src/net/pterodactylus/jsite/core/InsertListenerSupport.java deleted file mode 100644 index 2504d61..0000000 --- a/src/net/pterodactylus/jsite/core/InsertListenerSupport.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * jSite-next - InsertListenerSupport.java - - * Copyright © 2008 David Roden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package net.pterodactylus.jsite.core; - -import net.pterodactylus.util.event.ListenerManager; - -/** - * Helper class that fires {@link InsertListener} events. - * - * @author David ‘Bombe’ Roden <bombe@freenetproject.org> - */ -public class InsertListenerSupport extends ListenerManager { - - /** - * Notifies all listeners that the insert was added. - * - * @see InsertListener#insertAdded(Insert) - * @param insert - * The insert that was added - */ - public void fireInsertAdded(Insert insert) { - for (InsertListener insertListener : getListeners()) { - insertListener.insertAdded(insert); - } - } - - /** - * Notifies all listeners that the insert was removed. - * - * @see InsertListener#insertRemoved(Insert) - * @param insert - * The insert that was removed - */ - public void fireInsertRemoved(Insert insert) { - for (InsertListener insertListener : getListeners()) { - insertListener.insertRemoved(insert); - } - } - - /** - * Notifies all listeners that the insert was started. - * - * @see InsertListener#insertStarted(Insert) - * @param insert - * The insert that was started - */ - public void fireInsertStarted(Insert insert) { - for (InsertListener insertListener : getListeners()) { - insertListener.insertStarted(insert); - } - } - - /** - * Notifies all listeners that the insert made progress. - * - * @see InsertListener#insertProgressed(Insert) - * @param insert - * The insert that made progress - */ - public void fireInsertProgressed(Insert insert) { - for (InsertListener insertListener : getListeners()) { - insertListener.insertProgressed(insert); - } - } - - /** - * Notifies all listeners that the insert generated a URI. - * - * @see InsertListener#insertGeneratedURI(Insert, String) - * @param insert - * The insert that generated a URI - * @param generatedUri - * The URI that was generated - */ - public void fireInsertGeneratedURI(Insert insert, String generatedUri) { - for (InsertListener insertListener : getListeners()) { - insertListener.insertGeneratedURI(insert, generatedUri); - } - } - - /** - * Notifies all listeners that the insert has finished. - * - * @see InsertListener#insertFinished(Insert) - * @param insert - * The insert that was finished - */ - public void fireInsertFinished(Insert insert) { - for (InsertListener insertListener : getListeners()) { - insertListener.insertFinished(insert); - } - } - -} diff --git a/src/net/pterodactylus/jsite/core/InsertManager.java b/src/net/pterodactylus/jsite/core/InsertManager.java deleted file mode 100644 index 52f3d46..0000000 --- a/src/net/pterodactylus/jsite/core/InsertManager.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * jSite2 - InsertManager.java - Copyright © 2008 David Roden - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation; either version 2 of the License, or (at your option) any later - * version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package net.pterodactylus.jsite.core; - -import java.util.HashMap; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -import net.pterodactylus.util.logging.Logging; - -/** - * Manages all currently running and past inserts. - * - * @author David ‘Bombe’ Roden <bombe@freenetproject.org> - */ -public class InsertManager { - - /** Logger. */ - private static final Logger logger = Logging.getLogger(InsertManager.class.getName()); - - /** The insert listener support. */ - private final InsertListenerSupport insertListenerSupport = new InsertListenerSupport(); - - /** Mapping from insert IDs to inserts. */ - private final Map inserts = new HashMap(); - - // - // EVENT MANAGEMENT - // - - /** - * Adds an insert listener to the list of insert listeners. - * - * @param insertListener - * The insert listener to add - */ - public void addInsertListener(InsertListener insertListener) { - logger.log(Level.FINEST, "addInsertListener(insertListener=" + insertListener + ")"); - insertListenerSupport.addListener(insertListener); - } - - /** - * Removes an insert listener from the list of insert listeners. - * - * @param insertListener - * The insert listener to remove - */ - public void removeInsertListener(InsertListener insertListener) { - logger.log(Level.FINEST, "removeInsertListener(insertListener=" + insertListener + ")"); - insertListenerSupport.removeListener(insertListener); - } - - // - // ACTIONS - // - - /** - * Starts to insert the given project. - * - * @param project - * The project to insert - * @param node - * The node to insert the project to if the project does not - * specify a node - */ - public void insertProject(Project project, Node node) { - logger.log(Level.FINEST, "insertProject(project=" + project + ",node=" + node + ")"); - String insertId = "insert-" + project.getId(); - Insert newInsert = new Insert(project, node, insertId); - inserts.put(insertId, newInsert); - saveConfiguration(); - insertListenerSupport.fireInsertAdded(newInsert); - /* TODO - start insert */ - } - - /** - * Starts the insert manager. - */ - public void start() { - logger.log(Level.FINEST, "start()"); - loadConfiguration(); - } - - // - // PRIVATE METHODS - // - - /** - * Loads the configuration. - */ - private void loadConfiguration() { - logger.log(Level.FINEST, "loadConfiguration()"); - } - - /** - * Saves the configuration. - */ - private void saveConfiguration() { - logger.log(Level.FINEST, "saveConfiguration()"); - } - -} diff --git a/src/net/pterodactylus/jsite/core/Request.java b/src/net/pterodactylus/jsite/core/Request.java deleted file mode 100644 index a61bb94..0000000 --- a/src/net/pterodactylus/jsite/core/Request.java +++ /dev/null @@ -1,408 +0,0 @@ -/* - * jSite2 - Request.java - - * Copyright © 2008 David Roden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package net.pterodactylus.jsite.core; - -import net.pterodactylus.util.beans.AbstractBean; - -/** - * A request is an ongoing download or upload reported by the freenet node. - * - * @author David ‘Bombe’ Roden <bombe@freenetproject.org> - */ -public class Request extends AbstractBean { - - /** - * The type of a request. - * - * @author David ‘Bombe’ Roden <bombe@freenetproject.org> - */ - public enum Type { - - /** Type of request is unknown. */ - unknown, - - /** The request is a Get request. */ - get, - - /** The request is a Put request. */ - put, - - /** The request is a PutDir request. */ - putDir - - } - - /** Name of the “type” property. */ - public static final String PROPERTY_TYPE = "type"; - - /** Name of the “client token” property. */ - public static final String PROPERTY_CLIENT_TOKEN = "clientToken"; - - /** Name of the “finished” property. */ - public static final String PROPERTY_FINISHED = "finished"; - - /** Name of the “successful” property. */ - public static final String PROPERTY_SUCCESSFUL = "successful"; - - /** Name of the “fetchable” property. */ - public static final String PROPERTY_FETCHABLE = "fetchable"; - - /** Name of the “URI” property. */ - public static final String PROPERTY_URI = "uri"; - - /** Name of the “total blocks” property. */ - public static final String PROPERTY_TOTAL_BLOCKS = "totalBlocks"; - - /** Name of the “required blocks” property. */ - public static final String PROPERTY_REQUIRED_BLOCKS = "requiredBlocks"; - - /** Name of the “successful blocks” property. */ - public static final String PROPERTY_SUCCESSFUL_BLOCKS = "successfulBlocks"; - - /** Name of the “failed blocks” property. */ - public static final String PROPERTY_FAILED_BLOCKS = "failedBlocks"; - - /** Name of the “fatally failed blocks” property. */ - public static final String PROPERTY_FATALLY_FAILED_BLOCKS = "fatallyFailedBlocks"; - - /** Name of the “total finalized” property. */ - public static final String PROPERTY_TOTAL_FINALIZED = "totalFinalized"; - - /** The node the request belongs to. */ - private final Node node; - - /** The identifier of the request. */ - private final String identifier; - - /** The type of the request. */ - private Type type; - - /** The client token of the request. */ - private String clientToken; - - /** Whether the request is finished. */ - private boolean finished; - - /** Whether the request was finished successfully. */ - private boolean successful; - - /** Whether the data is already fetchable (in case of put requests). */ - private boolean fetchable; - - /** The generated URI. */ - private String uri; - - /** The total number of blocks. */ - private int totalBlocks; - - /** The required number of blocks. */ - private int requiredBlocks; - - /** The number of successful blocks. */ - private int successfulBlocks; - - /** The number of failedBlocks. */ - private int failedBlocks; - - /** The number of fatally failed blocks. */ - private int fatallyFailedBlocks; - - /** Whether the total number has been finalized. */ - private boolean totalFinalized; - - /** - * Creates a new request with the given identifier. - * - * @param node - * The node the request belongs to - * @param identifier - * The identifier of the request - */ - Request(Node node, String identifier) { - this.node = node; - this.identifier = identifier; - } - - // - // EVENT MANAGEMENT - // - - /** - * Returns the node the request belongs to. - * - * @return The node the request belongs to - */ - public Node getNode() { - return node; - } - - /** - * Returns the identifier of the request. It is unique per node. - * - * @return The identifier of the request - */ - public String getIdentifier() { - return identifier; - } - - /** - * Returns the type of the request. - * - * @return The type of the request - */ - - public Type getType() { - return type; - } - - /** - * Sets the type of the request. - * - * @param type - * The type of the request - */ - void setType(Type type) { - Type oldType = this.type; - this.type = type; - fireIfPropertyChanged(PROPERTY_TYPE, oldType, type); - } - - /** - * Returns the client token of the request. - * - * @return The client token of the request - */ - public String getClientToken() { - return clientToken; - } - - /** - * Sets the client token of the request. - * - * @param clientToken - * The client token of the request - */ - void setClientToken(String clientToken) { - String oldClientToken = this.clientToken; - this.clientToken = clientToken; - fireIfPropertyChanged(PROPERTY_CLIENT_TOKEN, oldClientToken, clientToken); - } - - /** - * Returns whether the request has finished. - * - * @see #isSuccessful() - * @return true if the request is finished, - * false otherwise - */ - public boolean isFinished() { - return finished; - } - - /** - * Sets whether the request has finished. - * - * @param finished - * true if the request has finished, - * false otherwise - */ - void setFinished(boolean finished) { - boolean oldFinished = this.finished; - this.finished = finished; - firePropertyChange(PROPERTY_FINISHED, oldFinished, finished); - } - - /** - * Returns whether the request finished successfully. This value will only - * have meaning if {@link #isFinished()} returns true. - * - * @return true if the request finished successfully, - * false otherwise - */ - public boolean isSuccessful() { - return successful; - } - - /** - * Sets whether this request finished successfully. - * - * @param successful - * true if the request finished successfully, - * false otherwise - */ - void setSuccessful(boolean successful) { - boolean oldSuccessful = this.successful; - this.successful = successful; - firePropertyChange(PROPERTY_SUCCESSFUL, oldSuccessful, successful); - } - - /** - * Returns whether the data inserted by this {@link Type#put} or - * {@link Type#putDir} request is already fetchable by other clients. - * - * @return true if the data is already fetchable, - * false otherwise - */ - public boolean isFetchable() { - return fetchable; - } - - /** - * Sets whether the data inserted by this {@link Type#put} or - * {@link Type#putDir} request is already fetchable by other clients. - * - * @param fetchable - * true if the data is already fetchable, - * false otherwise - */ - void setFetchable(boolean fetchable) { - boolean oldFetchable = this.fetchable; - this.fetchable = fetchable; - firePropertyChange(PROPERTY_FETCHABLE, oldFetchable, fetchable); - } - - /** - * Returns the URI generated by this request. - * - * @return The generated URI - */ - public String getURI() { - return uri; - } - - /** - * Sets the URI generated by this request. - * - * @param uri - * The generated URI - */ - void setURI(String uri) { - this.uri = uri; - } - - /** - * Returns the total number of blocks of a request. Until - * {@link #isTotalFinalized()} returns true this value may - * change! - * - * @return The total number of blocks of a request - */ - public int getTotalBlocks() { - return totalBlocks; - } - - /** - * Sets the total number of blocks of a request. - * - * @param totalBlocks - * The total number of blocks - */ - void setTotalBlocks(int totalBlocks) { - int oldTotalBlocks = this.totalBlocks; - this.totalBlocks = totalBlocks; - fireIfPropertyChanged(PROPERTY_TOTAL_BLOCKS, oldTotalBlocks, totalBlocks); - } - - /** - * @return the requiredBlocks - */ - public int getRequiredBlocks() { - return requiredBlocks; - } - - /** - * @param requiredBlocks - * the requiredBlocks to set - */ - void setRequiredBlocks(int requiredBlocks) { - int oldRequiredBlocks = this.requiredBlocks; - this.requiredBlocks = requiredBlocks; - fireIfPropertyChanged(PROPERTY_REQUIRED_BLOCKS, oldRequiredBlocks, requiredBlocks); - } - - /** - * @return the successfulBlocks - */ - public int getSuccessfulBlocks() { - return successfulBlocks; - } - - /** - * @param successfulBlocks - * the successfulBlocks to set - */ - void setSuccessfulBlocks(int successfulBlocks) { - int oldSuccessfulBlocks = this.successfulBlocks; - this.successfulBlocks = successfulBlocks; - fireIfPropertyChanged(PROPERTY_SUCCESSFUL_BLOCKS, oldSuccessfulBlocks, successfulBlocks); - } - - /** - * @return the failedBlocks - */ - public int getFailedBlocks() { - return failedBlocks; - } - - /** - * @param failedBlocks - * the failedBlocks to set - */ - void setFailedBlocks(int failedBlocks) { - int oldFailedBlocks = this.failedBlocks; - this.failedBlocks = failedBlocks; - fireIfPropertyChanged(PROPERTY_FAILED_BLOCKS, oldFailedBlocks, failedBlocks); - } - - /** - * @return the fatallyFailedBlocks - */ - public int getFatallyFailedBlocks() { - return fatallyFailedBlocks; - } - - /** - * @param fatallyFailedBlocks - * the fatallyFailedBlocks to set - */ - void setFatallyFailedBlocks(int fatallyFailedBlocks) { - int oldFatallyFailedBlocks = this.fatallyFailedBlocks; - this.fatallyFailedBlocks = fatallyFailedBlocks; - fireIfPropertyChanged(PROPERTY_FATALLY_FAILED_BLOCKS, oldFatallyFailedBlocks, fatallyFailedBlocks); - } - - /** - * @return the totalFinalized - */ - public boolean isTotalFinalized() { - return totalFinalized; - } - - /** - * @param totalFinalized - * the totalFinalized to set - */ - void setTotalFinalized(boolean totalFinalized) { - boolean oldTotalFinalized = this.totalFinalized; - this.totalFinalized = totalFinalized; - fireIfPropertyChanged(PROPERTY_TOTAL_FINALIZED, oldTotalFinalized, totalFinalized); - } - -} diff --git a/src/net/pterodactylus/jsite/core/RequestListener.java b/src/net/pterodactylus/jsite/core/RequestListener.java deleted file mode 100644 index d8f874e..0000000 --- a/src/net/pterodactylus/jsite/core/RequestListener.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * jSite2 - RequestListener.java - - * Copyright © 2008 David Roden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package net.pterodactylus.jsite.core; - -import java.util.EventListener; - -/** - * Interface for objects that want to be notified on request events. - * - * @author David ‘Bombe’ Roden <bombe@freenetproject.org> - */ -public interface RequestListener extends EventListener { - - /** - * Notifies a listener that a request was added to a node. - * - * @param request - * The request that was added - */ - public void requestAdded(Request request); - - /** - * Notifies a listener that a request made progress. - * - * @param request - * The request - */ - public void requestProgressed(Request request); - - /** - * Notifies a listener that a request was removed. - * - * @param request - * The request that was removed - */ - public void requestRemoved(Request request); - - /** - * Notifies a listener that a Put request has generated a URI. - * - * @param request - * The request that generated a URI - * @param uri - * The generated URI - */ - public void requestGeneratedURI(Request request, String uri); - - /** - * Notifies a listener that a request has completed. - * - * @param request - * The finished request - */ - public void requestFinished(Request request); - -} diff --git a/src/net/pterodactylus/jsite/core/RequestListenerManager.java b/src/net/pterodactylus/jsite/core/RequestListenerManager.java deleted file mode 100644 index 4197313..0000000 --- a/src/net/pterodactylus/jsite/core/RequestListenerManager.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * jSite-next - RequestListenerManager.java - - * Copyright © 2009 David Roden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package net.pterodactylus.jsite.core; - -import net.pterodactylus.util.event.ListenerManager; - -/** - * Manager for {@link RequestListener} event listeners. - * - * @author David ‘Bombe’ Roden - */ -public class RequestListenerManager extends ListenerManager { - - /** - * Notifies all listeners that a request was added. - * - * @see RequestListener#requestAdded(Request) - * @param request - * The added request - */ - public void fireRequestAdded(Request request) { - for (RequestListener requestListener : getListeners()) { - requestListener.requestAdded(request); - } - } - - /** - * Notifies all listeners that a request has made progress. - * - * @see RequestListener#requestProgressed(Request) - * @param request - * The request that made progress - */ - public void fireRequestProgressed(Request request) { - for (RequestListener requestListener : getListeners()) { - requestListener.requestProgressed(request); - } - } - - /** - * Notifies all listeners that a request was removed. - * - * @see RequestListener#requestRemoved(Request) - * @param request - * The removed request - */ - public void fireRequestRemoved(Request request) { - for (RequestListener requestListener : getListeners()) { - requestListener.requestRemoved(request); - } - } - - /** - * Notifies all listeners that a request generated a URI. - * - * @see RequestListener#requestGeneratedURI(Request, String) - * @param request - * The request that generated the URI - * @param uri - * The generated URI - */ - public void fireRequestGeneratedURI(Request request, String uri) { - for (RequestListener requestListener : getListeners()) { - requestListener.requestGeneratedURI(request, uri); - } - } - - /** - * Notifies all listeners that a request finished. - * - * @see RequestListener#requestFinished(Request) - * @param request - * The finished request - */ - public void fireRequestFinished(Request request) { - for (RequestListener requestListener : getListeners()) { - requestListener.requestFinished(request); - } - } - -} diff --git a/src/net/pterodactylus/jsite/core/RequestManager.java b/src/net/pterodactylus/jsite/core/RequestManager.java deleted file mode 100644 index ac9d588..0000000 --- a/src/net/pterodactylus/jsite/core/RequestManager.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * jSite2 - RequestManager.java - - * Copyright © 2008 David Roden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package net.pterodactylus.jsite.core; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.logging.Logger; - -import net.pterodactylus.util.logging.Logging; - -/** - * The request manager keeps track of all the request on all connected nodes. - * The request manager is added to the {@link NodeManager} as a - * {@link NodeListener} so that it can fire request-removed events in case a - * node is disconnected. - * - * @author David ‘Bombe’ Roden <bombe@freenetproject.org> - */ -public class RequestManager implements NodeListener { - - /** Logger. */ - private static final Logger logger = Logging.getLogger(RequestManager.class.getName()); - - /** Request listeners. */ - private List requestListeners = Collections.synchronizedList(new ArrayList()); - - /** The node manager. */ - private NodeManager nodeManager; - - /** Request lists for all nodes. */ - private Map> nodeRequests = Collections.synchronizedMap(new HashMap>()); - - // - // EVENT MANAGEMENT - // - - /** - * Adds a request listener. - * - * @param requestListener - * The request listener to add - */ - public void addRequestListener(RequestListener requestListener) { - requestListeners.add(requestListener); - } - - /** - * Removes a request listener. - * - * @param requestListener - * The request listener to remove - */ - public void removeRequestListener(RequestListener requestListener) { - requestListeners.remove(requestListener); - } - - /** - * Notifies all listeners that a request was added. - * - * @param request - * The request that was added - */ - private void fireRequestAdded(Request request) { - for (RequestListener requestListener : requestListeners) { - requestListener.requestAdded(request); - } - } - - /** - * Notifies all listeners that a request progressed. - * - * @param request - * The request - */ - private void fireRequestProgressed(Request request) { - for (RequestListener requestListener : requestListeners) { - requestListener.requestProgressed(request); - } - } - - /** - * Notifies all listeners that a request was removed. - * - * @param request - * The request that was removed - */ - private void fireRequestRemoved(Request request) { - for (RequestListener requestListener : requestListeners) { - requestListener.requestRemoved(request); - } - } - - /** - * Notifies all listeners that a request has finished. - * - * @see RequestListener#requestFinished(Request) - * @param request - * The request that has finished - */ - private void fireRequestFinished(Request request) { - for (RequestListener requestListener : requestListeners) { - requestListener.requestFinished(request); - } - } - - /** - * Notifies all listeners that a request has generated a URI. - * - * @see RequestListener#requestGeneratedURI(Request, String) - * @param request - * The request that has generated a URI - * @param uri - * The generated URI - */ - private void fireRequestGeneratedURI(Request request, String uri) { - for (RequestListener requestListener : requestListeners) { - requestListener.requestGeneratedURI(request, uri); - } - } - - // - // ACCESSORS - // - - /** - * Sets the node manager to use. - * - * @param nodeManager - * The node manager - */ - public void setNodeManager(NodeManager nodeManager) { - this.nodeManager = nodeManager; - } - - // - // ACTIONS - // - - // - // PRIVATE ACTIONS - // - - /** - * Requests a list of all running requests from a node. This method will - * block until the request has been sent! - * - * @param node - * The node to get all requests for - * @throws IOException - * if an I/O error occurs while communicating with the node - * @throws JSiteException - * if there is a problem with the node - */ - private void getRequests(final Node node) throws IOException, JSiteException { - } - - // - // INTERFACE NodeListener - // - - /** - * {@inheritDoc} - */ - public void nodeAdded(Node node) { - } - - /** - * {@inheritDoc} - */ - public void nodeRemoved(Node node) { - } - - /** - * {@inheritDoc} - */ - public void nodeConnected(Node node) { - } - - /** - * {@inheritDoc} - */ - public void nodeConnectionFailed(Node node, Throwable cause) { - /* we don't care about this. */ - } - - /** - * {@inheritDoc} - */ - public void nodeDisconnected(Node node, Throwable throwable) { - Map identifierRequests = nodeRequests.get(node); - if (identifierRequests == null) { - logger.warning("got node without request map: " + node); - return; - } - for (Request request : identifierRequests.values()) { - fireRequestRemoved(request); - } - identifierRequests.clear(); - } - -} -- 2.7.4