"node.xml");
*/
NodeFactory nodeFactory = NodeFactory.newInstance();
URL nodeConfigURL = nodeDirectory.toURI().resolve("node.xml").toURL();
Node node = nodeFactory.createNode(nodeConfigURL);
try {
node.start();
// for testing we're going to set up a deamon that listens for
// a shutdown message on a specified port (well it actually just
// waits for a client to connect to the port as that's all we need
// for now). If no port is specified then just stop straight away
if (deamonPort >= 0){
// Its a runtime that has to act as a deamon
ServerSocket serverSocket = null;
try {
serverSocket = new ServerSocket(deamonPort);
} catch (IOException e) {
System.out.println("Can't create a ServerSocket on port: " + deamonPort);
return;
}
// all we're doing here is waiting for a connection. If we wanted to implement
// a real deamon we should perhaps listen to what's coming in over the resulting socket
// and see if a shutdown has been requested
Socket clientSocket = null;
try {
clientSocket = serverSocket.accept();
} catch (IOException e) {
System.out.println("Accept failed on port: " + deamonPort);
return;
}
}
} finally {
node.stop();
}
}