[vlma-devel] commit: Only use System.exit() in the main() function. (Adrien Grand )
git version control
git at videolan.org
Sat Feb 14 21:38:06 CET 2009
vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Sat Feb 14 20:51:53 2009 +0100| [2586e97ffa9dad887065429b5dbcc077e50fdf35] | committer: Adrien Grand
Only use System.exit() in the main() function.
> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=2586e97ffa9dad887065429b5dbcc077e50fdf35
---
.../main/java/org/videolan/vlma/daemon/VLMad.java | 29 +++++++++-----------
1 files changed, 13 insertions(+), 16 deletions(-)
diff --git a/vlma-daemon/src/main/java/org/videolan/vlma/daemon/VLMad.java b/vlma-daemon/src/main/java/org/videolan/vlma/daemon/VLMad.java
index e588c46..158cef2 100644
--- a/vlma-daemon/src/main/java/org/videolan/vlma/daemon/VLMad.java
+++ b/vlma-daemon/src/main/java/org/videolan/vlma/daemon/VLMad.java
@@ -63,7 +63,7 @@ public class VLMad {
System.out.println("Usage: java org.videolan.vlma.daemon.VLMad (start|reload|stop)");
}
- public void dispatch(Command command) {
+ public void dispatch(Command command) throws RemoteException {
if(command.equals(Command.start)) {
logger.debug("Starting VLMad");
logger.debug("Loading Spring application context");
@@ -73,20 +73,12 @@ public class VLMad {
Runtime.getRuntime().addShutdownHook(new ShutdownHook(daemon));
daemon.start();
} else {
- try {
- ConfigurableApplicationContext ac = new ClassPathXmlApplicationContext("client.xml");
- Data data = (Data) ac.getBean("dataImporter");
- if(command.equals(Command.stop)) {
- data.stop();
- } else if (command.equals(Command.reload)) {
- data.reload();
- }
- } catch (RemoteException e) {
- System.err.println("[ERROR] Unable to contact VLMa daemon. Is it really running?");
- System.exit(1);
- } catch (BeanCreationException e) {
- System.err.println("[ERROR] Unable to contact VLMa daemon. Is it really running?");
- System.exit(1);
+ ConfigurableApplicationContext ac = new ClassPathXmlApplicationContext("client.xml");
+ Data data = (Data) ac.getBean("dataImporter");
+ if(command.equals(Command.stop)) {
+ data.stop();
+ } else if (command.equals(Command.reload)) {
+ data.reload();
}
}
}
@@ -105,7 +97,12 @@ public class VLMad {
}
}
VLMad vlmad = new VLMad();
- vlmad.dispatch(command);
+ try {
+ vlmad.dispatch(command);
+ } catch (RemoteException e) {
+ System.err.println("[ERROR] Cannot reach VLMa daemon. Please verify that it is currently running.");
+ System.exit(1);
+ }
}
public static URL getDefaultConfigurationFile() {
More information about the vlma-devel
mailing list