From: <pg...@us...> - 2007-05-18 05:19:29
|
Revision: 142 http://simulacion.svn.sourceforge.net/simulacion/?rev=142&view=rev Author: pguyot Date: 2007-05-17 22:19:16 -0700 (Thu, 17 May 2007) Log Message: ----------- Allow init method to throw a ServerException. Modified Paths: -------------- simulacion/src/fr/lip6/sma/simulacion/app/CLIApplication.java simulacion/src/fr/lip6/sma/simulacion/app/CLIServerApplication.java simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServer.java Modified: simulacion/src/fr/lip6/sma/simulacion/app/CLIApplication.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/app/CLIApplication.java 2007-05-17 22:38:11 UTC (rev 141) +++ simulacion/src/fr/lip6/sma/simulacion/app/CLIApplication.java 2007-05-18 05:19:16 UTC (rev 142) @@ -43,6 +43,8 @@ import sun.misc.SignalHandler; // CSON: IllegalImport +import fr.lip6.sma.simulacion.server.ServerException; + /** * Class for command line applications. * @@ -158,7 +160,12 @@ */ public final void run() { // Call the init method. - init(); + try { + init(); + } catch (ServerException anException) { + anException.printStackTrace(); + System.exit(0); + } mRunning = true; @@ -209,8 +216,10 @@ /** * Method called at the beginning of the application. * By default, it doesn't do anything. + * + * @throws ServerException if we could not create the local agent. */ - protected void init() { + protected void init() throws ServerException { // This space for rent. } Modified: simulacion/src/fr/lip6/sma/simulacion/app/CLIServerApplication.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/app/CLIServerApplication.java 2007-05-17 22:38:11 UTC (rev 141) +++ simulacion/src/fr/lip6/sma/simulacion/app/CLIServerApplication.java 2007-05-18 05:19:16 UTC (rev 142) @@ -87,8 +87,9 @@ /** * Initialize the application, creating the local agent. + * @throws ServerException if we could not create the local agent. */ - protected final void init() { + protected final void init() throws ServerException { // Create the local agent. mLocalAgent = createLocalAgent(); @@ -132,8 +133,9 @@ * Create the local agent. Subclasses must implement this method. * * @return a newly created local agent. + * @throws ServerException if we could not create the local agent. */ - protected abstract LocalAgent createLocalAgent(); + protected abstract LocalAgent createLocalAgent() throws ServerException; /** * Accessor on the configuration. Modified: simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServer.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServer.java 2007-05-17 22:38:11 UTC (rev 141) +++ simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServer.java 2007-05-18 05:19:16 UTC (rev 142) @@ -54,6 +54,7 @@ import fr.lip6.sma.simulacion.app.Configuration; import fr.lip6.sma.simulacion.server.AgentSpecification; import fr.lip6.sma.simulacion.server.NetworkAgentException; +import fr.lip6.sma.simulacion.server.ServerException; /** * Classe pour le serveur HTTP qui g\xE8re les diff\xE9rents clients. @@ -376,8 +377,10 @@ /** * Method called at the beginning of the application. * Starts the server. + * + * @throws ServerException if there is a problem during initialization. */ - protected void init() { + protected void init() throws ServerException { super.init(); mServer.start(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |