Reformatting.
[jSite2.git] / src / net / pterodactylus / jsite / core / Core.java
1 /*
2  * jSite2 - Core.java -
3  * Copyright © 2008 David Roden
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 package net.pterodactylus.jsite.core;
21
22 import java.io.IOException;
23 import java.net.UnknownHostException;
24 import java.util.List;
25 import java.util.concurrent.Executor;
26
27 /**
28  * Interface for the core.
29  *
30  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
31  */
32 public interface Core {
33
34         /**
35          * Adds the given listener to the list of registered listeners.
36          *
37          * @param coreListener
38          *            The listener to add
39          */
40         public void addCoreListener(CoreListener coreListener);
41
42         /**
43          * Removes the given listener from the list of registered listeners.
44          *
45          * @param coreListener
46          *            The listener to remove
47          */
48         public void removeCoreListener(CoreListener coreListener);
49
50         /**
51          * Returns a thread pool.
52          *
53          * @return A thread pool
54          */
55         public Executor getThreadPool();
56
57         /**
58          * Adds the given node to the core.
59          *
60          * @param node
61          *            The node to add
62          * @return <code>true</code> if the node was added, <code>false</code> if it
63          *         was not added because it was already known
64          * @throws UnknownHostException
65          *             if the hostname of the node can not be resolved
66          */
67         public boolean addNode(Node node) throws UnknownHostException;
68
69         /**
70          * Removes the given node from the core.
71          *
72          * @param node
73          *            The node to remove
74          */
75         public void removeNode(Node node);
76
77         /**
78          * Returns the list of all configured nodes.
79          *
80          * @return All configured nodes
81          */
82         public List<Node> getNodes();
83
84         /**
85          * Returns whether the core is currently connected to the given node.
86          *
87          * @param node
88          *            The node to check
89          * @return <code>true</code> if the core is currently connected to the node,
90          *         <code>false</code> otherwise
91          */
92         public boolean isNodeConnected(Node node);
93
94         /**
95          * Starts the core.
96          */
97         public void start();
98
99         /**
100          * Stops the core.
101          */
102         public void stop();
103
104         /**
105          * Connects to the given node.
106          *
107          * @param node
108          *            The node to connect to
109          */
110         public void connectToNode(Node node);
111
112         /**
113          * Disconnects from the given node.
114          *
115          * @param node
116          *            The node to disconnect from
117          */
118         public void disconnectFromNode(Node node);
119
120         /**
121          * Creates a new project.
122          *
123          * @throws IOException
124          *             if an I/O error occured communicating with the node
125          * @throws JSiteException
126          *             if there is a problem with the node
127          */
128         public void createProject() throws IOException, JSiteException;
129
130         /**
131          * Clones the given project. {@link CoreListener}s will be notified of the
132          * new clone via the {@link CoreListener#projectCloned(Project, Project)}
133          * event.
134          *
135          * @param project
136          *            The project to clone
137          */
138         public void cloneProject(Project project);
139
140         /**
141          * Removes the given project.
142          *
143          * @param project
144          *            The project to remove
145          */
146         public void removeProject(Project project);
147
148         /**
149          * Returns a list of all projects.
150          *
151          * @return A list of all projects
152          */
153         public List<Project> getProjects();
154
155 }