*/
private void connect(int numberOfConnections) throws NntpNotConnectedException {
//TODO check available connections
if(availableConnections.size() < 1) {
try {
NNTPConnection con = new NNTPConnection(Application.getInstance().getProperty("nntp.hostname", "localhost"),
Integer.parseInt(Application.getInstance().getProperty("nntp.port", "119")));
String username = Application.getInstance().getProperty("nntp.username");
if(!"".equals(username)) {
if(con.authinfo(username, Application.getInstance().getProperty("nntp.password"))) {
System.out.println(new Date() + ": connected");
availableConnections.push(con);
} else {
System.err.println(new Date() + ": not connected. check username/password");
throw new NntpNotConnectedException();
}
}
} catch (NumberFormatException e) {
// e.printStackTrace();
throw new NntpNotConnectedException();
} catch(UnknownHostException e) {
// e.printStackTrace();
throw new NntpNotConnectedException();
} catch (IOException e) {
// e.printStackTrace();
throw new NntpNotConnectedException();
}
}
//TODO open multiple connections
for (int i = 0; i < numberOfConnections; i++) {
if(i >= availableConnections.size()) break;
NNTPConnection con = availableConnections.pop();
//TODO connect
// con.connect();
fireConnected();
usedConnections.push(con);
}