import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
import net.pterodactylus.jsite.project.Project;
import net.pterodactylus.jsite.project.ProjectManager;
/** The core listeners. */
private final List<CoreListener> coreListeners = new ArrayList<CoreListener>();
+ /** Thread pool. */
+ private Executor threadPool = Executors.newCachedThreadPool();
+
/** The project manager. */
private ProjectManager projectManager;
* The directory the projects were loaded from
*/
private void fireLoadingProjectsDone(String directory) {
- for (CoreListener coreListener: coreListeners) {
+ for (CoreListener coreListener : coreListeners) {
coreListener.loadingProjectsDone(directory);
}
}
* The exception that occured when loading projects
*/
private void fireLoadingProjectsFailed(String directory, Throwable throwable) {
- for (CoreListener coreListener: coreListeners) {
+ for (CoreListener coreListener : coreListeners) {
coreListener.loadingProjectsFailed(directory, throwable);
}
}
* The directory the projects were saved to
*/
private void fireSavingProjectsDone(String directory) {
- for (CoreListener coreListener: coreListeners) {
+ for (CoreListener coreListener : coreListeners) {
coreListener.savingProjectsDone(directory);
}
}
* The exception that occured when saving the projects
*/
private void fireSavingProjectsFailed(String directory, Throwable throwable) {
- for (CoreListener coreListener: coreListeners) {
+ for (CoreListener coreListener : coreListeners) {
coreListener.savingProjectsFailed(directory, throwable);
}
}
* The project that was added
*/
private void fireProjectAdded(Project project) {
- for (CoreListener coreListener: coreListeners) {
+ for (CoreListener coreListener : coreListeners) {
coreListener.projectAdded(project);
}
}
-
+
/**
* Notifies all listeners that a project was cloned.
- * @param clonedProject The project that was cloned
- * @param projectClone The clone of the project
+ *
+ * @param clonedProject
+ * The project that was cloned
+ * @param projectClone
+ * The clone of the project
*/
private void fireProjectCloned(Project clonedProject, Project projectClone) {
- for (CoreListener coreListener: coreListeners) {
+ for (CoreListener coreListener : coreListeners) {
coreListener.projectCloned(clonedProject, projectClone);
}
}
* The project that was removed
*/
private void fireProjectRemoved(Project project) {
- for (CoreListener coreListener: coreListeners) {
+ for (CoreListener coreListener : coreListeners) {
coreListener.projectRemoved(project);
}
}
* The directory the nodes were loaded from
*/
private void fireLoadingNodesDone(String directory) {
- for (CoreListener coreListener: coreListeners) {
+ for (CoreListener coreListener : coreListeners) {
coreListener.loadingNodesDone(directory);
}
}
* The exception that occured while loading the nodes
*/
private void fireLoadingNodesFailed(String directory, Throwable throwable) {
- for (CoreListener coreListener: coreListeners) {
+ for (CoreListener coreListener : coreListeners) {
coreListener.loadingNodesFailed(directory, throwable);
}
}
* The directory the nodes were saved to
*/
private void fireSavingNodesDone(String directory) {
- for (CoreListener coreListener: coreListeners) {
+ for (CoreListener coreListener : coreListeners) {
coreListener.savingNodesDone(directory);
}
}
* The exception that occured while saving the nodes
*/
private void fireSavingNodesFailed(String directory, Throwable throwable) {
- for (CoreListener coreListener: coreListeners) {
+ for (CoreListener coreListener : coreListeners) {
coreListener.savingProjectsFailed(directory, throwable);
}
}
* Notifies all core listeners that the core has loaded and is ready to run.
*/
private void fireCoreLoaded() {
- for (CoreListener coreListener: coreListeners) {
+ for (CoreListener coreListener : coreListeners) {
coreListener.coreLoaded();
}
}
* Notifies all listeners that the core was stopped.
*/
private void fireCoreStopped() {
- for (CoreListener coreListener: coreListeners) {
+ for (CoreListener coreListener : coreListeners) {
coreListener.coreStopped();
}
}
* The node that was added
*/
private void fireNodeAdded(Node node) {
- for (CoreListener coreListener: coreListeners) {
+ for (CoreListener coreListener : coreListeners) {
coreListener.nodeAdded(node);
}
}
* The node that was removed
*/
private void fireNodeRemoved(Node node) {
- for (CoreListener coreListener: coreListeners) {
+ for (CoreListener coreListener : coreListeners) {
coreListener.nodeRemoved(node);
}
}
* The node that is being connected to
*/
private void fireNodeConnecting(Node node) {
- for (CoreListener coreListener: coreListeners) {
+ for (CoreListener coreListener : coreListeners) {
coreListener.nodeConnecting(node);
}
}
* The node that is now connected
*/
private void fireNodeConnected(Node node) {
- for (CoreListener coreListener: coreListeners) {
+ for (CoreListener coreListener : coreListeners) {
coreListener.nodeConnected(node);
}
}
* The cause of the failure
*/
private void fireNodeConnectionFailed(Node node, Throwable cause) {
- for (CoreListener coreListener: coreListeners) {
+ for (CoreListener coreListener : coreListeners) {
coreListener.nodeConnectionFailed(node, cause);
}
}
* if there was no exception
*/
private void fireNodeDisconnected(Node node, Throwable throwable) {
- for (CoreListener coreListener: coreListeners) {
+ for (CoreListener coreListener : coreListeners) {
coreListener.nodeDisconnected(node, throwable);
}
}
//
/**
+ * {@inheritDoc}
+ */
+ public Executor getThreadPool() {
+ return threadPool;
+ }
+
+ /**
* Returns the project manager.
*
* @return The project manager
Project projectClone = projectManager.cloneProject(project);
fireProjectCloned(project, projectClone);
}
-
+
/**
* {@inheritDoc}
*/
projectManager.removeProject(project);
fireProjectRemoved(project);
}
-
+
//
// PRIVATE METHODS
//