/**
* The core of jSite.
- *
+ *
* @author David ‘Bombe’ Roden <bombe@freenetproject.org>
* @version $Id$
*/
-public class CoreImpl implements Core, NodeListener {
+public class CoreImpl implements Core, NodeListener, RequestListener {
/** The core listeners. */
private final List<CoreListener> coreListeners = new ArrayList<CoreListener>();
/** The node manager. */
private NodeManager nodeManager;
+ /** The request manager. */
+ /* TODO - remove */
+ @SuppressWarnings("unused")
+ private RequestManager requestManager;
+
//
// LISTENER MANAGEMENT
//
/**
* Notifies all listeners that the projects were loaded successfully.
- *
+ *
* @param directory
* The directory the projects were loaded from
*/
/**
* Notifies all core listeners that loading the projects from the given
* directory has failed.
- *
+ *
* @param directory
* The directory the projects were tried to load from
* @param throwable
/**
* Notifies all listeners that the projects were successfully saved.
- *
+ *
* @param directory
* The directory the projects were saved to
*/
/**
* Notifies all listeners that the projects could not be saved.
- *
+ *
* @param directory
* The directory the projects were to be saved to
* @param throwable
/**
* Notifies all listeners that the nodes were successfully loaded.
- *
+ *
* @param directory
* The directory the nodes were loaded from
*/
/**
* Notifies all listeners that loading the nodes has failed.
- *
+ *
* @param directory
* The directory the nodes were loaded from
* @param throwable
/**
* Notifies all listeners that the nodes were saved successfully.
- *
+ *
* @param directory
* The directory the nodes were saved to
*/
/**
* Notifies all listeners that saving the nodes has failed.
- *
+ *
* @param directory
* The directory the nodes were saved to
* @param throwable
/**
* Notifies all listeners that a connection to the given node is now being
* established.
- *
+ *
* @param node
* The node that is being connected to
*/
/**
* Notifies all listeners that the given node is now connected.
- *
+ *
* @param node
* The node that is now connected
*/
/**
* Notifies all listeners that the given node was disconnected.
- *
+ *
* @param node
* The node that is now disconnected
* @param throwable
}
}
+ /**
+ * Notifies all listeners that a request was added to a node.
+ *
+ * @param node
+ * The node the request was added to
+ * @param request
+ * The request that was added
+ */
+ private void fireRequestAdded(Node node, Request request) {
+ for (CoreListener coreListener: coreListeners) {
+ coreListener.requestAdded(node, request);
+ }
+ }
+
//
// ACCESSORS
//
/**
* Returns the project manager.
- *
+ *
* @return The project manager
*/
public ProjectManager getProjectManager() {
/**
* Sets the project manager to use.
- *
+ *
* @param projectManager
* The project manager to use
*/
/**
* Returns the node manager.
- *
+ *
* @return The node manager
*/
public NodeManager getNodeManager() {
/**
* Sets the node manager to use.
- *
+ *
* @param nodeManager
* The node manager to use
*/
}
/**
+ * Sets the request manager to use.
+ *
+ * @param requestManager
+ * The request manager to use
+ */
+ public void setRequestManager(RequestManager requestManager) {
+ this.requestManager = requestManager;
+ }
+
+ /**
* {@inheritDoc}
*/
public List<Node> getNodes() {
fireNodeDisconnected(node, throwable);
}
+ //
+ // INTERFACE RequestListener
+ //
+
+ /**
+ * {@inheritDoc}
+ */
+ public void requestAdded(Node node, Request request) {
+ fireRequestAdded(node, request);
+ }
+
}