diff options
Diffstat (limited to 'sca-java-2.x')
-rw-r--r-- | sca-java-2.x/trunk/testing/itest/nodes/two-jvm-hazelcast/src/main/java/org/apache/tuscany/sca/impl/Tuscany.java | 77 |
1 files changed, 33 insertions, 44 deletions
diff --git a/sca-java-2.x/trunk/testing/itest/nodes/two-jvm-hazelcast/src/main/java/org/apache/tuscany/sca/impl/Tuscany.java b/sca-java-2.x/trunk/testing/itest/nodes/two-jvm-hazelcast/src/main/java/org/apache/tuscany/sca/impl/Tuscany.java index 6915ca73d7..5c6ca7476e 100644 --- a/sca-java-2.x/trunk/testing/itest/nodes/two-jvm-hazelcast/src/main/java/org/apache/tuscany/sca/impl/Tuscany.java +++ b/sca-java-2.x/trunk/testing/itest/nodes/two-jvm-hazelcast/src/main/java/org/apache/tuscany/sca/impl/Tuscany.java @@ -65,38 +65,40 @@ public class Tuscany { URL nodeConfigURL = nodeDirectory.toURI().resolve("node.xml").toURL();
Node node = nodeFactory.createNode(nodeConfigURL);
- ShutdownThread shutdown = new ShutdownThread(node);
- Runtime.getRuntime().addShutdownHook(shutdown);
-
- 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);
- }
+ try {
+ node.start();
- // 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);
- }
- }
+ // 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;
+ }
+ }
- node.stop();
+ } finally {
+ node.stop();
+ }
}
/**
@@ -132,18 +134,5 @@ public class Tuscany { return false;
}
}
-
- private static class ShutdownThread extends Thread {
- private Node node;
-
- public ShutdownThread(Node node) {
- super();
- this.node = node;
- }
-
- @Override
- public void run() {
- node.stop();
- }
- }
+
}
\ No newline at end of file |