You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
(15) |
May
(55) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: <pg...@us...> - 2007-05-30 17:44:31
|
Revision: 165 http://simulacion.svn.sourceforge.net/simulacion/?rev=165&view=rev Author: pguyot Date: 2007-05-30 10:44:26 -0700 (Wed, 30 May 2007) Log Message: ----------- Update APIs. Deal with a potential problem where parameters are not copied between asynchronous calls. Modified Paths: -------------- simulacion/src/fr/lip6/sma/simulacion/server/Agent.java simulacion/src/fr/lip6/sma/simulacion/server/AgentImpl.java simulacion/src/fr/lip6/sma/simulacion/server/FacelessLocalAgentImpl.java simulacion/src/fr/lip6/sma/simulacion/server/LocalAgent.java simulacion/src/fr/lip6/sma/simulacion/server/LocalAgentImpl.java simulacion/src/fr/lip6/sma/simulacion/server/MutableParamSet.java simulacion/src/fr/lip6/sma/simulacion/server/MutableParamSetImpl.java simulacion/src/fr/lip6/sma/simulacion/server/ParamSet.java simulacion/src/fr/lip6/sma/simulacion/server/ParamSetImpl.java simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPAgent.java simulacion/src/fr/lip6/sma/simulacion/server/mdxr/MDXRAgent.java Modified: simulacion/src/fr/lip6/sma/simulacion/server/Agent.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/Agent.java 2007-05-28 09:46:09 UTC (rev 164) +++ simulacion/src/fr/lip6/sma/simulacion/server/Agent.java 2007-05-30 17:44:26 UTC (rev 165) @@ -122,7 +122,7 @@ * and asynchronously. * * @param inOperationName name of the operation to execute. - * @param inParams parameters for the operation. + * @param inParams parameters for the operation (copied). * @throws AgentException if a problem occurred during the execution of the * operation. */ Modified: simulacion/src/fr/lip6/sma/simulacion/server/AgentImpl.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/AgentImpl.java 2007-05-28 09:46:09 UTC (rev 164) +++ simulacion/src/fr/lip6/sma/simulacion/server/AgentImpl.java 2007-05-30 17:44:26 UTC (rev 165) @@ -110,7 +110,7 @@ * @throws AgentException if a problem occurred during the execution of the * operation. */ - public final void executeAsync(String inOperationName) + public void executeAsync(String inOperationName) throws AgentException { executeAsync(inOperationName, new ParamSetImpl()); } Modified: simulacion/src/fr/lip6/sma/simulacion/server/FacelessLocalAgentImpl.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/FacelessLocalAgentImpl.java 2007-05-28 09:46:09 UTC (rev 164) +++ simulacion/src/fr/lip6/sma/simulacion/server/FacelessLocalAgentImpl.java 2007-05-30 17:44:26 UTC (rev 165) @@ -72,12 +72,13 @@ */ public final void executeAsync( final String inOperationName, - final ParamSet inParams) { + ParamSet inParams) { // Execute the operation in a separated thread. + final ParamSet theParams = inParams.createImmutableCopy(); final Thread theThread = new Thread(getClass().getName()) { public void run() { try { - execute(inOperationName, inParams); + execute(inOperationName, theParams); } catch (AgentException anException) { // Just print the exception. anException.printStackTrace(); @@ -87,6 +88,14 @@ theThread.start(); } + + /** + * {@inheritDoc} + */ + @Override + public final void executeAsync(String inOperationName) { + executeAsync(inOperationName, new ParamSetImpl()); + } } // ======================================================== // Modified: simulacion/src/fr/lip6/sma/simulacion/server/LocalAgent.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/LocalAgent.java 2007-05-28 09:46:09 UTC (rev 164) +++ simulacion/src/fr/lip6/sma/simulacion/server/LocalAgent.java 2007-05-30 17:44:26 UTC (rev 165) @@ -46,6 +46,11 @@ void executeAsync(String inOperationName, ParamSet inParams); /** + * {@inheritDoc} + */ + void executeAsync(String inOperationName); + + /** * Selector on the model and the view. * * @param inModel model associated with this agent. Modified: simulacion/src/fr/lip6/sma/simulacion/server/LocalAgentImpl.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/LocalAgentImpl.java 2007-05-28 09:46:09 UTC (rev 164) +++ simulacion/src/fr/lip6/sma/simulacion/server/LocalAgentImpl.java 2007-05-30 17:44:26 UTC (rev 165) @@ -44,7 +44,7 @@ * * @see "aucun test d\xE9fini." */ -public abstract class LocalAgentImpl extends AgentImpl +public abstract class LocalAgentImpl extends FacelessLocalAgentImpl implements LocalAgentWithProperties { /** * R\xE9f\xE9rence sur la liste des agents. @@ -233,31 +233,6 @@ } /** - * Ex\xE9cute une op\xE9ration de mani\xE8re asynchrone sans retourner - * le r\xE9sultat. - * - * @param inOperationName nom de l'op\xE9ration \xE0 ex\xE9cuter. - * @param inParams param\xE8tres de l'op\xE9ration. - */ - public final void executeAsync( - final String inOperationName, - final ParamSet inParams) { - // On ex\xE9cute dans un fil s\xE9par\xE9. - final Thread theThread = new Thread(getClass().getName()) { - public void run() { - try { - execute(inOperationName, inParams); - } catch (AgentException anException) { - // On ignore. - anException.printStackTrace(); - } - } - }; - - theThread.start(); - } - - /** * Ajoute un client pour les changements des propri\xE9t\xE9s. * * @param inListener client \xE0 ajouter. Modified: simulacion/src/fr/lip6/sma/simulacion/server/MutableParamSet.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/MutableParamSet.java 2007-05-28 09:46:09 UTC (rev 164) +++ simulacion/src/fr/lip6/sma/simulacion/server/MutableParamSet.java 2007-05-30 17:44:26 UTC (rev 165) @@ -101,7 +101,7 @@ * @param inName name of the parameter. * @param inValue value of the parameter. */ - void put(String inName, Map<String, String> inValue); + void put(String inName, Map<String, ?> inValue); /** * Set a parameter as a paramset. Modified: simulacion/src/fr/lip6/sma/simulacion/server/MutableParamSetImpl.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/MutableParamSetImpl.java 2007-05-28 09:46:09 UTC (rev 164) +++ simulacion/src/fr/lip6/sma/simulacion/server/MutableParamSetImpl.java 2007-05-30 17:44:26 UTC (rev 165) @@ -116,7 +116,7 @@ /** * {@inheritDoc} */ - public void put(String inName, Map<String, String> inValue) { + public void put(String inName, Map<String, ?> inValue) { getParameters().put(inName, inValue); } Modified: simulacion/src/fr/lip6/sma/simulacion/server/ParamSet.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/ParamSet.java 2007-05-28 09:46:09 UTC (rev 164) +++ simulacion/src/fr/lip6/sma/simulacion/server/ParamSet.java 2007-05-30 17:44:26 UTC (rev 165) @@ -112,7 +112,7 @@ * @return the value of the parameter. * @throws ClassCastException if the parameter cannot be cast to a map. */ - Map<String, String> getAsMap(String inParamName); + Map<String, ?> getAsMap(String inParamName); /** * Get a parameter as an object. Modified: simulacion/src/fr/lip6/sma/simulacion/server/ParamSetImpl.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/ParamSetImpl.java 2007-05-28 09:46:09 UTC (rev 164) +++ simulacion/src/fr/lip6/sma/simulacion/server/ParamSetImpl.java 2007-05-30 17:44:26 UTC (rev 165) @@ -149,9 +149,9 @@ * {@inheritDoc} */ @SuppressWarnings("unchecked") - public final Map<String, String> getAsMap(String inParamName) { + public final Map<String, ?> getAsMap(String inParamName) { final Object theValue = mParameters.get(inParamName); - return (Map<String, String>) theValue; + return (Map<String, ?>) theValue; } /** Modified: simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPAgent.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPAgent.java 2007-05-28 09:46:09 UTC (rev 164) +++ simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPAgent.java 2007-05-30 17:44:26 UTC (rev 165) @@ -147,7 +147,7 @@ "server.executeAgentMethodAsync", mAgentSpecStr, inOperationName, - inParams.toMap()); + inParams.createImmutableCopy().toMap()); if (theResultObj instanceof Exception) { throw new NetworkAgentException((Exception) theResultObj); } Modified: simulacion/src/fr/lip6/sma/simulacion/server/mdxr/MDXRAgent.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/mdxr/MDXRAgent.java 2007-05-28 09:46:09 UTC (rev 164) +++ simulacion/src/fr/lip6/sma/simulacion/server/mdxr/MDXRAgent.java 2007-05-30 17:44:26 UTC (rev 165) @@ -159,7 +159,7 @@ */ public void executeAsync( final String inOperationName, - final ParamSet inParams) { + ParamSet inParams) { final ParamSet theParams = inParams.createImmutableCopy(); // On ex\xE9cute dans un fil s\xE9par\xE9. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2007-05-28 09:46:10
|
Revision: 164 http://simulacion.svn.sourceforge.net/simulacion/?rev=164&view=rev Author: pguyot Date: 2007-05-28 02:46:09 -0700 (Mon, 28 May 2007) Log Message: ----------- Use jetty instead of XmlRpc ServletWebServer (which isn't robust enough). Modified Paths: -------------- simulacion/.classpath simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServer.java Modified: simulacion/.classpath =================================================================== --- simulacion/.classpath 2007-05-27 15:39:24 UTC (rev 163) +++ simulacion/.classpath 2007-05-28 09:46:09 UTC (rev 164) @@ -20,6 +20,8 @@ <classpathentry kind="lib" path="lib/xmlrpc-common-3.0.jar"/> <classpathentry kind="lib" path="lib/xmlrpc-server-3.0.jar"/> <classpathentry kind="lib" path="lib/servlet-api-2.5-6.1.3.jar"/> + <classpathentry kind="lib" path="lib/jetty-6.1.3.jar"/> + <classpathentry kind="lib" path="lib/jetty-util-6.1.3.jar"/> <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> </classpath> Modified: simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServer.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServer.java 2007-05-27 15:39:24 UTC (rev 163) +++ simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServer.java 2007-05-28 09:46:09 UTC (rev 164) @@ -32,8 +32,10 @@ import javax.servlet.ServletException; -import org.apache.xmlrpc.webserver.ServletWebServer; import org.apache.xmlrpc.webserver.XmlRpcServlet; +import org.mortbay.jetty.Server; +import org.mortbay.jetty.servlet.Context; +import org.mortbay.jetty.servlet.ServletHolder; import com.kallisys.zeroconf.MDNSException; import com.kallisys.zeroconf.MulticastDNSClient; @@ -57,7 +59,7 @@ /** * Reference on the web server. */ - private final ServletWebServer mServer; + private final Server mServer; /** * Reference to the mDNS server (or <code>null</code> if we don't publish @@ -79,14 +81,18 @@ * Reference on the MDNS registration ID. */ private int mMDNSRegistrationOpID; + + /** + * Port we listen to. + */ + private final int mPort; /** * Constructor from the command line arguments. * * @param inArgs arguments on the command line. - * @throws ServletException if we could not create the server. */ - public HTTPServer(String[] inArgs) throws ServletException { + public HTTPServer(String[] inArgs) { super(HTTPServer.class.getName()); // Check that we have one or two arguments. @@ -144,7 +150,10 @@ // Create the web server. // Create a servlet. final XmlRpcServlet theServlet = new HTTPServlet(mHandler); - mServer = new ServletWebServer(theServlet, thePort); + mServer = new Server(thePort); + mPort = thePort; + final Context theRoot = new Context(mServer, "/", Context.SESSIONS); + theRoot.addServlet(new ServletHolder(theServlet), "/*"); } /** @@ -165,7 +174,7 @@ super.init(); try { mServer.start(); - } catch (IOException anException) { + } catch (Exception anException) { throw new ServerException(anException); } @@ -183,7 +192,7 @@ final NetService theService = new NetService( theServiceName, HTTPConsts.MDNS_SERVICE_TYPE, - mServer.getPort()); + mPort); registrationOpID = mMDNSServer.registerService(this, theService); } catch (IOException anException) { @@ -205,7 +214,11 @@ */ private void shutdown() { // Shutdown the server. - mServer.shutdown(); + try { + mServer.stop(); + } catch (Exception anException) { + anException.printStackTrace(); + } // and the handler. mHandler.shutdown(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2007-05-27 15:39:29
|
Revision: 163 http://simulacion.svn.sourceforge.net/simulacion/?rev=163&view=rev Author: pguyot Date: 2007-05-27 08:39:24 -0700 (Sun, 27 May 2007) Log Message: ----------- New APIs for execute. We now use a specific data structure to better control the types of the parameters. Modified Paths: -------------- simulacion/src/fr/lip6/sma/simulacion/avatar/BubblePanel.java simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java simulacion/src/fr/lip6/sma/simulacion/server/Agent.java simulacion/src/fr/lip6/sma/simulacion/server/AgentImpl.java simulacion/src/fr/lip6/sma/simulacion/server/FacelessLocalAgentImpl.java simulacion/src/fr/lip6/sma/simulacion/server/FacelessLocalLogAgentImpl.java simulacion/src/fr/lip6/sma/simulacion/server/LocalAgent.java simulacion/src/fr/lip6/sma/simulacion/server/LocalAgentImpl.java simulacion/src/fr/lip6/sma/simulacion/server/LocalLogAgentImpl.java simulacion/src/fr/lip6/sma/simulacion/server/adapter/AdapterAgent.java simulacion/src/fr/lip6/sma/simulacion/server/adapter/xmlrpc/XmlRpcAdapter.java simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPAgent.java simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java simulacion/src/fr/lip6/sma/simulacion/server/log/LogAgent.java simulacion/src/fr/lip6/sma/simulacion/server/log/Logger.java simulacion/src/fr/lip6/sma/simulacion/server/mdxr/MDXRAgent.java simulacion/src/fr/lip6/sma/simulacion/server/xmlrpc/AgentHandler.java Added Paths: ----------- simulacion/src/fr/lip6/sma/simulacion/server/MutableParamSet.java simulacion/src/fr/lip6/sma/simulacion/server/MutableParamSetImpl.java simulacion/src/fr/lip6/sma/simulacion/server/ParamSet.java simulacion/src/fr/lip6/sma/simulacion/server/ParamSetImpl.java Modified: simulacion/src/fr/lip6/sma/simulacion/avatar/BubblePanel.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/avatar/BubblePanel.java 2007-05-27 00:17:33 UTC (rev 162) +++ simulacion/src/fr/lip6/sma/simulacion/avatar/BubblePanel.java 2007-05-27 15:39:24 UTC (rev 163) @@ -41,7 +41,6 @@ import java.awt.event.KeyListener; import java.util.LinkedList; import java.util.List; -import java.util.Map; import javax.swing.JButton; import javax.swing.JComponent; @@ -52,6 +51,7 @@ import fr.lip6.sma.simulacion.app.Bundle; import fr.lip6.sma.simulacion.server.LocalAgent; +import fr.lip6.sma.simulacion.server.MutableParamSet; /** * Classe pour la bulle d'interaction avec l'assistant. @@ -115,7 +115,7 @@ /** * Param\xE8tres pass\xE9s \xE0 l'agent lorsque le bouton est valid\xE9. */ - private Map<String, Object> mReplyParams; + private MutableParamSet mReplyParams; /** * Liste des actions \xE0 effectuer. @@ -305,15 +305,12 @@ * @param inParams param\xE8tres \xE0 passer \xE0 l'agent. */ public void askQuestion( - String inQuestion, - String inReplyMethod, - Map<String, Object> inParams) { - final String theQuestion = inQuestion; - final String theReplyMethod = inReplyMethod; - final Map<String, Object> theParams = inParams; + final String inQuestion, + final String inReplyMethod, + final MutableParamSet inParams) { final Runnable theEffectCode = new Runnable() { public void run() { - doAskQuestion(theQuestion, theReplyMethod, theParams); + doAskQuestion(inQuestion, inReplyMethod, inParams); } }; @@ -342,7 +339,7 @@ private void doAskQuestion( String inQuestion, String inReplyMethod, - Map<String, Object> inParams) { + MutableParamSet inParams) { mAssistantMessage.setText(inQuestion); mPlayerMessage.setText(""); mReplyMethod = inReplyMethod; Modified: simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java 2007-05-27 00:17:33 UTC (rev 162) +++ simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java 2007-05-27 15:39:24 UTC (rev 163) @@ -122,7 +122,7 @@ * {@inheritDoc} */ public void addWindowListener(WindowListener inWindowListener) { - // TODO: implement a window listener. + // TODO: implement a window listener. } /** @@ -143,7 +143,7 @@ * {@inheritDoc} */ public void setDefaultCloseOperation(int inOperation) { - // TODO: implement close operation stuff. + // TODO: implement close operation stuff. } /** Modified: simulacion/src/fr/lip6/sma/simulacion/server/Agent.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/Agent.java 2007-05-27 00:17:33 UTC (rev 162) +++ simulacion/src/fr/lip6/sma/simulacion/server/Agent.java 2007-05-27 15:39:24 UTC (rev 163) @@ -28,7 +28,6 @@ package fr.lip6.sma.simulacion.server; // import -import java.util.Map; /** * Interface pour un agent (local ou sur le r\xE9seau). @@ -115,7 +114,7 @@ * @throws AgentException if a problem occurred during the execution of the * operation. */ - String execute(String inOperationName, Map<String, Object> inParams) + String execute(String inOperationName, ParamSet inParams) throws AgentException; /** @@ -127,7 +126,7 @@ * @throws AgentException if a problem occurred during the execution of the * operation. */ - void executeAsync(String inOperationName, Map<String, Object> inParams) + void executeAsync(String inOperationName, ParamSet inParams) throws AgentException; /** @@ -151,38 +150,6 @@ * operation. */ void executeAsync(String inOperationName) throws AgentException; - - /** - * Execute an operation (locally or through the network). - * Utility method to execute operations without a single parameter. - * - * @param inOperationName name of the operation to execute. - * @param inParamName name of the parameter. - * @param inParamValue value of the parameter. - * @return the result of the operation (as a string). - * @throws AgentException if a problem occurred during the execution of the - * operation. - */ - String execute( - String inOperationName, - String inParamName, - Object inParamValue) throws AgentException; - - /** - * Execute an operation (locally or through the network), without any result - * and asynchronously. - * Utility method to execute operations without any parameter. - * - * @param inOperationName name of the operation to execute. - * @param inParamName name of the parameter. - * @param inParamValue value of the parameter. - * @throws AgentException if a problem occurred during the execution of the - * operation. - */ - void executeAsync( - String inOperationName, - String inParamName, - Object inParamValue) throws AgentException; } // ====================================================== // Modified: simulacion/src/fr/lip6/sma/simulacion/server/AgentImpl.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/AgentImpl.java 2007-05-27 00:17:33 UTC (rev 162) +++ simulacion/src/fr/lip6/sma/simulacion/server/AgentImpl.java 2007-05-27 15:39:24 UTC (rev 163) @@ -27,8 +27,6 @@ // paquet package fr.lip6.sma.simulacion.server; -import java.util.Hashtable; -import java.util.Map; /** * Classe abstraite pour des agents, met en place le minimum pour d\xE9finir @@ -100,8 +98,7 @@ * operation. */ public final String execute(String inOperationName) throws AgentException { - final Map<String, Object> theParams = new Hashtable<String, Object>(); - return execute(inOperationName, theParams); + return execute(inOperationName, new ParamSetImpl()); } /** @@ -115,49 +112,8 @@ */ public final void executeAsync(String inOperationName) throws AgentException { - final Map<String, Object> theParams = new Hashtable<String, Object>(); - executeAsync(inOperationName, theParams); + executeAsync(inOperationName, new ParamSetImpl()); } - - /** - * Execute an operation (locally or through the network). - * Utility method to execute operations without a single parameter. - * - * @param inOperationName name of the operation to execute. - * @param inParamName name of the parameter. - * @param inParamValue value of the parameter. - * @return the result of the operation (as a string). - * @throws AgentException if a problem occurred during the execution of the - * operation. - */ - public final String execute( - String inOperationName, - String inParamName, - Object inParamValue) throws AgentException { - final Map<String, Object> theParams = new Hashtable<String, Object>(); - theParams.put(inParamName, inParamValue); - return execute(inOperationName, theParams); - } - - /** - * Execute an operation (locally or through the network), without any result - * and asynchronously. - * Utility method to execute operations without any parameter. - * - * @param inOperationName name of the operation to execute. - * @param inParamName name of the parameter. - * @param inParamValue value of the parameter. - * @throws AgentException if a problem occurred during the execution of the - * operation. - */ - public final void executeAsync( - String inOperationName, - String inParamName, - Object inParamValue) throws AgentException { - final Map<String, Object> theParams = new Hashtable<String, Object>(); - theParams.put(inParamName, inParamValue); - executeAsync(inOperationName, theParams); - } } // =================================================================== // Modified: simulacion/src/fr/lip6/sma/simulacion/server/FacelessLocalAgentImpl.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/FacelessLocalAgentImpl.java 2007-05-27 00:17:33 UTC (rev 162) +++ simulacion/src/fr/lip6/sma/simulacion/server/FacelessLocalAgentImpl.java 2007-05-27 15:39:24 UTC (rev 163) @@ -28,8 +28,6 @@ package fr.lip6.sma.simulacion.server; // imports -import java.util.Map; - import fr.lip6.sma.simulacion.app.Model; import fr.lip6.sma.simulacion.app.View; @@ -74,7 +72,7 @@ */ public final void executeAsync( final String inOperationName, - final Map<String, Object> inParams) { + final ParamSet inParams) { // Execute the operation in a separated thread. final Thread theThread = new Thread(getClass().getName()) { public void run() { Modified: simulacion/src/fr/lip6/sma/simulacion/server/FacelessLocalLogAgentImpl.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/FacelessLocalLogAgentImpl.java 2007-05-27 00:17:33 UTC (rev 162) +++ simulacion/src/fr/lip6/sma/simulacion/server/FacelessLocalLogAgentImpl.java 2007-05-27 15:39:24 UTC (rev 163) @@ -28,8 +28,6 @@ package fr.lip6.sma.simulacion.server; // imports -import java.util.Map; - import fr.lip6.sma.simulacion.server.log.Logger; /** @@ -68,7 +66,7 @@ */ public final synchronized String execute( String inOperationName, - Map<String, Object> inParams) + ParamSet inParams) throws AgentException { String theResult; @@ -92,7 +90,7 @@ */ protected String doExecute( String inOperationName, - Map<String, Object> inParams) + ParamSet inParams) throws AgentException { String theResult; Modified: simulacion/src/fr/lip6/sma/simulacion/server/LocalAgent.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/LocalAgent.java 2007-05-27 00:17:33 UTC (rev 162) +++ simulacion/src/fr/lip6/sma/simulacion/server/LocalAgent.java 2007-05-27 15:39:24 UTC (rev 163) @@ -28,8 +28,6 @@ package fr.lip6.sma.simulacion.server; // import -import java.util.Map; - import fr.lip6.sma.simulacion.app.Model; import fr.lip6.sma.simulacion.app.View; @@ -45,7 +43,7 @@ /** * {@inheritDoc} */ - void executeAsync(String inOperationName, Map<String, Object> inParams); + void executeAsync(String inOperationName, ParamSet inParams); /** * Selector on the model and the view. Modified: simulacion/src/fr/lip6/sma/simulacion/server/LocalAgentImpl.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/LocalAgentImpl.java 2007-05-27 00:17:33 UTC (rev 162) +++ simulacion/src/fr/lip6/sma/simulacion/server/LocalAgentImpl.java 2007-05-27 15:39:24 UTC (rev 163) @@ -30,9 +30,6 @@ // import import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; -import java.util.Arrays; -import java.util.Hashtable; -import java.util.List; import java.util.Map; import fr.lip6.sma.simulacion.app.Model; @@ -221,7 +218,7 @@ */ public synchronized String execute( String inOperationName, - Map<String, Object> inParams) + ParamSet inParams) throws AgentException { String theResult; @@ -244,15 +241,12 @@ */ public final void executeAsync( final String inOperationName, - final Map<String, Object> inParams) { - final Map<String, Object> theParams = - new Hashtable<String, Object>(inParams); - + final ParamSet inParams) { // On ex\xE9cute dans un fil s\xE9par\xE9. final Thread theThread = new Thread(getClass().getName()) { public void run() { try { - execute(inOperationName, theParams); + execute(inOperationName, inParams); } catch (AgentException anException) { // On ignore. anException.printStackTrace(); @@ -308,33 +302,6 @@ mPropertyChangeSupport.removePropertyChangeListener( inPropertyName, inListener); } - - /** - * Transform a parameter into a list. - * - * @param inParamName name of the parameter. - * @param inParams parameters maps. - * @return the value of the parameter as a list. - * @throws ClassCastException if the parameter cannot be cast into - * a list. - */ - protected static final List getParamAsList( - Map<String, Object> inParams, String inParamName) { - List theResult = null; - final Object theParam = inParams.get(inParamName); - if (theParam != null) { - if (theParam instanceof List) { - theResult = (List) theParam; - } else if (theParam instanceof Object[]) { - theResult = Arrays.asList((Object[]) theParam); - } else { - throw new ClassCastException("Parameter " + inParamName - + " cannot be cast into a list."); - } - } - - return theResult; - } } // ========================================================================= // Modified: simulacion/src/fr/lip6/sma/simulacion/server/LocalLogAgentImpl.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/LocalLogAgentImpl.java 2007-05-27 00:17:33 UTC (rev 162) +++ simulacion/src/fr/lip6/sma/simulacion/server/LocalLogAgentImpl.java 2007-05-27 15:39:24 UTC (rev 163) @@ -75,7 +75,7 @@ */ public final synchronized String execute( String inOperationName, - Map<String, Object> inParams) + ParamSet inParams) throws AgentException { String theResult; @@ -99,7 +99,7 @@ */ protected String doExecute( String inOperationName, - Map<String, Object> inParams) + ParamSet inParams) throws AgentException { String theResult; Added: simulacion/src/fr/lip6/sma/simulacion/server/MutableParamSet.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/MutableParamSet.java (rev 0) +++ simulacion/src/fr/lip6/sma/simulacion/server/MutableParamSet.java 2007-05-27 15:39:24 UTC (rev 163) @@ -0,0 +1,133 @@ +// ============================== +// File: MutableParamSet.java +// Project: Simulaci\xF3n +// Written by: Paul Guyot (pau...@ac...) +// +// Created on: 4/5/2003 +// Tabs: 4 spaces +// +// This software is governed by the CeCILL license under French law and abiding +// by the rules of distribution of free software. You can use, modify and/ or +// redistribute the software under the terms of the CeCILL license as +// circulated by CEA, CNRS and INRIA at the following URL +// "http://www.cecill.info". +// +// As a counterpart to the access to the source code and rights to copy, modify +// and redistribute granted by the license, users are provided only with a +// limited warranty and the software's author, the holder of the economic +// rights, and the successive licensors have only limited liability. +// +// The fact that you are presently reading this means that you have had +// knowledge of the CeCILL license and that you accept its terms. +// +// =========== +// $Id$ +// =========== + +// paquet +package fr.lip6.sma.simulacion.server; + +// import +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * Interface for a set of parameters. + * + * @author Paul Guyot <pau...@ac...> + * @version $Revision$ + */ +public interface MutableParamSet extends ParamSet { + /** + * Set a parameter as an agent specification. + * + * @param inName name of the parameter. + * @param inValue value of the parameter. + */ + void put(String inName, AgentSpecification inValue); + + /** + * Set a parameter as a boolean. + * + * @param inName name of the parameter. + * @param inValue value of the parameter. + */ + void put(String inName, boolean inValue); + + /** + * Set a parameter as an array of bytes. + * + * @param inName name of the parameter. + * @param inValue value of the parameter. + */ + void put(String inName, byte[] inValue); + + /** + * Set a parameter as a date. + * + * @param inName name of the parameter. + * @param inValue value of the parameter. + */ + void put(String inName, Date inValue); + + /** + * Set a parameter as a double. + * + * @param inName name of the parameter. + * @param inValue value of the parameter. + */ + void put(String inName, double inValue); + + /** + * Set a parameter as an integer. + * + * @param inName name of the parameter. + * @param inValue value of the parameter. + */ + void put(String inName, int inValue); + + /** + * Set a parameter as a list. + * + * @param inName name of the parameter. + * @param inValue value of the parameter. + */ + void put(String inName, List<String> inValue); + + /** + * Set a parameter as a map. + * + * @param inName name of the parameter. + * @param inValue value of the parameter. + */ + void put(String inName, Map<String, String> inValue); + + /** + * Set a parameter as a paramset. + * + * @param inName name of the parameter. + * @param inValue value of the parameter. + */ + void put(String inName, ParamSet inValue); + + /** + * Set a parameter as a string. + * + * @param inName name of the parameter. + * @param inValue value of the parameter. + */ + void put(String inName, String inValue); + + /** + * Remove a parameter. + * + * @param inName name of the parameter. + */ + void remove(String inName); +} + +// ============================================================= // +// Testing can show the presense of bugs, but not their absence. // +// -- Dijkstra // +// ============================================================= // Property changes on: simulacion/src/fr/lip6/sma/simulacion/server/MutableParamSet.java ___________________________________________________________________ Name: svn:executable + * Name: svn:keywords + Revision Id Added: simulacion/src/fr/lip6/sma/simulacion/server/MutableParamSetImpl.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/MutableParamSetImpl.java (rev 0) +++ simulacion/src/fr/lip6/sma/simulacion/server/MutableParamSetImpl.java 2007-05-27 15:39:24 UTC (rev 163) @@ -0,0 +1,147 @@ +// ============================== +// File: ParamSetImpl.java +// Project: Simulaci\xF3n +// Written by: Paul Guyot (pau...@ac...) +// +// Created on: 4/5/2003 +// Tabs: 4 spaces +// +// This software is governed by the CeCILL license under French law and abiding +// by the rules of distribution of free software. You can use, modify and/ or +// redistribute the software under the terms of the CeCILL license as +// circulated by CEA, CNRS and INRIA at the following URL +// "http://www.cecill.info". +// +// As a counterpart to the access to the source code and rights to copy, modify +// and redistribute granted by the license, users are provided only with a +// limited warranty and the software's author, the holder of the economic +// rights, and the successive licensors have only limited liability. +// +// The fact that you are presently reading this means that you have had +// knowledge of the CeCILL license and that you accept its terms. +// +// =========== +// $Id$ +// =========== + +// paquet +package fr.lip6.sma.simulacion.server; + +// import +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * Implementation for a set of parameters. + * + * @author Paul Guyot <pau...@ac...> + * @version $Revision$ + */ +public final class MutableParamSetImpl + extends ParamSetImpl + implements MutableParamSet { + /** + * Default constructor. + */ + public MutableParamSetImpl() { + // This space for rent. + } + + /** + * Constructor from a dictionary. + * + * @param inParameters Map with the params. It is not copied. + */ + MutableParamSetImpl(Map<String, Object> inParameters) { + super(inParameters); + } + + /** + * {@inheritDoc} + */ + public ParamSet createImmutableCopy() { + return new ParamSetImpl(getParameters()); + } + + /** + * {@inheritDoc} + */ + public void put(String inName, AgentSpecification inValue) { + getParameters().put(inName, inValue.toString()); + } + + /** + * {@inheritDoc} + */ + public void put(String inName, boolean inValue) { + getParameters().put(inName, Boolean.valueOf(inValue)); + } + + /** + * {@inheritDoc} + */ + public void put(String inName, byte[] inValue) { + getParameters().put(inName, inValue); + } + + /** + * {@inheritDoc} + */ + public void put(String inName, Date inValue) { + getParameters().put(inName, inValue); + } + + /** + * {@inheritDoc} + */ + public void put(String inName, double inValue) { + getParameters().put(inName, new Double(inValue)); + } + + /** + * {@inheritDoc} + */ + public void put(String inName, int inValue) { + getParameters().put(inName, new Integer(inValue)); + } + + /** + * {@inheritDoc} + */ + public void put(String inName, List<String> inValue) { + getParameters().put(inName, inValue); + } + + /** + * {@inheritDoc} + */ + public void put(String inName, Map<String, String> inValue) { + getParameters().put(inName, inValue); + } + + /** + * {@inheritDoc} + */ + public void put(String inName, ParamSet inValue) { + getParameters().put(inName, inValue.toMap()); + } + + /** + * {@inheritDoc} + */ + public void put(String inName, String inValue) { + getParameters().put(inName, inValue); + } + + /** + * {@inheritDoc} + */ + public void remove(String inName) { + getParameters().remove(inName); + } +} + +// =================================== // +// Your password is pitifully obvious. // +// =================================== // Property changes on: simulacion/src/fr/lip6/sma/simulacion/server/MutableParamSetImpl.java ___________________________________________________________________ Name: svn:executable + * Name: svn:keywords + Revision Id Added: simulacion/src/fr/lip6/sma/simulacion/server/ParamSet.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/ParamSet.java (rev 0) +++ simulacion/src/fr/lip6/sma/simulacion/server/ParamSet.java 2007-05-27 15:39:24 UTC (rev 163) @@ -0,0 +1,175 @@ +// ============================== +// File: ParamSet.java +// Project: Simulaci\xF3n +// Written by: Paul Guyot (pau...@ac...) +// +// Created on: 4/5/2003 +// Tabs: 4 spaces +// +// This software is governed by the CeCILL license under French law and abiding +// by the rules of distribution of free software. You can use, modify and/ or +// redistribute the software under the terms of the CeCILL license as +// circulated by CEA, CNRS and INRIA at the following URL +// "http://www.cecill.info". +// +// As a counterpart to the access to the source code and rights to copy, modify +// and redistribute granted by the license, users are provided only with a +// limited warranty and the software's author, the holder of the economic +// rights, and the successive licensors have only limited liability. +// +// The fact that you are presently reading this means that you have had +// knowledge of the CeCILL license and that you accept its terms. +// +// =========== +// $Id$ +// =========== + +// paquet +package fr.lip6.sma.simulacion.server; + +// import +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * Interface for a set of parameters. + * + * @author Paul Guyot <pau...@ac...> + * @version $Revision$ + */ +public interface ParamSet { + /** + * Get a parameter as an agent specification. + * + * @param inParamName name of the parameter. + * @return the value of the parameter. + * @throws ClassCastException if the parameter cannot be cast to a boolean. + */ + AgentSpecification getAsAgentSpec(String inParamName); + + /** + * Get a parameter as a boolean. + * + * @param inParamName name of the parameter. + * @return the value of the parameter. + * @throws ClassCastException if the parameter cannot be cast to a boolean. + */ + Boolean getAsBoolean(String inParamName); + + /** + * Get a parameter as an array of bytes. + * + * @param inParamName name of the parameter. + * @return the value of the parameter. + * @throws ClassCastException if the parameter cannot be cast to an array + * of bytes. + */ + byte[] getAsData(String inParamName); + + /** + * Get a parameter as a date. + * + * @param inParamName name of the parameter. + * @return the value of the parameter. + * @throws ClassCastException if the parameter cannot be cast to a date. + */ + Date getAsDate(String inParamName); + + /** + * Get a parameter as a double. + * + * @param inParamName name of the parameter. + * @return the value of the parameter. + * @throws ClassCastException if the parameter cannot be cast to a double. + */ + Double getAsDouble(String inParamName); + + /** + * Get a parameter as an integer. + * + * @param inParamName name of the parameter. + * @return the value of the parameter. + * @throws ClassCastException if the parameter cannot be cast to an + * integer. + */ + Integer getAsInteger(String inParamName); + + /** + * Get a parameter as a list. + * + * @param inParamName name of the parameter. + * @return the value of the parameter. + * @throws ClassCastException if the parameter cannot be cast to a list. + */ + List<String> getAsList(String inParamName); + + /** + * Get a parameter as a map. + * + * @param inParamName name of the parameter. + * @return the value of the parameter. + * @throws ClassCastException if the parameter cannot be cast to a map. + */ + Map<String, String> getAsMap(String inParamName); + + /** + * Get a parameter as an object. + * + * @param inParamName name of the parameter. + * @return the value of the parameter. + */ + Object getAsObject(String inParamName); + + /** + * Get a parameter as a paramset. + * + * @param inParamName name of the parameter. + * @return the value of the parameter. + * @throws ClassCastException if the parameter cannot be cast to a paramset. + */ + ParamSet getAsParamSet(String inParamName); + + /** + * Get a parameter as a string. + * + * @param inParamName name of the parameter. + * @return the value of the parameter. + * @throws ClassCastException if the parameter cannot be cast to a string. + */ + String getAsString(String inParamName); + + /** + * Get the set of parameter names. + * + * @return the set of parameter names. + */ + Set<String> getParameterNames(); + + /** + * Clone the current set, unless it is not mutable. + * + * @return a copy of the current set. + */ + ParamSet createImmutableCopy(); + + /** + * Clone the current set, and return a mutable copy. + * + * @return a copy of the current set. + */ + MutableParamSet createMutableCopy(); + + /** + * Return the representation of the set as a (read-only) map. + * + * @return a representation of the set. + */ + Map<String, Object> toMap(); +} + +// ============================================================= // +// Testing can show the presense of bugs, but not their absence. // +// -- Dijkstra // +// ============================================================= // Property changes on: simulacion/src/fr/lip6/sma/simulacion/server/ParamSet.java ___________________________________________________________________ Name: svn:executable + * Name: svn:keywords + Revision Id Added: simulacion/src/fr/lip6/sma/simulacion/server/ParamSetImpl.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/ParamSetImpl.java (rev 0) +++ simulacion/src/fr/lip6/sma/simulacion/server/ParamSetImpl.java 2007-05-27 15:39:24 UTC (rev 163) @@ -0,0 +1,214 @@ +// ============================== +// File: ParamSetImpl.java +// Project: Simulaci\xF3n +// Written by: Paul Guyot (pau...@ac...) +// +// Created on: 4/5/2003 +// Tabs: 4 spaces +// +// This software is governed by the CeCILL license under French law and abiding +// by the rules of distribution of free software. You can use, modify and/ or +// redistribute the software under the terms of the CeCILL license as +// circulated by CEA, CNRS and INRIA at the following URL +// "http://www.cecill.info". +// +// As a counterpart to the access to the source code and rights to copy, modify +// and redistribute granted by the license, users are provided only with a +// limited warranty and the software's author, the holder of the economic +// rights, and the successive licensors have only limited liability. +// +// The fact that you are presently reading this means that you have had +// knowledge of the CeCILL license and that you accept its terms. +// +// =========== +// $Id$ +// =========== + +// paquet +package fr.lip6.sma.simulacion.server; + +// import +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * Implementation for a set of parameters. + * + * @author Paul Guyot <pau...@ac...> + * @version $Revision$ + */ +public class ParamSetImpl implements ParamSet { + /** + * Dictionary with the parameters. + */ + private final Map<String, Object> mParameters; + + /** + * Default constructor. + */ + public ParamSetImpl() { + mParameters = new HashMap<String, Object>(); + } + + /** + * Constructor from a dictionary. + * + * @param inParameters Map with the params. It is not copied. + */ + public ParamSetImpl(Map<String, Object> inParameters) { + mParameters = inParameters; + } + + /** + * Accessor on the map. + * + * @return the map. + */ + protected Map<String, Object> getParameters() { + return mParameters; + } + + /** + * {@inheritDoc} + */ + public final AgentSpecification getAsAgentSpec(String inParamName) { + final Object theValue = mParameters.get(inParamName); + return AgentSpecification.fromString((String) theValue); + } + + /** + * {@inheritDoc} + */ + public final Boolean getAsBoolean(String inParamName) { + final Object theValue = mParameters.get(inParamName); + return (Boolean) theValue; + } + + /** + * {@inheritDoc} + */ + public final byte[] getAsData(String inParamName) { + final Object theValue = mParameters.get(inParamName); + return (byte[]) theValue; + } + + /** + * {@inheritDoc} + */ + public final Date getAsDate(String inParamName) { + final Object theValue = mParameters.get(inParamName); + return (Date) theValue; + } + + /** + * {@inheritDoc} + */ + public final Double getAsDouble(String inParamName) { + final Object theValue = mParameters.get(inParamName); + return (Double) theValue; + } + + /** + * {@inheritDoc} + */ + public final Integer getAsInteger(String inParamName) { + final Object theValue = mParameters.get(inParamName); + return (Integer) theValue; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public final List<String> getAsList(String inParamName) { + final Object theValue = mParameters.get(inParamName); + List<String> theResult = null; + if (theValue != null) { + if (theValue instanceof List) { + theResult = (List<String>) theValue; + } else if (theValue instanceof Object[]) { + // In fact, here, we're casting from List<Object> to + // List<String>. This works with the current JVM implementation. + final List theResultList = Arrays.asList((Object[]) theValue); + theResult = theResultList; + } else { + throw new ClassCastException("Parameter " + inParamName + + " cannot be cast into a list."); + } + } + + return theResult; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public final Map<String, String> getAsMap(String inParamName) { + final Object theValue = mParameters.get(inParamName); + return (Map<String, String>) theValue; + } + + /** + * {@inheritDoc} + */ + public final Object getAsObject(String inParamName) { + return mParameters.get(inParamName); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public final ParamSet getAsParamSet(String inParamName) { + final Object theValue = mParameters.get(inParamName); + return new ParamSetImpl((Map<String, Object>) theValue); + } + + /** + * {@inheritDoc} + */ + public final String getAsString(String inParamName) { + final Object theValue = mParameters.get(inParamName); + return (String) theValue; + } + + /** + * {@inheritDoc} + */ + public final Set<String> getParameterNames() { + return mParameters.keySet(); + } + + /** + * {@inheritDoc} + */ + public ParamSet createImmutableCopy() { + return this; + } + + /** + * {@inheritDoc} + */ + public final MutableParamSet createMutableCopy() { + return new MutableParamSetImpl( + new HashMap<String, Object>(mParameters)); + } + + /** + * {@inheritDoc} + */ + public final Map<String, Object> toMap() { + return Collections.unmodifiableMap(mParameters); + } +} + +// ============================================================= // +// Testing can show the presense of bugs, but not their absence. // +// -- Dijkstra // +// ============================================================= // Property changes on: simulacion/src/fr/lip6/sma/simulacion/server/ParamSetImpl.java ___________________________________________________________________ Name: svn:executable + * Name: svn:keywords + Revision Id Modified: simulacion/src/fr/lip6/sma/simulacion/server/adapter/AdapterAgent.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/adapter/AdapterAgent.java 2007-05-27 00:17:33 UTC (rev 162) +++ simulacion/src/fr/lip6/sma/simulacion/server/adapter/AdapterAgent.java 2007-05-27 15:39:24 UTC (rev 163) @@ -28,10 +28,9 @@ package fr.lip6.sma.simulacion.server.adapter; // imports -import java.util.Map; - import fr.lip6.sma.simulacion.server.AgentException; import fr.lip6.sma.simulacion.server.FacelessLocalAgentImpl; +import fr.lip6.sma.simulacion.server.ParamSet; /** * Classe de base pour un agent accessible via l'adaptateur. @@ -97,9 +96,9 @@ */ public String execute( final String inOperationName, - final Map<String, Object> inParams) throws AgentException { - return mAdapter - .executeAgentMethod(mClass, mName, inOperationName, inParams); + final ParamSet inParams) throws AgentException { + return mAdapter.executeAgentMethod( + mClass, mName, inOperationName, inParams.toMap()); } } Modified: simulacion/src/fr/lip6/sma/simulacion/server/adapter/xmlrpc/XmlRpcAdapter.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/adapter/xmlrpc/XmlRpcAdapter.java 2007-05-27 00:17:33 UTC (rev 162) +++ simulacion/src/fr/lip6/sma/simulacion/server/adapter/xmlrpc/XmlRpcAdapter.java 2007-05-27 15:39:24 UTC (rev 163) @@ -54,6 +54,7 @@ import fr.lip6.sma.simulacion.server.AgentSpecification; import fr.lip6.sma.simulacion.server.LocalAgent; import fr.lip6.sma.simulacion.server.NetworkAgentException; +import fr.lip6.sma.simulacion.server.ParamSetImpl; import fr.lip6.sma.simulacion.server.adapter.Adapter; import fr.lip6.sma.simulacion.server.adapter.AdapterAgent; import fr.lip6.sma.simulacion.server.xmlrpc.SimpleHandlerMapping; @@ -282,7 +283,8 @@ new NullPointerException("No such agent"))); } try { - theResult = theAgent.execute(theMethod, theParams); + theResult = + theAgent.execute(theMethod, new ParamSetImpl(theParams)); } catch (AgentException anException) { throw new XmlRpcException(anException.toString(), anException); } Modified: simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPAgent.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPAgent.java 2007-05-27 00:17:33 UTC (rev 162) +++ simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPAgent.java 2007-05-27 15:39:24 UTC (rev 163) @@ -28,8 +28,6 @@ package fr.lip6.sma.simulacion.server.http; // imports -import java.util.Map; - import org.apache.xmlrpc.XmlRpcException; import fr.lip6.sma.simulacion.server.AgentException; @@ -37,6 +35,7 @@ import fr.lip6.sma.simulacion.server.AgentSpecification; import fr.lip6.sma.simulacion.server.NetworkAgent; import fr.lip6.sma.simulacion.server.NetworkAgentException; +import fr.lip6.sma.simulacion.server.ParamSet; /** * Classe pour un agent accessible via un serveur HTTP. @@ -109,7 +108,7 @@ */ public final synchronized String execute( String inOperationName, - Map<String, Object> inParams) + ParamSet inParams) throws AgentException { String theResult = null; @@ -119,7 +118,7 @@ "server.executeAgentMethod", mAgentSpecStr, inOperationName, - inParams); + inParams.toMap()); if (theResultObj instanceof Exception) { throw new NetworkAgentException((Exception) theResultObj); } @@ -141,14 +140,14 @@ */ public void executeAsync( final String inOperationName, - final Map<String, Object> inParams) throws AgentException { + final ParamSet inParams) throws AgentException { try { final Object theResultObj = mClient.execute( "server.executeAgentMethodAsync", mAgentSpecStr, inOperationName, - inParams); + inParams.toMap()); if (theResultObj instanceof Exception) { throw new NetworkAgentException((Exception) theResultObj); } Modified: simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java 2007-05-27 00:17:33 UTC (rev 162) +++ simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java 2007-05-27 15:39:24 UTC (rev 163) @@ -50,6 +50,7 @@ import fr.lip6.sma.simulacion.server.AgentListManager; import fr.lip6.sma.simulacion.server.AgentSpecification; import fr.lip6.sma.simulacion.server.LocalAgent; +import fr.lip6.sma.simulacion.server.ParamSetImpl; import fr.lip6.sma.simulacion.server.Server; /** @@ -352,7 +353,8 @@ final String theResult = theLocalAgent.execute( (String) inEvent.get("method"), - (Map<String, Object>) inEvent.get("params")); + new ParamSetImpl( + (Map<String, Object>) inEvent.get("params"))); // On renvoie le r\xE9sultat au serveur. try { @@ -378,7 +380,7 @@ .getLocalAgentWaitingIfRequired(theAgentSpec); theLocalAgent.executeAsync( (String) inEvent.get("method"), - (Map<String, Object>) inEvent.get("params")); + new ParamSetImpl((Map<String, Object>) inEvent.get("params"))); } else { System.err.println("Unknown event : " + theEventName); } Modified: simulacion/src/fr/lip6/sma/simulacion/server/log/LogAgent.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/log/LogAgent.java 2007-05-27 00:17:33 UTC (rev 162) +++ simulacion/src/fr/lip6/sma/simulacion/server/log/LogAgent.java 2007-05-27 15:39:24 UTC (rev 163) @@ -33,12 +33,14 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; -import java.util.Hashtable; -import java.util.Map; +import java.util.Set; import fr.lip6.sma.simulacion.server.Agent; import fr.lip6.sma.simulacion.server.AgentException; import fr.lip6.sma.simulacion.server.FacelessLocalAgentImpl; +import fr.lip6.sma.simulacion.server.MutableParamSet; +import fr.lip6.sma.simulacion.server.MutableParamSetImpl; +import fr.lip6.sma.simulacion.server.ParamSet; /** * Classe pour un agent qui note, en XML et dans un flux, tout ce qui se passe. @@ -202,9 +204,8 @@ System.exit(1); } - final Map<String, Object> theParams = - new Hashtable<String, Object>(); - theParams.put(PARAM_AGENT, getAgentSpecification().toString()); + final MutableParamSet theParams = new MutableParamSetImpl(); + theParams.put(PARAM_AGENT, getAgentSpecification()); try { inAgent.executeAsync(OP_REGISTER_LOG_AGENT, theParams); } catch (AgentException anException) { @@ -223,9 +224,8 @@ public final void unregisterAgent(Agent inAgent, boolean inTellAgent) { if (!inAgent.getAgentClass().equals(getAgentClass())) { if (inTellAgent) { - final Map<String, Object> theParams = - new Hashtable<String, Object>(); - theParams.put(PARAM_AGENT, getAgentSpecification().toString()); + final MutableParamSet theParams = new MutableParamSetImpl(); + theParams.put(PARAM_AGENT, getAgentSpecification()); try { inAgent.executeAsync(OP_UNREGISTER_LOG_AGENT, theParams); } catch (AgentException anException) { @@ -275,30 +275,35 @@ @SuppressWarnings("unchecked") public final synchronized String execute( String inOperationName, - Map<String, Object> inParams) + ParamSet inParams) throws AgentException { try { if (inOperationName.equals(OP_LOG)) { synchronized (mOutputStreamWriter) { final String theStartTag = "\t<operation name=\"" - + inParams.get(PARAM_OP_NAME) + + inParams.getAsString(PARAM_OP_NAME) + "\" agentSpec=\"" - + inParams.get(PARAM_AGENT) + + inParams.getAsString(PARAM_AGENT) + "\" result=\"" - + inParams.get(PARAM_RESULT) + + inParams.getAsObject(PARAM_RESULT) + "\" time=\"" + System.currentTimeMillis() + "\""; - final Map<String, Object> theParams = - (Map<String, Object>) inParams.get(PARAM_PARAMS); - if ((theParams != null) && (theParams.size() > 0)) { + final ParamSet theParams = + inParams.getAsParamSet(PARAM_PARAMS); + Set<String> theParamsNames = null; + if (theParams != null) { + theParamsNames = theParams.getParameterNames(); + } + if ((theParamsNames != null) + && (theParamsNames.size() > 0)) { mOutputStreamWriter.write(theStartTag + ">\n"); // It\xE9ration sur les param\xE8tres. - for (String theKey : theParams.keySet()) { + for (String theKey : theParamsNames) { final String theValue = - theParams.get(theKey).toString(); + theParams.getAsObject(theKey).toString(); mOutputStreamWriter.write( "\t\t<param name=\"" Modified: simulacion/src/fr/lip6/sma/simulacion/server/log/Logger.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/log/Logger.java 2007-05-27 00:17:33 UTC (rev 162) +++ simulacion/src/fr/lip6/sma/simulacion/server/log/Logger.java 2007-05-27 15:39:24 UTC (rev 163) @@ -36,6 +36,9 @@ import fr.lip6.sma.simulacion.server.AgentListManager; import fr.lip6.sma.simulacion.server.AgentSpecification; import fr.lip6.sma.simulacion.server.LocalAgent; +import fr.lip6.sma.simulacion.server.MutableParamSet; +import fr.lip6.sma.simulacion.server.MutableParamSetImpl; +import fr.lip6.sma.simulacion.server.ParamSet; import static fr.lip6.sma.simulacion.server.log.LogAgent.*; @@ -79,17 +82,16 @@ public void logOperation( LocalAgent inAgent, String inOperationName, - Map<String, Object> inParams, + ParamSet inParams, String inResult) { - // Création du paramètre pour les agents de log. - final Map<String, Object> theLogParams = - new Hashtable<String, Object>(); + // Parameters for the log agent. + final MutableParamSet theLogParams = + new MutableParamSetImpl(); String theResult = inResult; if (inResult == null) { theResult = "(null)"; } - theLogParams.put(PARAM_AGENT, - inAgent.getAgentSpecification().toString()); + theLogParams.put(PARAM_AGENT, inAgent.getAgentSpecification()); theLogParams.put(PARAM_OP_NAME, inOperationName); theLogParams.put(PARAM_PARAMS, inParams); theLogParams.put(PARAM_RESULT, theResult); @@ -117,13 +119,12 @@ */ public String executeLogOperation( String inOperationName, - Map<String, Object> inParams) { + ParamSet inParams) { String theResult = null; if (inOperationName.equals(OP_REGISTER_LOG_AGENT)) { - final String theAgentSpecStr = (String) inParams.get(PARAM_AGENT); final AgentSpecification theLogAgentSpec = - AgentSpecification.fromString(theAgentSpecStr); + inParams.getAsAgentSpec(PARAM_AGENT); // Get the log agent. Agent theLogAgent = null; @@ -149,9 +150,8 @@ } } } else if (inOperationName.equals(OP_UNREGISTER_LOG_AGENT)) { - final String theAgentSpecStr = (String) inParams.get(PARAM_AGENT); final AgentSpecification theLogAgentSpec = - AgentSpecification.fromString(theAgentSpecStr); + inParams.getAsAgentSpec(PARAM_AGENT); // Remove from the list. if (mLogAgents.remove(theLogAgentSpec) == null) { Modified: simulacion/src/fr/lip6/sma/simulacion/server/mdxr/MDXRAgent.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/mdxr/MDXRAgent.java 2007-05-27 00:17:33 UTC (rev 162) +++ simulacion/src/fr/lip6/sma/simulacion/server/mdxr/MDXRAgent.java 2007-05-27 15:39:24 UTC (rev 163) @@ -29,8 +29,6 @@ // imports import java.io.IOException; -import java.util.Hashtable; -import java.util.Map; import org.apache.xmlrpc.XmlRpcException; @@ -41,6 +39,7 @@ import fr.lip6.sma.simulacion.server.AgentImpl; import fr.lip6.sma.simulacion.server.NetworkAgent; import fr.lip6.sma.simulacion.server.NetworkAgentException; +import fr.lip6.sma.simulacion.server.ParamSet; /** * Classe pour un agent sur le r\xE9seau identifi\xE9 par un service ZeroConf @@ -132,7 +131,7 @@ */ public final synchronized String execute( String inOperationName, - Map<String, Object> inParams) + ParamSet inParams) throws AgentException { // Cr\xE9ation d'une requ\xEAte. final MDXRAgentRequest theRequest = new MDXRAgentRequest(mMDNSServer); @@ -141,7 +140,7 @@ try { theResult = - theRequest.execute(mService, inOperationName, inParams); + theRequest.execute(mService, inOperationName, inParams.toMap()); } catch (IOException anException) { throw new NetworkAgentException(anException); } catch (XmlRpcException anException) { @@ -160,9 +159,8 @@ */ public void executeAsync( final String inOperationName, - final Map<String, Object> inParams) { - final Map<String, Object> theParams = - new Hashtable<String, Object>(inParams); + final ParamSet inParams) { + final ParamSet theParams = inParams.createImmutableCopy(); // On ex\xE9cute dans un fil s\xE9par\xE9. final Thread theThread = new Thread(getClass().getName()) { Modified: simulacion/src/fr/lip6/sma/simulacion/server/xmlrpc/AgentHandler.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/xmlrpc/AgentHandler.java 2007-05-27 00:17:33 UTC (rev 162) +++ simulacion/src/fr/lip6/sma/simulacion/server/xmlrpc/AgentHandler.java 2007-05-27 15:39:24 UTC (rev 163) @@ -36,6 +36,7 @@ import fr.lip6.sma.simulacion.server.Agent; import fr.lip6.sma.simulacion.server.AgentException; +import fr.lip6.sma.simulacion.server.ParamSetImpl; /** * Classe pour l'interface publique du serveur. @@ -74,7 +75,8 @@ final Map<String, Object> theParams = (Map<String, Object>) inRequest.getParameter(1); try { - theResult = mLocalAgent.execute(operationName, theParams); + theResult = mLocalAgent.execute( + operationName, new ParamSetImpl(theParams)); } catch (AgentException anException) { throw new XmlRpcException(anException.toString(), anException); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2007-05-27 00:17:36
|
Revision: 162 http://simulacion.svn.sourceforge.net/simulacion/?rev=162&view=rev Author: pguyot Date: 2007-05-26 17:17:33 -0700 (Sat, 26 May 2007) Log Message: ----------- New interface for pairs. Added Paths: ----------- simulacion/src/fr/lip6/sma/simulacion/util/ simulacion/src/fr/lip6/sma/simulacion/util/ConstPair.java simulacion/src/fr/lip6/sma/simulacion/util/Pair.java simulacion/src/fr/lip6/sma/simulacion/util/package.html Added: simulacion/src/fr/lip6/sma/simulacion/util/ConstPair.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/util/ConstPair.java (rev 0) +++ simulacion/src/fr/lip6/sma/simulacion/util/ConstPair.java 2007-05-27 00:17:33 UTC (rev 162) @@ -0,0 +1,95 @@ +// ============================== +// File: ConstPair.java +// Project: Simulaci\xF3n +// Written by: Paul Guyot (pau...@ac...) +// +// Created on: 17/10/2006 +// Tabs: 4 spaces +// +// This software is governed by the CeCILL license under French law and abiding +// by the rules of distribution of free software. You can use, modify and/ or +// redistribute the software under the terms of the CeCILL license as +// circulated by CEA, CNRS and INRIA at the following URL +// "http://www.cecill.info". +// +// As a counterpart to the access to the source code and rights to copy, modify +// and redistribute granted by the license, users are provided only with a +// limited warranty and the software's author, the holder of the economic +// rights, and the successive licensors have only limited liability. +// +// The fact that you are presently reading this means that you have had +// knowledge of the CeCILL license and that you accept its terms. +// +// =========== +// $Id$ +// =========== + +// paquet +package fr.lip6.sma.simulacion.util; + +// imports + +/** + * Class for a constant pair. + * + * @author Paul Guyot <pau...@ac...> + * @version $Revision$ + * + * @param <A> class of first element. + * @param <B> class of second element. + */ +public final class ConstPair<A, B> implements Pair<A, B> { + /** + * First element. + */ + private final A mFirstElement; + + /** + * Second element. + */ + private final B mSecondElement; + + /** + * Constructor from two elements. + * + * @param inFirstElement first element. + * @param inSecondElement second element. + */ + public ConstPair(A inFirstElement, B inSecondElement) { + mFirstElement = inFirstElement; + mSecondElement = inSecondElement; + } + + /** + * {@inheritDoc} + */ + public A getFirst() { + return mFirstElement; + } + + /** + * {@inheritDoc} + */ + public B getSecond() { + return mSecondElement; + } + + /** + * {@inheritDoc} + */ + public void setFirst(A inElement) { + throw new UnsupportedOperationException("This pair is read only"); + } + + /** + * {@inheritDoc} + */ + public void setSecond(B inElement) { + throw new UnsupportedOperationException("This pair is read only"); + } +} + +// ===================================================== // +// Intel CPUs are not defective, they just act that way. // +// -- Henry Spencer // +// ===================================================== // Property changes on: simulacion/src/fr/lip6/sma/simulacion/util/ConstPair.java ___________________________________________________________________ Name: svn:keywords + Revision Id Added: simulacion/src/fr/lip6/sma/simulacion/util/Pair.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/util/Pair.java (rev 0) +++ simulacion/src/fr/lip6/sma/simulacion/util/Pair.java 2007-05-27 00:17:33 UTC (rev 162) @@ -0,0 +1,74 @@ +// ============================== +// File: Pair.java +// Project: Simulaci\xF3n +// Written by: Paul Guyot (pau...@ac...) +// +// Created on: 17/10/2006 +// Tabs: 4 spaces +// +// This software is governed by the CeCILL license under French law and abiding +// by the rules of distribution of free software. You can use, modify and/ or +// redistribute the software under the terms of the CeCILL license as +// circulated by CEA, CNRS and INRIA at the following URL +// "http://www.cecill.info". +// +// As a counterpart to the access to the source code and rights to copy, modify +// and redistribute granted by the license, users are provided only with a +// limited warranty and the software's author, the holder of the economic +// rights, and the successive licensors have only limited liability. +// +// The fact that you are presently reading this means that you have had +// knowledge of the CeCILL license and that you accept its terms. +// +// =========== +// $Id$ +// =========== + +// paquet +package fr.lip6.sma.simulacion.util; + +// imports + +/** + * Interface for a pair. + * + * @author Paul Guyot <pau...@ac...> + * @version $Revision$ + * + * @param <A> class of first element. + * @param <B> class of second element. + */ +public interface Pair<A, B> { + /** + * Accessor on the first element. + * + * @return the first element. + */ + A getFirst(); + + /** + * Accessor on the second element. + * + * @return the second element. + */ + B getSecond(); + + /** + * Selector on the first element. + * + * @param inElement new value for the first element. + */ + void setFirst(A inElement); + + /** + * Selector on the second element. + * + * @param inElement new value for the second element. + */ + void setSecond(B inElement); +} + +// ======================================================================== // +// Our informal mission is to improve the love life of operators worldwide. // +// -- Peter Behrendt, president of Exabyte // +// ======================================================================== // Property changes on: simulacion/src/fr/lip6/sma/simulacion/util/Pair.java ___________________________________________________________________ Name: svn:keywords + Revision Id Added: simulacion/src/fr/lip6/sma/simulacion/util/package.html =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/util/package.html (rev 0) +++ simulacion/src/fr/lip6/sma/simulacion/util/package.html 2007-05-27 00:17:33 UTC (rev 162) @@ -0,0 +1,42 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<!-- +============================== +Fichier: fr/lip6/sma/simulacion/util/package.html +Projet: Simulaci\xF3n +Ecrit par: Paul Guyot (pau...@ac...) + +Cr\xE9\xE9 le: 27/05/2007 +Tabulation: 4 espaces + +This software is governed by the CeCILL license under French law and abiding +by the rules of distribution of free software. You can use, modify and/ or +redistribute the software under the terms of the CeCILL license as +circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, modify +and redistribute granted by the license, users are provided only with a +limited warranty and the software's author, the holder of the economic +rights, and the successive licensors have only limited liability. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +=========== +$Id$ +=========== +--!> +<html> +<head> +</head> +<body bgcolor="white"> + +Package for utility classes. + +</body> +</html> +<!-- +======================================== +Cobol programmers are down in the dumps. +======================================== +--> Property changes on: simulacion/src/fr/lip6/sma/simulacion/util/package.html ___________________________________________________________________ Name: svn:executable + * Name: svn:keywords + Revision Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2007-05-25 15:17:22
|
Revision: 161 http://simulacion.svn.sourceforge.net/simulacion/?rev=161&view=rev Author: pguyot Date: 2007-05-25 08:17:18 -0700 (Fri, 25 May 2007) Log Message: ----------- New utility methods to invoke agent methods with no or one parameter. Modified Paths: -------------- simulacion/src/fr/lip6/sma/simulacion/server/Agent.java simulacion/src/fr/lip6/sma/simulacion/server/AgentImpl.java Modified: simulacion/src/fr/lip6/sma/simulacion/server/Agent.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/Agent.java 2007-05-25 10:55:41 UTC (rev 160) +++ simulacion/src/fr/lip6/sma/simulacion/server/Agent.java 2007-05-25 15:17:18 UTC (rev 161) @@ -107,28 +107,82 @@ int hashCode(); /** - * Ex\xE9cute une op\xE9ration (localement ou \xE0 travers le r\xE9seau). + * Execute an operation (locally or through the network). * - * @param inOperationName nom de l'op\xE9ration \xE0 ex\xE9cuter. - * @param inParams param\xE8tres de l'op\xE9ration. - * @return le r\xE9sultat de l'op\xE9ration (sous forme de cha\xEEne). - * @throws AgentException si un probl\xE8me est survenu dans l'ex\xE9cution - * de la m\xE9thode de l'agent. + * @param inOperationName name of the operation to execute. + * @param inParams parameters for the operation. + * @return the result of the operation (as a string). + * @throws AgentException if a problem occurred during the execution of the + * operation. */ String execute(String inOperationName, Map<String, Object> inParams) throws AgentException; /** - * Ex\xE9cute une op\xE9ration (localement ou \xE0 travers le r\xE9seau) sans - * r\xE9sultat (et de mani\xE8re asynchrone). + * Execute an operation (locally or through the network), without any result + * and asynchronously. * - * @param inOperationName nom de l'op\xE9ration \xE0 ex\xE9cuter. - * @param inParams param\xE8tres de l'op\xE9ration. - * @throws AgentException si un probl\xE8me est survenu dans l'ex\xE9cution - * de la m\xE9thode de l'agent. + * @param inOperationName name of the operation to execute. + * @param inParams parameters for the operation. + * @throws AgentException if a problem occurred during the execution of the + * operation. */ void executeAsync(String inOperationName, Map<String, Object> inParams) throws AgentException; + + /** + * Execute an operation (locally or through the network). + * Utility method to execute operations without any parameter. + * + * @param inOperationName name of the operation to execute. + * @return the result of the operation (as a string). + * @throws AgentException if a problem occurred during the execution of the + * operation. + */ + String execute(String inOperationName) throws AgentException; + + /** + * Execute an operation (locally or through the network), without any result + * and asynchronously. + * Utility method to execute operations without any parameter. + * + * @param inOperationName name of the operation to execute. + * @throws AgentException if a problem occurred during the execution of the + * operation. + */ + void executeAsync(String inOperationName) throws AgentException; + + /** + * Execute an operation (locally or through the network). + * Utility method to execute operations without a single parameter. + * + * @param inOperationName name of the operation to execute. + * @param inParamName name of the parameter. + * @param inParamValue value of the parameter. + * @return the result of the operation (as a string). + * @throws AgentException if a problem occurred during the execution of the + * operation. + */ + String execute( + String inOperationName, + String inParamName, + Object inParamValue) throws AgentException; + + /** + * Execute an operation (locally or through the network), without any result + * and asynchronously. + * Utility method to execute operations without any parameter. + * + * @param inOperationName name of the operation to execute. + * @param inParamName name of the parameter. + * @param inParamValue value of the parameter. + * @throws AgentException if a problem occurred during the execution of the + * operation. + */ + void executeAsync( + String inOperationName, + String inParamName, + Object inParamValue) throws AgentException; } // ====================================================== // Modified: simulacion/src/fr/lip6/sma/simulacion/server/AgentImpl.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/AgentImpl.java 2007-05-25 10:55:41 UTC (rev 160) +++ simulacion/src/fr/lip6/sma/simulacion/server/AgentImpl.java 2007-05-25 15:17:18 UTC (rev 161) @@ -27,6 +27,9 @@ // paquet package fr.lip6.sma.simulacion.server; +import java.util.Hashtable; +import java.util.Map; + /** * Classe abstraite pour des agents, met en place le minimum pour d\xE9finir * l'\xE9galit\xE9 entre deux agents. @@ -86,6 +89,75 @@ return mAgentSpecification; } + + /** + * Execute an operation (locally or through the network). + * Utility method to execute operations without any parameter. + * + * @param inOperationName name of the operation to execute. + * @return the result of the operation (as a string). + * @throws AgentException if a problem occurred during the execution of the + * operation. + */ + public final String execute(String inOperationName) throws AgentException { + final Map<String, Object> theParams = new Hashtable<String, Object>(); + return execute(inOperationName, theParams); + } + + /** + * Execute an operation (locally or through the network), without any result + * and asynchronously. + * Utility method to execute operations without any parameter. + * + * @param inOperationName name of the operation to execute. + * @throws AgentException if a problem occurred during the execution of the + * operation. + */ + public final void executeAsync(String inOperationName) + throws AgentException { + final Map<String, Object> theParams = new Hashtable<String, Object>(); + executeAsync(inOperationName, theParams); + } + + /** + * Execute an operation (locally or through the network). + * Utility method to execute operations without a single parameter. + * + * @param inOperationName name of the operation to execute. + * @param inParamName name of the parameter. + * @param inParamValue value of the parameter. + * @return the result of the operation (as a string). + * @throws AgentException if a problem occurred during the execution of the + * operation. + */ + public final String execute( + String inOperationName, + String inParamName, + Object inParamValue) throws AgentException { + final Map<String, Object> theParams = new Hashtable<String, Object>(); + theParams.put(inParamName, inParamValue); + return execute(inOperationName, theParams); + } + + /** + * Execute an operation (locally or through the network), without any result + * and asynchronously. + * Utility method to execute operations without any parameter. + * + * @param inOperationName name of the operation to execute. + * @param inParamName name of the parameter. + * @param inParamValue value of the parameter. + * @throws AgentException if a problem occurred during the execution of the + * operation. + */ + public final void executeAsync( + String inOperationName, + String inParamName, + Object inParamValue) throws AgentException { + final Map<String, Object> theParams = new Hashtable<String, Object>(); + theParams.put(inParamName, inParamValue); + executeAsync(inOperationName, theParams); + } } // =================================================================== // This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2007-05-25 10:55:44
|
Revision: 160 http://simulacion.svn.sourceforge.net/simulacion/?rev=160&view=rev Author: pguyot Date: 2007-05-25 03:55:41 -0700 (Fri, 25 May 2007) Log Message: ----------- New utility method to convert a parameter to a list, compatible with both XmlRpc 2.0 and 3.0. Modified Paths: -------------- simulacion/src/fr/lip6/sma/simulacion/server/LocalAgentImpl.java Modified: simulacion/src/fr/lip6/sma/simulacion/server/LocalAgentImpl.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/LocalAgentImpl.java 2007-05-24 23:26:41 UTC (rev 159) +++ simulacion/src/fr/lip6/sma/simulacion/server/LocalAgentImpl.java 2007-05-25 10:55:41 UTC (rev 160) @@ -30,7 +30,9 @@ // import import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; +import java.util.Arrays; import java.util.Hashtable; +import java.util.List; import java.util.Map; import fr.lip6.sma.simulacion.app.Model; @@ -306,6 +308,33 @@ mPropertyChangeSupport.removePropertyChangeListener( inPropertyName, inListener); } + + /** + * Transform a parameter into a list. + * + * @param inParamName name of the parameter. + * @param inParams parameters maps. + * @return the value of the parameter as a list. + * @throws ClassCastException if the parameter cannot be cast into + * a list. + */ + protected static final List getParamAsList( + Map<String, Object> inParams, String inParamName) { + List theResult = null; + final Object theParam = inParams.get(inParamName); + if (theParam != null) { + if (theParam instanceof List) { + theResult = (List) theParam; + } else if (theParam instanceof Object[]) { + theResult = Arrays.asList((Object[]) theParam); + } else { + throw new ClassCastException("Parameter " + inParamName + + " cannot be cast into a list."); + } + } + + return theResult; + } } // ========================================================================= // This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2007-05-24 23:26:44
|
Revision: 159 http://simulacion.svn.sourceforge.net/simulacion/?rev=159&view=rev Author: pguyot Date: 2007-05-24 16:26:41 -0700 (Thu, 24 May 2007) Log Message: ----------- More work on the applet GUI, which is nearly completely functional. Modified Paths: -------------- simulacion/src/fr/lip6/sma/simulacion/app/ApplicationWindow.java simulacion/src/fr/lip6/sma/simulacion/app/LocalizedWindow.java simulacion/src/fr/lip6/sma/simulacion/app/ModalWindow.java simulacion/src/fr/lip6/sma/simulacion/avatar/AvatarDialog2D.java simulacion/src/fr/lip6/sma/simulacion/gui/BaseApplet.java simulacion/src/fr/lip6/sma/simulacion/gui/GraphicalUserInterface.java simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java simulacion/src/fr/lip6/sma/simulacion/gui/SwingApplicationGUI.java simulacion/src/fr/lip6/sma/simulacion/gui/Window.java simulacion/src/fr/lip6/sma/simulacion/gui/WindowImplementation.java Added Paths: ----------- simulacion/src/fr/lip6/sma/simulacion/gui/WindowKind.java Modified: simulacion/src/fr/lip6/sma/simulacion/app/ApplicationWindow.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/app/ApplicationWindow.java 2007-05-24 22:11:07 UTC (rev 158) +++ simulacion/src/fr/lip6/sma/simulacion/app/ApplicationWindow.java 2007-05-24 23:26:41 UTC (rev 159) @@ -32,6 +32,8 @@ import java.lang.reflect.InvocationTargetException; import java.security.AccessControlException; +import fr.lip6.sma.simulacion.gui.WindowKind; + /** * Classe de base pour les fen\xEAtres des applications Simulaci\xF3n. * G\xE8re la traduction des \xE9l\xE9ments graphiques et la fermeture. @@ -63,6 +65,8 @@ * @param inApplication application object. */ protected ApplicationWindow(Application inApplication) { + super(WindowKind.MAIN_WINDOW, inApplication.getConfiguration()); + // On note le mod\xE8le. mApplication = inApplication; Modified: simulacion/src/fr/lip6/sma/simulacion/app/LocalizedWindow.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/app/LocalizedWindow.java 2007-05-24 22:11:07 UTC (rev 158) +++ simulacion/src/fr/lip6/sma/simulacion/app/LocalizedWindow.java 2007-05-24 23:26:41 UTC (rev 159) @@ -41,6 +41,7 @@ import fr.lip6.sma.simulacion.gui.Window; import fr.lip6.sma.simulacion.gui.WindowAdapter; import fr.lip6.sma.simulacion.gui.WindowEvent; +import fr.lip6.sma.simulacion.gui.WindowKind; /** * Classe pour une fen\xEAtre dans la langue de l'utilisateur. C'est la classe de @@ -63,9 +64,20 @@ private boolean mShown; /** - * Constructeur par d\xE9faut. + * Default constructor. */ public LocalizedWindow() { + this(WindowKind.REGULAR_WINDOW); + } + + /** + * Constructor from a window kind. + * + * @param inWindowKind kind of window. + */ + public LocalizedWindow(WindowKind inWindowKind) { + super(inWindowKind); + mLocalizationEngine = LocalizationEngine.getEngine(); init(); } @@ -76,6 +88,17 @@ * @param inConfigPath path to the configuration file. */ public LocalizedWindow(String inConfigPath) { + this(WindowKind.REGULAR_WINDOW, inConfigPath); + } + + /** + * Constructor from a window kind and the configuration file. + * + * @param inWindowKind kind of window. + * @param inConfigPath path to the configuration file. + */ + public LocalizedWindow(WindowKind inWindowKind, String inConfigPath) { + super(inWindowKind); mLocalizationEngine = LocalizationEngine.getEngine(inConfigPath); init(); } @@ -86,6 +109,17 @@ * @param inConfig reference on the configuration. */ public LocalizedWindow(Configuration inConfig) { + this(WindowKind.REGULAR_WINDOW, inConfig); + } + + /** + * Constructor from a window kind and the configuration. + * + * @param inWindowKind kind of window. + * @param inConfig reference on the configuration. + */ + public LocalizedWindow(WindowKind inWindowKind, Configuration inConfig) { + super(inWindowKind); mLocalizationEngine = LocalizationEngine.getEngine(inConfig); init(); } Modified: simulacion/src/fr/lip6/sma/simulacion/app/ModalWindow.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/app/ModalWindow.java 2007-05-24 22:11:07 UTC (rev 158) +++ simulacion/src/fr/lip6/sma/simulacion/app/ModalWindow.java 2007-05-24 23:26:41 UTC (rev 159) @@ -28,21 +28,20 @@ package fr.lip6.sma.simulacion.app; // imports +import fr.lip6.sma.simulacion.gui.WindowKind; /** - * Classe de base pour une fen\xEAtre sans d\xE9coration, centr\xE9e. + * Base class for a centered, undecorated window. * * @author Paul Guyot <pau...@ac...> * @version $Revision$ - * - * @see "aucun test d\xE9fini." */ public class ModalWindow extends LocalizedWindow { /** - * Constructeur par d\xE9faut. + * Default constructor. */ public ModalWindow() { - setUndecorated(true); + super(WindowKind.UNDECORATED_WINDOW); } } Modified: simulacion/src/fr/lip6/sma/simulacion/avatar/AvatarDialog2D.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/avatar/AvatarDialog2D.java 2007-05-24 22:11:07 UTC (rev 158) +++ simulacion/src/fr/lip6/sma/simulacion/avatar/AvatarDialog2D.java 2007-05-24 23:26:41 UTC (rev 159) @@ -122,87 +122,98 @@ synchronized (this) { if (mKeepRunning) { // R\xE9cup\xE9ration des couches. - final Map[] theLayers = mModel.getImageCollection(mCollectionID) + final Map[] theLayers = + mModel.getImageCollection(mCollectionID) .getLayers(inNewAttitude); - // Cr\xE9ation/remplacement du tableau des indices et des couches. - final int nbLayers = theLayers.length; - mIndexes = new int[nbLayers][]; - mSequences = new Image[nbLayers][][]; - mLayerIsHorizontal = new boolean[nbLayers]; - - // Dimension maximale des couches. - int maxWidth = 0; - int maxHeight = 0; - - // It\xE9ration sur les couches. - int indexLayers; - for ( - indexLayers = 0; - indexLayers < nbLayers; - indexLayers++) { - int layerHeight = 0; - int layerWidth = 0; - - final boolean isHorizontal = theLayers[indexLayers].get( - AvatarImageCollection.LAYER_ORIENTATION_KEY) - .equals( - AvatarImageCollection - .LAYER_HORIZONTAL_ORIENTATION); - mLayerIsHorizontal[indexLayers] = isHorizontal; - - // On r\xE9cup\xE8re les s\xE9quences. - final Image[][] slices = (Image[][]) - theLayers[indexLayers].get( - AvatarImageCollection.LAYER_SLICES_KEY); - final int nbSlices = slices.length; - mSequences[indexLayers] = slices; - mIndexes[indexLayers] = new int[nbSlices]; + if (theLayers != null) { + final Dimension myNewSize = updateLayers(theLayers); - // On commence par les premi\xE8res images. - int indexSlices; - for ( - indexSlices = 0; - indexSlices < nbSlices; - indexSlices++) { - mIndexes[indexLayers][indexSlices] = 0; - - // Calcul de la taille de cette couche. - if (isHorizontal) { - layerHeight += - mSequences[indexLayers][indexSlices][0] - .getHeight(this); - } else { - layerWidth += - mSequences[indexLayers][indexSlices][0] - .getWidth(this); - } - } - - if (isHorizontal) { - layerWidth = - mSequences[indexLayers][0][0].getWidth(this); - } else { - layerHeight = - mSequences[indexLayers][0][0].getHeight(this); - } - - if (layerWidth > maxWidth) { - maxWidth = layerWidth; - } - if (layerHeight > maxHeight) { - maxHeight = layerHeight; - } + // Define that as our new preferred size. + setPreferredSize(myNewSize); } - - // On se redimensionne en fonction de la taille des images. - setPreferredSize( - new Dimension(maxWidth, maxHeight)); } } } /** + * Update the layer arrays to build the image. + * + * @param inLayers new layers. + * @return the dimension of the image. + */ + private Dimension updateLayers(Map[] inLayers) { + // Cr\xE9ation/remplacement du tableau des indices et des + // couches. + final int nbLayers = inLayers.length; + mIndexes = new int[nbLayers][]; + mSequences = new Image[nbLayers][][]; + mLayerIsHorizontal = new boolean[nbLayers]; + + // Dimension maximale des couches. + int maxWidth = 0; + int maxHeight = 0; + + // It\xE9ration sur les couches. + int indexLayers; + for ( + indexLayers = 0; + indexLayers < nbLayers; + indexLayers++) { + int layerHeight = 0; + int layerWidth = 0; + + final boolean isHorizontal = + inLayers[indexLayers].get( + AvatarImageCollection.LAYER_ORIENTATION_KEY) + .equals(AvatarImageCollection.LAYER_HORIZONTAL_ORIENTATION); + mLayerIsHorizontal[indexLayers] = isHorizontal; + + // On r\xE9cup\xE8re les s\xE9quences. + final Image[][] slices = (Image[][]) + inLayers[indexLayers].get( + AvatarImageCollection.LAYER_SLICES_KEY); + final int nbSlices = slices.length; + mSequences[indexLayers] = slices; + mIndexes[indexLayers] = new int[nbSlices]; + + // On commence par les premi\xE8res images. + int indexSlices; + for ( + indexSlices = 0; + indexSlices < nbSlices; + indexSlices++) { + mIndexes[indexLayers][indexSlices] = 0; + + // Calcul de la taille de cette couche. + if (isHorizontal) { + layerHeight += + mSequences[indexLayers][indexSlices][0].getHeight(this); + } else { + layerWidth += + mSequences[indexLayers][indexSlices][0].getWidth(this); + } + } + + if (isHorizontal) { + layerWidth = mSequences[indexLayers][0][0].getWidth(this); + } else { + layerHeight = mSequences[indexLayers][0][0].getHeight(this); + } + + if (layerWidth > maxWidth) { + maxWidth = layerWidth; + } + if (layerHeight > maxHeight) { + maxHeight = layerHeight; + } + } + + // Return the dimension of the image. + return new Dimension(maxWidth, maxHeight); + } + + /** * M\xE9thode invoqu\xE9e pour dessiner le composant. * * @param inGraphics contexte pour dessiner Modified: simulacion/src/fr/lip6/sma/simulacion/gui/BaseApplet.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/BaseApplet.java 2007-05-24 22:11:07 UTC (rev 158) +++ simulacion/src/fr/lip6/sma/simulacion/gui/BaseApplet.java 2007-05-24 23:26:41 UTC (rev 159) @@ -28,10 +28,12 @@ package fr.lip6.sma.simulacion.gui; // imports +import java.awt.Component; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import javax.swing.JApplet; +import javax.swing.JLayeredPane; /** * Base class for the applet. @@ -48,6 +50,11 @@ private final Class mMainClass; /** + * Pane for the items in the applet. + */ + private final JLayeredPane mLayeredPane; + + /** * Constructor from a class. * * @param inMainClass class with the main entry point. @@ -57,6 +64,10 @@ new SwingAppletGUI(this); mMainClass = inMainClass; + + // We use a JLayeredPane. + mLayeredPane = new JLayeredPane(); + add(mLayeredPane); } /** @@ -96,6 +107,34 @@ theExecThread.start(); } } + + /** + * Add a window. + * + * @param inWindow window to add. + * @param inKind kind of the window to add. + */ + public void addWindow(Component inWindow, WindowKind inKind) { + int theLevel; + switch (inKind) { + case REGULAR_WINDOW: + theLevel = 0; + break; + + case UNDECORATED_WINDOW: + theLevel = 10; + break; + + case MAIN_WINDOW: + theLevel = -10; + break; + + default: + theLevel = 0; + } + mLayeredPane.add(inWindow, new Integer(theLevel)); + validate(); + } } // ======================================================================== // Modified: simulacion/src/fr/lip6/sma/simulacion/gui/GraphicalUserInterface.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/GraphicalUserInterface.java 2007-05-24 22:11:07 UTC (rev 158) +++ simulacion/src/fr/lip6/sma/simulacion/gui/GraphicalUserInterface.java 2007-05-24 23:26:41 UTC (rev 159) @@ -77,9 +77,11 @@ * Create a window. * * @param inHook hook for the subclass method calls. + * @param inKind kind of window to create. * @return a new window. */ - public abstract WindowImplementation createWindow(WindowHook inHook); + public abstract WindowImplementation createWindow( + WindowHook inHook, WindowKind inKind); /** * Create the GUI. @@ -90,14 +92,7 @@ } } -// ========================================================================= // -// If just one piece of mail gets lost, well, they'll just think they forgot // -// to send it. But if *two* pieces of mail get lost, hell, they'll just // -// think the other guy hasn't gotten around to answering his mail. And if // -// *fifty* pieces of mail get lost, can you imagine it, if *fifty* pieces of // -// mail get lost, why they'll think someone *else* is broken! And if 1Gb of // -// mail gets lost, they'll just *know* that Arpa [ucbarpa.berkeley.edu] is // -// down and think it's a conspiracy to keep them from their God given right // -// to receive Net Mail ... // -// -- Casey Leedom // -// ========================================================================= // +// ====================================================================== // +// Real Users find the one combination of bizarre input values that shuts // +// down the system for days. // +// ====================================================================== // Modified: simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java 2007-05-24 22:11:07 UTC (rev 158) +++ simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java 2007-05-24 23:26:41 UTC (rev 159) @@ -28,9 +28,12 @@ package fr.lip6.sma.simulacion.gui; // imports +import java.awt.Color; import java.awt.Dimension; +import javax.swing.BorderFactory; import javax.swing.JInternalFrame; +import javax.swing.JRootPane; /** * Class for the swing applet GUI. @@ -45,9 +48,9 @@ private final BaseApplet mApplet; /** - * Class for the internal frames in the applet. + * Class for an undecorated frame in the applet. */ - private static final class AppletFrame extends JInternalFrame + private static final class AppletUndecoratedFrame extends JRootPane implements WindowImplementation { /** * Reference on the hook for overridden methods. @@ -58,6 +61,11 @@ * Reference on the applet we belong to. */ private final BaseApplet mApplet; + + /** + * Kind of window. + */ + private final WindowKind mWindowKind; /** * If we've been added to the applet. @@ -67,12 +75,19 @@ /** * Constructor from the hook and the applet. * - * @param inHook hook for overriden methods. - * @param inApplet applet we belong to. + * @param inHook hook for overriden methods. + * @param inApplet applet we belong to. + * @param inWindowKind kind of window. */ - private AppletFrame(WindowHook inHook, BaseApplet inApplet) { + private AppletUndecoratedFrame( + WindowHook inHook, + BaseApplet inApplet, + WindowKind inWindowKind) { mHook = inHook; mApplet = inApplet; + mWindowKind = inWindowKind; + + setBorder(BorderFactory.createLineBorder(Color.BLACK)); } /** @@ -97,7 +112,7 @@ public void setVisible(boolean inVisible) { if (inVisible && !mAdded) { mAdded = true; - mApplet.add(this); + mApplet.addWindow(this, mWindowKind); } super.setVisible(inVisible); @@ -107,17 +122,122 @@ * {@inheritDoc} */ public void addWindowListener(WindowListener inWindowListener) { - addInternalFrameListener( - new ListenerProxy(mHook.getProxy(), inWindowListener)); + // TODO: implement a window listener. } /** * {@inheritDoc} */ - public void setUndecorated(boolean inUndecorated) { + public void dispose() { + setVisible(false); + } + + /** + * {@inheritDoc} + */ + public void pack() { + setSize(getPreferredSize()); + } + + /** + * {@inheritDoc} + */ + public void setDefaultCloseOperation(int inOperation) { + // TODO: implement close operation stuff. + } + + /** + * {@inheritDoc} + */ + public void setResizable(boolean inResizable) { // This space for rent. } + + /** + * {@inheritDoc} + */ + public void setTitle(String inTitle) { + // This space for rent. + } } + + /** + * Class for the internal frames in the applet. + */ + private static final class AppletFrame extends JInternalFrame + implements WindowImplementation { + /** + * Reference on the hook for overridden methods. + */ + private final WindowHook mHook; + + /** + * Reference on the applet we belong to. + */ + private final BaseApplet mApplet; + + /** + * Kind of window. + */ + private final WindowKind mWindowKind; + + /** + * If we've been added to the applet. + */ + private boolean mAdded; + + /** + * Constructor from the hook and the applet. + * + * @param inHook hook for overriden methods. + * @param inApplet applet we belong to. + * @param inWindowKind kind of window. + */ + private AppletFrame( + WindowHook inHook, + BaseApplet inApplet, + WindowKind inWindowKind) { + mHook = inHook; + mApplet = inApplet; + mWindowKind = inWindowKind; + } + + /** + * {@inheritDoc} + */ + public void addNotify() { + super.addNotify(); + mHook.addNotify(); + } + + /** + * {@inheritDoc} + */ + public void removeNotify() { + super.removeNotify(); + mHook.removeNotify(); + } + + /** + * {@inheritDoc} + */ + public void setVisible(boolean inVisible) { + if (inVisible && !mAdded) { + mAdded = true; + mApplet.addWindow(this, mWindowKind); + } + + super.setVisible(inVisible); + } + + /** + * {@inheritDoc} + */ + public void addWindowListener(WindowListener inWindowListener) { + addInternalFrameListener( + new ListenerProxy(mHook.getProxy(), inWindowListener)); + } + } /** * Constructor from the base applet. @@ -136,13 +256,19 @@ } /** - * Create a window. + * {@inheritDoc} * - * @param inHook hook for the subclass method calls. - * @return a new window. + * We currently ignore inKind parameter. */ - public WindowImplementation createWindow(final WindowHook inHook) { - final WindowImplementation theResult = new AppletFrame(inHook, mApplet); + public WindowImplementation createWindow( + WindowHook inHook, WindowKind inKind) { + WindowImplementation theResult; + if ((inKind == WindowKind.MAIN_WINDOW) + || (inKind == WindowKind.UNDECORATED_WINDOW)) { + theResult = new AppletUndecoratedFrame(inHook, mApplet, inKind); + } else { + theResult = new AppletFrame(inHook, mApplet, inKind); + } return theResult; } Modified: simulacion/src/fr/lip6/sma/simulacion/gui/SwingApplicationGUI.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/SwingApplicationGUI.java 2007-05-24 22:11:07 UTC (rev 158) +++ simulacion/src/fr/lip6/sma/simulacion/gui/SwingApplicationGUI.java 2007-05-24 23:26:41 UTC (rev 159) @@ -53,10 +53,14 @@ /** * Constructor from a hook. * - * @param inHook hook for overridden methods. + * @param inHook hook for overridden methods. + * @param inKind kind of windows. */ - private ApplicationFrame(WindowHook inHook) { + private ApplicationFrame(WindowHook inHook, WindowKind inKind) { mHook = inHook; + if (inKind == WindowKind.UNDECORATED_WINDOW) { + setUndecorated(true); + } } /** @@ -99,13 +103,11 @@ } /** - * Create a window. - * - * @param inHook hook for the subclass method calls. - * @return a new window. + * {@inheritDoc} */ - public WindowImplementation createWindow(final WindowHook inHook) { - return new ApplicationFrame(inHook); + public WindowImplementation createWindow( + WindowHook inHook, WindowKind inKind) { + return new ApplicationFrame(inHook, inKind); } } Modified: simulacion/src/fr/lip6/sma/simulacion/gui/Window.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/Window.java 2007-05-24 22:11:07 UTC (rev 158) +++ simulacion/src/fr/lip6/sma/simulacion/gui/Window.java 2007-05-24 23:26:41 UTC (rev 159) @@ -68,13 +68,15 @@ private boolean mCenterWindow; /** - * Default constructor. + * Constructor from a window kind. + * + * @param inKind kind of window we want. */ - public Window() { + public Window(WindowKind inKind) { // Note the associated GUI. mGraphicalUserInterface = GraphicalUserInterface.getGUI(); // Ask the GUI for a window implementation. - mImplementation = mGraphicalUserInterface.createWindow(this); + mImplementation = mGraphicalUserInterface.createWindow(this, inKind); } /** @@ -304,13 +306,6 @@ /** * {@inheritDoc} */ - public void setUndecorated(boolean inUndecorated) { - mImplementation.setUndecorated(inUndecorated); - } - - /** - * {@inheritDoc} - */ public void dispose() { mImplementation.dispose(); } Modified: simulacion/src/fr/lip6/sma/simulacion/gui/WindowImplementation.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/WindowImplementation.java 2007-05-24 22:11:07 UTC (rev 158) +++ simulacion/src/fr/lip6/sma/simulacion/gui/WindowImplementation.java 2007-05-24 23:26:41 UTC (rev 159) @@ -186,14 +186,6 @@ void setVisible(boolean inVisible); /** - * Remove (or reset) the decoration for this window. - * - * @param inUndecorated if this window should be undecorated. - * @see javax.swing.JFrame#setUndecorated(boolean) - */ - void setUndecorated(boolean inUndecorated); - - /** * Dispose this window. * * @see javax.swing.JFrame#dispose() Added: simulacion/src/fr/lip6/sma/simulacion/gui/WindowKind.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/WindowKind.java (rev 0) +++ simulacion/src/fr/lip6/sma/simulacion/gui/WindowKind.java 2007-05-24 23:26:41 UTC (rev 159) @@ -0,0 +1,49 @@ +// ============================== +// File: WindowKind.java +// Project: Simulaci\xF3n +// Written by: Paul Guyot (pau...@ac...) +// +// Created on: 20/5/2007 +// Tabs: 4 spaces +// +// This software is governed by the CeCILL license under French law and abiding +// by the rules of distribution of free software. You can use, modify and/ or +// redistribute the software under the terms of the CeCILL license as +// circulated by CEA, CNRS and INRIA at the following URL +// "http://www.cecill.info". +// +// As a counterpart to the access to the source code and rights to copy, modify +// and redistribute granted by the license, users are provided only with a +// limited warranty and the software's author, the holder of the economic +// rights, and the successive licensors have only limited liability. +// +// The fact that you are presently reading this means that you have had +// knowledge of the CeCILL license and that you accept its terms. +// +// =========== +// $Id$ +// =========== + +// package +package fr.lip6.sma.simulacion.gui; + +/** + * Window kinds. + * + * @author Paul Guyot <pau...@ac...> + * @version $Revision$ + */ +public enum WindowKind { + /** A regular window. */ + REGULAR_WINDOW, + + /** A window without native window manager decorations */ + UNDECORATED_WINDOW, + + /** The main window, which is undecorated for applets */ + MAIN_WINDOW; +} + +// ======================== // +// Beware the new TTY code! // +// ======================== // Property changes on: simulacion/src/fr/lip6/sma/simulacion/gui/WindowKind.java ___________________________________________________________________ Name: svn:executable + * Name: svn:keywords + Revision Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2007-05-24 22:11:13
|
Revision: 158 http://simulacion.svn.sourceforge.net/simulacion/?rev=158&view=rev Author: pguyot Date: 2007-05-24 15:11:07 -0700 (Thu, 24 May 2007) Log Message: ----------- Cleaned up the window proxy code. Fixed the HTTP server handler test. Modified Paths: -------------- simulacion/src/fr/lip6/sma/simulacion/app/LocalizationEngine.java simulacion/src/fr/lip6/sma/simulacion/app/WaitShowing.java simulacion/src/fr/lip6/sma/simulacion/gui/GraphicalUserInterface.java simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java simulacion/src/fr/lip6/sma/simulacion/gui/SwingApplicationGUI.java simulacion/src/fr/lip6/sma/simulacion/gui/Window.java simulacion/src/fr/lip6/sma/simulacion/gui/WindowHook.java simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServer.java simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServerHandler.java Added Paths: ----------- simulacion/src/fr/lip6/sma/simulacion/gui/WindowImplementation.java simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServerHandlerTest.java Removed Paths: ------------- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServerTest.java Modified: simulacion/src/fr/lip6/sma/simulacion/app/LocalizationEngine.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/app/LocalizationEngine.java 2007-05-24 21:22:44 UTC (rev 157) +++ simulacion/src/fr/lip6/sma/simulacion/app/LocalizationEngine.java 2007-05-24 22:11:07 UTC (rev 158) @@ -46,6 +46,7 @@ import javax.swing.text.JTextComponent; import fr.lip6.sma.simulacion.gui.Window; +import fr.lip6.sma.simulacion.gui.WindowImplementation; /** * Singleton class to localize strings. @@ -329,7 +330,12 @@ * @param inWindow widget to translate. */ public void localizeWindow(Window inWindow) { - localizeComponent(inWindow.getImplementation()); + final WindowImplementation theImplem = inWindow.getImplementation(); + if (theImplem instanceof Component) { + localizeComponent((Component) theImplem); + } + + localizeComponent(theImplem.getContentPane()); } /** Modified: simulacion/src/fr/lip6/sma/simulacion/app/WaitShowing.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/app/WaitShowing.java 2007-05-24 21:22:44 UTC (rev 157) +++ simulacion/src/fr/lip6/sma/simulacion/app/WaitShowing.java 2007-05-24 22:11:07 UTC (rev 158) @@ -33,6 +33,7 @@ import java.awt.event.HierarchyListener; import fr.lip6.sma.simulacion.gui.Window; +import fr.lip6.sma.simulacion.gui.WindowImplementation; /** * Classe pour attendre qu'un composant soit affich\xE9. @@ -85,7 +86,12 @@ * @param inWindow window to wait for. */ public static void wait(Window inWindow) { - wait(inWindow.getImplementation()); + final WindowImplementation theImplem = inWindow.getImplementation(); + if (theImplem instanceof Component) { + wait((Component) theImplem); + } else { + wait(theImplem.getContentPane()); + } } /** @@ -114,7 +120,12 @@ * @param inCallback callback. */ public static void wait(Window inWindow, Runnable inCallback) { - wait(inWindow.getImplementation(), inCallback); + final WindowImplementation theImplem = inWindow.getImplementation(); + if (theImplem instanceof Component) { + wait((Component) theImplem, inCallback); + } else { + wait(theImplem.getContentPane(), inCallback); + } } /** Modified: simulacion/src/fr/lip6/sma/simulacion/gui/GraphicalUserInterface.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/GraphicalUserInterface.java 2007-05-24 21:22:44 UTC (rev 157) +++ simulacion/src/fr/lip6/sma/simulacion/gui/GraphicalUserInterface.java 2007-05-24 22:11:07 UTC (rev 158) @@ -30,8 +30,6 @@ // imports import java.awt.Dimension; -import javax.swing.RootPaneContainer; - /** * Base class for the various GUI modes. * @@ -81,7 +79,7 @@ * @param inHook hook for the subclass method calls. * @return a new window. */ - public abstract RootPaneContainer createWindow(WindowHook inHook); + public abstract WindowImplementation createWindow(WindowHook inHook); /** * Create the GUI. Modified: simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java 2007-05-24 21:22:44 UTC (rev 157) +++ simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java 2007-05-24 22:11:07 UTC (rev 158) @@ -31,7 +31,6 @@ import java.awt.Dimension; import javax.swing.JInternalFrame; -import javax.swing.RootPaneContainer; /** * Class for the swing applet GUI. @@ -48,7 +47,8 @@ /** * Class for the internal frames in the applet. */ - private static final class AppletFrame extends JInternalFrame { + private static final class AppletFrame extends JInternalFrame + implements WindowImplementation { /** * Reference on the hook for overridden methods. */ @@ -102,6 +102,21 @@ super.setVisible(inVisible); } + + /** + * {@inheritDoc} + */ + public void addWindowListener(WindowListener inWindowListener) { + addInternalFrameListener( + new ListenerProxy(mHook.getProxy(), inWindowListener)); + } + + /** + * {@inheritDoc} + */ + public void setUndecorated(boolean inUndecorated) { + // This space for rent. + } } /** @@ -126,8 +141,8 @@ * @param inHook hook for the subclass method calls. * @return a new window. */ - public RootPaneContainer createWindow(final WindowHook inHook) { - final JInternalFrame theResult = new AppletFrame(inHook, mApplet); + public WindowImplementation createWindow(final WindowHook inHook) { + final WindowImplementation theResult = new AppletFrame(inHook, mApplet); return theResult; } Modified: simulacion/src/fr/lip6/sma/simulacion/gui/SwingApplicationGUI.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/SwingApplicationGUI.java 2007-05-24 21:22:44 UTC (rev 157) +++ simulacion/src/fr/lip6/sma/simulacion/gui/SwingApplicationGUI.java 2007-05-24 22:11:07 UTC (rev 158) @@ -32,7 +32,6 @@ import java.awt.Toolkit; import javax.swing.JFrame; -import javax.swing.RootPaneContainer; /** * Class for the swing application GUI. @@ -42,6 +41,50 @@ */ public class SwingApplicationGUI extends GraphicalUserInterface { /** + * Class for the windows. + */ + private static final class ApplicationFrame extends JFrame + implements WindowImplementation { + /** + * Reference on the hook. + */ + private final WindowHook mHook; + + /** + * Constructor from a hook. + * + * @param inHook hook for overridden methods. + */ + private ApplicationFrame(WindowHook inHook) { + mHook = inHook; + } + + /** + * {@inheritDoc} + */ + public void addNotify() { + super.addNotify(); + mHook.addNotify(); + } + + /** + * {@inheritDoc} + */ + public void removeNotify() { + super.removeNotify(); + mHook.removeNotify(); + } + + /** + * {@inheritDoc} + */ + public void addWindowListener(WindowListener inWindowListener) { + super.addWindowListener( + new ListenerProxy(mHook.getProxy(), inWindowListener)); + } + } + + /** * Default constructor. */ SwingApplicationGUI() { @@ -61,18 +104,8 @@ * @param inHook hook for the subclass method calls. * @return a new window. */ - public RootPaneContainer createWindow(final WindowHook inHook) { - return new JFrame() { - public void addNotify() { - super.addNotify(); - inHook.addNotify(); - } - - public void removeNotify() { - super.removeNotify(); - inHook.removeNotify(); - } - }; + public WindowImplementation createWindow(final WindowHook inHook) { + return new ApplicationFrame(inHook); } } Modified: simulacion/src/fr/lip6/sma/simulacion/gui/Window.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/Window.java 2007-05-24 21:22:44 UTC (rev 157) +++ simulacion/src/fr/lip6/sma/simulacion/gui/Window.java 2007-05-24 22:11:07 UTC (rev 158) @@ -38,12 +38,9 @@ import java.awt.Toolkit; import java.awt.event.MouseListener; -import javax.swing.JFrame; -import javax.swing.JInternalFrame; import javax.swing.JLayeredPane; import javax.swing.JMenuBar; import javax.swing.JRootPane; -import javax.swing.RootPaneContainer; import javax.swing.WindowConstants; /** @@ -53,11 +50,12 @@ * @author Paul Guyot <pau...@ac...> * @version $Revision$ */ -public class Window implements RootPaneContainer, WindowConstants, WindowHook { +public class Window implements + WindowImplementation, WindowConstants, WindowHook { /** * Actual implementation. */ - private final RootPaneContainer mImplementation; + private final WindowImplementation mImplementation; /** * Reference on the GUI. @@ -80,114 +78,73 @@ } /** + * Center the window on the screen or in the applet. + */ + public final void centerWindow() { + if (!isVisible()) { + mCenterWindow = true; + } + final Dimension theEnvironmentSize = + mGraphicalUserInterface.getEnvironmentSize(); + // Compute the offset. + final Insets theInsets = getInsets(); + final Point theLocation = new Point( + (int) ((theEnvironmentSize.getWidth() - getWidth()) / 2) + - theInsets.left + theInsets.right, + (int) ((theEnvironmentSize.getHeight() - getHeight()) / 2) + - theInsets.top + theInsets.bottom); + setLocation(theLocation); + } + + /** * Accessor on the implementation. * * @return the implementation. */ - public Component getImplementation() { - Component theResult; - if (mImplementation instanceof Component) { - theResult = (Component) mImplementation; - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } - - return theResult; + public WindowImplementation getImplementation() { + return mImplementation; } /** - * Pack the window. - * - * @see JFrame#pack() - * @see JInternalFrame#pack() + * {@inheritDoc} */ + public Window getProxy() { + return this; + } + + /** + * {@inheritDoc} + */ public void pack() { - if (mImplementation instanceof JFrame) { - ((JFrame) mImplementation).pack(); - } else if (mImplementation instanceof JInternalFrame) { - ((JInternalFrame) mImplementation).pack(); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } + mImplementation.pack(); } /** - * Sets the operation that will happen by default when the user initiates a - * "close" on this window. - * - * @param inOperation operation. - * @see JFrame#setDefaultCloseOperation(int) - * @see JInternalFrame#setDefaultCloseOperation(int) + * {@inheritDoc} */ public void setDefaultCloseOperation(int inOperation) { - if (mImplementation instanceof JFrame) { - ((JFrame) mImplementation).setDefaultCloseOperation(inOperation); - } else if (mImplementation instanceof JInternalFrame) { - ((JInternalFrame) mImplementation) - .setDefaultCloseOperation(inOperation); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } + mImplementation.setDefaultCloseOperation(inOperation); } /** - * Add a window listener to this window. - * - * @param inWindowListener listener to add. - * @see java.awt.Window#addWindowListener(java.awt.event.WindowListener) - * @see JInternalFrame#addInternalFrameListener + * {@inheritDoc} */ public void addWindowListener(WindowListener inWindowListener) { - if (mImplementation instanceof JFrame) { - ((JFrame) mImplementation).addWindowListener( - new ListenerProxy(this, inWindowListener)); - } else if (mImplementation instanceof JInternalFrame) { - ((JInternalFrame) mImplementation).addInternalFrameListener( - new ListenerProxy(this, inWindowListener)); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } + mImplementation.addWindowListener(inWindowListener); } /** - * Add a mouase listener to this window. - * - * @param inMouseListener listener to add. - * @see java.awt.Window#addMouseListener(MouseListener) - * @see JInternalFrame#addMouseListener(MouseListener) + * {@inheritDoc} */ public void addMouseListener(MouseListener inMouseListener) { - if (mImplementation instanceof JFrame) { - ((JFrame) mImplementation).addMouseListener(inMouseListener); - } else if (mImplementation instanceof JInternalFrame) { - ((JInternalFrame) mImplementation).addMouseListener( - inMouseListener); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } + mImplementation.addMouseListener(inMouseListener); } /** - * Sets whether this window is resizable by the user. - * - * @param inResizable if this window should be resizable by the user. - * @see JFrame#setResizable(boolean) - * @see JInternalFrame#setResizable(boolean) + * {@inheritDoc} */ public void setResizable(boolean inResizable) { - if (mImplementation instanceof JFrame) { - ((JFrame) mImplementation).setResizable(inResizable); - } else if (mImplementation instanceof JInternalFrame) { - ((JInternalFrame) mImplementation).setResizable(inResizable); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } + mImplementation.setResizable(inResizable); } /** @@ -254,211 +211,90 @@ } /** - * Get the menu bar for this window. - * - * @return the menu bar for this window. + * {@inheritDoc} */ public JMenuBar getJMenuBar() { - JMenuBar theMenuBar; - if (mImplementation instanceof JFrame) { - theMenuBar = ((JFrame) mImplementation).getJMenuBar(); - } else if (mImplementation instanceof JInternalFrame) { - theMenuBar = ((JInternalFrame) mImplementation).getJMenuBar(); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } - - return theMenuBar; + return mImplementation.getJMenuBar(); } /** - * Set the menu bar for this window. - * - * @param inMenuBar the menu bar for this window. + * {@inheritDoc} */ public void setJMenuBar(JMenuBar inMenuBar) { - if (mImplementation instanceof JFrame) { - ((JFrame) mImplementation).setJMenuBar(inMenuBar); - } else if (mImplementation instanceof JInternalFrame) { - ((JInternalFrame) mImplementation).setJMenuBar(inMenuBar); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } + mImplementation.setJMenuBar(inMenuBar); } /** - * Get the size of this window. - * - * @return the size of this window. + * {@inheritDoc} */ public Dimension getSize() { - Dimension theResult; - if (mImplementation instanceof JFrame) { - theResult = ((JFrame) mImplementation).getSize(); - } else if (mImplementation instanceof JInternalFrame) { - theResult = ((JInternalFrame) mImplementation).getSize(); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } - - return theResult; + return mImplementation.getSize(); } /** - * Set the size of this window. - * - * @param inSize the new size for this window. - * @see Component#setSize(Dimension) + * {@inheritDoc} */ public void setSize(Dimension inSize) { - if (mImplementation instanceof Component) { - ((Component) mImplementation).setSize(inSize); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } + mImplementation.setSize(inSize); } /** - * Set the size of this window. - * - * @param inWidth new width for this window. - * @param inHeight new height. - * @see Component#setSize(int, int) + * {@inheritDoc} */ public void setSize(int inWidth, int inHeight) { - if (mImplementation instanceof Component) { - ((Component) mImplementation).setSize(inWidth, inHeight); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } + mImplementation.setSize(inWidth, inHeight); } /** - * Get the height of this window. - * - * @return the height of this window. - * @see Component#getHeight() + * {@inheritDoc} */ public int getHeight() { - int theResult; - if (mImplementation instanceof Component) { - theResult = ((Component) mImplementation).getHeight(); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } - - return theResult; + return mImplementation.getHeight(); } /** - * Get the insets of this window. - * - * @return the insets of this window. - * @see Container#getInsets() + * {@inheritDoc} */ public Insets getInsets() { - Insets theResult; - if (mImplementation instanceof Component) { - theResult = ((Container) mImplementation).getInsets(); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } - - return theResult; + return mImplementation.getInsets(); } /** - * Get the width of this window. - * - * @return the width of this window. - * @see Component#getWidth() + * {@inheritDoc} */ public int getWidth() { - int theResult; - if (mImplementation instanceof Component) { - theResult = ((Component) mImplementation).getWidth(); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } - - return theResult; + return mImplementation.getWidth(); } /** - * Get the toolkit for this window. - * - * @return the toolkit for this window. - * @see Component#getToolkit() + * {@inheritDoc} */ public Toolkit getToolkit() { - Toolkit theResult; - if (mImplementation instanceof Component) { - theResult = ((Component) mImplementation).getToolkit(); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } - - return theResult; + return mImplementation.getToolkit(); } /** - * Get the location of this window. - * - * @return the location of this window. - * @see Component#getLocation() + * {@inheritDoc} */ public Point getLocation() { - Point theResult; - if (mImplementation instanceof Component) { - theResult = ((Component) mImplementation).getLocation(); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } - - return theResult; + return mImplementation.getLocation(); } /** - * Get the visibility of this window. - * - * @return the visibility of this window. - * @see Component#isVisible() + * {@inheritDoc} */ public boolean isVisible() { - boolean theResult; - if (mImplementation instanceof Component) { - theResult = ((Component) mImplementation).isVisible(); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } - - return theResult; + return mImplementation.isVisible(); } /** - * Set this window visibility. - * - * @param inVisible the new visibility - * @see Component#setVisible(boolean) + * {@inheritDoc} + * + * Also center the window if it's set visible. */ public void setVisible(boolean inVisible) { - if (mImplementation instanceof Component) { - ((Component) mImplementation).setVisible(inVisible); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } + mImplementation.setVisible(inVisible); + if (inVisible && mCenterWindow) { centerWindow(); mCenterWindow = false; @@ -466,188 +302,77 @@ } /** - * Remove (or reset) the decoration for this window. - * - * @param inUndecorated if this window should be undecorated. - * @see JFrame#setUndecorated(boolean) + * {@inheritDoc} */ public void setUndecorated(boolean inUndecorated) { - if (mImplementation instanceof JFrame) { - ((JFrame) mImplementation).setUndecorated(inUndecorated); - } else if (mImplementation instanceof JInternalFrame) { -// ((JInternalFrame) mImplementation).setUndecorated(inUndecorated); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } + mImplementation.setUndecorated(inUndecorated); } /** - * Dispose this window. - * - * @see JFrame#dispose() - * @see JInternalFrame#dispose() + * {@inheritDoc} */ public void dispose() { - if (mImplementation instanceof JFrame) { - ((JFrame) mImplementation).dispose(); - } else if (mImplementation instanceof JInternalFrame) { - ((JInternalFrame) mImplementation).dispose(); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } + mImplementation.dispose(); } /** - * Set the location of this window. - * - * @param inLocation new location for the window. - * @see Component#setLocation(Point) + * {@inheritDoc} */ public void setLocation(Point inLocation) { - if (mImplementation instanceof Component) { - ((Component) mImplementation).setLocation(inLocation); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } + mImplementation.setLocation(inLocation); } /** - * Set the location of this window. - * - * @param inXCoord new x coordinate - * @param inYCoord new y coordinate - * @see Component#setLocation(int, int) + * {@inheritDoc} */ public void setLocation(int inXCoord, int inYCoord) { - if (mImplementation instanceof Component) { - ((Component) mImplementation).setLocation(inXCoord, inYCoord); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } + mImplementation.setLocation(inXCoord, inYCoord); } /** - * Set the bounds of this window. - * - * @param inBounds new bounds for the window. + * {@inheritDoc} */ public void setBounds(Rectangle inBounds) { - if (mImplementation instanceof JFrame) { - ((JFrame) mImplementation).setBounds(inBounds); - } else if (mImplementation instanceof JInternalFrame) { - ((JInternalFrame) mImplementation).setBounds(inBounds); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } + mImplementation.setBounds(inBounds); } /** - * Set the title of this window. - * - * @param inTitle new title for the window. + * {@inheritDoc} */ public void setTitle(String inTitle) { - if (mImplementation instanceof JFrame) { - ((JFrame) mImplementation).setTitle(inTitle); - } else if (mImplementation instanceof JInternalFrame) { - ((JInternalFrame) mImplementation).setTitle(inTitle); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } + mImplementation.setTitle(inTitle); } /** - * Mark this window to be repainted. - * - * @see Component#repaint() + * {@inheritDoc} */ public void repaint() { - if (mImplementation instanceof Component) { - ((Component) mImplementation).repaint(); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } + mImplementation.repaint(); } /** - * Validate this window. - * - * @see Component#validate() + * {@inheritDoc} */ public void validate() { - if (mImplementation instanceof Component) { - ((Component) mImplementation).validate(); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } + mImplementation.validate(); } /** - * Set the focus traversal policy. - * - * @param inPolicy new policy - * @see Container#setFocusTraversalPolicy(FocusTraversalPolicy) + * {@inheritDoc} */ public void setFocusTraversalPolicy(FocusTraversalPolicy inPolicy) { - if (mImplementation instanceof Component) { - ((Container) mImplementation).setFocusTraversalPolicy(inPolicy); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } + mImplementation.setFocusTraversalPolicy(inPolicy); } /** - * Sets whether this window is the root of a focus traversal cycle. - * - * @param inIsRoot new value - * @see Container#setFocusCycleRoot(boolean) + * {@inheritDoc} */ public void setFocusCycleRoot(boolean inIsRoot) { - if (mImplementation instanceof Container) { - ((Container) mImplementation).setFocusCycleRoot(inIsRoot); - } else { - throw new UnsupportedOperationException( - "Unsupported window implementation"); - } + mImplementation.setFocusCycleRoot(inIsRoot); } - - /** - * Center the window on the screen or in the applet. - */ - public final void centerWindow() { - if (!isVisible()) { - mCenterWindow = true; - } - final Dimension theEnvironmentSize = - mGraphicalUserInterface.getEnvironmentSize(); - // Compute the offset. - final Insets theInsets = getInsets(); - final Point theLocation = new Point( - (int) ((theEnvironmentSize.getWidth() - getWidth()) / 2) - - theInsets.left + theInsets.right, - (int) ((theEnvironmentSize.getHeight() - getHeight()) / 2) - - theInsets.top + theInsets.bottom); - setLocation(theLocation); - } } -// ========================================================================= // -// If just one piece of mail gets lost, well, they'll just think they forgot // -// to send it. But if *two* pieces of mail get lost, hell, they'll just // -// think the other guy hasn't gotten around to answering his mail. And if // -// *fifty* pieces of mail get lost, can you imagine it, if *fifty* pieces of // -// mail get lost, why they'll think someone *else* is broken! And if 1Gb of // -// mail gets lost, they'll just *know* that Arpa [ucbarpa.berkeley.edu] is // -// down and think it's a conspiracy to keep them from their God given right // -// to receive Net Mail ... // -// -- Casey Leedom // -// ========================================================================= // +// ===================================================================== // +// The best book on programming for the layman is "Alice in Wonderland"; // +// but that's because it's the best book on anything for the layman. // +// ===================================================================== // Modified: simulacion/src/fr/lip6/sma/simulacion/gui/WindowHook.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/WindowHook.java 2007-05-24 21:22:44 UTC (rev 157) +++ simulacion/src/fr/lip6/sma/simulacion/gui/WindowHook.java 2007-05-24 22:11:07 UTC (rev 158) @@ -45,6 +45,13 @@ * Method called when the window is removed. */ void removeNotify(); + + /** + * Accessor on the window proxy. + * + * @return the window proxy object. + */ + Window getProxy(); } // ========================================================================= // Added: simulacion/src/fr/lip6/sma/simulacion/gui/WindowImplementation.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/WindowImplementation.java (rev 0) +++ simulacion/src/fr/lip6/sma/simulacion/gui/WindowImplementation.java 2007-05-24 22:11:07 UTC (rev 158) @@ -0,0 +1,282 @@ +// ============================== +// File: WindowImplementation.java +// Project: Simulaci\xF3n +// Written by: Paul Guyot (pau...@ac...) +// +// Created on: 20/5/2007 +// Tabs: 4 spaces +// +// This software is governed by the CeCILL license under French law and abiding +// by the rules of distribution of free software. You can use, modify and/ or +// redistribute the software under the terms of the CeCILL license as +// circulated by CEA, CNRS and INRIA at the following URL +// "http://www.cecill.info". +// +// As a counterpart to the access to the source code and rights to copy, modify +// and redistribute granted by the license, users are provided only with a +// limited warranty and the software's author, the holder of the economic +// rights, and the successive licensors have only limited liability. +// +// The fact that you are presently reading this means that you have had +// knowledge of the CeCILL license and that you accept its terms. +// +// =========== +// $Id$ +// =========== + +// paquet +package fr.lip6.sma.simulacion.gui; + +// imports +import java.awt.Dimension; +import java.awt.FocusTraversalPolicy; +import java.awt.Insets; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.awt.event.MouseListener; + +import javax.swing.JMenuBar; +import javax.swing.RootPaneContainer; + +/** + * Interface for a window. + * + * @author Paul Guyot <pau...@ac...> + * @version $Revision$ + */ +public interface WindowImplementation extends RootPaneContainer { + /** + * Pack the window. + * + * @see javax.swing.JFrame#pack() + * @see javax.swing.JInternalFrame#pack() + */ + void pack(); + + /** + * Sets the operation that will happen by default when the user initiates a + * "close" on this window. + * + * @param inOperation operation. + * @see javax.swing.JFrame#setDefaultCloseOperation(int) + * @see javax.swing.JInternalFrame#setDefaultCloseOperation(int) + */ + void setDefaultCloseOperation(int inOperation); + + /** + * Add a window listener to this window. + * + * @param inWindowListener listener to add. + * @see java.awt.Window#addWindowListener(java.awt.event.WindowListener) + * @see javax.swing.JInternalFrame#addInternalFrameListener + */ + void addWindowListener(WindowListener inWindowListener); + + /** + * Add a mouase listener to this window. + * + * @param inMouseListener listener to add. + * @see java.awt.Window#addMouseListener(MouseListener) + * @see javax.swing.JInternalFrame#addMouseListener(MouseListener) + */ + void addMouseListener(MouseListener inMouseListener); + + /** + * Sets whether this window is resizable by the user. + * + * @param inResizable if this window should be resizable by the user. + * @see javax.swing.JFrame#setResizable(boolean) + * @see javax.swing.JInternalFrame#setResizable(boolean) + */ + void setResizable(boolean inResizable); + + /** + * Get the menu bar for this window. + * + * @return the menu bar for this window. + */ + JMenuBar getJMenuBar(); + + /** + * Set the menu bar for this window. + * + * @param inMenuBar the menu bar for this window. + */ + void setJMenuBar(JMenuBar inMenuBar); + + /** + * Get the size of this window. + * + * @return the size of this window. + */ + Dimension getSize(); + + /** + * Set the size of this window. + * + * @param inSize the new size for this window. + * @see java.awt.Component#setSize(Dimension) + */ + void setSize(Dimension inSize); + + /** + * Set the size of this window. + * + * @param inWidth new width for this window. + * @param inHeight new height. + * @see java.awt.Component#setSize(int, int) + */ + void setSize(int inWidth, int inHeight); + + /** + * Get the height of this window. + * + * @return the height of this window. + * @see java.awt.Component#getHeight() + */ + int getHeight(); + + /** + * Get the insets of this window. + * + * @return the insets of this window. + * @see java.awt.Container#getInsets() + */ + Insets getInsets(); + + /** + * Get the width of this window. + * + * @return the width of this window. + * @see java.awt.Component#getWidth() + */ + int getWidth(); + + /** + * Get the toolkit for this window. + * + * @return the toolkit for this window. + * @see java.awt.Component#getToolkit() + */ + Toolkit getToolkit(); + + /** + * Get the location of this window. + * + * @return the location of this window. + * @see java.awt.Component#getLocation() + */ + Point getLocation(); + + /** + * Get the visibility of this window. + * + * @return the visibility of this window. + * @see java.awt.Component#isVisible() + */ + boolean isVisible(); + + /** + * Set this window visibility. + * + * @param inVisible the new visibility + * @see java.awt.Component#setVisible(boolean) + */ + void setVisible(boolean inVisible); + + /** + * Remove (or reset) the decoration for this window. + * + * @param inUndecorated if this window should be undecorated. + * @see javax.swing.JFrame#setUndecorated(boolean) + */ + void setUndecorated(boolean inUndecorated); + + /** + * Dispose this window. + * + * @see javax.swing.JFrame#dispose() + * @see javax.swing.JInternalFrame#dispose() + */ + void dispose(); + + /** + * Set the location of this window. + * + * @param inLocation new location for the window. + * @see java.awt.Component#setLocation(Point) + */ + void setLocation(Point inLocation); + + /** + * Set the location of this window. + * + * @param inXCoord new x coordinate + * @param inYCoord new y coordinate + * @see java.awt.Component#setLocation(int, int) + */ + void setLocation(int inXCoord, int inYCoord); + + /** + * Set the bounds of this window. + * + * @param inBounds new bounds for the window. + */ + void setBounds(Rectangle inBounds); + + /** + * Set the title of this window. + * + * @param inTitle new title for the window. + */ + void setTitle(String inTitle); + + /** + * Mark this window to be repainted. + * + * @see java.awt.Component#repaint() + */ + void repaint(); + + /** + * Validate this window. + * + * @see java.awt.Component#validate() + */ + void validate(); + + /** + * Set the focus traversal policy. + * + * @param inPolicy new policy + * @see java.awt.Container#setFocusTraversalPolicy(FocusTraversalPolicy) + */ + void setFocusTraversalPolicy(FocusTraversalPolicy inPolicy); + + /** + * Sets whether this window is the root of a focus traversal cycle. + * + * @param inIsRoot new value + * @see java.awt.Container#setFocusCycleRoot(boolean) + */ + void setFocusCycleRoot(boolean inIsRoot); +} + +// ========================================================================== // +// The FIELD GUIDE to NORTH AMERICAN MALES // +// // +// SPECIES: Cranial Males // +// SUBSPECIES: The Hacker (homo computatis) // +// Description: // +// Gangly and frail, the hacker has a high forehead and thinning hair. // +// Head disproportionately large and crooked forward, complexion wan and // +// sightly gray from CRT illumination. He has heavy black-rimmed glasses // +// and a look of intense concentration, which may be due to a software // +// problem or to a pork-and-bean breakfast. // +// Feathering: // +// HOMO COMPUTATIS saw a Brylcreem ad fifteen years ago and believed it. // +// Consequently, crest is greased down, except for the cowlick. // +// Song: // +// A rather plaintive "Is it up?" // +// ========================================================================== // Property changes on: simulacion/src/fr/lip6/sma/simulacion/gui/WindowImplementation.java ___________________________________________________________________ Name: svn:executable + * Name: svn:keywords + Revision Id Modified: simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServer.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServer.java 2007-05-24 21:22:44 UTC (rev 157) +++ simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServer.java 2007-05-24 22:11:07 UTC (rev 158) @@ -50,8 +50,6 @@ * * @author Paul Guyot <pau...@ac...> * @version $Revision$ - * - * @see HTTPServerTest */ public final class HTTPServer extends CLIApplication @@ -274,7 +272,7 @@ /** * {@inheritDoc} */ - public final void multicastDNSRegistrationCallBack( + public void multicastDNSRegistrationCallBack( int inRequestID, NetService inService, IOException inException) { @@ -288,7 +286,7 @@ * * Ignored. */ - public final void multicastDNSResolutionCallBack( + public void multicastDNSResolutionCallBack( int inRequestID, NetService inService, IOException inException) { @@ -300,7 +298,7 @@ * * Ignored. */ - public final void multicastDNSBrowserCallBack( + public void multicastDNSBrowserCallBack( int inRequestID, int inBrowserFlags, NetService inService, Modified: simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServerHandler.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServerHandler.java 2007-05-24 21:22:44 UTC (rev 157) +++ simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServerHandler.java 2007-05-24 22:11:07 UTC (rev 158) @@ -312,12 +312,8 @@ (Map<String, Object>) inRequest.getParameter(3); String theResultStr = null; try { - theResultStr = - executeAgentMethod( - theClientID, - theAgentSpecStr, - theMethodName, - theParams); + theResultStr = executeAgentMethod(theClientID, theAgentSpecStr, + theMethodName, theParams); } catch (NetworkAgentException anException) { if (mVerboseMode) { anException.printStackTrace(); @@ -326,12 +322,8 @@ } theResult = theResultStr; if (mVerboseMode) { - logExecuteAgentMethodVerbose( - theClientID, - theAgentSpecStr, - theMethodName, - theParams, - theResultStr); + logExecuteAgentMethodVerbose(theClientID, theAgentSpecStr, + theMethodName, theParams, theResultStr); } } else if (operationName.equals("server.executeAgentMethodAsync")) { final int theClientID = @@ -340,11 +332,8 @@ final String theMethodName = (String) inRequest.getParameter(2); final Map theParams = (Map) inRequest.getParameter(3); try { - executeAgentMethodAsync( - theClientID, - theAgentSpecStr, - theMethodName, - theParams); + executeAgentMethodAsync(theClientID, theAgentSpecStr, + theMethodName, theParams); } catch (NetworkAgentException anException) { if (mVerboseMode) { anException.printStackTrace(); @@ -353,19 +342,14 @@ } theResult = "(void)"; if (mVerboseMode) { - logExecuteAgentMethodVerbose( - theClientID, - theAgentSpecStr, - theMethodName, - theParams, - "(void)"); + logExecuteAgentMethodVerbose(theClientID, theAgentSpecStr, + theMethodName, theParams, "(void)"); } } else if (operationName.equals("server.result")) { - final Integer theOperationID = (Integer) inRequest.getParameter(1); + final Integer theOpID = (Integer) inRequest.getParameter(1); final String theMethodResult = (String) inRequest.getParameter(2); theResult = ""; - final List<Object> theHolder = - mPendingOperations.get(theOperationID); + final List<Object> theHolder = mPendingOperations.get(theOpID); if (theHolder != null) { synchronized (theHolder) { theHolder.add(theMethodResult); @@ -373,12 +357,11 @@ } } } else if (operationName.equals("server.exception")) { - final Integer theOperationID = (Integer) inRequest.getParameter(1); + final Integer theOpID = (Integer) inRequest.getParameter(1); final String theExceptionString = (String) inRequest.getParameter(2); theResult = ""; - final List<Object> theHolder = - mPendingOperations.get(theOperationID); + final List<Object> theHolder = mPendingOperations.get(theOpID); if (theHolder != null) { synchronized (theHolder) { theHolder.add(new Exception(theExceptionString)); Copied: simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServerHandlerTest.java (from rev 146, simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServerTest.java) =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServerHandlerTest.java (rev 0) +++ simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServerHandlerTest.java 2007-05-24 22:11:07 UTC (rev 158) @@ -0,0 +1,151 @@ +// ============================== +// File: HTTPServerHandlerTest.java +// Project: Simulaci\xF3n +// Written by: Paul Guyot (pau...@ac...) +// +// Created on: 22/9/2006 +// Tabs: 4 spaces +// +// This software is governed by the CeCILL license under French law and abiding +// by the rules of distribution of free software. You can use, modify and/ or +// redistribute the software under the terms of the CeCILL license as +// circulated by CEA, CNRS and INRIA at the following URL +// "http://www.cecill.info". +// +// As a counterpart to the access to the source code and rights to copy, modify +// and redistribute granted by the license, users are provided only with a +// limited warranty and the software's author, the holder of the economic +// rights, and the successive licensors have only limited liability. +// +// The fact that you are presently reading this means that you have had +// knowledge of the CeCILL license and that you accept its terms. +// +// =========== +// $Id$ +// =========== + +// paquet +package fr.lip6.sma.simulacion.server.http; + +// imports +import java.lang.reflect.InvocationTargetException; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import fr.lip6.sma.simulacion.test.PrivateAccessor; + +import junit.framework.Assert; +import junit.framework.TestCase; + +/** + * Class for tests of the HTTPServer class. + * + * @author Paul Guyot <pau...@ac...> + * @version $Revision$ + */ +public class HTTPServerHandlerTest extends TestCase { + /** + * Default constructor. + */ + public HTTPServerHandlerTest() { + // This space for rent. + } + + /** + * Set up the test. + */ + protected void setUp() { + // This space for rent. + } + + /** + * Tear down the test. + */ + protected void tearDown() { + // This space for rent. + } + + /** + * Test for the queueEventInList method. + * + * @throws InvocationTargetException if a problem occurs while calling + * the methods. + */ + public void testQueueEventInList() throws InvocationTargetException { + // Create a List. + final List theEventList = new Vector(); + final Map<String, String> theEvent = new Hashtable<String, String>(); + theEvent.put("event", "2"); + callqueueEventInList(theEventList, theEvent); + theEvent.put("event", "3"); + callqueueEventInList(theEventList, theEvent); + theEvent.put("event", "0"); + theEvent.put("priority", "high"); + callqueueEventInList(theEventList, theEvent); + theEvent.put("event", "4"); + theEvent.remove("priority"); + callqueueEventInList(theEventList, theEvent); + theEvent.put("event", "1"); + theEvent.put("priority", "high"); + callqueueEventInList(theEventList, theEvent); + Assert.assertEquals(5, theEventList.size()); + Assert.assertEquals("0", + ((Map) theEventList.get(0)).get("event")); + Assert.assertEquals("1", + ((Map) theEventList.get(1)).get("event")); + Assert.assertEquals("2", + ((Map) theEventList.get(2)).get("event")); + Assert.assertEquals("3", + ((Map) theEventList.get(3)).get("event")); + Assert.assertEquals("4", + ((Map) theEventList.get(4)).get("event")); + + // Create a second List. + theEventList.clear(); + theEvent.put("event", "0"); + theEvent.put("priority", "high"); + callqueueEventInList(theEventList, theEvent); + theEvent.put("event", "1"); + callqueueEventInList(theEventList, theEvent); + theEvent.put("event", "3"); + theEvent.remove("priority"); + callqueueEventInList(theEventList, theEvent); + theEvent.put("event", "2"); + theEvent.put("priority", "high"); + callqueueEventInList(theEventList, theEvent); + Assert.assertEquals(4, theEventList.size()); + Assert.assertEquals("0", + ((Map) theEventList.get(0)).get("event")); + Assert.assertEquals("1", + ((Map) theEventList.get(1)).get("event")); + Assert.assertEquals("2", + ((Map) theEventList.get(2)).get("event")); + Assert.assertEquals("3", + ((Map) theEventList.get(3)).get("event")); + } + + /** + * Call the queueEventInList method. + * + * @param inEventList list of events. + * @param inEvent event to queue. + * @throws InvocationTargetException if a problem occurs while calling + * the method. + */ + private void callqueueEventInList( + List inEventList, + Map<String, String> inEvent) + throws InvocationTargetException { + PrivateAccessor.invokeMethod( + HTTPServerHandler.class, "queueEventInList", + new Object[] {inEventList, + new Hashtable<String, String>(inEvent), + }); + } +} + +// =============================== // +// //GO.SYSIN DD *, DOODAH, DOODAH // +// =============================== // Deleted: simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServerTest.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServerTest.java 2007-05-24 21:22:44 UTC (rev 157) +++ simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServerTest.java 2007-05-24 22:11:07 UTC (rev 158) @@ -1,168 +0,0 @@ -// ============================== -// File: HTTPServerTest.java -// Project: Simulaci\xF3n -// Written by: Paul Guyot (pau...@ac...) -// -// Created on: 22/9/2006 -// Tabs: 4 spaces -// -// This software is governed by the CeCILL license under French law and abiding -// by the rules of distribution of free software. You can use, modify and/ or -// redistribute the software under the terms of the CeCILL license as -// circulated by CEA, CNRS and INRIA at the following URL -// "http://www.cecill.info". -// -// As a counterpart to the access to the source code and rights to copy, modify -// and redistribute granted by the license, users are provided only with a -// limited warranty and the software's author, the holder of the economic -// rights, and the successive licensors have only limited liability. -// -// The fact that you are presently reading this means that you have had -// knowledge of the CeCILL license and that you accept its terms. -// -// =========== -// $Id$ -// =========== - -// paquet -package fr.lip6.sma.simulacion.server.http; - -// imports -import java.lang.reflect.InvocationTargetException; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; -import java.util.Vector; - -import fr.lip6.sma.simulacion.test.PrivateAccessor; - -import junit.framework.Assert; -import junit.framework.TestCase; - -/** - * Class for tests of the HTTPServer class. - * - * @author Paul Guyot <pau...@ac...> - * @version $Revision$ - */ -public class HTTPServerTest extends TestCase { - /** - * Default constructor. - */ - public HTTPServerTest() { - // This space for rent. - } - - /** - * Set up the test. - */ - protected void setUp() { - // This space for rent. - } - - /** - * Tear down the test. - */ - protected void tearDown() { - // This space for rent. - } - - /** - * Test for the queueEventInList method. - * - * @throws InvocationTargetException if a problem occurs while calling - * the methods. - */ - public void testQueueEventInList() throws InvocationTargetException { - // Create a List. - final List theEventList = new Vector(); - final Map<String, String> theEvent = new Hashtable<String, String>(); - theEvent.put("event", "2"); - PrivateAccessor.invokeMethod( - HTTPServer.class, "queueEventInList", - new Object[] {theEventList, - new Hashtable<String, String>(theEvent), - }); - theEvent.put("event", "3"); - PrivateAccessor.invokeMethod( - HTTPServer.class, "queueEventInList", - new Object[] {theEventList, - new Hashtable<String, String>(theEvent), - }); - theEvent.put("event", "0"); - theEvent.put("priority", "high"); - PrivateAccessor.invokeMethod( - HTTPServer.class, "queueEventInList", - new Object[] {theEventList, - new Hashtable<String, String>(theEvent), - }); - theEvent.put("event", "4"); - theEvent.remove("priority"); - PrivateAccessor.invokeMethod( - HTTPServer.class, "queueEventInList", - new Object[] {theEventList, - new Hashtable<String, String>(theEvent), - }); - theEvent.put("event", "1"); - theEvent.put("priority", "high"); - PrivateAccessor.invokeMethod( - HTTPServer.class, "queueEventInList", - new Object[] {theEventList, - new Hashtable<String, String>(theEvent), - }); - Assert.assertEquals(5, theEventList.size()); - Assert.assertEquals("0", - ((Map) theEventList.get(0)).get("event")); - Assert.assertEquals("1", - ((Map) theEventList.get(1)).get("event")); - Assert.assertEquals("2", - ((Map) theEventList.get(2)).get("event")); - Assert.assertEquals("3", - ((Map) theEventList.get(3)).get("event")); - Assert.assertEquals("4", - ((Map) theEventList.get(4)).get("event")); - - // Create a second List. - theEventList.clear(); - theEvent.put("event", "0"); - theEvent.put("priority", "high"); - PrivateAccessor.invokeMethod( - HTTPServer.class, "queueEventInList", - new Object[] {theEventList, - new Hashtable<String, String>(theEvent), - }); - theEvent.put("event", "1"); - PrivateAccessor.invokeMethod( - HTTPServer.class, "queueEventInList", - new Object[] {theEventList, - new Hashtable<String, String>(theEvent), - }); - theEvent.put("event", "3"); - theEvent.remove("priority"); - PrivateAccessor.invokeMethod( - HTTPServer.class, "queueEventInList", - new Object[] {theEventList, - new Hashtable<String, String>(theEvent), - }); - theEvent.put("event", "2"); - theEvent.put("priority", "high"); - PrivateAccessor.invokeMethod( - HTTPServer.class, "queueEventInList", - new Object[] {theEventList, - new Hashtable<String, String>(theEvent), - }); - Assert.assertEquals(4, theEventList.size()); - Assert.assertEquals("0", - ((Map) theEventList.get(0)).get("event")); - Assert.assertEquals("1", - ((Map) theEventList.get(1)).get("event")); - Assert.assertEquals("2", - ((Map) theEventList.get(2)).get("event")); - Assert.assertEquals("3", - ((Map) theEventList.get(3)).get("event")); - } -} - -// =============================== // -// //GO.SYSIN DD *, DOODAH, DOODAH // -// =============================== // This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2007-05-24 21:22:45
|
Revision: 157 http://simulacion.svn.sourceforge.net/simulacion/?rev=157&view=rev Author: pguyot Date: 2007-05-24 14:22:44 -0700 (Thu, 24 May 2007) Log Message: ----------- Fixed the center window method, so the window is properly centered. This is especially important for applets. Modified Paths: -------------- simulacion/src/fr/lip6/sma/simulacion/gui/Window.java Modified: simulacion/src/fr/lip6/sma/simulacion/gui/Window.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/Window.java 2007-05-24 15:25:57 UTC (rev 156) +++ simulacion/src/fr/lip6/sma/simulacion/gui/Window.java 2007-05-24 21:22:44 UTC (rev 157) @@ -65,6 +65,11 @@ private final GraphicalUserInterface mGraphicalUserInterface; /** + * If we should center the window. + */ + private boolean mCenterWindow; + + /** * Default constructor. */ public Window() { @@ -424,6 +429,24 @@ } /** + * Get the visibility of this window. + * + * @return the visibility of this window. + * @see Component#isVisible() + */ + public boolean isVisible() { + boolean theResult; + if (mImplementation instanceof Component) { + theResult = ((Component) mImplementation).isVisible(); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + + return theResult; + } + + /** * Set this window visibility. * * @param inVisible the new visibility @@ -436,6 +459,10 @@ throw new UnsupportedOperationException( "Unsupported window implementation"); } + if (inVisible && mCenterWindow) { + centerWindow(); + mCenterWindow = false; + } } /** @@ -597,19 +624,18 @@ * Center the window on the screen or in the applet. */ public final void centerWindow() { + if (!isVisible()) { + mCenterWindow = true; + } final Dimension theEnvironmentSize = mGraphicalUserInterface.getEnvironmentSize(); // Compute the offset. - // FIXME: looks like there is still a horizontal problem, - // maybe the insets are not valid yet. final Insets theInsets = getInsets(); final Point theLocation = new Point( - (int) ((theEnvironmentSize.getWidth() - getWidth() - - theInsets.left - theInsets.right) / 2) - - theInsets.left, - (int) ((theEnvironmentSize.getHeight() - getHeight() - - theInsets.top - theInsets.bottom) / 2) - - theInsets.top); + (int) ((theEnvironmentSize.getWidth() - getWidth()) / 2) + - theInsets.left + theInsets.right, + (int) ((theEnvironmentSize.getHeight() - getHeight()) / 2) + - theInsets.top + theInsets.bottom); setLocation(theLocation); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2007-05-24 15:25:59
|
Revision: 156 http://simulacion.svn.sourceforge.net/simulacion/?rev=156&view=rev Author: pguyot Date: 2007-05-24 08:25:57 -0700 (Thu, 24 May 2007) Log Message: ----------- Center the windows with the applet (nearly complete). Modified Paths: -------------- simulacion/src/fr/lip6/sma/simulacion/app/LocalizedWindow.java simulacion/src/fr/lip6/sma/simulacion/gui/GraphicalUserInterface.java simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java simulacion/src/fr/lip6/sma/simulacion/gui/SwingApplicationGUI.java simulacion/src/fr/lip6/sma/simulacion/gui/Window.java Modified: simulacion/src/fr/lip6/sma/simulacion/app/LocalizedWindow.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/app/LocalizedWindow.java 2007-05-24 15:19:28 UTC (rev 155) +++ simulacion/src/fr/lip6/sma/simulacion/app/LocalizedWindow.java 2007-05-24 15:25:57 UTC (rev 156) @@ -186,17 +186,6 @@ } /** - * M\xE9thode pour centrer la fen\xEAtre. - */ - protected final void centerWindow() { - final Dimension theScreenSize = getToolkit().getScreenSize(); - final Point theLocation = new Point( - (int) ((theScreenSize.getWidth() - getWidth()) / 2), - (int) ((theScreenSize.getHeight() - getHeight()) / 2)); - setLocation(theLocation); - } - - /** * M\xE9thode appel\xE9e pour quitter. On ferme la fen\xEAtre puis on quitte * l'application. */ Modified: simulacion/src/fr/lip6/sma/simulacion/gui/GraphicalUserInterface.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/GraphicalUserInterface.java 2007-05-24 15:19:28 UTC (rev 155) +++ simulacion/src/fr/lip6/sma/simulacion/gui/GraphicalUserInterface.java 2007-05-24 15:25:57 UTC (rev 156) @@ -28,6 +28,8 @@ package fr.lip6.sma.simulacion.gui; // imports +import java.awt.Dimension; + import javax.swing.RootPaneContainer; /** @@ -66,6 +68,14 @@ } /** + * Get the dimension of the environment where windows are layed out + * (applet, screen). + * + * @return the dimension of the environment. + */ + public abstract Dimension getEnvironmentSize(); + + /** * Create a window. * * @param inHook hook for the subclass method calls. Modified: simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java 2007-05-24 15:19:28 UTC (rev 155) +++ simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java 2007-05-24 15:25:57 UTC (rev 156) @@ -28,6 +28,8 @@ package fr.lip6.sma.simulacion.gui; // imports +import java.awt.Dimension; + import javax.swing.JInternalFrame; import javax.swing.RootPaneContainer; @@ -44,6 +46,65 @@ private final BaseApplet mApplet; /** + * Class for the internal frames in the applet. + */ + private static final class AppletFrame extends JInternalFrame { + /** + * Reference on the hook for overridden methods. + */ + private final WindowHook mHook; + + /** + * Reference on the applet we belong to. + */ + private final BaseApplet mApplet; + + /** + * If we've been added to the applet. + */ + private boolean mAdded; + + /** + * Constructor from the hook and the applet. + * + * @param inHook hook for overriden methods. + * @param inApplet applet we belong to. + */ + private AppletFrame(WindowHook inHook, BaseApplet inApplet) { + mHook = inHook; + mApplet = inApplet; + } + + /** + * {@inheritDoc} + */ + public void addNotify() { + super.addNotify(); + mHook.addNotify(); + } + + /** + * {@inheritDoc} + */ + public void removeNotify() { + super.removeNotify(); + mHook.removeNotify(); + } + + /** + * {@inheritDoc} + */ + public void setVisible(boolean inVisible) { + if (inVisible && !mAdded) { + mAdded = true; + mApplet.add(this); + } + + super.setVisible(inVisible); + } + } + + /** * Constructor from the base applet. * * @param inApplet reference on the base applet. @@ -53,50 +114,28 @@ } /** + * {@inheritDoc} + */ + public Dimension getEnvironmentSize() { + return mApplet.getSize(); + } + + /** * Create a window. * * @param inHook hook for the subclass method calls. * @return a new window. */ public RootPaneContainer createWindow(final WindowHook inHook) { - final JInternalFrame theResult = new JInternalFrame() { - /** - * If we've been added to the applet. - */ - private boolean mAdded; - - public void addNotify() { - super.addNotify(); - inHook.addNotify(); - } - - public void removeNotify() { - super.removeNotify(); - inHook.removeNotify(); - } - - public void setVisible(boolean inVisible) { - if (inVisible && !mAdded) { - mAdded = true; - mApplet.add(this); - } - - super.setVisible(inVisible); - } - }; + final JInternalFrame theResult = new AppletFrame(inHook, mApplet); return theResult; } } -// ========================================================================= // -// If just one piece of mail gets lost, well, they'll just think they forgot // -// to send it. But if *two* pieces of mail get lost, hell, they'll just // -// think the other guy hasn't gotten around to answering his mail. And if // -// *fifty* pieces of mail get lost, can you imagine it, if *fifty* pieces of // -// mail get lost, why they'll think someone *else* is broken! And if 1Gb of // -// mail gets lost, they'll just *know* that Arpa [ucbarpa.berkeley.edu] is // -// down and think it's a conspiracy to keep them from their God given right // -// to receive Net Mail ... // -// -- Casey Leedom // -// ========================================================================= // +// ====================================================================== // +// Thus spake the master programmer: // +// "Without the wind, the grass does not move. Without software, // +// hardware is useless." // +// -- Geoffrey James, "The Tao of Programming" // +// ====================================================================== // Modified: simulacion/src/fr/lip6/sma/simulacion/gui/SwingApplicationGUI.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/SwingApplicationGUI.java 2007-05-24 15:19:28 UTC (rev 155) +++ simulacion/src/fr/lip6/sma/simulacion/gui/SwingApplicationGUI.java 2007-05-24 15:25:57 UTC (rev 156) @@ -28,6 +28,9 @@ package fr.lip6.sma.simulacion.gui; // imports +import java.awt.Dimension; +import java.awt.Toolkit; + import javax.swing.JFrame; import javax.swing.RootPaneContainer; @@ -44,6 +47,13 @@ SwingApplicationGUI() { // This space for rent. } + + /** + * {@inheritDoc} + */ + public Dimension getEnvironmentSize() { + return Toolkit.getDefaultToolkit().getScreenSize(); + } /** * Create a window. Modified: simulacion/src/fr/lip6/sma/simulacion/gui/Window.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/Window.java 2007-05-24 15:19:28 UTC (rev 155) +++ simulacion/src/fr/lip6/sma/simulacion/gui/Window.java 2007-05-24 15:25:57 UTC (rev 156) @@ -32,6 +32,7 @@ import java.awt.Container; import java.awt.Dimension; import java.awt.FocusTraversalPolicy; +import java.awt.Insets; import java.awt.Point; import java.awt.Rectangle; import java.awt.Toolkit; @@ -59,11 +60,18 @@ private final RootPaneContainer mImplementation; /** + * Reference on the GUI. + */ + private final GraphicalUserInterface mGraphicalUserInterface; + + /** * Default constructor. */ public Window() { + // Note the associated GUI. + mGraphicalUserInterface = GraphicalUserInterface.getGUI(); // Ask the GUI for a window implementation. - mImplementation = GraphicalUserInterface.getGUI().createWindow(this); + mImplementation = mGraphicalUserInterface.createWindow(this); } /** @@ -344,6 +352,24 @@ } /** + * Get the insets of this window. + * + * @return the insets of this window. + * @see Container#getInsets() + */ + public Insets getInsets() { + Insets theResult; + if (mImplementation instanceof Component) { + theResult = ((Container) mImplementation).getInsets(); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + + return theResult; + } + + /** * Get the width of this window. * * @return the width of this window. @@ -566,6 +592,26 @@ "Unsupported window implementation"); } } + + /** + * Center the window on the screen or in the applet. + */ + public final void centerWindow() { + final Dimension theEnvironmentSize = + mGraphicalUserInterface.getEnvironmentSize(); + // Compute the offset. + // FIXME: looks like there is still a horizontal problem, + // maybe the insets are not valid yet. + final Insets theInsets = getInsets(); + final Point theLocation = new Point( + (int) ((theEnvironmentSize.getWidth() - getWidth() + - theInsets.left - theInsets.right) / 2) + - theInsets.left, + (int) ((theEnvironmentSize.getHeight() - getHeight() + - theInsets.top - theInsets.bottom) / 2) + - theInsets.top); + setLocation(theLocation); + } } // ========================================================================= // This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2007-05-24 15:21:17
|
Revision: 155 http://simulacion.svn.sourceforge.net/simulacion/?rev=155&view=rev Author: pguyot Date: 2007-05-24 08:19:28 -0700 (Thu, 24 May 2007) Log Message: ----------- Cleanup. Modified Paths: -------------- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java Modified: simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java 2007-05-24 14:32:37 UTC (rev 154) +++ simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java 2007-05-24 15:19:28 UTC (rev 155) @@ -32,7 +32,6 @@ import java.net.ConnectException; import java.net.URL; import java.security.AccessControlException; -import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.PropertyPermission; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2007-05-24 14:32:39
|
Revision: 154 http://simulacion.svn.sourceforge.net/simulacion/?rev=154&view=rev Author: pguyot Date: 2007-05-24 07:32:37 -0700 (Thu, 24 May 2007) Log Message: ----------- Fixed a bug introduced with the transition to XmlRpc 3.0 that prevented the HTTP clients to get the result of method calls. Modified Paths: -------------- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java Modified: simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java 2007-05-24 10:40:21 UTC (rev 153) +++ simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java 2007-05-24 14:32:37 UTC (rev 154) @@ -32,6 +32,7 @@ import java.net.ConnectException; import java.net.URL; import java.security.AccessControlException; +import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.PropertyPermission; @@ -284,26 +285,33 @@ notifyAll(); } - if (inResult != null && inResult instanceof List) { - // Le r\xE9sultat est un vecteur de hashtable. - final List<Map> theEventList = (List<Map>) inResult; - + Object[] theEventArray = null; + if (inResult instanceof List) { + // The result is a list. + theEventArray = ((List) inResult).toArray(); + } else if (inResult instanceof Object[]) { + theEventArray = (Object[]) inResult; + } + + if (theEventArray != null) { // It\xE9ration sur la liste. - for (final Map theEvent : theEventList) { - // Gestion de l'\xE9v\xE9nement. - final Thread theEventRunner = new Thread() { - public void run() { - // CSOFF: IllegalCatch - try { - processEvent(theEvent); - } catch (Throwable aThrowable) { - aThrowable.printStackTrace(); + for (final Object theEventObj : theEventArray) { + if (theEventObj instanceof Map) { + final Map theEvent = (Map) theEventObj; + // Gestion de l'\xE9v\xE9nement. + final Thread theEventRunner = new Thread() { + public void run() { + // CSOFF: IllegalCatch + try { + processEvent(theEvent); + } catch (Throwable aThrowable) { + aThrowable.printStackTrace(); + } + // CSON: IllegalCatch } - // CSON: IllegalCatch - } - }; - - theEventRunner.start(); + }; + theEventRunner.start(); + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2007-05-24 10:40:24
|
Revision: 153 http://simulacion.svn.sourceforge.net/simulacion/?rev=153&view=rev Author: pguyot Date: 2007-05-24 03:40:21 -0700 (Thu, 24 May 2007) Log Message: ----------- Fixed yet another problem with the Applet limited environment. SimProtocol now works within appletviewer. Modified Paths: -------------- simulacion/src/fr/lip6/sma/simulacion/app/ApplicationWindow.java Modified: simulacion/src/fr/lip6/sma/simulacion/app/ApplicationWindow.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/app/ApplicationWindow.java 2007-05-24 10:35:48 UTC (rev 152) +++ simulacion/src/fr/lip6/sma/simulacion/app/ApplicationWindow.java 2007-05-24 10:40:21 UTC (rev 153) @@ -78,6 +78,8 @@ theAppleClassIsThere = false; } catch (AccessControlException anIgnoredException) { theAppleClassIsThere = false; + } catch (NoClassDefFoundError anIgnoredException) { + theAppleClassIsThere = false; } if (theAppleClassIsThere) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2007-05-24 10:35:51
|
Revision: 152 http://simulacion.svn.sourceforge.net/simulacion/?rev=152&view=rev Author: pguyot Date: 2007-05-24 03:35:48 -0700 (Thu, 24 May 2007) Log Message: ----------- Use the lite http transport when we cannot read properties, instead of the default transport that does not work. Modified Paths: -------------- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java Modified: simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java 2007-05-24 09:12:21 UTC (rev 151) +++ simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java 2007-05-24 10:35:48 UTC (rev 152) @@ -43,6 +43,7 @@ import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; import org.apache.xmlrpc.client.XmlRpcCommonsTransportFactory; +import org.apache.xmlrpc.client.XmlRpcLiteHttpTransportFactory; import fr.lip6.sma.simulacion.app.Configuration; import fr.lip6.sma.simulacion.server.AgentException; @@ -152,8 +153,9 @@ mXmlRpcClient.setTransportFactory( new XmlRpcCommonsTransportFactory(mXmlRpcClient)); } catch (AccessControlException anException) { - // Simply ignore it (and use default HTTP client). - anException.printStackTrace(); + // Simply ignore it (and use the light HTTP client). + mXmlRpcClient.setTransportFactory( + new XmlRpcLiteHttpTransportFactory(mXmlRpcClient)); } mXmlRpcClient.setConfig(theConfig); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2007-05-24 09:12:22
|
Revision: 151 http://simulacion.svn.sourceforge.net/simulacion/?rev=151&view=rev Author: pguyot Date: 2007-05-24 02:12:21 -0700 (Thu, 24 May 2007) Log Message: ----------- Use extensions, but put the content header. Modified Paths: -------------- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServlet.java Modified: simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java 2007-05-24 08:22:16 UTC (rev 150) +++ simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java 2007-05-24 09:12:21 UTC (rev 151) @@ -32,7 +32,6 @@ import java.net.ConnectException; import java.net.URL; import java.security.AccessControlException; -import java.security.AccessController; import java.util.List; import java.util.Map; import java.util.PropertyPermission; @@ -134,6 +133,8 @@ final XmlRpcClientConfigImpl theConfig = new XmlRpcClientConfigImpl(); theConfig.setServerURL(new URL(inURL)); + theConfig.setEnabledForExtensions(true); + theConfig.setContentLengthOptional(false); mXmlRpcClient = new XmlRpcClient(); // If we can read system properties, use Jakarta commons http client // for HTTP requests. Modified: simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServlet.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServlet.java 2007-05-24 08:22:16 UTC (rev 150) +++ simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServlet.java 2007-05-24 09:12:21 UTC (rev 151) @@ -75,10 +75,11 @@ throws XmlRpcException { final XmlRpcServletServer theResult = super.newXmlRpcServer(inConfig); - // Force to use extensions. + // Force to use extensions and to put the content-length header. final XmlRpcServerConfigImpl theServerConfig = (XmlRpcServerConfigImpl) theResult.getConfig(); theServerConfig.setEnabledForExtensions(true); + theServerConfig.setContentLengthOptional(false); return theResult; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2007-05-24 08:22:19
|
Revision: 150 http://simulacion.svn.sourceforge.net/simulacion/?rev=150&view=rev Author: pguyot Date: 2007-05-24 01:22:16 -0700 (Thu, 24 May 2007) Log Message: ----------- Update of the network code. Use of a servlet. Modified Paths: -------------- simulacion/.classpath simulacion/_Build_/Ant/build.xml simulacion/_Build_/Ant/simulacion-ant.xml simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPConsts.java simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServer.java Added Paths: ----------- simulacion/lib/jetty-6.1.3.jar simulacion/lib/jetty-util-6.1.3.jar simulacion/lib/servlet-api-2.5-6.1.3.jar simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServerHandler.java simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServlet.java Removed Paths: ------------- simulacion/lib/servletapi-2.2.jar Modified: simulacion/.classpath =================================================================== --- simulacion/.classpath 2007-05-24 05:34:49 UTC (rev 149) +++ simulacion/.classpath 2007-05-24 08:22:16 UTC (rev 150) @@ -19,6 +19,7 @@ <classpathentry kind="lib" path="lib/xmlrpc-client-3.0.jar"/> <classpathentry kind="lib" path="lib/xmlrpc-common-3.0.jar"/> <classpathentry kind="lib" path="lib/xmlrpc-server-3.0.jar"/> + <classpathentry kind="lib" path="lib/servlet-api-2.5-6.1.3.jar"/> + <classpathentry kind="src" path="src"/> <classpathentry kind="output" path="bin"/> - <classpathentry kind="src" path="src"/> </classpath> Modified: simulacion/_Build_/Ant/build.xml =================================================================== --- simulacion/_Build_/Ant/build.xml 2007-05-24 05:34:49 UTC (rev 149) +++ simulacion/_Build_/Ant/build.xml 2007-05-24 08:22:16 UTC (rev 150) @@ -40,7 +40,7 @@ </loadfile> <property name="src.dir" value="${base.dir}/src/" /> <property name="build.dir" value="build" /> - <property name="cp-jars" value="${base.dir}/lib/Java-mDNS.jar:${base.dir}/lib/jmdns.jar:${base.dir}/lib/junit-4.3.1.jar:${base.dir}/lib/ws-commons-util-1.0.1.jar:${base.dir}/lib/xmlrpc-client-3.0.jar:${base.dir}/lib/xmlrpc-common-3.0.jar:${base.dir}/lib/xmlrpc-server-3.0.jar:${base.dir}/lib/kawa-1.8beta.jar:${base.dir}/lib/jazzy.jar:${base.dir}/lib/AppleJavaExtensions.jar" /> + <property name="cp-jars" value="${base.dir}/lib/AppleJavaExtensions.jar:${base.dir}/lib/Java-mDNS.jar:${base.dir}/lib/jazzy.jar:${base.dir}/lib/jetty-6.1.3.jar:${base.dir}/lib/jetty-util-6.1.3.jar:${base.dir}/lib/jmdns.jar:${base.dir}/lib/junit-4.3.1.jar:${base.dir}/lib/kawa-1.8beta.jar:${base.dir}/lib/servlet-api-2.5-6.1.3.jar:${base.dir}/lib/ws-commons-util-1.0.1.jar:${base.dir}/lib/xmlrpc-client-3.0.jar:${base.dir}/lib/xmlrpc-common-3.0.jar:${base.dir}/lib/xmlrpc-server-3.0.jar" /> <property environment="env" /> <property name="checkstyle-jars" value="${env.ANT_HOME}/lib/ant.jar:${base.dir}/lib/checkstyle-4.3.jar:${base.dir}/lib/checkstyle-optional-4.3.jar:${base.dir}/lib/antlr.jar:${base.dir}/lib/jakarta-regexp-1.3.jar:${base.dir}/lib/commons-beanutils-core.jar:${base.dir}/lib/commons-collections.jar:${base.dir}/lib/commons-logging-1.1.jar" /> <taskdef resource="checkstyletask.properties" classpath="${checkstyle-jars}"/> Modified: simulacion/_Build_/Ant/simulacion-ant.xml =================================================================== --- simulacion/_Build_/Ant/simulacion-ant.xml 2007-05-24 05:34:49 UTC (rev 149) +++ simulacion/_Build_/Ant/simulacion-ant.xml 2007-05-24 08:22:16 UTC (rev 150) @@ -91,7 +91,7 @@ </patternset> <property name="checkstyle-jars" value="${env.ANT_HOME}/lib/ant.jar:${simulacion.dir}/lib/checkstyle-4.3.jar:${simulacion.dir}/lib/checkstyle-optional-4.3.jar:${simulacion.dir}/lib/antlr.jar:${simulacion.dir}/lib/jakarta-regexp-1.3.jar:${simulacion.dir}/lib/commons-beanutils-core.jar:${simulacion.dir}/lib/commons-codec-1.3.jar:${simulacion.dir}/lib/commons-httpclient-3.0.1.jar:${simulacion.dir}/lib/commons-logging-1.1.jar" /> - <patternset id="simulacion-runtime-libs" includes="commons-codec-1.3.jar commons-collections-3.2.jar commons-httpclient-3.0.1.jar commons-logging-1.1.jar Java-mDNS.jar jmdns.jar ws-commons-util-1.0.1.jar xercesImpl.jar xmlrpc-client-3.0.jar xmlrpc-common-3.0.jar xmlrpc-server-3.0.jar" /> + <patternset id="simulacion-runtime-libs" includes="commons-codec-1.3.jar commons-collections-3.2.jar commons-httpclient-3.0.1.jar commons-logging-1.1.jar Java-mDNS.jar jetty-6.1.3.jar jetty-util-6.1.3.jar jmdns.jar servlet-api-2.5-6.1.3.jar ws-commons-util-1.0.1.jar xercesImpl.jar xmlrpc-client-3.0.jar xmlrpc-common-3.0.jar xmlrpc-server-3.0.jar" /> <patternset id="runtime-libs" includes="" /> <!-- Check the version of Simulación --> Added: simulacion/lib/jetty-6.1.3.jar =================================================================== (Binary files differ) Property changes on: simulacion/lib/jetty-6.1.3.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: simulacion/lib/jetty-util-6.1.3.jar =================================================================== (Binary files differ) Property changes on: simulacion/lib/jetty-util-6.1.3.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: simulacion/lib/servlet-api-2.5-6.1.3.jar =================================================================== (Binary files differ) Property changes on: simulacion/lib/servlet-api-2.5-6.1.3.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Deleted: simulacion/lib/servletapi-2.2.jar =================================================================== (Binary files differ) Modified: simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java 2007-05-24 05:34:49 UTC (rev 149) +++ simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java 2007-05-24 08:22:16 UTC (rev 150) @@ -31,8 +31,11 @@ import java.io.IOException; import java.net.ConnectException; import java.net.URL; +import java.security.AccessControlException; +import java.security.AccessController; import java.util.List; import java.util.Map; +import java.util.PropertyPermission; import java.util.Vector; import org.apache.xmlrpc.XmlRpcException; @@ -132,8 +135,25 @@ new XmlRpcClientConfigImpl(); theConfig.setServerURL(new URL(inURL)); mXmlRpcClient = new XmlRpcClient(); - mXmlRpcClient.setTransportFactory( - new XmlRpcCommonsTransportFactory(mXmlRpcClient)); + // If we can read system properties, use Jakarta commons http client + // for HTTP requests. + try { + final SecurityManager theSecurityMgr = + System.getSecurityManager(); + if (theSecurityMgr != null) { + final PropertyPermission thePerm = + new PropertyPermission( + "org.apache.commons.logging.LogFactory" + + ".HashtableImpl", + "read"); + theSecurityMgr.checkPermission(thePerm); + } + mXmlRpcClient.setTransportFactory( + new XmlRpcCommonsTransportFactory(mXmlRpcClient)); + } catch (AccessControlException anException) { + // Simply ignore it (and use default HTTP client). + anException.printStackTrace(); + } mXmlRpcClient.setConfig(theConfig); // Appel de la m\xE9thode getVersion. Modified: simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPConsts.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPConsts.java 2007-05-24 05:34:49 UTC (rev 149) +++ simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPConsts.java 2007-05-24 08:22:16 UTC (rev 150) @@ -87,6 +87,13 @@ = "fr.lip6.sma.simulacion.gameid"; /** + * Determine if we should run the server in verbose mode. The mode can also + * be enabled on the command line. + */ + static final String VERBOSE_MODE_PROPERTY + = "fr.lip6.sma.simulacion.server.verbose"; + + /** * mDNS service type prefix for the HTTP server. */ static final String MDNS_SERVICE_TYPE Modified: simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServer.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServer.java 2007-05-24 05:34:49 UTC (rev 149) +++ simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServer.java 2007-05-24 08:22:16 UTC (rev 150) @@ -29,24 +29,12 @@ // imports import java.io.IOException; -import java.io.InterruptedIOException; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.ListIterator; -import java.util.Map; -import java.util.Timer; -import java.util.TimerTask; -import java.util.Vector; -import org.apache.xmlrpc.XmlRpcException; -import org.apache.xmlrpc.XmlRpcHandler; -import org.apache.xmlrpc.XmlRpcRequest; -import org.apache.xmlrpc.server.XmlRpcServer; -import org.apache.xmlrpc.server.XmlRpcServerConfigImpl; -import org.apache.xmlrpc.webserver.WebServer; +import javax.servlet.ServletException; +import org.apache.xmlrpc.webserver.ServletWebServer; +import org.apache.xmlrpc.webserver.XmlRpcServlet; + import com.kallisys.zeroconf.MDNSException; import com.kallisys.zeroconf.MulticastDNSClient; import com.kallisys.zeroconf.MulticastDNSServer; @@ -55,10 +43,7 @@ import fr.lip6.sma.simulacion.app.CLIApplication; 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; -import fr.lip6.sma.simulacion.server.xmlrpc.SimpleHandlerMapping; /** * Classe pour le serveur HTTP qui g\xE8re les diff\xE9rents clients. @@ -68,193 +53,45 @@ * * @see HTTPServerTest */ -public class HTTPServer +public final class HTTPServer extends CLIApplication - implements MulticastDNSClient, XmlRpcHandler { + implements MulticastDNSClient { /** - * Classe pour les donn\xE9es sur un client. - * Cette classe g\xE8re aussi la temporisation du client, i.e. elle d\xE9termine - * si \xE7a fait trop longtemps qu'on n'a pas entendu parler du client. + * Reference on the web server. */ - private final class ClientData { - /** - * Identifiant du client. - */ - private final int mClientID; - - /** - * Dur\xE9e maximale depuis laquelle on veut avoir entendu le client. - * En millisecondes. - */ - private final int mTimeout; - - /** - * Liste des \xE9v\xE9nements pour ce client. - */ - private final List<Map<String, Object>> mEvents; - - /** - * Liste des \xE9v\xE9nements pour ce client. - */ - private final Timer mTimer; - - /** - * T\xE2che de timeout courante. - */ - private TimerTask mTimerTask; - - /** - * Flag indicating that the client seems to be dead. - */ - private boolean mLooksDead; - - /** - * Constructeur \xE0 partir de l'identifiant du client et du temps maximal - * pendant lequel on accepte de ne pas entendre parler du client. - * - * @param inClientID identifiant du client. - * @param inTimeout dur\xE9e maximale depuis laquelle on veut avoir - * entendu le client, en millisecondes. - */ - private ClientData(int inClientID, int inTimeout) { - mClientID = inClientID; - mTimeout = inTimeout; - mEvents = new LinkedList<Map<String, Object>>(); - mTimer = new Timer(); - mLooksDead = false; - - // Au d\xE9part, le client n'\xE9coute pas. - resetTimer(); - } - - /** - * (Re)lance la t\xE2che de temporisation. - */ - public void resetTimer() { - synchronized (mTimer) { - mLooksDead = false; - if (mTimerTask != null) { - mTimerTask.cancel(); - } - mTimerTask = new TimerTask() { - public void run() { - // Le client semble mort. - println("Client " + mClientID + " seems to be dead."); - mLooksDead = true; - } - }; - - try { - mTimer.schedule(mTimerTask, mTimeout); - } catch (IllegalStateException anException) { - // C'est rien, on est juste en train de fermer. - } - } - } - - /** - * Accesseur sur la liste des \xE9v\xE9nements. - * - * @return la liste des \xE9v\xE9nements. - */ - private List<Map<String, Object>> getEvents() { - return mEvents; - } - - /** - * Accessor on the looks dead property. - * - * @return <code>true</code> if the client seems dead, - * <code>false</code> otherwise. - */ - private boolean doesLookDead() { - return mLooksDead; - } - - /** - * Extinction de la t\xE2che de temporisation. - */ - private void shutdown() { - synchronized (mTimer) { - if (mTimerTask != null) { - mTimerTask.cancel(); - mTimerTask = null; - } - - mTimer.cancel(); - } - } - } + private final ServletWebServer mServer; /** - * If we're in verbose mode. - */ - private final boolean mVerboseMode; - - /** - * R\xE9f\xE9rence sur le serveur. - */ - private final WebServer mServer; - - /** * Reference to the mDNS server (or <code>null</code> if we don't publish * the server over mDNS). */ private final MulticastDNSServer mMDNSServer; /** - * Registration operation ID or 0 if we don't register to the mDNS server. + * Reference on the HTTP server handler. */ - private final int mMDNSRegistrationOpID; + private final HTTPServerHandler mHandler; /** - * Identification du jeu. + * Reference on the configuration. */ - private final String mGameID; + private final Configuration mConfiguration; /** - * La liste des \xE9v\xE9nements pour les clients. - * Les cl\xE9s sont les identifiants des clients et les valeurs - * des ClientData. + * Reference on the MDNS registration ID. */ - private final Map<Integer, ClientData> mClients; + private int mMDNSRegistrationOpID; /** - * ID du prochain client. - */ - private int mClientNextID; - - /** - * La liste des op\xE9rations en cours. - * Les cl\xE9s sont les identifiants des op\xE9rations et les valeurs des - * vecteurs \xE0 un \xE9l\xE9ment pour accueillir le r\xE9sultat. - */ - private final Map<Integer, List<Object>> mPendingOperations; - - /** - * ID de la prochaine op\xE9ration. + * Constructor from the command line arguments. * - * Remarque: une op\xE9ration a une dur\xE9e de vie limit\xE9e, par cons\xE9quent - * ce nombre peut \xEAtre sur 32 bits. + * @param inArgs arguments on the command line. + * @throws ServletException if we could not create the server. */ - private int mOperationNextID; - - /** - * La liste des agents enregistr\xE9s. - * Les cl\xE9s sont les cl\xE9s de la forme Classe:Nom. - * Les valeurs sont les ID des clients correspondant. - */ - private final Map<AgentSpecification, Integer> mAgentsRegistry; - - /** - * Constructeur \xE0 partir des arguments. - * - * @param inArgs arguments sur la ligne de commande - */ - public HTTPServer(String[] inArgs) { + public HTTPServer(String[] inArgs) throws ServletException { super(HTTPServer.class.getName()); - // V\xE9rification qu'on a un ou deux arguments. + // Check that we have one or two arguments. if ((inArgs.length != 1) && (inArgs.length != 2)) { usage(); System.exit(1); @@ -272,36 +109,25 @@ } } - mVerboseMode = verbose; - - // Le premier param\xE8tre est le chemin vers le fichier de configuration. - final Configuration theConfig = + // The first parameter is the path to the configuration file. + mConfiguration = Configuration.getConfiguration(inArgs[configArgIx]); - // R\xE9cup\xE9ration du port. + // Find the port. final String thePortProperty = - theConfig.getProperty(HTTPConsts.PORT_PROPERTY); + mConfiguration.getProperty(HTTPConsts.PORT_PROPERTY); int thePort = HTTPConsts.DEFAULT_PORT; if (thePortProperty != null) { thePort = Integer.parseInt(thePortProperty); } - // R\xE9cup\xE9ration du jeu et de la version. - final String theGameProperty = - theConfig.getProperty(HTTPConsts.GAMEID_PROPERTY); - - if (theGameProperty == null) { - println( - "Can't find the game ID (property " - + HTTPConsts.GAMEID_PROPERTY + ")"); - } - - mGameID = theGameProperty; + // Create the server handler. + mHandler = new HTTPServerHandler(mConfiguration, verbose); // Create mDNS server (if we publish over mDNS). final String theMDNSProperty = - theConfig.getProperty(HTTPConsts.ZEROCONF_PUBLISH_PROPERTY); + mConfiguration.getProperty(HTTPConsts.ZEROCONF_PUBLISH_PROPERTY); if ((theMDNSProperty != null) && (Boolean.valueOf(theMDNSProperty).booleanValue())) { MulticastDNSServer theMDNSServer = null; @@ -316,51 +142,11 @@ } else { mMDNSServer = null; } - - // Cr\xE9ation de la liste des \xE9v\xE9nements pour les clients. - mClients = new Hashtable<Integer, ClientData>(); - - // Cr\xE9ation de la liste des op\xE9rations. - mPendingOperations = new Hashtable<Integer, List<Object>>(); - // Cr\xE9ation de la liste des agents. - mAgentsRegistry = new Hashtable<AgentSpecification, Integer>(); - - // Cr\xE9ation du serveur. - mServer = new WebServer(thePort); - - // Configure the server. - final SimpleHandlerMapping theMapping = new SimpleHandlerMapping(); - theMapping.addHandler("server", this); - final XmlRpcServer theServer = mServer.getXmlRpcServer(); - theServer.setHandlerMapping(theMapping); - final XmlRpcServerConfigImpl theServerConfig = - (XmlRpcServerConfigImpl) theServer.getConfig(); - theServerConfig.setEnabledForExtensions(true); - - // Publication du serveur. - if (mMDNSServer != null) { - String theServiceName = theGameProperty; - final String serviceNameSuffix = - theConfig.getProperty(HTTPConsts.ZEROCONF_NAME_SUFFIX_PROPERTY); - if (serviceNameSuffix != null) { - theServiceName += serviceNameSuffix; - } - int registrationOpID = -1; - try { - final NetService theService = new NetService( - theServiceName, - HTTPConsts.MDNS_SERVICE_TYPE, - thePort); - registrationOpID = - mMDNSServer.registerService(this, theService); - } catch (IOException anException) { - anException.printStackTrace(); - } - mMDNSRegistrationOpID = registrationOpID; - } else { - mMDNSRegistrationOpID = -1; - } + // Create the web server. + // Create a servlet. + final XmlRpcServlet theServlet = new HTTPServlet(mHandler); + mServer = new ServletWebServer(theServlet, thePort); } /** @@ -384,6 +170,29 @@ } catch (IOException anException) { throw new ServerException(anException); } + + // Publish the web server. + if (mMDNSServer != null) { + String theServiceName = mHandler.getGameID(); + final String serviceNameSuffix = + mConfiguration.getProperty( + HTTPConsts.ZEROCONF_NAME_SUFFIX_PROPERTY); + if (serviceNameSuffix != null) { + theServiceName += serviceNameSuffix; + } + int registrationOpID = -1; + try { + final NetService theService = new NetService( + theServiceName, + HTTPConsts.MDNS_SERVICE_TYPE, + mServer.getPort()); + registrationOpID = + mMDNSServer.registerService(this, theService); + } catch (IOException anException) { + anException.printStackTrace(); + } + mMDNSRegistrationOpID = registrationOpID; + } } /** @@ -397,650 +206,19 @@ * Arr\xEAte le serveur. */ private void shutdown() { - // On n'accepte plus les requ\xEAtes. + // Shutdown the server. mServer.shutdown(); - // Puis on ferme tous les clients. - for (ClientData theClientData : mClients.values()) { - // On ferme le client. - theClientData.shutdown(); - - final List<Map<String, Object>> theEvents = - theClientData.getEvents(); - - synchronized (theEvents) { - // On notifie. - theEvents.notifyAll(); - } - } + // and the handler. + mHandler.shutdown(); - mClients.clear(); - // Unregister the mDNS service. - if (mMDNSServer != null) { + if ((mMDNSServer != null) && (mMDNSRegistrationOpID >= 0)) { mMDNSServer.cancelOperation(mMDNSRegistrationOpID); } } /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public Object execute(XmlRpcRequest inRequest) throws XmlRpcException { - final String operationName = inRequest.getMethodName(); - Object theResult; - if (operationName.equals("server.getGameID")) { - theResult = mGameID; - } else if (operationName.equals("server.newClient")) { - theResult = new Integer(newClient()); - } else if (operationName.equals("server.listen")) { - final int theClientID = - ((Integer) inRequest.getParameter(0)).intValue(); - theResult = listen(theClientID); - } else if (operationName.equals("server.endClient")) { - final int theClientID = - ((Integer) inRequest.getParameter(0)).intValue(); - endClient(theClientID); - theResult = ""; - } else if (operationName.equals("server.register")) { - final int theClientID = - ((Integer) inRequest.getParameter(0)).intValue(); - final String theAgentSpecStr = (String) inRequest.getParameter(1); - theResult = Boolean.valueOf( - register(theClientID, theAgentSpecStr)); - } else if (operationName.equals("server.unregister")) { - final int theClientID = - ((Integer) inRequest.getParameter(0)).intValue(); - final String theAgentSpecStr = (String) inRequest.getParameter(1); - unregister(theClientID, theAgentSpecStr); - theResult = ""; - } else if (operationName.equals("server.executeAgentMethod")) { - final int theClientID = - ((Integer) inRequest.getParameter(0)).intValue(); - final String theAgentSpecStr = (String) inRequest.getParameter(1); - final String theMethodName = (String) inRequest.getParameter(2); - final Map<String, Object> theParams = - (Map<String, Object>) inRequest.getParameter(3); - String theResultStr = null; - try { - theResultStr = - executeAgentMethod( - theClientID, - theAgentSpecStr, - theMethodName, - theParams); - } catch (NetworkAgentException anException) { - if (mVerboseMode) { - anException.printStackTrace(); - } - throw new XmlRpcException(anException.toString(), anException); - } - theResult = theResultStr; - if (mVerboseMode) { - logExecuteAgentMethodVerbose( - theClientID, - theAgentSpecStr, - theMethodName, - theParams, - theResultStr); - } - } else if (operationName.equals("server.executeAgentMethodAsync")) { - final int theClientID = - ((Integer) inRequest.getParameter(0)).intValue(); - final String theAgentSpecStr = (String) inRequest.getParameter(1); - final String theMethodName = (String) inRequest.getParameter(2); - final Map theParams = (Map) inRequest.getParameter(3); - try { - executeAgentMethodAsync( - theClientID, - theAgentSpecStr, - theMethodName, - theParams); - } catch (NetworkAgentException anException) { - if (mVerboseMode) { - anException.printStackTrace(); - } - throw new XmlRpcException(anException.toString(), anException); - } - theResult = "(void)"; - if (mVerboseMode) { - logExecuteAgentMethodVerbose( - theClientID, - theAgentSpecStr, - theMethodName, - theParams, - "(void)"); - } - } else if (operationName.equals("server.result")) { - final Integer theOperationID = (Integer) inRequest.getParameter(1); - final String theMethodResult = (String) inRequest.getParameter(2); - theResult = ""; - final List<Object> theHolder = - mPendingOperations.get(theOperationID); - if (theHolder != null) { - synchronized (theHolder) { - theHolder.add(theMethodResult); - theHolder.notifyAll(); - } - } - } else if (operationName.equals("server.exception")) { - final Integer theOperationID = (Integer) inRequest.getParameter(1); - final String theExceptionString = - (String) inRequest.getParameter(2); - theResult = ""; - final List<Object> theHolder = - mPendingOperations.get(theOperationID); - if (theHolder != null) { - synchronized (theHolder) { - theHolder.add(new Exception(theExceptionString)); - theHolder.notifyAll(); - } - } - } else { - throw new XmlRpcException("No such method", - new NoSuchMethodException(operationName)); - } - return theResult; - } - - /** - * Nouveau client. - * - * @return l'ID du nouveau client (qui est l'indice dans la liste des - * \xE9v\xE9nements). - */ - private int newClient() { - int theResult; - // V\xE9rification que l'agent n'est pas d\xE9j\xE0 dans la liste. - synchronized (mClients) { - theResult = mClientNextID++; - - final ClientData theNewClientData = - new ClientData(theResult, HTTPConsts.CLIENT_TIMEOUT); - - // Le r\xE9sultat est l'indice dans la liste des \xE9v\xE9nements. - mClients.put(new Integer(theResult), theNewClientData); - } - - synchronized (mAgentsRegistry) { - // On indique au client tous les agents qu'on connait d\xE9j\xE0. - int indexClients = 0; - for (AgentSpecification theAgentSpec : mAgentsRegistry.keySet()) { - // S\xE9paration classe:nom. - final Map<String, Object> theEvent = - new Hashtable<String, Object>(); - theEvent.put("name", "newAgent"); - theEvent.put("agentSpec", theAgentSpec.toString()); - theEvent.put("clientID", indexClients + ""); - postEvent(theResult, theEvent); - indexClients++; - } - } - - return theResult; - } - - /** - * Envoie \xE0 un client tous les nouveaux \xE9v\xE9nements. - * Attend au plus LISTEN_TIMEOUT pour les nouveaux \xE9v\xE9nements. - * - * @param inClientID le num\xE9ro du client. - * @return une liste d'\xE9v\xE9nements pour le client. - */ - private List<Map<String, Object>> listen(int inClientID) { - ClientData theClientData; - theClientData = mClients.get(new Integer(inClientID)); - - if (theClientData == null) { - throw new IllegalStateException( - "listen: Unknown client ID " + inClientID); - } - - if (theClientData.doesLookDead()) { - println("Client " + inClientID + " seems back."); - } - theClientData.resetTimer(); - final List<Map<String, Object>> theEvents = theClientData.getEvents(); - - List<Map<String, Object>> theResult; - - synchronized (theEvents) { - // Si la taille est nulle, on attend au plus LISTEN_TIMEOUT - // pour de nouveaux \xE9v\xE9nements. - if (theEvents.size() == 0) { - try { - theEvents.wait(HTTPConsts.LISTEN_TIMEOUT); - } catch (InterruptedException anException) { - // This space for rent. - } - } - - filterEvents(theEvents); - theResult = new Vector<Map<String, Object>>(theEvents); - theEvents.clear(); - } - - theClientData.resetTimer(); - - return theResult; - } - - /** - * Fin d'un client. - * D\xE9senregistre tous ses agents. - * - * @param inClientID le num\xE9ro du client. - */ - private void endClient(int inClientID) { - synchronized (mClients) { - final Integer theKey = new Integer(inClientID); - final ClientData theClient = mClients.get(theKey); - theClient.shutdown(); - mClients.remove(theKey); - } - - // La liste des ses agents. - final List<AgentSpecification> theRemovedAgents = - new LinkedList<AgentSpecification>(); - - synchronized (mAgentsRegistry) { - for (AgentSpecification theAgentKey : mAgentsRegistry.keySet()) { - final Integer theClientID = - mAgentsRegistry.get(theAgentKey); - if (theClientID.intValue() == inClientID) { - theRemovedAgents.add(theAgentKey); - } - } - } - - // Suppression. - for (AgentSpecification theAgentSpec : theRemovedAgents) { - unregister(inClientID, theAgentSpec); - } - } - - /** - * Enregistre un agent. - * - * @param inClientID le num\xE9ro du client. - * @param inAgentSpecStr specification of the agent. - * @return <code>true</code> si l'enregistrement a r\xE9ussi. - */ - private boolean register( - int inClientID, - String inAgentSpecStr) { - final AgentSpecification theAgentSpec = - AgentSpecification.fromString(inAgentSpecStr); - final Integer theValue = new Integer(inClientID); - boolean theResult = true; - synchronized (mAgentsRegistry) { - if (mAgentsRegistry.containsKey(theAgentSpec)) { - theResult = false; - } else { - mAgentsRegistry.put(theAgentSpec, theValue); - } - } - - // On le dit aux clients. - if (theResult) { - final Map<String, Object> theEvent = - new Hashtable<String, Object>(); - theEvent.put("name", "newAgent"); - theEvent.put("agentSpec", inAgentSpecStr); - theEvent.put("clientID", inClientID + ""); - theEvent.put("priority", "high"); - postEventToAll(theEvent); - } - - return theResult; - } - - /** - * Unregister an agent. - * - * @param inClientID ID of the client. - * @param inAgentSpecStr the agent specification as a string. - */ - private void unregister( - int inClientID, - String inAgentSpecStr) { - unregister(inClientID, AgentSpecification.fromString(inAgentSpecStr)); - } - - /** - * Unregister an agent. - * - * @param inClientID ID of the client. - * @param inAgentSpec specification of the agent. - */ - private void unregister( - int inClientID, - AgentSpecification inAgentSpec) { - synchronized (mAgentsRegistry) { - final Integer theOwnerID = - mAgentsRegistry.remove(inAgentSpec); - if (theOwnerID == null) { - println( - "Unregistering an agent that is not in the registry!"); - } else if (theOwnerID.intValue() != inClientID) { - println( - "Mismatch client ID for the unregistry call! (agent: " - + inAgentSpec + " clients: " - + inClientID + " != " + theOwnerID + ")"); - } - } - - // On le dit aux clients. - final Map<String, Object> theEvent = new Hashtable<String, Object>(); - theEvent.put("name", "agentDisappeared"); - theEvent.put("agentSpec", inAgentSpec.toString()); - theEvent.put("priority", "high"); - postEventToAll(theEvent); - } - - /** - * Ex\xE9cute une m\xE9thode sur un agent. - * - * @param inClientID le num\xE9ro du client. - * @param inAgentSpecStr agent specification as a string. - * @param inMethodName la m\xE9thode \xE0 ex\xE9cuter. - * @param inParams les param\xE8tres de l'agent. - * @return le r\xE9sultat de la m\xE9thode ou <code>null</code> si on n'a - * jamais eu le r\xE9sultat. - * @throws NetworkAgentException si un probl\xE8me est survenu. - */ - private String executeAgentMethod( - int inClientID, - String inAgentSpecStr, - String inMethodName, - Map inParams) throws NetworkAgentException { - final AgentSpecification theAgentSpec = - AgentSpecification.fromString(inAgentSpecStr); - int theTargetClient; - final Integer theAgentClient = - mAgentsRegistry.get(theAgentSpec); - if (theAgentClient == null) { - println("Client no longer exists (agent: " - + theAgentSpec + " client: " + inClientID + ")"); - throw new NetworkAgentException( - new InterruptedIOException("Client no longer exists")); - } - theTargetClient = theAgentClient.intValue(); - - // Cr\xE9ation de l'\xE9v\xE9nement. - final Map<String, Object> theEvent = new Hashtable<String, Object>(); - theEvent.put("name", "execute"); - theEvent.put("method", inMethodName); - theEvent.put("params", inParams); - theEvent.put("agentSpec", inAgentSpecStr); - - final List<Object> theResultHolder = new Vector<Object>(); - Integer theOperationID; - synchronized (mPendingOperations) { - theOperationID = new Integer(mOperationNextID++); - theEvent.put("operationID", theOperationID); - mPendingOperations.put(theOperationID, theResultHolder); - } - - postEvent(theTargetClient, theEvent); - - Object theResult = null; - - synchronized (theResultHolder) { - // Le r\xE9sultat est-il d\xE9j\xE0 l\xE0? - if (theResultHolder.size() > 0) { - theResult = theResultHolder.get(0); - } else { - // On l'attend. - try { - theResultHolder.wait(HTTPConsts.EXECUTE_TIMEOUT); - } catch (InterruptedException anException) { - // On ignore. - System.err.println("Exception while waiting for client"); - anException.printStackTrace(); - } - - if (theResultHolder.size() > 0) { - theResult = theResultHolder.get(0); - } else { - System.err.println( - "Client " + inClientID - + " didn't provide any response... didn't reply? (opid:" - + theOperationID + ")\n" - + " " + theAgentSpec + "->" - + inMethodName + "(" + inParams + ")"); - } - } - } - - // Suppression de la liste. - synchronized (mPendingOperations) { - mPendingOperations.remove(theOperationID); - } - - if (theResult == null) { - println("Client didn't reply (agent: " - + theAgentSpec + " client: " + inClientID + ")"); - throw new NetworkAgentException( - new InterruptedIOException("Client didn't reply")); - } - - // On g\xE8re le cas o\xF9 l'agent a retourn\xE9 une exception. - if (theResult instanceof NetworkAgentException) { - println("Client threw an exception " + theResult - + " (agent: " + theAgentSpec - + " client: " + inClientID + ")"); - throw (NetworkAgentException) theResult; - } - - String theResultString; - try { - theResultString = (String) theResult; - } catch (ClassCastException anException) { - println("Class cast " + theResult); - throw new NetworkAgentException(anException); - } - - return theResultString; - } - - /** - * Ex\xE9cute une m\xE9thode sur un agent de mani\xE8re asynchrone. - * - * @param inClientID le num\xE9ro du client. - * @param inAgentSpecStr agent specification as a string. - * @param inMethodName la m\xE9thode \xE0 ex\xE9cuter. - * @param inParams les param\xE8tres de l'agent. - * @throws NetworkAgentException si un probl\xE8me est survenu. - */ - private void executeAgentMethodAsync( - int inClientID, - String inAgentSpecStr, - String inMethodName, - Map inParams) throws NetworkAgentException { - final AgentSpecification theAgentSpec = - AgentSpecification.fromString(inAgentSpecStr); - int theTargetClient; - final Integer theAgentClient = - mAgentsRegistry.get(theAgentSpec); - if (theAgentClient == null) { - println("Client no longer exists (agent: " - + inAgentSpecStr + " client: " + inClientID + ")"); - throw new NetworkAgentException( - new InterruptedIOException("Client no longer exists")); - } - theTargetClient = theAgentClient.intValue(); - - // Cr\xE9ation de l'\xE9v\xE9nement. - final Map<String, Object> theEvent = new Hashtable<String, Object>(); - theEvent.put("name", "executeAsync"); - theEvent.put("method", inMethodName); - theEvent.put("params", inParams); - theEvent.put("agentSpec", inAgentSpecStr); - - postEvent(theTargetClient, theEvent); - } - - /** - * Affiche l'ex\xE9cution d'une m\xE9thode sur un agent. - * - * @param inClientID le num\xE9ro du client. - * @param inAgentSpecStr agent specification as string. - * @param inMethodName la m\xE9thode \xE0 ex\xE9cuter. - * @param inParams les param\xE8tres de l'agent. - * @param inResult r\xE9sultat. - */ - private void logExecuteAgentMethodVerbose( - int inClientID, - String inAgentSpecStr, - String inMethodName, - Map<String, Object> inParams, - String inResult) { - final StringBuffer theVerboseBuffer = new StringBuffer(); - theVerboseBuffer.append(inClientID); - theVerboseBuffer.append("> "); - theVerboseBuffer.append(inAgentSpecStr); - theVerboseBuffer.append("."); - theVerboseBuffer.append(inMethodName); - theVerboseBuffer.append("("); - // Param\xE8tres. - final Iterator theIter = inParams.keySet().iterator(); - while (theIter.hasNext()) { - final String theKey = (String) theIter.next(); - theVerboseBuffer.append(theKey); - theVerboseBuffer.append("="); - theVerboseBuffer.append(inParams.get(theKey)); - if (theIter.hasNext()) { - theVerboseBuffer.append(", "); - } - } - theVerboseBuffer.append("):"); - theVerboseBuffer.append(inResult); - theVerboseBuffer.append("\n"); - print(theVerboseBuffer.toString()); - flush(); - } - - /** - * Filter an event list by removing unnecessary events - * (register & unregister events). - * - * @param inEventList list of event where to insert the event. - */ - private void filterEvents(List<Map<String, Object>> inEventList) { - synchronized (inEventList) { - final ListIterator<Map<String, Object>> theListIter = - inEventList.listIterator(); - while (theListIter.hasNext()) { - final Map theEvent = theListIter.next(); - final String theEventName = - (String) theEvent.get("name"); - if ("agentDisappeared".equals(theEventName)) { - final AgentSpecification theAgentSpec = - AgentSpecification.fromString( - (String) theEvent.get("agentSpec")); - if (mAgentsRegistry.containsKey(theAgentSpec)) { - // Filter out. - theListIter.remove(); - } - } else if ("newAgent".equals(theEventName)) { - final AgentSpecification theAgentSpec = - AgentSpecification.fromString( - (String) theEvent.get("agentSpec")); - if (!mAgentsRegistry.containsKey(theAgentSpec)) { - // Filter out. - theListIter.remove(); - } - } - } - } - } - - /** - * Add an event in a list. - * - * @param inEventList list of event where to insert the event. - * @param inEvent event to insert. - */ - private static void queueEventInList( - List<Map<String, Object>> inEventList, - Map<String, Object> inEvent) { - final String thePriority = (String) inEvent.get("priority"); - - // Add the event at the right place. - boolean added = false; - if (thePriority != null) { - final ListIterator<Map<String, Object>> theListIter = - inEventList.listIterator(); - while (theListIter.hasNext()) { - final Map theEvent = theListIter.next(); - final String theEventPriority = - (String) theEvent.get("priority"); - if (theEventPriority == null) { - // This is the right place. - theListIter.previous(); - theListIter.add(inEvent); - added = true; - break; - } - } - } - - if (!added) { - // Add it at the end. - inEventList.add(inEvent); - } - } - - /** - * Nouvel \xE9v\xE9nement pour un client. - * - * @param inClientID le num\xE9ro du client. - * @param inEvent un dictionnaire qui d\xE9crit l'\xE9v\xE9nement. - */ - private void postEvent(int inClientID, Map<String, Object> inEvent) { - final ClientData theClientData = - mClients.get(new Integer(inClientID)); - - if (theClientData == null) { - throw new - IllegalStateException( - "post event: Unknown client ID " + inClientID); - } - - final List<Map<String, Object>> theEvents = theClientData.getEvents(); - - synchronized (theEvents) { - // Queue the event. - queueEventInList(theEvents, inEvent); - - // Notify the client thread. - theEvents.notifyAll(); - } - } - - /** - * Nouvel \xE9v\xE9nement pour tous les clients. - * - * @param inEvent un dictionnaire qui d\xE9crit l'\xE9v\xE9nement. - */ - private void postEventToAll(Map<String, Object> inEvent) { - synchronized (mClients) { - for (ClientData theClientData : mClients.values()) { - final List<Map<String, Object>> theEvents = - theClientData.getEvents(); - - synchronized (theEvents) { - queueEventInList(theEvents, inEvent); - - // Notify the client thread. - theEvents.notifyAll(); - } - } - } - } - - /** * Method called to process commands. * * @param inCommand command to parse (in uppercase). @@ -1059,51 +237,20 @@ println("Syntax error. Syntax: KILL <ID>"); } else { final int theID = Integer.parseInt(theArray[1]); - final ClientData theClientData = - mClients.get(new Integer(theID)); - if (theClientData.doesLookDead()) { - endClient(theID); - } else { - println("I'm no killer! Client " - + theID + " seems alive!"); - } + mHandler.killClient(theID); } } else if (inCommand.equals("LIST")) { if (nbElements != 1) { println("Syntax error. Syntax: LIST"); } else { - synchronized (mAgentsRegistry) { - for (AgentSpecification theAgentSpec - : mAgentsRegistry.keySet()) { - final Integer theValue = - mAgentsRegistry.get(theAgentSpec); - final ClientData theClientData = - mClients.get(theValue); - String looksDeadStr = ""; - if (theClientData.doesLookDead()) { - looksDeadStr = " (dead?)"; - } - - println(theAgentSpec + " [#" + theValue - + looksDeadStr + "]"); - } - } + mHandler.listAgents(); } } else if (inCommand.equals("AGENTS")) { if (nbElements != 2) { println("Syntax error. Syntax: AGENTS <ID>"); } else { final int theID = Integer.parseInt(theArray[1]); - synchronized (mAgentsRegistry) { - for (AgentSpecification theAgentSpec - : mAgentsRegistry.keySet()) { - final Integer theValue = - mAgentsRegistry.get(theAgentSpec); - if (theValue.intValue() == theID) { - println("- " + theAgentSpec); - } - } - } + mHandler.listAgents(theID); } } else { theResult = false; @@ -1166,8 +313,10 @@ * Syntaxe: java ... HTTPServer <fichier de configuration> * * @param inArgs arguments sur la ligne de commande. + * @throws ServletException if a problem occurred while creating the + * server. */ - public static void main(String[] inArgs) { + public static void main(String[] inArgs) throws ServletException { final HTTPServer theServer = new HTTPServer(inArgs); theServer.start(); } Added: simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServerHandler.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServerHandler.java (rev 0) +++ simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServerHandler.java 2007-05-24 08:22:16 UTC (rev 150) @@ -0,0 +1,960 @@ +// ============================== +// File: HTTPServerHandler.java +// Project: Simulaci\xF3n +// Written by: Paul Guyot (pau...@ac...) +// +// Created on: 14/6/2004 +// Tabs: 4 spaces +// +// This software is governed by the CeCILL license under French law and abiding +// by the rules of distribution of free software. You can use, modify and/ or +// redistribute the software under the terms of the CeCILL license as +// circulated by CEA, CNRS and INRIA at the following URL +// "http://www.cecill.info". +// +// As a counterpart to the access to the source code and rights to copy, modify +// and redistribute granted by the license, users are provided only with a +// limited warranty and the software's author, the holder of the economic +// rights, and the successive licensors have only limited liability. +// +// The fact that you are presently reading this means that you have had +// knowledge of the CeCILL license and that you accept its terms. +// +// =========== +// $Id$ +// =========== + +// paquet +package fr.lip6.sma.simulacion.server.http; + +// imports +import java.io.InterruptedIOException; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Timer; +import java.util.TimerTask; +import java.util.Vector; + +import org.apache.xmlrpc.XmlRpcException; +import org.apache.xmlrpc.XmlRpcHandler; +import org.apache.xmlrpc.XmlRpcRequest; + +import fr.lip6.sma.simulacion.app.Configuration; +import fr.lip6.sma.simulacion.server.AgentSpecification; +import fr.lip6.sma.simulacion.server.NetworkAgentException; + +/** + * Class for the part of the HTTP server that consists in handling the various + * HTTP clients and processing their requests. + * + * @author Paul Guyot <pau...@ac...> + * @version $Revision$ + */ +public final class HTTPServerHandler implements XmlRpcHandler { + /** + * Classe pour les donn\xE9es sur un client. + * Cette classe g\xE8re aussi la temporisation du client, i.e. elle d\xE9termine + * si \xE7a fait trop longtemps qu'on n'a pas entendu parler du client. + */ + private final class ClientData { + /** + * Identifiant du client. + */ + private final int mClientID; + + /** + * Dur\xE9e maximale depuis laquelle on veut avoir entendu le client. + * En millisecondes. + */ + private final int mTimeout; + + /** + * Liste des \xE9v\xE9nements pour ce client. + */ + private final List<Map<String, Object>> mEvents; + + /** + * Liste des \xE9v\xE9nements pour ce client. + */ + private final Timer mTimer; + + /** + * T\xE2che de timeout courante. + */ + private TimerTask mTimerTask; + + /** + * Flag indicating that the client seems to be dead. + */ + private boolean mLooksDead; + + /** + * Constructeur \xE0 partir de l'identifiant du client et du temps maximal + * pendant lequel on accepte de ne pas entendre parler du client. + * + * @param inClientID identifiant du client. + * @param inTimeout dur\xE9e maximale depuis laquelle on veut avoir + * entendu le client, en millisecondes. + */ + private ClientData(int inClientID, int inTimeout) { + mClientID = inClientID; + mTimeout = inTimeout; + mEvents = new LinkedList<Map<String, Object>>(); + mTimer = new Timer(); + mLooksDead = false; + + // Au d\xE9part, le client n'\xE9coute pas. + resetTimer(); + } + + /** + * (Re)lance la t\xE2che de temporisation. + */ + public void resetTimer() { + synchronized (mTimer) { + mLooksDead = false; + if (mTimerTask != null) { + mTimerTask.cancel(); + } + mTimerTask = new TimerTask() { + public void run() { + // Le client semble mort. + System.out.println( + "Client " + mClientID + " seems to be dead."); + mLooksDead = true; + } + }; + + try { + mTimer.schedule(mTimerTask, mTimeout); + } catch (IllegalStateException anException) { + // C'est rien, on est juste en train de fermer. + } + } + } + + /** + * Accesseur sur la liste des \xE9v\xE9nements. + * + * @return la liste des \xE9v\xE9nements. + */ + private List<Map<String, Object>> getEvents() { + return mEvents; + } + + /** + * Accessor on the looks dead property. + * + * @return <code>true</code> if the client seems dead, + * <code>false</code> otherwise. + */ + private boolean doesLookDead() { + return mLooksDead; + } + + /** + * Extinction de la t\xE2che de temporisation. + */ + private void shutdown() { + synchronized (mTimer) { + if (mTimerTask != null) { + mTimerTask.cancel(); + mTimerTask = null; + } + + mTimer.cancel(); + } + } + } + + /** + * If we're in verbose mode. + */ + private final boolean mVerboseMode; + + /** + * Identification du jeu. + */ + private final String mGameID; + + /** + * La liste des \xE9v\xE9nements pour les clients. + * Les cl\xE9s sont les identifiants des clients et les valeurs + * des ClientData. + */ + private final Map<Integer, ClientData> mClients; + + /** + * ID du prochain client. + */ + private int mClientNextID; + + /** + * La liste des op\xE9rations en cours. + * Les cl\xE9s sont les identifiants des op\xE9rations et les valeurs des + * vecteurs \xE0 un \xE9l\xE9ment pour accueillir le r\xE9sultat. + */ + private final Map<Integer, List<Object>> mPendingOperations; + + /** + * ID de la prochaine op\xE9ration. + * + * Remarque: une op\xE9ration a une dur\xE9e de vie limit\xE9e, par cons\xE9quent + * ce nombre peut \xEAtre sur 32 bits. + */ + private int mOperationNextID; + + /** + * La liste des agents enregistr\xE9s. + * Les cl\xE9s sont les cl\xE9s de la forme Classe:Nom. + * Les valeurs sont les ID des clients correspondant. + */ + private final Map<AgentSpecification, Integer> mAgentsRegistry; + + /** + * Constructor from a configuration and a boolean. + * + * @param inConfig configuration for the application. + * @param inVerbose if we are in verbose mode. + */ + public HTTPServerHandler(Configuration inConfig, boolean inVerbose) { + // Determine if we are in verbose mode. + mVerboseMode = + inVerbose + || inConfig.getPropertyAsBoolean( + HTTPConsts.VERBOSE_MODE_PROPERTY); + + // R\xE9cup\xE9ration du jeu et de la version. + final String theGameProperty = + inConfig.getProperty(HTTPConsts.GAMEID_PROPERTY); + + if (theGameProperty == null) { + System.err.println( + "Can't find the game ID (property " + + HTTPConsts.GAMEID_PROPERTY + ")"); + } + + mGameID = theGameProperty; + + // Cr\xE9ation de la liste des \xE9v\xE9nements pour les clients. + mClients = new Hashtable<Integer, ClientData>(); + + // Cr\xE9ation de la liste des op\xE9rations. + mPendingOperations = new Hashtable<Integer, List<Object>>(); + + // Cr\xE9ation de la liste des agents. + mAgentsRegistry = new Hashtable<AgentSpecification, Integer>(); + } + + /** + * Close all clients. + */ + public synchronized void shutdown() { + // Puis on ferme tous les clients. + for (ClientData theClientData : mClients.values()) { + // On ferme le client. + theClientData.shutdown(); + + final List<Map<String, Object>> theEvents = + theClientData.getEvents(); + + synchronized (theEvents) { + // On notifie. + theEvents.notifyAll(); + } + } + + mClients.clear(); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public Object execute(XmlRpcRequest inRequest) throws XmlRpcException { + final String operationName = inRequest.getMethodName(); + Object theResult; + if (operationName.equals("server.getGameID")) { + theResult = mGameID; + } else if (operationName.equals("server.newClient")) { + theResult = new Integer(newClient()); + } else if (operationName.equals("server.listen")) { + final int theClientID = + ((Integer) inRequest.getParameter(0)).intValue(); + theResult = listen(theClientID); + } else if (operationName.equals("server.endClient")) { + final int theClientID = + ((Integer) inRequest.getParameter(0)).intValue(); + endClient(theClientID); + theResult = ""; + } else if (operationName.equals("server.register")) { + final int theClientID = + ((Integer) inRequest.getParameter(0)).intValue(); + final String theAgentSpecStr = (String) inRequest.getParameter(1); + theResult = Boolean.valueOf( + register(theClientID, theAgentSpecStr)); + } else if (operationName.equals("server.unregister")) { + final int theClientID = + ((Integer) inRequest.getParameter(0)).intValue(); + final String theAgentSpecStr = (String) inRequest.getParameter(1); + unregister(theClientID, theAgentSpecStr); + theResult = ""; + } else if (operationName.equals("server.executeAgentMethod")) { + final int theClientID = + ((Integer) inRequest.getParameter(0)).intValue(); + final String theAgentSpecStr = (String) inRequest.getParameter(1); + final String theMethodName = (String) inRequest.getParameter(2); + final Map<String, Object> theParams = + (Map<String, Object>) inRequest.getParameter(3); + String theResultStr = null; + try { + theResultStr = + executeAgentMethod( + theClientID, + theAgentSpecStr, + theMethodName, + theParams); + } catch (NetworkAgentException anException) { + if (mVerboseMode) { + anException.printStackTrace(); + } + throw new XmlRpcException(anException.toString(), anException); + } + theResult = theResultStr; + if (mVerboseMode) { + logExecuteAgentMethodVerbose( + theClientID, + theAgentSpecStr, + theMethodName, + theParams, + theResultStr); + } + } else if (operationName.equals("server.executeAgentMethodAsync")) { + final int theClientID = + ((Integer) inRequest.getParameter(0)).intValue(); + final String theAgentSpecStr = (String) inRequest.getParameter(1); + final String theMethodName = (String) inRequest.getParameter(2); + final Map theParams = (Map) inRequest.getParameter(3); + try { + executeAgentMethodAsync( + theClientID, + theAgentSpecStr, + theMethodName, + theParams); + } catch (NetworkAgentException anException) { + if (mVerboseMode) { + anException.printStackTrace(); + } + throw new XmlRpcException(anException.toString(), anException); + } + theResult = "(void)"; + if (mVerboseMode) { + logExecuteAgentMethodVerbose( + theClientID, + theAgentSpecStr, + theMethodName, + theParams, + "(void)"); + } + } else if (operationName.equals("server.result")) { + final Integer theOperationID = (Integer) inRequest.getParameter(1); + final String theMethodResult = (String) inRequest.getParameter(2); + theResult = ""; + final List<Object> theHolder = + mPendingOperations.get(theOperationID); + if (theHolder != null) { + synchronized (theHolder) { + theHolder.add(theMethodResult); + theHolder.notifyAll(); + } + } + } else if (operationName.equals("server.exception")) { + final Integer theOperationID = (Integer) inRequest.getParameter(1); + final String theExceptionString = + (String) inRequest.getParameter(2); + theResult = ""; + final List<Object> theHolder = + mPendingOperations.get(theOperationID); + if (theHolder != null) { + synchronized (theHolder) { + theHolder.add(new Exception(theExceptionString)); + theHolder.notifyAll(); + } + } + } else { + throw new XmlRpcException("No such method", + new NoSuchMethodException(operationName)); + } + return theResult; + } + + /** + * Nouveau client. + * + * @return l'ID du nouveau client (qui est l'indice dans la liste des + * \xE9v\xE9nements). + */ + private int newClient() { + int theResult; + // V\xE9rification que l'agent n'est pas d\xE9j\xE0 dans la liste. + synchronized (mClients) { + theResult = mClientNextID++; + + final ClientData theNewClientData = + new ClientData(theResult, HTTPConsts.CLIENT_TIMEOUT); + + // Le r\xE9sultat est l'indice dans la liste des \xE9v\xE9nements. + mClients.put(new Integer(theResult), theNewClientData); + } + + synchronized (mAgentsRegistry) { + // On indique au client tous les agents qu'on connait d\xE9j\xE0. + int indexClients = 0; + for (AgentSpecification theAgentSpec : mAgentsRegistry.keySet()) { + // S\xE9paration classe:nom. + final Map<String, Object> theEvent = + new Hashtable<String, Object>(); + theEvent.put("name", "newAgent"); + theEvent.put("agentSpec", theAgentSpec.toString()); + theEvent.put("clientID", indexClients + ""); + postEvent(theResult, theEvent); + indexClients++; + } + } + + return theResult; + } + + /** + * Envoie \xE0 un client tous les nouveaux \xE9v\xE9nements. + * Attend au plus LISTEN_TIMEOUT pour les nouveaux \xE9v\xE9nements. + * + * @param inClientID le num\xE9ro du client. + * @return une liste d'\xE9v\xE9nements pour le client. + */ + private List<Map<String, Object>> listen(int inClientID) { + ClientData theClientData; + theClientData = mClients.get(new Integer(inClientID)); + + if (theClientData == null) { + throw new IllegalStateException( + "listen: Unknown client ID " + inClientID); + } + + if (theClientData.doesLookDead()) { + System.out.println("Client " + inClientID + " seems back."); + } + theClientData.resetTimer(); + final List<Map<String, Object>> theEvents = theClientData.getEvents(); + + List<Map<String, Object>> theResult; + + synchronized (theEvents) { + // Si la taille est nulle, on attend au plus LISTEN_TIMEOUT + // pour de nouveaux \xE9v\xE9nements. + if (theEvents.size() == 0) { + try { + theEvents.wait(HTTPConsts.LISTEN_TIMEOUT); + } catch (InterruptedException anException) { + // This space for rent. + } + } + + filterEvents(theEvents); + theResult = new Vector<Map<String, Object>>(theEvents); + theEvents.clear(); + } + + theClientData.resetTimer(); + + return theResult; + } + + /** + * Fin d'un client. + * D\xE9senregistre tous ses agents. + * + * @param inClientID le num\xE9ro du client. + */ + private void endClient(int inClientID) { + synchronized (mClients) { + final Integer theKey = new Integer(inClientID); + final ClientData theClient = mClients.get(theKey); + theClient.shutdown(); + mClients.remove(theKey); + } + + // La liste des ses agents. + final List<AgentSpecification> theRemovedAgents = + new LinkedList<AgentSpecification>(); + + synchronized (mAgentsRegistry) { + for (AgentSpecification theAgentKey : mAgentsRegistry.keySet()) { + final Integer theClientID = + mAgentsRegistry.get(theAgentKey); + if (theClientID.intValue() == inClientID) { + theRemovedAgents.add(theAgentKey); + } + } + } + + // Suppression. + for (AgentSpecification theAgentSpec : theRemovedAgents) { + unregister(inClientID, theAgentSpec); + } + } + + /** + * Enregistre un agent. + * + * @param inClientID le num\xE9ro du client. + * @param inAgentSpecStr specification of the agent. + * @return <code>true</code> si l'enregistrement a r\xE9ussi. + */ + private boolean register( + int inClientID, + String inAgentSpecStr) { + final AgentSpecification theAgentSpec = + AgentSpecification.fromString(inAgentSpecStr); + final Integer theValue = new Integer(inClientID); + boolean theResult = true; + synchronized (mAgentsRegistry) { + if (mAgentsRegistry.containsKey(theAgentSpec)) { + theResult = false; + } else { + mAgentsRegistry.put(theAgentSpec, theValue); + } + } + + // On le dit aux clients. + if (theResult) { + final Map<String, Object> theEvent = + new Hashtable<String, Object>(); + theEvent.put("name", "newAgent"); + theEvent.put("agentSpec", inAgentSpecStr); + theEvent.put("clientID", inClientID + ""); + theEvent.put("priority", "high"); + postEventToAll(theEvent); + } + + return theResult; + } + + /** + * Unregister an agent. + * + * @param inClientID ID of the client. + * @param inAgentSpecStr the agent specification as a string. + */ + private void unregister( + int inClientID, + String inAgentSpecStr) { + unregister(inClientID, AgentSpecification.fromString(inAgentSpecStr)); + } + + /** + * Unregister an agent. + * + * @param inClientID ID of the client. + * @param inAgentSpec specification of the agent. + */ + private void unregister( + int inClientID, + AgentSpecification inAgentSpec) { + synchronized (mAgentsRegistry) { + final Integer theOwnerID = + mAgentsRegistry.remove(inAgentSpec); + if (theOwnerID == null) { + System.err.println( + "Unregistering an agent that is not in the registry!"); + } else if (theOwnerID.intValue() != inClientID) { + System.err.println( + "Mismatch client ID for the unregistry call! (agent: " + + inAgentSpec + " clients: " + + inClientID + " != " + theOwnerID + ")"); + } + } + + // On le dit aux clients. + final Map<String, Object> theEvent = new Hashtable<String, Object>(); + theEvent.put("name", "agentDisappeared"); + theEvent.put("agentSpec", inAgentSpec.toString()); + theEvent.put("priority", "high"); + postEventToAll(theEvent); + } + + /** + * Ex\xE9cute une m\xE9thode sur un agent. + * + * @param inClientID le num\xE9ro du client. + * @param inAgentSpecStr agent specification as a string. + * @param inMethodName la m\xE9thode \xE0 ex\xE9cuter. + * @param inParams les param\xE8tres de l'agent. + * @return le r\xE9sultat de la m\xE9thode ou <code>null</code> si on n'a + * jamais eu le r\xE9sultat. + * @throws NetworkAgentException si un probl\xE8me est survenu. + */ + private String executeAgentMethod( + int inClientID, + String inAgentSpecStr, + String inMethodName, + Map inParams) throws NetworkAgentException { + final AgentSpecification theAgentSpec = + AgentSpecification.fromString(inAgentSpecStr); + int theTargetClient; + final Integer theAgentClient = + mAgentsRegistry.get(theAgentSpec); + if (theAgentClient == null) { + System.err.println("Client no longer exists (agent: " + + theAgentSpec + " client: " + inClientID + ")"); + throw new NetworkAgentException( + new InterruptedIOException("Client no longer exists")); + } + theTargetClient = theAgentClient.intValue(); + + // Cr\xE9ation de l'\xE9v\xE9nement. + final Map<String, Object> theEvent = new Hashtabl... [truncated message content] |
From: <pg...@us...> - 2007-05-24 05:34:51
|
Revision: 149 http://simulacion.svn.sourceforge.net/simulacion/?rev=149&view=rev Author: pguyot Date: 2007-05-23 22:34:49 -0700 (Wed, 23 May 2007) Log Message: ----------- Fixed eclipse classpath. Modified Paths: -------------- examples/simbar/.classpath examples/simbar3/.classpath examples/simcafe/.classpath examples/simcommod/.classpath simulacion/.classpath Modified: examples/simbar/.classpath =================================================================== --- examples/simbar/.classpath 2007-05-24 05:07:50 UTC (rev 148) +++ examples/simbar/.classpath 2007-05-24 05:34:49 UTC (rev 149) @@ -6,10 +6,9 @@ <classpathentry kind="lib" path="simulacion/lib/checkstyle-4.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/checkstyle-optional-4.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-beanutils-core.jar"/> - <classpathentry kind="lib" path="simulacion/lib/commons-cli-1.0.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-codec-1.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-collections-3.2.jar"/> - <classpathentry kind="lib" path="simulacion/lib/commons-httpclient-2.0.2.jar"/> + <classpathentry kind="lib" path="simulacion/lib/commons-httpclient-3.0.1.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-logging-1.1.jar"/> <classpathentry kind="lib" path="simulacion/lib/jakarta-regexp-1.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/Java-mDNS.jar"/> Modified: examples/simbar3/.classpath =================================================================== --- examples/simbar3/.classpath 2007-05-24 05:07:50 UTC (rev 148) +++ examples/simbar3/.classpath 2007-05-24 05:34:49 UTC (rev 149) @@ -6,10 +6,9 @@ <classpathentry kind="lib" path="simulacion/lib/checkstyle-4.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/checkstyle-optional-4.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-beanutils-core.jar"/> - <classpathentry kind="lib" path="simulacion/lib/commons-cli-1.0.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-codec-1.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-collections-3.2.jar"/> - <classpathentry kind="lib" path="simulacion/lib/commons-httpclient-2.0.2.jar"/> + <classpathentry kind="lib" path="simulacion/lib/commons-httpclient-3.0.1.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-logging-1.1.jar"/> <classpathentry kind="lib" path="simulacion/lib/jakarta-regexp-1.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/Java-mDNS.jar"/> Modified: examples/simcafe/.classpath =================================================================== --- examples/simcafe/.classpath 2007-05-24 05:07:50 UTC (rev 148) +++ examples/simcafe/.classpath 2007-05-24 05:34:49 UTC (rev 149) @@ -6,10 +6,9 @@ <classpathentry kind="lib" path="simulacion/lib/checkstyle-4.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/checkstyle-optional-4.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-beanutils-core.jar"/> - <classpathentry kind="lib" path="simulacion/lib/commons-cli-1.0.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-codec-1.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-collections-3.2.jar"/> - <classpathentry kind="lib" path="simulacion/lib/commons-httpclient-2.0.2.jar"/> + <classpathentry kind="lib" path="simulacion/lib/commons-httpclient-3.0.1.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-logging-1.1.jar"/> <classpathentry kind="lib" path="simulacion/lib/jakarta-regexp-1.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/Java-mDNS.jar"/> Modified: examples/simcommod/.classpath =================================================================== --- examples/simcommod/.classpath 2007-05-24 05:07:50 UTC (rev 148) +++ examples/simcommod/.classpath 2007-05-24 05:34:49 UTC (rev 149) @@ -6,10 +6,9 @@ <classpathentry kind="lib" path="simulacion/lib/checkstyle-4.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/checkstyle-optional-4.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-beanutils-core.jar"/> - <classpathentry kind="lib" path="simulacion/lib/commons-cli-1.0.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-codec-1.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-collections-3.2.jar"/> - <classpathentry kind="lib" path="simulacion/lib/commons-httpclient-2.0.2.jar"/> + <classpathentry kind="lib" path="simulacion/lib/commons-httpclient-3.0.1.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-logging-1.1.jar"/> <classpathentry kind="lib" path="simulacion/lib/jakarta-regexp-1.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/Java-mDNS.jar"/> Modified: simulacion/.classpath =================================================================== --- simulacion/.classpath 2007-05-24 05:07:50 UTC (rev 148) +++ simulacion/.classpath 2007-05-24 05:34:49 UTC (rev 149) @@ -1,24 +1,24 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="lib" path="lib/AppleJavaExtensions.jar"/> + <classpathentry kind="lib" path="lib/commons-beanutils-core.jar"/> + <classpathentry kind="lib" path="lib/commons-codec-1.3.jar"/> + <classpathentry kind="lib" path="lib/commons-collections-3.2.jar"/> + <classpathentry kind="lib" path="lib/commons-httpclient-3.0.1.jar"/> + <classpathentry kind="lib" path="lib/commons-logging-1.1.jar"/> + <classpathentry kind="lib" path="lib/Java-mDNS.jar"/> + <classpathentry kind="lib" path="lib/jazzy.jar"/> + <classpathentry kind="lib" path="lib/jmdns.jar"/> + <classpathentry kind="lib" path="lib/junit-4.3.1.jar"/> + <classpathentry kind="lib" path="lib/kawa-1.8beta.jar"/> + <classpathentry kind="lib" path="lib/ws-commons-util-1.0.1.jar"/> + <classpathentry kind="lib" path="lib/xercesImpl.jar"/> + <classpathentry kind="lib" path="lib/xml-apis.jar"/> + <classpathentry kind="lib" path="lib/xmlParserAPIs.jar"/> <classpathentry kind="lib" path="lib/xmlrpc-client-3.0.jar"/> <classpathentry kind="lib" path="lib/xmlrpc-common-3.0.jar"/> <classpathentry kind="lib" path="lib/xmlrpc-server-3.0.jar"/> - <classpathentry kind="lib" path="lib/ws-commons-util-1.0.1.jar"/> - <classpathentry kind="lib" path="lib/kawa-1.8beta.jar"/> - <classpathentry kind="lib" path="lib/jmdns.jar"/> - <classpathentry kind="lib" path="lib/jazzy.jar"/> - <classpathentry kind="lib" path="lib/Java-mDNS.jar"/> - <classpathentry kind="lib" path="lib/AppleJavaExtensions.jar"/> - <classpathentry kind="lib" path="lib/xmlParserAPIs.jar"/> - <classpathentry kind="lib" path="lib/xml-apis.jar"/> - <classpathentry kind="lib" path="lib/xercesImpl.jar"/> - <classpathentry kind="lib" path="lib/commons-logging-1.1.jar"/> - <classpathentry kind="lib" path="lib/commons-httpclient-3.0.1.jar"/> - <classpathentry kind="lib" path="lib/commons-collections-3.2.jar"/> - <classpathentry kind="lib" path="lib/commons-codec-1.3.jar"/> - <classpathentry kind="lib" path="lib/commons-beanutils-core.jar"/> - <classpathentry kind="lib" path="lib/junit-4.3.1.jar"/> <classpathentry kind="output" path="bin"/> + <classpathentry kind="src" path="src"/> </classpath> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2007-05-24 05:07:51
|
Revision: 148 http://simulacion.svn.sourceforge.net/simulacion/?rev=148&view=rev Author: pguyot Date: 2007-05-23 22:07:50 -0700 (Wed, 23 May 2007) Log Message: ----------- Update for XmlRpc 3.0. Modified Paths: -------------- examples/simbar/.classpath examples/simbar/_Build_/Ant/build.xml examples/simbar3/.classpath examples/simbar3/_Build_/Ant/build.xml examples/simcafe/.classpath examples/simcafe/_Build_/Ant/build.xml examples/simcommod/.classpath examples/simcommod/_Build_/Ant/build.xml Modified: examples/simbar/.classpath =================================================================== --- examples/simbar/.classpath 2007-05-24 05:06:59 UTC (rev 147) +++ examples/simbar/.classpath 2007-05-24 05:07:50 UTC (rev 148) @@ -6,11 +6,11 @@ <classpathentry kind="lib" path="simulacion/lib/checkstyle-4.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/checkstyle-optional-4.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-beanutils-core.jar"/> - <classpathentry kind="lib" path="simulacion/lib/commons-cli.jar"/> + <classpathentry kind="lib" path="simulacion/lib/commons-cli-1.0.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-codec-1.3.jar"/> - <classpathentry kind="lib" path="simulacion/lib/commons-collections.jar"/> + <classpathentry kind="lib" path="simulacion/lib/commons-collections-3.2.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-httpclient-2.0.2.jar"/> - <classpathentry kind="lib" path="simulacion/lib/commons-logging-1.0.2.jar"/> + <classpathentry kind="lib" path="simulacion/lib/commons-logging-1.1.jar"/> <classpathentry kind="lib" path="simulacion/lib/jakarta-regexp-1.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/Java-mDNS.jar"/> <classpathentry kind="lib" path="simulacion/lib/jazzy.jar"/> @@ -20,11 +20,14 @@ <classpathentry kind="lib" path="simulacion/lib/q.jar"/> <classpathentry kind="lib" path="simulacion/lib/resolver.jar"/> <classpathentry kind="lib" path="simulacion/lib/servletapi-2.2.jar"/> + <classpathentry kind="lib" path="simulacion/lib/ws-commons-util-1.0.1.jar"/> <classpathentry kind="lib" path="simulacion/lib/xercesImpl.jar"/> <classpathentry kind="lib" path="simulacion/lib/xml-apis.jar"/> <classpathentry kind="lib" path="simulacion/lib/xmlParserAPIs.jar"/> - <classpathentry kind="lib" path="simulacion/lib/xmlrpc-2.0.jar"/> - <classpathentry kind="lib" path="simulacion/simulacion-20070224.jar"/> + <classpathentry kind="lib" path="simulacion/lib/xmlrpc-client-3.0.jar"/> + <classpathentry kind="lib" path="simulacion/lib/xmlrpc-common-3.0.jar"/> + <classpathentry kind="lib" path="simulacion/lib/xmlrpc-server-3.0.jar"/> + <classpathentry kind="lib" path="simulacion/simulacion-20070224.jar" sourcepath="simulacion/src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="output" path="bin"/> </classpath> Modified: examples/simbar/_Build_/Ant/build.xml =================================================================== --- examples/simbar/_Build_/Ant/build.xml 2007-05-24 05:06:59 UTC (rev 147) +++ examples/simbar/_Build_/Ant/build.xml 2007-05-24 05:07:50 UTC (rev 148) @@ -49,11 +49,9 @@ <property name="build.dir" value="build" /> <property name="cp-jars" value="${simulacion.dir}/lib/Java-mDNS.jar:${simulacion.dir}/lib/jmdns.jar:${simulacion.dir}/lib/junit-4.3.1.jar:${simulacion.dir}/lib/xmlrpc-2.0.jar:${simulacion.dir}/lib/kawa-1.8beta.jar:${simulacion.dir}/lib/jazzy.jar" /> <property environment="env" /> - <property name="checkstyle-jars" value="${env.ANT_HOME}/lib/ant.jar:${simulacion.dir}/lib/checkstyle-4.3.jar:${simulacion.dir}/lib/checkstyle-optional-4.3.jar:${simulacion.dir}/lib/antlr.jar:${simulacion.dir}/lib/jakarta-regexp-1.3.jar:${simulacion.dir}/lib/commons-beanutils-core.jar:${simulacion.dir}/lib/commons-codec-1.3.jar:${simulacion.dir}/lib/commons-httpclient-2.0.2.jar:${simulacion.dir}/lib/commons-logging-1.0.2.jar" /> <available file="${keystore}" type="dir" property="have.keystore"/> - <patternset id="runtime-libs" includes="commons-codec-1.3.jar commons-httpclient-2.0.2.jar commons-logging-1.0.2.jar Java-mDNS.jar jmdns.jar xercesImpl.jar xmlrpc-2.0.jar" /> <patternset id="junit-tests"> <include name="**/*Test.java" /> <!-- Exclude non-JUnit tests --> @@ -85,18 +83,14 @@ </untar> </target> - <target name="prepare" depends="-untar.simulacion"> - <taskdef resource="checkstyletask.properties" classpath="${checkstyle-jars}"/> - </target> - - <target name="ApplicationJar" depends="prepare"> + <target name="ApplicationJar"> <ant antfile="${simulacion.dir}/simulacion-ant.xml" target="ProjectJar" inheritRefs="true"> <property name="jarname" value="${jarname}"/> <property name="mainclass" value="${appchooserclass}"/> </ant> </target> - <target name="ApplicationDebugJar" depends="prepare"> + <target name="ApplicationDebugJar"> <ant antfile="${simulacion.dir}/simulacion-ant.xml" target="ProjectJar" inheritRefs="true"> <property name="debug" value="true" /> <property name="jarname" value="${jarname}" /> @@ -104,14 +98,14 @@ </ant> </target> - <target name="FatApplicationJar" depends="prepare"> + <target name="FatApplicationJar"> <ant antfile="${simulacion.dir}/simulacion-ant.xml" target="FatProjectJar" inheritRefs="true"> <property name="jarname" value="${jarname}"/> <property name="mainclass" value="${appchooserclass}"/> </ant> </target> - <target name="FatApplicationDebugJar" depends="prepare"> + <target name="FatApplicationDebugJar"> <ant antfile="${simulacion.dir}/simulacion-ant.xml" target="FatProjectJar" inheritRefs="true"> <property name="debug" value="true" /> <property name="jarname" value="${jarname}" /> @@ -119,7 +113,7 @@ </ant> </target> - <target name="ApplicationJavaDoc" depends="prepare"> + <target name="ApplicationJavaDoc"> <ant antfile="${simulacion.dir}/simulacion-ant.xml" target="ProjectJavaDoc" inheritRefs="true"> <property name="jarname" value="${jarname}" /> <property name="mainclass" value="${appchooserclass}" /> Modified: examples/simbar3/.classpath =================================================================== --- examples/simbar3/.classpath 2007-05-24 05:06:59 UTC (rev 147) +++ examples/simbar3/.classpath 2007-05-24 05:07:50 UTC (rev 148) @@ -6,11 +6,11 @@ <classpathentry kind="lib" path="simulacion/lib/checkstyle-4.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/checkstyle-optional-4.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-beanutils-core.jar"/> - <classpathentry kind="lib" path="simulacion/lib/commons-cli.jar"/> + <classpathentry kind="lib" path="simulacion/lib/commons-cli-1.0.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-codec-1.3.jar"/> - <classpathentry kind="lib" path="simulacion/lib/commons-collections.jar"/> + <classpathentry kind="lib" path="simulacion/lib/commons-collections-3.2.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-httpclient-2.0.2.jar"/> - <classpathentry kind="lib" path="simulacion/lib/commons-logging-1.0.2.jar"/> + <classpathentry kind="lib" path="simulacion/lib/commons-logging-1.1.jar"/> <classpathentry kind="lib" path="simulacion/lib/jakarta-regexp-1.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/Java-mDNS.jar"/> <classpathentry kind="lib" path="simulacion/lib/jazzy.jar"/> @@ -20,10 +20,13 @@ <classpathentry kind="lib" path="simulacion/lib/q.jar"/> <classpathentry kind="lib" path="simulacion/lib/resolver.jar"/> <classpathentry kind="lib" path="simulacion/lib/servletapi-2.2.jar"/> + <classpathentry kind="lib" path="simulacion/lib/ws-commons-util-1.0.1.jar"/> <classpathentry kind="lib" path="simulacion/lib/xercesImpl.jar"/> <classpathentry kind="lib" path="simulacion/lib/xml-apis.jar"/> <classpathentry kind="lib" path="simulacion/lib/xmlParserAPIs.jar"/> - <classpathentry kind="lib" path="simulacion/lib/xmlrpc-2.0.jar"/> + <classpathentry kind="lib" path="simulacion/lib/xmlrpc-client-3.0.jar"/> + <classpathentry kind="lib" path="simulacion/lib/xmlrpc-common-3.0.jar"/> + <classpathentry kind="lib" path="simulacion/lib/xmlrpc-server-3.0.jar"/> <classpathentry kind="lib" path="simulacion/simulacion-20070224.jar" sourcepath="simulacion/src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="output" path="bin"/> Modified: examples/simbar3/_Build_/Ant/build.xml =================================================================== --- examples/simbar3/_Build_/Ant/build.xml 2007-05-24 05:06:59 UTC (rev 147) +++ examples/simbar3/_Build_/Ant/build.xml 2007-05-24 05:07:50 UTC (rev 148) @@ -50,11 +50,9 @@ <property name="build.dir" value="build" /> <property name="cp-jars" value="${simulacion.dir}/lib/Java-mDNS.jar:${simulacion.dir}/lib/jmdns.jar:${simulacion.dir}/lib/junit-4.3.1.jar:${simulacion.dir}/lib/xmlrpc-2.0.jar:${simulacion.dir}/lib/kawa-1.8beta.jar:${simulacion.dir}/lib/jazzy.jar" /> <property environment="env" /> - <property name="checkstyle-jars" value="${env.ANT_HOME}/lib/ant.jar:${simulacion.dir}/lib/checkstyle-4.3.jar:${simulacion.dir}/lib/checkstyle-optional-4.3.jar:${simulacion.dir}/lib/antlr.jar:${simulacion.dir}/lib/jakarta-regexp-1.3.jar:${simulacion.dir}/lib/commons-beanutils-core.jar:${simulacion.dir}/lib/commons-codec-1.3.jar:${simulacion.dir}/lib/commons-httpclient-2.0.2.jar:${simulacion.dir}/lib/commons-logging-1.0.2.jar" /> <available file="${keystore}" type="dir" property="have.keystore"/> - <patternset id="runtime-libs" includes="commons-codec-1.3.jar commons-httpclient-2.0.2.jar commons-logging-1.0.2.jar Java-mDNS.jar jmdns.jar xercesImpl.jar xmlrpc-2.0.jar" /> <patternset id="junit-tests"> <include name="**/*Test.java" /> <!-- Exclude non-JUnit tests --> @@ -88,18 +86,14 @@ </untar> </target> - <target name="prepare" depends="-untar.simulacion"> - <taskdef resource="checkstyletask.properties" classpath="${checkstyle-jars}"/> - </target> - - <target name="ApplicationJar" depends="prepare"> + <target name="ApplicationJar"> <ant antfile="${simulacion.dir}/simulacion-ant.xml" target="ProjectJar" inheritRefs="true"> <property name="jarname" value="${jarname}"/> <property name="mainclass" value="${appchooserclass}"/> </ant> </target> - <target name="ApplicationDebugJar" depends="prepare"> + <target name="ApplicationDebugJar"> <ant antfile="${simulacion.dir}/simulacion-ant.xml" target="ProjectJar" inheritRefs="true"> <property name="debug" value="true" /> <property name="jarname" value="${jarname}" /> @@ -107,14 +101,14 @@ </ant> </target> - <target name="FatApplicationJar" depends="prepare"> + <target name="FatApplicationJar"> <ant antfile="${simulacion.dir}/simulacion-ant.xml" target="FatProjectJar" inheritRefs="true"> <property name="jarname" value="${jarname}"/> <property name="mainclass" value="${appchooserclass}"/> </ant> </target> - <target name="FatApplicationDebugJar" depends="prepare"> + <target name="FatApplicationDebugJar"> <ant antfile="${simulacion.dir}/simulacion-ant.xml" target="FatProjectJar" inheritRefs="true"> <property name="debug" value="true" /> <property name="jarname" value="${jarname}"/> @@ -122,14 +116,14 @@ </ant> </target> - <target name="FatRegularApplicationJar" depends="prepare"> + <target name="FatRegularApplicationJar"> <ant antfile="${simulacion.dir}/simulacion-ant.xml" target="FatProjectJar" inheritRefs="true"> <property name="jarname" value="${jarname}Regular" /> <property name="mainclass" value="${regularclass}"/> </ant> </target> - <target name="ApplicationJavaDoc" depends="prepare"> + <target name="ApplicationJavaDoc"> <ant antfile="${simulacion.dir}/simulacion-ant.xml" target="ProjectJavaDoc" inheritRefs="true"> <property name="jarname" value="${jarname}" /> <property name="mainclass" value="${appchooserclass}" /> Modified: examples/simcafe/.classpath =================================================================== --- examples/simcafe/.classpath 2007-05-24 05:06:59 UTC (rev 147) +++ examples/simcafe/.classpath 2007-05-24 05:07:50 UTC (rev 148) @@ -6,11 +6,11 @@ <classpathentry kind="lib" path="simulacion/lib/checkstyle-4.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/checkstyle-optional-4.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-beanutils-core.jar"/> - <classpathentry kind="lib" path="simulacion/lib/commons-cli.jar"/> + <classpathentry kind="lib" path="simulacion/lib/commons-cli-1.0.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-codec-1.3.jar"/> - <classpathentry kind="lib" path="simulacion/lib/commons-collections.jar"/> + <classpathentry kind="lib" path="simulacion/lib/commons-collections-3.2.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-httpclient-2.0.2.jar"/> - <classpathentry kind="lib" path="simulacion/lib/commons-logging-1.0.2.jar"/> + <classpathentry kind="lib" path="simulacion/lib/commons-logging-1.1.jar"/> <classpathentry kind="lib" path="simulacion/lib/jakarta-regexp-1.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/Java-mDNS.jar"/> <classpathentry kind="lib" path="simulacion/lib/jazzy.jar"/> @@ -20,11 +20,14 @@ <classpathentry kind="lib" path="simulacion/lib/q.jar"/> <classpathentry kind="lib" path="simulacion/lib/resolver.jar"/> <classpathentry kind="lib" path="simulacion/lib/servletapi-2.2.jar"/> + <classpathentry kind="lib" path="simulacion/lib/ws-commons-util-1.0.1.jar"/> <classpathentry kind="lib" path="simulacion/lib/xercesImpl.jar"/> <classpathentry kind="lib" path="simulacion/lib/xml-apis.jar"/> <classpathentry kind="lib" path="simulacion/lib/xmlParserAPIs.jar"/> - <classpathentry kind="lib" path="simulacion/lib/xmlrpc-2.0.jar"/> - <classpathentry kind="lib" path="simulacion/simulacion-20070224.jar" sourcepath="/simulacion/src"/> + <classpathentry kind="lib" path="simulacion/lib/xmlrpc-client-3.0.jar"/> + <classpathentry kind="lib" path="simulacion/lib/xmlrpc-common-3.0.jar"/> + <classpathentry kind="lib" path="simulacion/lib/xmlrpc-server-3.0.jar"/> + <classpathentry kind="lib" path="simulacion/simulacion-20070224.jar" sourcepath="simulacion/src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="output" path="bin"/> </classpath> Modified: examples/simcafe/_Build_/Ant/build.xml =================================================================== --- examples/simcafe/_Build_/Ant/build.xml 2007-05-24 05:06:59 UTC (rev 147) +++ examples/simcafe/_Build_/Ant/build.xml 2007-05-24 05:07:50 UTC (rev 148) @@ -49,11 +49,9 @@ <property name="build.dir" value="build" /> <property name="cp-jars" value="${simulacion.dir}/lib/Java-mDNS.jar:${simulacion.dir}/lib/jmdns.jar:${simulacion.dir}/lib/junit-4.3.1.jar:${simulacion.dir}/lib/xmlrpc-2.0.jar:${simulacion.dir}/lib/kawa-1.8beta.jar:${simulacion.dir}/lib/jazzy.jar" /> <property environment="env" /> - <property name="checkstyle-jars" value="${env.ANT_HOME}/lib/ant.jar:${simulacion.dir}/lib/checkstyle-4.3.jar:${simulacion.dir}/lib/checkstyle-optional-4.3.jar:${simulacion.dir}/lib/antlr.jar:${simulacion.dir}/lib/jakarta-regexp-1.3.jar:${simulacion.dir}/lib/commons-beanutils-core.jar:${simulacion.dir}/lib/commons-codec-1.3.jar:${simulacion.dir}/lib/commons-httpclient-2.0.2.jar:${simulacion.dir}/lib/commons-logging-1.0.2.jar" /> <available file="${keystore}" type="dir" property="have.keystore"/> - <patternset id="runtime-libs" includes="commons-codec-1.3.jar commons-httpclient-2.0.2.jar commons-logging-1.0.2.jar Java-mDNS.jar jmdns.jar xercesImpl.jar xmlrpc-2.0.jar" /> <patternset id="junit-tests"> <include name="**/*Test.java" /> <!-- Exclude non-JUnit tests --> @@ -85,18 +83,14 @@ </untar> </target> - <target name="prepare" depends="-untar.simulacion"> - <taskdef resource="checkstyletask.properties" classpath="${checkstyle-jars}"/> - </target> - - <target name="ApplicationJar" depends="prepare"> + <target name="ApplicationJar"> <ant antfile="${simulacion.dir}/simulacion-ant.xml" target="ProjectJar" inheritRefs="true"> <property name="jarname" value="${jarname}"/> <property name="mainclass" value="${appchooserclass}"/> </ant> </target> - <target name="ApplicationDebugJar" depends="prepare"> + <target name="ApplicationDebugJar"> <ant antfile="${simulacion.dir}/simulacion-ant.xml" target="ProjectJar" inheritRefs="true"> <property name="debug" value="true" /> <property name="jarname" value="${jarname}" /> @@ -104,14 +98,14 @@ </ant> </target> - <target name="FatApplicationJar" depends="prepare"> + <target name="FatApplicationJar"> <ant antfile="${simulacion.dir}/simulacion-ant.xml" target="FatProjectJar" inheritRefs="true"> <property name="jarname" value="${jarname}"/> <property name="mainclass" value="${appchooserclass}"/> </ant> </target> - <target name="FatApplicationDebugJar" depends="prepare"> + <target name="FatApplicationDebugJar"> <ant antfile="${simulacion.dir}/simulacion-ant.xml" target="FatProjectJar" inheritRefs="true"> <property name="debug" value="true" /> <property name="jarname" value="${jarname}" /> @@ -119,7 +113,7 @@ </ant> </target> - <target name="ApplicationJavaDoc" depends="prepare"> + <target name="ApplicationJavaDoc"> <ant antfile="${simulacion.dir}/simulacion-ant.xml" target="ProjectJavaDoc" inheritRefs="true"> <property name="jarname" value="${jarname}" /> <property name="mainclass" value="${appchooserclass}" /> Modified: examples/simcommod/.classpath =================================================================== --- examples/simcommod/.classpath 2007-05-24 05:06:59 UTC (rev 147) +++ examples/simcommod/.classpath 2007-05-24 05:07:50 UTC (rev 148) @@ -6,11 +6,11 @@ <classpathentry kind="lib" path="simulacion/lib/checkstyle-4.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/checkstyle-optional-4.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-beanutils-core.jar"/> - <classpathentry kind="lib" path="simulacion/lib/commons-cli.jar"/> + <classpathentry kind="lib" path="simulacion/lib/commons-cli-1.0.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-codec-1.3.jar"/> - <classpathentry kind="lib" path="simulacion/lib/commons-collections.jar"/> + <classpathentry kind="lib" path="simulacion/lib/commons-collections-3.2.jar"/> <classpathentry kind="lib" path="simulacion/lib/commons-httpclient-2.0.2.jar"/> - <classpathentry kind="lib" path="simulacion/lib/commons-logging-1.0.2.jar"/> + <classpathentry kind="lib" path="simulacion/lib/commons-logging-1.1.jar"/> <classpathentry kind="lib" path="simulacion/lib/jakarta-regexp-1.3.jar"/> <classpathentry kind="lib" path="simulacion/lib/Java-mDNS.jar"/> <classpathentry kind="lib" path="simulacion/lib/jazzy.jar"/> @@ -20,11 +20,14 @@ <classpathentry kind="lib" path="simulacion/lib/q.jar"/> <classpathentry kind="lib" path="simulacion/lib/resolver.jar"/> <classpathentry kind="lib" path="simulacion/lib/servletapi-2.2.jar"/> + <classpathentry kind="lib" path="simulacion/lib/ws-commons-util-1.0.1.jar"/> <classpathentry kind="lib" path="simulacion/lib/xercesImpl.jar"/> <classpathentry kind="lib" path="simulacion/lib/xml-apis.jar"/> <classpathentry kind="lib" path="simulacion/lib/xmlParserAPIs.jar"/> - <classpathentry kind="lib" path="simulacion/lib/xmlrpc-2.0.jar"/> - <classpathentry kind="lib" path="simulacion/simulacion-20070224.jar" sourcepath="/simulacion/src"/> + <classpathentry kind="lib" path="simulacion/lib/xmlrpc-client-3.0.jar"/> + <classpathentry kind="lib" path="simulacion/lib/xmlrpc-common-3.0.jar"/> + <classpathentry kind="lib" path="simulacion/lib/xmlrpc-server-3.0.jar"/> + <classpathentry kind="lib" path="simulacion/simulacion-20070224.jar" sourcepath="simulacion/src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="output" path="bin"/> </classpath> Modified: examples/simcommod/_Build_/Ant/build.xml =================================================================== --- examples/simcommod/_Build_/Ant/build.xml 2007-05-24 05:06:59 UTC (rev 147) +++ examples/simcommod/_Build_/Ant/build.xml 2007-05-24 05:07:50 UTC (rev 148) @@ -49,11 +49,9 @@ <property name="build.dir" value="build" /> <property name="cp-jars" value="${simulacion.dir}/lib/Java-mDNS.jar:${simulacion.dir}/lib/jmdns.jar:${simulacion.dir}/lib/junit-4.3.1.jar:${simulacion.dir}/lib/xmlrpc-2.0.jar:${simulacion.dir}/lib/kawa-1.8beta.jar:${simulacion.dir}/lib/jazzy.jar" /> <property environment="env" /> - <property name="checkstyle-jars" value="${env.ANT_HOME}/lib/ant.jar:${simulacion.dir}/lib/checkstyle-4.3.jar:${simulacion.dir}/lib/checkstyle-optional-4.3.jar:${simulacion.dir}/lib/antlr.jar:${simulacion.dir}/lib/jakarta-regexp-1.3.jar:${simulacion.dir}/lib/commons-beanutils-core.jar:${simulacion.dir}/lib/commons-codec-1.3.jar:${simulacion.dir}/lib/commons-httpclient-2.0.2.jar:${simulacion.dir}/lib/commons-logging-1.0.2.jar" /> <available file="${keystore}" type="dir" property="have.keystore"/> - <patternset id="runtime-libs" includes="commons-codec-1.3.jar commons-httpclient-2.0.2.jar commons-logging-1.0.2.jar Java-mDNS.jar jmdns.jar xercesImpl.jar xmlrpc-2.0.jar" /> <patternset id="junit-tests"> <include name="**/*Test.java" /> <!-- Exclude non-JUnit tests --> @@ -84,18 +82,14 @@ </untar> </target> - <target name="prepare" depends="-untar.simulacion"> - <taskdef resource="checkstyletask.properties" classpath="${checkstyle-jars}"/> - </target> - - <target name="ApplicationJar" depends="prepare"> + <target name="ApplicationJar"> <ant antfile="${simulacion.dir}/simulacion-ant.xml" target="ProjectJar" inheritRefs="true"> <property name="jarname" value="${jarname}"/> <property name="mainclass" value="${appchooserclass}"/> </ant> </target> - <target name="ApplicationDebugJar" depends="prepare"> + <target name="ApplicationDebugJar"> <ant antfile="${simulacion.dir}/simulacion-ant.xml" target="ProjectJar" inheritRefs="true"> <property name="debug" value="true" /> <property name="jarname" value="${jarname}" /> @@ -103,14 +97,14 @@ </ant> </target> - <target name="FatApplicationJar" depends="prepare"> + <target name="FatApplicationJar"> <ant antfile="${simulacion.dir}/simulacion-ant.xml" target="FatProjectJar" inheritRefs="true"> <property name="jarname" value="${jarname}"/> <property name="mainclass" value="${appchooserclass}"/> </ant> </target> - <target name="FatApplicationDebugJar" depends="prepare"> + <target name="FatApplicationDebugJar"> <ant antfile="${simulacion.dir}/simulacion-ant.xml" target="FatProjectJar" inheritRefs="true"> <property name="debug" value="true" /> <property name="jarname" value="${jarname}" /> @@ -118,7 +112,7 @@ </ant> </target> - <target name="ApplicationJavaDoc" depends="prepare"> + <target name="ApplicationJavaDoc"> <ant antfile="${simulacion.dir}/simulacion-ant.xml" target="ProjectJavaDoc" inheritRefs="true"> <property name="jarname" value="${jarname}" /> <property name="mainclass" value="${appchooserclass}" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2007-05-24 05:07:01
|
Revision: 147 http://simulacion.svn.sourceforge.net/simulacion/?rev=147&view=rev Author: pguyot Date: 2007-05-23 22:06:59 -0700 (Wed, 23 May 2007) Log Message: ----------- Update for xmlrpc 3.0. Modified Paths: -------------- simulacion/.classpath simulacion/_Build_/Ant/build.xml simulacion/_Build_/Ant/simulacion-ant.xml simulacion/lib/commons-codec-1.3.jar simulacion/src/fr/lip6/sma/simulacion/server/adapter/xmlrpc/XmlRpcAdapter.java simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServer.java simulacion/src/fr/lip6/sma/simulacion/server/mdxr/MDXRAgentListManager.java simulacion/src/fr/lip6/sma/simulacion/server/mdxr/MDXRAgentRequest.java simulacion/src/fr/lip6/sma/simulacion/server/mdxr/MDXRServer.java Added Paths: ----------- simulacion/lib/commons-collections-3.2.jar simulacion/lib/commons-httpclient-3.0.1.jar simulacion/lib/commons-logging-1.1.jar simulacion/lib/ws-commons-util-1.0.1.jar simulacion/lib/xmlrpc-client-3.0.jar simulacion/lib/xmlrpc-common-3.0.jar simulacion/lib/xmlrpc-server-3.0.jar simulacion/src/fr/lip6/sma/simulacion/server/xmlrpc/ simulacion/src/fr/lip6/sma/simulacion/server/xmlrpc/AgentHandler.java simulacion/src/fr/lip6/sma/simulacion/server/xmlrpc/SimpleHandlerMapping.java simulacion/src/fr/lip6/sma/simulacion/server/xmlrpc/package.html Removed Paths: ------------- simulacion/lib/commons-cli.jar simulacion/lib/commons-collections.jar simulacion/lib/commons-httpclient-2.0.2.jar simulacion/lib/commons-logging-1.0.2.jar simulacion/lib/xmlrpc-2.0.jar simulacion/src/fr/lip6/sma/simulacion/server/Handler.java Modified: simulacion/.classpath =================================================================== --- simulacion/.classpath 2007-05-23 03:17:17 UTC (rev 146) +++ simulacion/.classpath 2007-05-24 05:06:59 UTC (rev 147) @@ -2,7 +2,10 @@ <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="lib" path="lib/xmlrpc-2.0.jar"/> + <classpathentry kind="lib" path="lib/xmlrpc-client-3.0.jar"/> + <classpathentry kind="lib" path="lib/xmlrpc-common-3.0.jar"/> + <classpathentry kind="lib" path="lib/xmlrpc-server-3.0.jar"/> + <classpathentry kind="lib" path="lib/ws-commons-util-1.0.1.jar"/> <classpathentry kind="lib" path="lib/kawa-1.8beta.jar"/> <classpathentry kind="lib" path="lib/jmdns.jar"/> <classpathentry kind="lib" path="lib/jazzy.jar"/> @@ -11,11 +14,10 @@ <classpathentry kind="lib" path="lib/xmlParserAPIs.jar"/> <classpathentry kind="lib" path="lib/xml-apis.jar"/> <classpathentry kind="lib" path="lib/xercesImpl.jar"/> - <classpathentry kind="lib" path="lib/commons-logging-1.0.2.jar"/> - <classpathentry kind="lib" path="lib/commons-httpclient-2.0.2.jar"/> - <classpathentry kind="lib" path="lib/commons-collections.jar"/> + <classpathentry kind="lib" path="lib/commons-logging-1.1.jar"/> + <classpathentry kind="lib" path="lib/commons-httpclient-3.0.1.jar"/> + <classpathentry kind="lib" path="lib/commons-collections-3.2.jar"/> <classpathentry kind="lib" path="lib/commons-codec-1.3.jar"/> - <classpathentry kind="lib" path="lib/commons-cli.jar"/> <classpathentry kind="lib" path="lib/commons-beanutils-core.jar"/> <classpathentry kind="lib" path="lib/junit-4.3.1.jar"/> <classpathentry kind="output" path="bin"/> Modified: simulacion/_Build_/Ant/build.xml =================================================================== --- simulacion/_Build_/Ant/build.xml 2007-05-23 03:17:17 UTC (rev 146) +++ simulacion/_Build_/Ant/build.xml 2007-05-24 05:06:59 UTC (rev 147) @@ -40,14 +40,12 @@ </loadfile> <property name="src.dir" value="${base.dir}/src/" /> <property name="build.dir" value="build" /> - <property name="cp-jars" value="${base.dir}/lib/Java-mDNS.jar:${base.dir}/lib/jmdns.jar:${base.dir}/lib/junit-4.3.1.jar:${base.dir}/lib/xmlrpc-2.0.jar:${base.dir}/lib/kawa-1.8beta.jar:${base.dir}/lib/jazzy.jar:${base.dir}/lib/AppleJavaExtensions.jar" /> + <property name="cp-jars" value="${base.dir}/lib/Java-mDNS.jar:${base.dir}/lib/jmdns.jar:${base.dir}/lib/junit-4.3.1.jar:${base.dir}/lib/ws-commons-util-1.0.1.jar:${base.dir}/lib/xmlrpc-client-3.0.jar:${base.dir}/lib/xmlrpc-common-3.0.jar:${base.dir}/lib/xmlrpc-server-3.0.jar:${base.dir}/lib/kawa-1.8beta.jar:${base.dir}/lib/jazzy.jar:${base.dir}/lib/AppleJavaExtensions.jar" /> <property environment="env" /> - <property name="checkstyle-jars" value="${env.ANT_HOME}/lib/ant.jar:${base.dir}/lib/checkstyle-4.3.jar:${base.dir}/lib/checkstyle-optional-4.3.jar:${base.dir}/lib/antlr.jar:${base.dir}/lib/jakarta-regexp-1.3.jar:${base.dir}/lib/commons-beanutils-core.jar:${base.dir}/lib/commons-collections.jar:${base.dir}/lib/commons-logging-1.0.2.jar" /> + <property name="checkstyle-jars" value="${env.ANT_HOME}/lib/ant.jar:${base.dir}/lib/checkstyle-4.3.jar:${base.dir}/lib/checkstyle-optional-4.3.jar:${base.dir}/lib/antlr.jar:${base.dir}/lib/jakarta-regexp-1.3.jar:${base.dir}/lib/commons-beanutils-core.jar:${base.dir}/lib/commons-collections.jar:${base.dir}/lib/commons-logging-1.1.jar" /> <taskdef resource="checkstyletask.properties" classpath="${checkstyle-jars}"/> <property name="svn.root" value="https://simulacion.svn.sourceforge.net/svnroot/simulacion/" /> - - <patternset id="runtime-libs" includes="commons-codec-1.3.jar commons-httpclient-2.0.2.jar commons-logging-1.0.2.jar Java-mDNS.jar jmdns.jar xercesImpl.jar xmlrpc-2.0.jar" /> <patternset id="junit-tests"> <include name="**/*Test.java" /> Modified: simulacion/_Build_/Ant/simulacion-ant.xml =================================================================== --- simulacion/_Build_/Ant/simulacion-ant.xml 2007-05-23 03:17:17 UTC (rev 146) +++ simulacion/_Build_/Ant/simulacion-ant.xml 2007-05-24 05:06:59 UTC (rev 147) @@ -90,6 +90,10 @@ <include name="**/*.java" /> </patternset> + <property name="checkstyle-jars" value="${env.ANT_HOME}/lib/ant.jar:${simulacion.dir}/lib/checkstyle-4.3.jar:${simulacion.dir}/lib/checkstyle-optional-4.3.jar:${simulacion.dir}/lib/antlr.jar:${simulacion.dir}/lib/jakarta-regexp-1.3.jar:${simulacion.dir}/lib/commons-beanutils-core.jar:${simulacion.dir}/lib/commons-codec-1.3.jar:${simulacion.dir}/lib/commons-httpclient-3.0.1.jar:${simulacion.dir}/lib/commons-logging-1.1.jar" /> + <patternset id="simulacion-runtime-libs" includes="commons-codec-1.3.jar commons-collections-3.2.jar commons-httpclient-3.0.1.jar commons-logging-1.1.jar Java-mDNS.jar jmdns.jar ws-commons-util-1.0.1.jar xercesImpl.jar xmlrpc-client-3.0.jar xmlrpc-common-3.0.jar xmlrpc-server-3.0.jar" /> + <patternset id="runtime-libs" includes="" /> + <!-- Check the version of Simulación --> <target name="-check.simulacion.version"> <loadfile property="simulacion.release.fromfile" srcfile="${simulacion.dir}/version"> @@ -200,7 +204,7 @@ <!-- extract the jars --> <unjar dest="${build.dir}/JarStuff"> <fileset dir="${simulacion.dir}/lib/"> - <patternset refid="runtime-libs" /> + <patternset refid="simulacion-runtime-libs" /> </fileset> </unjar> <unjar dest="${build.dir}/JarStuff" src="${simulacion.dir}/${simulacion.jar}" /> @@ -260,6 +264,7 @@ </target> <target name="ProjectCheckstyle" depends="ProjectJar" unless="skip.checkstyle"> + <taskdef resource="checkstyletask.properties" classpath="${checkstyle-jars}"/> <property name="samedir" value="${simulacion.dir}/checkstyle/"/> <checkstyle config="${samedir}/simulacion_checks.xml"> <fileset dir="${src.dir}" /> Deleted: simulacion/lib/commons-cli.jar =================================================================== (Binary files differ) Modified: simulacion/lib/commons-codec-1.3.jar =================================================================== (Binary files differ) Added: simulacion/lib/commons-collections-3.2.jar =================================================================== (Binary files differ) Property changes on: simulacion/lib/commons-collections-3.2.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Deleted: simulacion/lib/commons-collections.jar =================================================================== (Binary files differ) Deleted: simulacion/lib/commons-httpclient-2.0.2.jar =================================================================== (Binary files differ) Added: simulacion/lib/commons-httpclient-3.0.1.jar =================================================================== (Binary files differ) Property changes on: simulacion/lib/commons-httpclient-3.0.1.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Deleted: simulacion/lib/commons-logging-1.0.2.jar =================================================================== (Binary files differ) Added: simulacion/lib/commons-logging-1.1.jar =================================================================== (Binary files differ) Property changes on: simulacion/lib/commons-logging-1.1.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: simulacion/lib/ws-commons-util-1.0.1.jar =================================================================== (Binary files differ) Property changes on: simulacion/lib/ws-commons-util-1.0.1.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Deleted: simulacion/lib/xmlrpc-2.0.jar =================================================================== (Binary files differ) Added: simulacion/lib/xmlrpc-client-3.0.jar =================================================================== (Binary files differ) Property changes on: simulacion/lib/xmlrpc-client-3.0.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: simulacion/lib/xmlrpc-common-3.0.jar =================================================================== (Binary files differ) Property changes on: simulacion/lib/xmlrpc-common-3.0.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: simulacion/lib/xmlrpc-server-3.0.jar =================================================================== (Binary files differ) Property changes on: simulacion/lib/xmlrpc-server-3.0.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Deleted: simulacion/src/fr/lip6/sma/simulacion/server/Handler.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/Handler.java 2007-05-23 03:17:17 UTC (rev 146) +++ simulacion/src/fr/lip6/sma/simulacion/server/Handler.java 2007-05-24 05:06:59 UTC (rev 147) @@ -1,95 +0,0 @@ -// ============================== -// File: Handler.java -// Project: Simulaci\xF3n -// Written by: Paul Guyot (pau...@ac...) -// -// Created on: 12/5/2003 -// Tabs: 4 spaces -// -// This software is governed by the CeCILL license under French law and abiding -// by the rules of distribution of free software. You can use, modify and/ or -// redistribute the software under the terms of the CeCILL license as -// circulated by CEA, CNRS and INRIA at the following URL -// "http://www.cecill.info". -// -// As a counterpart to the access to the source code and rights to copy, modify -// and redistribute granted by the license, users are provided only with a -// limited warranty and the software's author, the holder of the economic -// rights, and the successive licensors have only limited liability. -// -// The fact that you are presently reading this means that you have had -// knowledge of the CeCILL license and that you accept its terms. -// -// =========== -// $Id$ -// =========== - -// paquet -package fr.lip6.sma.simulacion.server; - -// import -import java.util.Hashtable; - -/** - * Classe pour l'interface publique du serveur. - * L'int\xE9r\xEAt de cette classe est qu'elle limite les m\xE9thodes qui sont publi\xE9es. - * Inutile d'\xEAtre compl\xE8tement parano, mais ceci permet d'\xE9viter de publier des - * m\xE9thodes qui ne doivent pas \xEAtre appel\xE9es par le r\xE9seau. - * - * @author Paul Guyot <pau...@ac...> - * @version $Revision$ - * - * @see "aucun test d\xE9fini." - */ -public final class Handler { - /** - * R\xE9f\xE9rence sur l'agent. - */ - private final Agent mLocalAgent; - - /** - * Constructeur \xE0 partir de l'agent local. - * - * @param inLocalAgent mod\xE8le associ\xE9 \xE0 ce gestionnaire - */ - public Handler(Agent inLocalAgent) { - mLocalAgent = inLocalAgent; - } - - // CSOFF: IllegalType - /** - * Ex\xE9cute une op\xE9ration avec l'avatar. - * - * @param inOperationName nom de l'op\xE9ration \xE0 ex\xE9cuter. - * @param inParams param\xE8tres de l'op\xE9ration. - * @return le r\xE9sultat de l'op\xE9ration (sous forme de cha\xEEne). - * @throws Exception si une erreur est survenue. - */ - public synchronized String execute( - String inOperationName, - Hashtable<String, Object> inParams) - throws Exception { - // CSON: IllegalType - return mLocalAgent.execute(inOperationName, inParams); - } -} - -// ========================================================================= // -// Price Wang's programmer was coding software. His fingers danced // -// upon the keyboard. The program compiled without an error message, and // -// the program ran like a gentle wind. // -// Excellent!" the Price exclaimed, "Your technique is faultless!" // -// "Technique?" said the programmer, turning from his terminal, // -// "What I follow is the Tao -- beyond all technique. When I first began to // -// program I would see before me the whole program in one mass. After three // -// years I no longer saw this mass. Instead, I used subroutines. But now I // -// see nothing. My whole being exists in a formless void. My senses are // -// idle. My spirit, free to work without a plan, follows its own instinct. // -// In short, my program writes itself. True, sometimes there are difficult // -// problems. I see them coming, I slow down, I watch silently. Then I // -// change a single line of code and the difficulties vanish like puffs of // -// idle smoke. I then compile the program. I sit still and let the joy of // -// the work fill my being. I close my eyes for a moment and then log off." // -// Price Wang said, "Would that all of my programmers were as wise!" // -// -- Geoffrey James, "The Tao of Programming" // -// ========================================================================= // Modified: simulacion/src/fr/lip6/sma/simulacion/server/adapter/xmlrpc/XmlRpcAdapter.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/adapter/xmlrpc/XmlRpcAdapter.java 2007-05-23 03:17:17 UTC (rev 146) +++ simulacion/src/fr/lip6/sma/simulacion/server/adapter/xmlrpc/XmlRpcAdapter.java 2007-05-24 05:06:59 UTC (rev 147) @@ -28,7 +28,6 @@ package fr.lip6.sma.simulacion.server.adapter.xmlrpc; // imports -import java.io.IOException; import java.net.InetAddress; import java.net.URL; import java.util.HashSet; @@ -37,11 +36,16 @@ import java.util.Set; import java.util.Vector; -import org.apache.xmlrpc.WebServer; -import org.apache.xmlrpc.XmlRpc; -import org.apache.xmlrpc.XmlRpcClient; import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcHandler; +import org.apache.xmlrpc.XmlRpcRequest; +import org.apache.xmlrpc.client.XmlRpcClient; +import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; +import org.apache.xmlrpc.client.XmlRpcClientException; +import org.apache.xmlrpc.client.XmlRpcCommonsTransportFactory; +import org.apache.xmlrpc.server.XmlRpcServer; +import org.apache.xmlrpc.server.XmlRpcServerConfigImpl; +import org.apache.xmlrpc.webserver.WebServer; import fr.lip6.sma.simulacion.app.Configuration; import fr.lip6.sma.simulacion.server.Agent; @@ -52,6 +56,7 @@ import fr.lip6.sma.simulacion.server.NetworkAgentException; import fr.lip6.sma.simulacion.server.adapter.Adapter; import fr.lip6.sma.simulacion.server.adapter.AdapterAgent; +import fr.lip6.sma.simulacion.server.xmlrpc.SimpleHandlerMapping; /** * Classe pour un adaptateur XmlRpc. @@ -118,18 +123,6 @@ AgentListManager inAgentListManager) throws Exception { mAgentListManager = inAgentListManager; - // Configuration de XML-RPC. -// XmlRpc.setDebug(true); - try { - XmlRpc.setDriver("xerces"); - // le pilote par d\xE9faut ne sait pas g\xE9rer les - // encodages correctement. - XmlRpc.setEncoding("UTF8"); - } catch (ClassNotFoundException anException) { - anException.printStackTrace(); - System.exit(1); - } - // R\xE9cup\xE9ration de l'interface (par d\xE9faut, null). final String theInterface = inConfiguration.getProperty(INTERFACE_PROPERTY); @@ -137,26 +130,38 @@ // Cr\xE9ation du serveur. final InetAddress theAddress = InetAddress.getByName(theInterface); mServer = new WebServer(0, theAddress); - mServer.start(); - mPort = mServer.getPort(); - // On s'enregistre comme gestionnaire. - mServer.addHandler("adapter", this); + final SimpleHandlerMapping theMapping = new SimpleHandlerMapping(); + theMapping.addHandler("adapter", this); + final XmlRpcServer theServer = mServer.getXmlRpcServer(); + theServer.setHandlerMapping(theMapping); + final XmlRpcServerConfigImpl theServerConfig = + (XmlRpcServerConfigImpl) theServer.getConfig(); + theServerConfig.setEnabledForExtensions(true); + mServer.start(); + mPort = mServer.getPort(); + // R\xE9cup\xE9ration de l'URL du client. final String theClientURL = inConfiguration.getProperty(CLIENT_URL_PROPERTY); // Cr\xE9ation du client. - mClient = new XmlRpcClient(new URL(theClientURL)); + final XmlRpcClientConfigImpl theConfig = + new XmlRpcClientConfigImpl(); + theConfig.setServerURL(new URL(theClientURL)); + mClient = new XmlRpcClient(); + mClient.setTransportFactory( + new XmlRpcCommonsTransportFactory(mClient)); + mClient.setConfig(theConfig); // On s'enregistre aupr\xE8s du client. final String theServerURL = "http://" + theAddress.toString() + ":" + mPort + "/"; - final List<Object> theParams = new Vector<Object>(); + final List<Object> theParams = new Vector<Object>(1); theParams.add(theServerURL); - mClient.execute("adapter.setupAdapter", (Vector<Object>) theParams); + mClient.execute("adapter.setupAdapter", theParams); // On s'enregistre aupr\xE8s de la liste. mAgentListManager.addListener(this); @@ -186,8 +191,8 @@ try { theResult = (String) mClient.execute( - "adapter.executeAgentMethod", (Vector<Object>) theParams); - } catch (IOException anException) { + "adapter.executeAgentMethod", theParams); + } catch (XmlRpcClientException anException) { throw new NetworkAgentException(anException); } catch (XmlRpcException anException) { throw new AgentException(anException); @@ -212,21 +217,19 @@ /** * Point d'entr\xE9e de l'adaptateur XML-RPC. * - * @param inMethodName nom de la m\xE9thode. - * @param inMethodParams param\xE8tres de la m\xE9thode. - * @return le r\xE9sultat de la requ\xEAte. - * @throws Exception si un probl\xE8me est survenu. + * @param inRequest request. + * @return the result of the request. + * @throws XmlRpcException if a problem occurred. */ @SuppressWarnings("unchecked") - public final Object execute( - String inMethodName, - Vector inMethodParams) throws Exception { - // CSON: IllegalType + public final Object execute(XmlRpcRequest inRequest) + throws XmlRpcException { + final String theMethodName = inRequest.getMethodName(); Object theResult; - if (inMethodName.equals("adapter.registerLocalAgent")) { - final String theAgentClass = (String) inMethodParams.get(0); - final String theAgentName = (String) inMethodParams.get(1); + if (theMethodName.equals("adapter.registerLocalAgent")) { + final String theAgentClass = (String) inRequest.getParameter(0); + final String theAgentName = (String) inRequest.getParameter(1); // Cr\xE9ation de l'agent local. assert mLocalAgent == null; @@ -257,17 +260,17 @@ // \xC9chec. theResult = "NO"; } - } else if (inMethodName.equals("adapter.unregisterLocalAgent")) { -// final String theAgentName = (String) inMethodParams.get(0); -// final String theAgentClass = (String) inMethodParams.get(1); + } else if (theMethodName.equals("adapter.unregisterLocalAgent")) { +// final String theAgentClass = (String) inRequest.getParameter(0); +// final String theAgentName = (String) inRequest.getParameter(1); mAgentListManager.unregisterLocalAgent(mLocalAgent); theResult = "OK"; - } else if (inMethodName.equals("adapter.executeMethod")) { - final String theAgentClass = (String) inMethodParams.get(0); - final String theAgentName = (String) inMethodParams.get(1); - final String theMethod = (String) inMethodParams.get(2); + } else if (theMethodName.equals("adapter.executeMethod")) { + final String theAgentClass = (String) inRequest.getParameter(0); + final String theAgentName = (String) inRequest.getParameter(1); + final String theMethod = (String) inRequest.getParameter(2); final Map<String, Object> theParams = - (Map<String, Object>) inMethodParams.get(3); + (Map<String, Object>) inRequest.getParameter(3); final Agent theAgent = mAgentListManager.getAgent( @@ -275,11 +278,15 @@ if (theAgent == null) { // Remarque: il peut y avoir un d\xE9lai, et donc le client peut // ne pas savoir que l'agent n'existe plus. - throw new AgentException( - new NullPointerException("No such agent")); + throw new XmlRpcException("No such agent", new AgentException( + new NullPointerException("No such agent"))); } - theResult = theAgent.execute(theMethod, theParams); - } else if (inMethodName.equals("adapter.getAgentSet")) { + try { + theResult = theAgent.execute(theMethod, theParams); + } catch (AgentException anException) { + throw new XmlRpcException(anException.toString(), anException); + } + } else if (theMethodName.equals("adapter.getAgentSet")) { final Set<String> theAgentIDSet = new HashSet<String>(); for (Agent theAgent : mAgentListManager.getAgentSet()) { theAgentIDSet.add(theAgent.getAgentSpecification().toString()); @@ -287,7 +294,8 @@ theResult = theAgentIDSet; } else { - throw new NoSuchMethodException(inMethodName); + throw new XmlRpcException("No such method", + new NoSuchMethodException(theMethodName)); } return theResult; @@ -322,8 +330,6 @@ public final void listChanged() { try { mClient.execute("adapter.listChanged", new Vector<Object>()); - } catch (IOException anException) { - // Tant pis. } catch (XmlRpcException anException) { // Tant pis (bis). } Modified: simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java 2007-05-23 03:17:17 UTC (rev 146) +++ simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPClient.java 2007-05-24 05:06:59 UTC (rev 147) @@ -35,10 +35,12 @@ import java.util.Map; import java.util.Vector; -import org.apache.xmlrpc.AsyncCallback; -import org.apache.xmlrpc.XmlRpc; -import org.apache.xmlrpc.XmlRpcClient; import org.apache.xmlrpc.XmlRpcException; +import org.apache.xmlrpc.XmlRpcRequest; +import org.apache.xmlrpc.client.AsyncCallback; +import org.apache.xmlrpc.client.XmlRpcClient; +import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; +import org.apache.xmlrpc.client.XmlRpcCommonsTransportFactory; import fr.lip6.sma.simulacion.app.Configuration; import fr.lip6.sma.simulacion.server.AgentException; @@ -89,17 +91,7 @@ * Constructeur par d\xE9faut. */ public HTTPClient() { - // Configuration du serveur. -// XmlRpc.setDebug(true); - try { - XmlRpc.setDriver("xerces"); - // le pilote par d\xE9faut ne sait pas g\xE9rer les - // encodages correctement. - XmlRpc.setEncoding("UTF8"); - } catch (ClassNotFoundException anException) { - anException.printStackTrace(); - System.exit(1); - } + // This space for rent. } /** @@ -136,7 +128,13 @@ try { // Tentative de conversion en URL // et cr\xE9ation du client XmlRpc. - mXmlRpcClient = new XmlRpcClient(new URL(inURL)); + final XmlRpcClientConfigImpl theConfig = + new XmlRpcClientConfigImpl(); + theConfig.setServerURL(new URL(inURL)); + mXmlRpcClient = new XmlRpcClient(); + mXmlRpcClient.setTransportFactory( + new XmlRpcCommonsTransportFactory(mXmlRpcClient)); + mXmlRpcClient.setConfig(theConfig); // Appel de la m\xE9thode getVersion. final String theServerGameID = @@ -176,9 +174,6 @@ } catch (XmlRpcException anException) { anException.printStackTrace(); mXmlRpcClient = null; - } catch (IOException anException) { - anException.printStackTrace(); - mXmlRpcClient = null; } catch (ClassCastException anException) { anException.printStackTrace(); mXmlRpcClient = null; @@ -195,8 +190,13 @@ mRunning = true; while (mRunning) { synchronized (this) { - mXmlRpcClient.executeAsync( - "server.listen", (Vector<Object>) theParams, this); + try { + mXmlRpcClient.executeAsync( + "server.listen", theParams, this); + } catch (XmlRpcException anException) { + anException.printStackTrace(); + // On ignore. + } // On attend. try { @@ -210,13 +210,10 @@ try { mXmlRpcClient.execute( "server.endClient", - (Vector<Object>) theParams); + theParams); } catch (XmlRpcException anException) { anException.printStackTrace(); // On ignore. - } catch (IOException anException) { - anException.printStackTrace(); - // On ignore aussi. } mXmlRpcClient = null; @@ -244,17 +241,12 @@ } /** - * M\xE9thode appel\xE9e lorsque le serveur a r\xE9pondu \xE0 notre requ\xEAte listen. - * - * @param inResult r\xE9sultat de la m\xE9thode. - * @param inURL URL du serveur. - * @param inMethod m\xE9thode appel\xE9e (ici listen). + * {@inheritDoc} */ @SuppressWarnings("unchecked") public void handleResult( - Object inResult, - URL inURL, - String inMethod) { + XmlRpcRequest inRequest, + Object inResult) { if ((inResult != null) && (inResult instanceof Throwable)) { // Output the exception. ((Throwable) inResult).printStackTrace(); @@ -295,16 +287,11 @@ } /** - * M\xE9thode appel\xE9e lorsqu'une erreur est survenue avec notre requ\xEAte listen. - * - * @param inException exception survenue. - * @param inURL URL de la requ\xEAte. - * @param inMethod m\xE9thode invoqu\xE9e (listen). + * {@inheritDoc} */ public void handleError( - Exception inException, - URL inURL, - String inMethod) { + XmlRpcRequest inRequest, + Throwable inException) { // On sort. // \xC0 terme, on pourrait \xEAtre plus robuste. inException.printStackTrace(); @@ -467,14 +454,14 @@ theResult = mXmlRpcClient.execute( inMethodName, - (Vector<Object>) inParams); + inParams); } catch (NullPointerException anException) { // On ignore si c'est juste le serveur qui est ferm\xE9. if (mXmlRpcClient != null) { anException.printStackTrace(); } - } catch (IOException anException) { - if (!(anException instanceof ConnectException)) { + } catch (XmlRpcException anException) { + if (!(anException.getCause() instanceof ConnectException)) { anException.printStackTrace(); } Modified: simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServer.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServer.java 2007-05-23 03:17:17 UTC (rev 146) +++ simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPServer.java 2007-05-24 05:06:59 UTC (rev 147) @@ -40,9 +40,12 @@ import java.util.TimerTask; import java.util.Vector; -import org.apache.xmlrpc.WebServer; -import org.apache.xmlrpc.XmlRpc; +import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcHandler; +import org.apache.xmlrpc.XmlRpcRequest; +import org.apache.xmlrpc.server.XmlRpcServer; +import org.apache.xmlrpc.server.XmlRpcServerConfigImpl; +import org.apache.xmlrpc.webserver.WebServer; import com.kallisys.zeroconf.MDNSException; import com.kallisys.zeroconf.MulticastDNSClient; @@ -55,6 +58,7 @@ import fr.lip6.sma.simulacion.server.AgentSpecification; import fr.lip6.sma.simulacion.server.NetworkAgentException; import fr.lip6.sma.simulacion.server.ServerException; +import fr.lip6.sma.simulacion.server.xmlrpc.SimpleHandlerMapping; /** * Classe pour le serveur HTTP qui g\xE8re les diff\xE9rents clients. @@ -322,24 +326,17 @@ // Cr\xE9ation de la liste des agents. mAgentsRegistry = new Hashtable<AgentSpecification, Integer>(); - // Configuration du serveur. -// XmlRpc.setDebug(true); - XmlRpc.setMaxThreads(2048); - try { - XmlRpc.setDriver("xerces"); - // le pilote par d\xE9faut ne sait pas g\xE9rer les - // encodages correctement. - XmlRpc.setEncoding("UTF8"); - } catch (ClassNotFoundException anException) { - anException.printStackTrace(); - System.exit(1); - } - // Cr\xE9ation du serveur. mServer = new WebServer(thePort); - // On s'enregistre comme gestionnaire. - mServer.addHandler("server", this); + // Configure the server. + final SimpleHandlerMapping theMapping = new SimpleHandlerMapping(); + theMapping.addHandler("server", this); + final XmlRpcServer theServer = mServer.getXmlRpcServer(); + theServer.setHandlerMapping(theMapping); + final XmlRpcServerConfigImpl theServerConfig = + (XmlRpcServerConfigImpl) theServer.getConfig(); + theServerConfig.setEnabledForExtensions(true); // Publication du serveur. if (mMDNSServer != null) { @@ -382,7 +379,11 @@ */ protected void init() throws ServerException { super.init(); - mServer.start(); + try { + mServer.start(); + } catch (IOException anException) { + throw new ServerException(anException); + } } /** @@ -421,53 +422,59 @@ } } - // CSOFF: IllegalType /** - * Point d'entr\xE9e du serveur XML-RPC. - * Cette m\xE9thode est r\xE9-entrante et appel\xE9e \xE0 chaque requ\xEAte. - * - * @param inMethod nom de la m\xE9thode appel\xE9e (objet.nom). - * @param inParams liste des param\xE8tres. - * @return une cha\xEEne d\xE9crivant le jeu (et la version) de ce serveur. - * @throws Exception si un probl\xE8me est survenu. + * {@inheritDoc} */ @SuppressWarnings("unchecked") - public Object execute(String inMethod, Vector inParams) throws Exception { - // CSON: IllegalType + public Object execute(XmlRpcRequest inRequest) throws XmlRpcException { + final String operationName = inRequest.getMethodName(); Object theResult; - if (inMethod.equals("server.getGameID")) { + if (operationName.equals("server.getGameID")) { theResult = mGameID; - } else if (inMethod.equals("server.newClient")) { + } else if (operationName.equals("server.newClient")) { theResult = new Integer(newClient()); - } else if (inMethod.equals("server.listen")) { - final int theClientID = ((Integer) inParams.get(0)).intValue(); + } else if (operationName.equals("server.listen")) { + final int theClientID = + ((Integer) inRequest.getParameter(0)).intValue(); theResult = listen(theClientID); - } else if (inMethod.equals("server.endClient")) { - final int theClientID = ((Integer) inParams.get(0)).intValue(); + } else if (operationName.equals("server.endClient")) { + final int theClientID = + ((Integer) inRequest.getParameter(0)).intValue(); endClient(theClientID); theResult = ""; - } else if (inMethod.equals("server.register")) { - final int theClientID = ((Integer) inParams.get(0)).intValue(); - final String theAgentSpecStr = (String) inParams.get(1); + } else if (operationName.equals("server.register")) { + final int theClientID = + ((Integer) inRequest.getParameter(0)).intValue(); + final String theAgentSpecStr = (String) inRequest.getParameter(1); theResult = Boolean.valueOf( register(theClientID, theAgentSpecStr)); - } else if (inMethod.equals("server.unregister")) { - final int theClientID = ((Integer) inParams.get(0)).intValue(); - final String theAgentSpecStr = (String) inParams.get(1); + } else if (operationName.equals("server.unregister")) { + final int theClientID = + ((Integer) inRequest.getParameter(0)).intValue(); + final String theAgentSpecStr = (String) inRequest.getParameter(1); unregister(theClientID, theAgentSpecStr); theResult = ""; - } else if (inMethod.equals("server.executeAgentMethod")) { - final int theClientID = ((Integer) inParams.get(0)).intValue(); - final String theAgentSpecStr = (String) inParams.get(1); - final String theMethodName = (String) inParams.get(2); + } else if (operationName.equals("server.executeAgentMethod")) { + final int theClientID = + ((Integer) inRequest.getParameter(0)).intValue(); + final String theAgentSpecStr = (String) inRequest.getParameter(1); + final String theMethodName = (String) inRequest.getParameter(2); final Map<String, Object> theParams = - (Map<String, Object>) inParams.get(3); - final String theResultStr = - executeAgentMethod( - theClientID, - theAgentSpecStr, - theMethodName, - theParams); + (Map<String, Object>) inRequest.getParameter(3); + String theResultStr = null; + try { + theResultStr = + executeAgentMethod( + theClientID, + theAgentSpecStr, + theMethodName, + theParams); + } catch (NetworkAgentException anException) { + if (mVerboseMode) { + anException.printStackTrace(); + } + throw new XmlRpcException(anException.toString(), anException); + } theResult = theResultStr; if (mVerboseMode) { logExecuteAgentMethodVerbose( @@ -477,16 +484,24 @@ theParams, theResultStr); } - } else if (inMethod.equals("server.executeAgentMethodAsync")) { - final int theClientID = ((Integer) inParams.get(0)).intValue(); - final String theAgentSpecStr = (String) inParams.get(1); - final String theMethodName = (String) inParams.get(2); - final Map theParams = (Map) inParams.get(3); - executeAgentMethodAsync( - theClientID, - theAgentSpecStr, - theMethodName, - theParams); + } else if (operationName.equals("server.executeAgentMethodAsync")) { + final int theClientID = + ((Integer) inRequest.getParameter(0)).intValue(); + final String theAgentSpecStr = (String) inRequest.getParameter(1); + final String theMethodName = (String) inRequest.getParameter(2); + final Map theParams = (Map) inRequest.getParameter(3); + try { + executeAgentMethodAsync( + theClientID, + theAgentSpecStr, + theMethodName, + theParams); + } catch (NetworkAgentException anException) { + if (mVerboseMode) { + anException.printStackTrace(); + } + throw new XmlRpcException(anException.toString(), anException); + } theResult = "(void)"; if (mVerboseMode) { logExecuteAgentMethodVerbose( @@ -496,9 +511,9 @@ theParams, "(void)"); } - } else if (inMethod.equals("server.result")) { - final Integer theOperationID = (Integer) inParams.get(1); - final String theMethodResult = (String) inParams.get(2); + } else if (operationName.equals("server.result")) { + final Integer theOperationID = (Integer) inRequest.getParameter(1); + final String theMethodResult = (String) inRequest.getParameter(2); theResult = ""; final List<Object> theHolder = mPendingOperations.get(theOperationID); @@ -508,9 +523,10 @@ theHolder.notifyAll(); } } - } else if (inMethod.equals("server.exception")) { - final Integer theOperationID = (Integer) inParams.get(1); - final String theExceptionString = (String) inParams.get(2); + } else if (operationName.equals("server.exception")) { + final Integer theOperationID = (Integer) inRequest.getParameter(1); + final String theExceptionString = + (String) inRequest.getParameter(2); theResult = ""; final List<Object> theHolder = mPendingOperations.get(theOperationID); @@ -521,7 +537,8 @@ } } } else { - throw new NoSuchMethodException(inMethod); + throw new XmlRpcException("No such method", + new NoSuchMethodException(operationName)); } return theResult; } Modified: simulacion/src/fr/lip6/sma/simulacion/server/mdxr/MDXRAgentListManager.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/mdxr/MDXRAgentListManager.java 2007-05-23 03:17:17 UTC (rev 146) +++ simulacion/src/fr/lip6/sma/simulacion/server/mdxr/MDXRAgentListManager.java 2007-05-24 05:06:59 UTC (rev 147) @@ -88,7 +88,7 @@ /** * Constructeur \xE0 partir d'un serveur MDXR. - * Lance la recherche des avatars. + * Lance la recherche des agents. * * @param inServer serveur MDXR (son port nous int\xE9resse). * @param inPlayerClasses classes des joueurs. Modified: simulacion/src/fr/lip6/sma/simulacion/server/mdxr/MDXRAgentRequest.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/mdxr/MDXRAgentRequest.java 2007-05-23 03:17:17 UTC (rev 146) +++ simulacion/src/fr/lip6/sma/simulacion/server/mdxr/MDXRAgentRequest.java 2007-05-24 05:06:59 UTC (rev 147) @@ -30,11 +30,16 @@ // imports import java.io.IOException; import java.net.InetSocketAddress; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.List; import java.util.Map; import java.util.Vector; -import org.apache.xmlrpc.XmlRpcClient; import org.apache.xmlrpc.XmlRpcException; +import org.apache.xmlrpc.client.XmlRpcClient; +import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; +import org.apache.xmlrpc.client.XmlRpcCommonsTransportFactory; import com.kallisys.zeroconf.MulticastDNSClient; import com.kallisys.zeroconf.MulticastDNSServer; @@ -113,19 +118,32 @@ // Contact du serveur maintenant qu'on a son adresse et son port. final InetSocketAddress theAddress = mService.getAddresses()[0]; - final XmlRpcClient theXMLRPCClient = - new XmlRpcClient( + final XmlRpcClientConfigImpl theConfig = + new XmlRpcClientConfigImpl(); + URL theURL; + + try { + theURL = + new URL("http", theAddress.getAddress().getHostAddress(), - theAddress.getPort()); - // CSOFF: IllegalType - final Vector<Object> theParamsVector = new Vector<Object>(); - // CSON: IllegalType + theAddress.getPort(), + "/"); + } catch (MalformedURLException anException) { + throw new XmlRpcException(anException.toString(), anException); + } + + theConfig.setServerURL(theURL); + final XmlRpcClient theXMLRPCClient = new XmlRpcClient(); + theXMLRPCClient.setTransportFactory( + new XmlRpcCommonsTransportFactory(theXMLRPCClient)); + theXMLRPCClient.setConfig(theConfig); + final List<Object> theParamsVector = new Vector<Object>(2); theParamsVector.add(inOperationName); theParamsVector.add(inParams); // La m\xE9thode retourne une cha\xEEne. final String theResult = - (String) theXMLRPCClient.execute("avatar.execute", theParamsVector); + (String) theXMLRPCClient.execute("agent.execute", theParamsVector); return theResult; } Modified: simulacion/src/fr/lip6/sma/simulacion/server/mdxr/MDXRServer.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/mdxr/MDXRServer.java 2007-05-23 03:17:17 UTC (rev 146) +++ simulacion/src/fr/lip6/sma/simulacion/server/mdxr/MDXRServer.java 2007-05-24 05:06:59 UTC (rev 147) @@ -28,14 +28,19 @@ package fr.lip6.sma.simulacion.server.mdxr; // imports -import org.apache.xmlrpc.WebServer; -import org.apache.xmlrpc.XmlRpc; +import java.io.IOException; +import org.apache.xmlrpc.server.XmlRpcServer; +import org.apache.xmlrpc.server.XmlRpcServerConfigImpl; +import org.apache.xmlrpc.webserver.WebServer; + import fr.lip6.sma.simulacion.app.Configuration; import fr.lip6.sma.simulacion.server.Agent; import fr.lip6.sma.simulacion.server.AgentListManager; -import fr.lip6.sma.simulacion.server.Handler; import fr.lip6.sma.simulacion.server.Server; +import fr.lip6.sma.simulacion.server.ServerException; +import fr.lip6.sma.simulacion.server.xmlrpc.AgentHandler; +import fr.lip6.sma.simulacion.server.xmlrpc.SimpleHandlerMapping; /** * Classe pour le serveur de Simulacion. @@ -56,7 +61,7 @@ * Gestionnaire pour l'agent local, <code>null</code> tant qu'il n'est * pas d\xE9fini. */ - private Handler mLocalAgentHandler; + private AgentHandler mLocalAgentHandler; /** * Gestionnaire de liste pour les agents. @@ -64,34 +69,42 @@ private MDXRAgentListManager mAgentListManager; /** + * Handler mappings. + */ + private final SimpleHandlerMapping mHandlerMapping; + + /** * Constructeur par d\xE9faut. */ public MDXRServer() { super(0); mLocalAgentHandler = null; + + mHandlerMapping = new SimpleHandlerMapping(); + final XmlRpcServer theServer = getXmlRpcServer(); + theServer.setHandlerMapping(mHandlerMapping); } /** * Configure et d\xE9marre le serveur. * * @param inConfiguration configuration de l'application. + * @throws ServerException if there was a problem binding the server. */ - public void start(Configuration inConfiguration) { - // Configuration du serveur. -// XmlRpc.setDebug(true); + public void start(Configuration inConfiguration) throws ServerException { + // Configuration. + final XmlRpcServer theServer = getXmlRpcServer(); + final XmlRpcServerConfigImpl theServerConfig = + (XmlRpcServerConfigImpl) theServer.getConfig(); + theServerConfig.setEnabledForExtensions(true); + + // On lance le serveur. try { - XmlRpc.setDriver("xerces"); - // le pilote par d\xE9faut ne sait pas g\xE9rer les - // encodages correctement. - XmlRpc.setEncoding("UTF8"); - } catch (ClassNotFoundException anException) { - anException.printStackTrace(); - System.exit(1); + start(); + } catch (IOException anException) { + throw new ServerException(anException); } - - // On lance le serveur. - start(); // Puis on construit le gestionnaire de liste. mAgentListManager = @@ -117,12 +130,12 @@ final void setLocalAgent(Agent inLocalAgent) { if (mLocalAgentHandler != null) { // Suppression de l'ancien agent. - removeHandler("avatar"); + mHandlerMapping.removeHandler("agent"); } // Ajout du (nouveau) gestionnaire. - mLocalAgentHandler = new Handler(inLocalAgent); - addHandler("avatar", mLocalAgentHandler); + mLocalAgentHandler = new AgentHandler(inLocalAgent); + mHandlerMapping.addHandler("agent", mLocalAgentHandler); } /** @@ -137,7 +150,7 @@ if (mLocalAgentHandler != null) { // On supprime le gestionnaire - removeHandler("avatar"); + mHandlerMapping.removeHandler("agent"); mLocalAgentHandler = null; } Added: simulacion/src/fr/lip6/sma/simulacion/server/xmlrpc/AgentHandler.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/xmlrpc/AgentHandler.java (rev 0) +++ simulacion/src/fr/lip6/sma/simulacion/server/xmlrpc/AgentHandler.java 2007-05-24 05:06:59 UTC (rev 147) @@ -0,0 +1,107 @@ +// ============================== +// File: Handler.java +// Project: Simulaci\xF3n +// Written by: Paul Guyot (pau...@ac...) +// +// Created on: 12/5/2003 +// Tabs: 4 spaces +// +// This software is governed by the CeCILL license under French law and abiding +// by the rules of distribution of free software. You can use, modify and/ or +// redistribute the software under the terms of the CeCILL license as +// circulated by CEA, CNRS and INRIA at the following URL +// "http://www.cecill.info". +// +// As a counterpart to the access to the source code and rights to copy, modify +// and redistribute granted by the license, users are provided only with a +// limited warranty and the software's author, the holder of the economic +// rights, and the successive licensors have only limited liability. +// +// The fact that you are presently reading this means that you have had +// knowledge of the CeCILL license and that you accept its terms. +// +// =========== +// $Id$ +// =========== + +// paquet +package fr.lip6.sma.simulacion.server.xmlrpc; + +// import +import java.util.Map; + +import org.apache.xmlrpc.XmlRpcException; +import org.apache.xmlrpc.XmlRpcHandler; +import org.apache.xmlrpc.XmlRpcRequest; + +import fr.lip6.sma.simulacion.server.Agent; +import fr.lip6.sma.simulacion.server.AgentException; + +/** + * Classe pour l'interface publique du serveur. + * L'int\xE9r\xEAt de cette classe est qu'elle limite les m\xE9thodes qui sont publi\xE9es. + * Inutile d'\xEAtre compl\xE8tement parano, mais ceci permet d'\xE9viter de publier des + * m\xE9thodes qui ne doivent pas \xEAtre appel\xE9es par le r\xE9seau. + * + * @author Paul Guyot <pau...@ac...> + * @version $Revision$ + * + * @see "aucun test d\xE9fini." + */ +public final class AgentHandler implements XmlRpcHandler { + /** + * R\xE9f\xE9rence sur l'agent. + */ + private final Agent mLocalAgent; + + /** + * Constructeur \xE0 partir de l'agent local. + * + * @param inLocalAgent mod\xE8le associ\xE9 \xE0 ce gestionnaire + */ + public AgentHandler(Agent inLocalAgent) { + mLocalAgent = inLocalAgent; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public Object execute(XmlRpcRequest inRequest) throws XmlRpcException { + Object theResult; + if (inRequest.getMethodName().endsWith(".execute")) { + final String operationName = (String) inRequest.getParameter(0); + final Map<String, Object> theParams = + (Map<String, Object>) inRequest.getParameter(1); + try { + theResult = mLocalAgent.execute(operationName, theParams); + } catch (AgentException anException) { + throw new XmlRpcException(anException.toString(), anException); + } + } else { + throw new XmlRpcException("No such method"); + } + + return theResult; + } +} + +// ========================================================================= // +// Price Wang's programmer was coding software. His fingers danced // +// upon the keyboard. The program compiled without an error message, and // +// the program ran like a gentle wind. // +// Excellent!" the Price exclaimed, "Your technique is faultless!" // +// "Technique?" said the programmer, turning from his terminal, // +// "What I follow is the Tao -- beyond all technique. When I first began to // +// program I would see before me the whole program in one mass. After three // +// years I no longer saw this mass. Instead, I used subroutines. But now I // +// see nothing. My whole being exists in a formless void. My senses are // +// idle. My spirit, free to work without a plan, follows its own instinct. // +// In short, my program writes itself. True, sometimes there are difficult // +// problems. I see them coming, I slow down, I watch silently. Then I // +// change a single line of code and the difficulties vanish like puffs of // +// idle smoke. I then compile the program. I sit still and let the joy of // +// the work fill my being. I close my eyes for a moment and then log off." // +// Price Wang said, "Would that all of my programmers were as wise!" // +// -- Geoffrey James, "The Tao of Programming" // +// ========================================================================= // Property changes on: simulacion/src/fr/lip6/sma/simulacion/server/xmlrpc/AgentHandler.java ___________________________________________________________________ Name: svn:executable + * Name: svn:keywords + Revision Id Added: simulacion/src/fr/lip6/sma/simulacion/server/xmlrpc/SimpleHandlerMapping.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/xmlrpc/SimpleHandlerMapping.java (rev 0) +++ simulacion/src/fr/lip6/sma/simulacion/server/xmlrpc/SimpleHandlerMapping.java 2007-05-24 05:06:59 UTC (rev 147) @@ -0,0 +1,91 @@ +// ============================== +// File: SimpleHandlerMapping.java +// Project: Simulaci\xF3n +// Written by: Paul Guyot (pau...@ac...) +// +// Created on: 24/5/2007 +// Tabs: 4 spaces +// +// This software is governed by the CeCILL license under French law and abiding +// by the rules of distribution of free software. You can use, modify and/ or +// redistribute the software under the terms of the CeCILL license as +// circulated by CEA, CNRS and INRIA at the following URL +// "http://www.cecill.info". +// +// As a counterpart to the access to the source code and rights to copy, modify +// and redistribute granted by the license, users are provided only with a +// limited warranty and the software's author, the holder of the economic +// rights, and the successive licensors have only limited liability. +// +// The fact that you are presently reading this means that you have had +// knowledge of the CeCILL license and that you accept its terms. +// +// =========== +// $Id$ +// =========== + +// paquet +package fr.lip6.sma.simulacion.server.xmlrpc; + +// imports +import java.util.HashMap; +import java.util.Map; + +import org.apache.xmlrpc.XmlRpcHandler; +import org.apache.xmlrpc.server.XmlRpcHandlerMapping; + +/** + * Simple handler mapping implementation for the purpose of the transition + * from Apache XmlRpc-2.0 to XmlRpc-3.0. + * + * @author Paul Guyot <pau...@ac...> + * @version $Revision$ + */ +public final class SimpleHandlerMapping implements XmlRpcHandlerMapping { + /** + * List of handlers. + */ + private final Map<String, XmlRpcHandler> mHandlers; + + /** + * Default constructor. + */ + public SimpleHandlerMapping() { + mHandlers = new HashMap<String, XmlRpcHandler>(); + } + + /** + * {@inheritDoc} + */ + public XmlRpcHandler getHandler(String inName) { + final String[] segments = inName.split("\\."); + return mHandlers.get(segments[0]); + } + + /** + * Add a handler. + * + * @param inName name of the handler. + * @param inHandler handler to add. + */ + public void addHandler(String inName, XmlRpcHandler inHandler) { + mHandlers.put(inName, inHandler); + } + + /** + * Remove a handler. + * + * @param inName name of the handler. + */ + public void removeHandler(String inName) { + mHandlers.remove(inName); + } +} + +// ======================================================================== // +// Making files is easy under the UNIX operating system. Therefore, users // +// tend to create numerous files using large amounts of file space. It has // +// been said that the only standard thing about all UNIX systems is the // +// message-of-the-day telling users to clean up their files. // +// -- System V.2 administrator's guide // +// ======================================================================== // Property changes on: simulacion/src/fr/lip6/sma/simulacion/server/xmlrpc/SimpleHandlerMapping.java ___________________________________________________________________ Name: svn:executable + * Name: svn:keywords + Revision Id Added: simulacion/src/fr/lip6/sma/simulacion/server/xmlrpc/package.html =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/server/xmlrpc/package.html (rev 0) +++ simulacion/src/fr/lip6/sma/simulacion/server/xmlrpc/package.html 2007-05-24 05:06:59 UTC (rev 147) @@ -0,0 +1,42 @@ +<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<!-- +============================== +Fichier: fr/lip6/sma/simulacion/server/xmlrpc/package.html +Projet: Simulaci\xF3n +Ecrit par: Paul Guyot (pau...@ac...) + +Cr\xE9\xE9 le: 24/5/2007 +Tabulation: 4 espaces + +This software is governed by the CeCILL license under French law and abiding +by the rules of distribution of free software. You can use, modify and/ or +redistribute the software under the terms of the CeCILL license as +circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, modify +and redistribute granted by the license, users are provided only with a +limited warranty and the software's author, the holder of the economic +rights, and the successive licensors have only limited liability. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL license and that you accept its terms. + +=========== +$Id$ +=========== +--!> +<html> +<head> +</head> +<body bgcolor="white"> + +Package for common classes related to Xml-Rpc. + +</body> +</html> +<!-- +=============================================================== +Excessive login or logout messages are a sure sign of senility. +=============================================================== +--> Property changes on: simulacion/src/fr/lip6/sma/simulacion/server/xmlrpc/package.html ___________________________________________________________________ Name: svn:executable + * Name: svn:keywords + Revision Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ep...@us...> - 2007-05-23 03:17:50
|
Revision: 146 http://simulacion.svn.sourceforge.net/simulacion/?rev=146&view=rev Author: eplaton Date: 2007-05-22 20:17:17 -0700 (Tue, 22 May 2007) Log Message: ----------- Paul has fixed a bug in the protocol file loading procedures (due to the old and new formats) Modified Paths: -------------- simulacion/src/fr/lip6/sma/simulacion/app/Configuration.java Modified: simulacion/src/fr/lip6/sma/simulacion/app/Configuration.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/app/Configuration.java 2007-05-21 09:10:36 UTC (rev 145) +++ simulacion/src/fr/lip6/sma/simulacion/app/Configuration.java 2007-05-23 03:17:17 UTC (rev 146) @@ -828,7 +828,7 @@ * * @return a set of file names. */ - public Iterable<String> getFileCollectionList() { + public Collection<String> getFileCollectionList() { return mFileCollections.keySet(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2007-05-21 09:10:45
|
Revision: 145 http://simulacion.svn.sourceforge.net/simulacion/?rev=145&view=rev Author: pguyot Date: 2007-05-21 02:10:36 -0700 (Mon, 21 May 2007) Log Message: ----------- Properties. Modified Paths: -------------- simulacion/src/fr/lip6/sma/simulacion/app/configuration/package.html simulacion/src/fr/lip6/sma/simulacion/gui/BaseApplet.java simulacion/src/fr/lip6/sma/simulacion/gui/GraphicalUserInterface.java simulacion/src/fr/lip6/sma/simulacion/gui/ListenerProxy.java simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java simulacion/src/fr/lip6/sma/simulacion/gui/SwingApplicationGUI.java simulacion/src/fr/lip6/sma/simulacion/gui/Window.java simulacion/src/fr/lip6/sma/simulacion/gui/WindowAdapter.java simulacion/src/fr/lip6/sma/simulacion/gui/WindowEvent.java simulacion/src/fr/lip6/sma/simulacion/gui/WindowHook.java simulacion/src/fr/lip6/sma/simulacion/gui/WindowListener.java simulacion/src/fr/lip6/sma/simulacion/gui/package.html Property Changed: ---------------- simulacion/src/fr/lip6/sma/simulacion/app/configuration/package.html simulacion/src/fr/lip6/sma/simulacion/gui/BaseApplet.java simulacion/src/fr/lip6/sma/simulacion/gui/GraphicalUserInterface.java simulacion/src/fr/lip6/sma/simulacion/gui/ListenerProxy.java simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java simulacion/src/fr/lip6/sma/simulacion/gui/SwingApplicationGUI.java simulacion/src/fr/lip6/sma/simulacion/gui/Window.java simulacion/src/fr/lip6/sma/simulacion/gui/WindowAdapter.java simulacion/src/fr/lip6/sma/simulacion/gui/WindowEvent.java simulacion/src/fr/lip6/sma/simulacion/gui/WindowHook.java simulacion/src/fr/lip6/sma/simulacion/gui/WindowListener.java simulacion/src/fr/lip6/sma/simulacion/gui/package.html Modified: simulacion/src/fr/lip6/sma/simulacion/app/configuration/package.html =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/app/configuration/package.html 2007-05-21 09:09:42 UTC (rev 144) +++ simulacion/src/fr/lip6/sma/simulacion/app/configuration/package.html 2007-05-21 09:10:36 UTC (rev 145) @@ -23,7 +23,7 @@ knowledge of the CeCILL license and that you accept its terms. =========== -$Id: package.html 3 2006-11-20 12:17:50Z pguyot $ +$Id$ =========== --!> <html> Property changes on: simulacion/src/fr/lip6/sma/simulacion/app/configuration/package.html ___________________________________________________________________ Name: svn:keywords + Revision Id Modified: simulacion/src/fr/lip6/sma/simulacion/gui/BaseApplet.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/BaseApplet.java 2007-05-21 09:09:42 UTC (rev 144) +++ simulacion/src/fr/lip6/sma/simulacion/gui/BaseApplet.java 2007-05-21 09:10:36 UTC (rev 145) @@ -21,7 +21,7 @@ // knowledge of the CeCILL license and that you accept its terms. // // =========== -// $Id: AppletMode.java 132 2007-05-09 07:39:21Z pguyot $ +// $Id$ // =========== // paquet @@ -39,7 +39,7 @@ * passed as a parameter to the constructor. * * @author Paul Guyot <pau...@ac...> - * @version $Revision: 132 $ + * @version $Revision$ */ public abstract class BaseApplet extends JApplet { /** Property changes on: simulacion/src/fr/lip6/sma/simulacion/gui/BaseApplet.java ___________________________________________________________________ Name: svn:keywords + Revision Id Modified: simulacion/src/fr/lip6/sma/simulacion/gui/GraphicalUserInterface.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/GraphicalUserInterface.java 2007-05-21 09:09:42 UTC (rev 144) +++ simulacion/src/fr/lip6/sma/simulacion/gui/GraphicalUserInterface.java 2007-05-21 09:10:36 UTC (rev 145) @@ -21,7 +21,7 @@ // knowledge of the CeCILL license and that you accept its terms. // // =========== -// $Id: AppletMode.java 132 2007-05-09 07:39:21Z pguyot $ +// $Id$ // =========== // paquet @@ -34,7 +34,7 @@ * Base class for the various GUI modes. * * @author Paul Guyot <pau...@ac...> - * @version $Revision: 132 $ + * @version $Revision$ */ public abstract class GraphicalUserInterface { /** Property changes on: simulacion/src/fr/lip6/sma/simulacion/gui/GraphicalUserInterface.java ___________________________________________________________________ Name: svn:keywords + Revision Id Modified: simulacion/src/fr/lip6/sma/simulacion/gui/ListenerProxy.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/ListenerProxy.java 2007-05-21 09:09:42 UTC (rev 144) +++ simulacion/src/fr/lip6/sma/simulacion/gui/ListenerProxy.java 2007-05-21 09:10:36 UTC (rev 145) @@ -21,7 +21,7 @@ // knowledge of the CeCILL license and that you accept its terms. // // =========== -// $Id: LocalizedWindow.java 132 2007-05-09 07:39:21Z pguyot $ +// $Id$ // =========== // paquet @@ -36,7 +36,7 @@ * (applet mode). * * @author Paul Guyot <pau...@ac...> - * @version $Revision: 132 $ + * @version $Revision$ */ final class ListenerProxy implements InternalFrameListener, java.awt.event.WindowListener { Property changes on: simulacion/src/fr/lip6/sma/simulacion/gui/ListenerProxy.java ___________________________________________________________________ Name: svn:keywords + Revision Id Modified: simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java 2007-05-21 09:09:42 UTC (rev 144) +++ simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java 2007-05-21 09:10:36 UTC (rev 145) @@ -21,7 +21,7 @@ // knowledge of the CeCILL license and that you accept its terms. // // =========== -// $Id: AppletMode.java 132 2007-05-09 07:39:21Z pguyot $ +// $Id$ // =========== // paquet @@ -35,7 +35,7 @@ * Class for the swing applet GUI. * * @author Paul Guyot <pau...@ac...> - * @version $Revision: 132 $ + * @version $Revision$ */ final class SwingAppletGUI extends GraphicalUserInterface { /** Property changes on: simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java ___________________________________________________________________ Name: svn:keywords + Revision Id Modified: simulacion/src/fr/lip6/sma/simulacion/gui/SwingApplicationGUI.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/SwingApplicationGUI.java 2007-05-21 09:09:42 UTC (rev 144) +++ simulacion/src/fr/lip6/sma/simulacion/gui/SwingApplicationGUI.java 2007-05-21 09:10:36 UTC (rev 145) @@ -21,7 +21,7 @@ // knowledge of the CeCILL license and that you accept its terms. // // =========== -// $Id: AppletMode.java 132 2007-05-09 07:39:21Z pguyot $ +// $Id$ // =========== // paquet @@ -35,7 +35,7 @@ * Class for the swing application GUI. * * @author Paul Guyot <pau...@ac...> - * @version $Revision: 132 $ + * @version $Revision$ */ public class SwingApplicationGUI extends GraphicalUserInterface { /** Property changes on: simulacion/src/fr/lip6/sma/simulacion/gui/SwingApplicationGUI.java ___________________________________________________________________ Name: svn:keywords + Revision Id Modified: simulacion/src/fr/lip6/sma/simulacion/gui/Window.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/Window.java 2007-05-21 09:09:42 UTC (rev 144) +++ simulacion/src/fr/lip6/sma/simulacion/gui/Window.java 2007-05-21 09:10:36 UTC (rev 145) @@ -21,7 +21,7 @@ // knowledge of the CeCILL license and that you accept its terms. // // =========== -// $Id: LocalizedWindow.java 132 2007-05-09 07:39:21Z pguyot $ +// $Id$ // =========== // paquet @@ -50,7 +50,7 @@ * (applet mode). * * @author Paul Guyot <pau...@ac...> - * @version $Revision: 132 $ + * @version $Revision$ */ public class Window implements RootPaneContainer, WindowConstants, WindowHook { /** Property changes on: simulacion/src/fr/lip6/sma/simulacion/gui/Window.java ___________________________________________________________________ Name: svn:keywords + Revision Id Modified: simulacion/src/fr/lip6/sma/simulacion/gui/WindowAdapter.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/WindowAdapter.java 2007-05-21 09:09:42 UTC (rev 144) +++ simulacion/src/fr/lip6/sma/simulacion/gui/WindowAdapter.java 2007-05-21 09:10:36 UTC (rev 145) @@ -21,7 +21,7 @@ // knowledge of the CeCILL license and that you accept its terms. // // =========== -// $Id: LocalizedWindow.java 132 2007-05-09 07:39:21Z pguyot $ +// $Id$ // =========== // paquet @@ -31,7 +31,7 @@ * Adapter for the proxy windows. * * @author Paul Guyot <pau...@ac...> - * @version $Revision: 132 $ + * @version $Revision$ */ public class WindowAdapter implements WindowListener { /** Property changes on: simulacion/src/fr/lip6/sma/simulacion/gui/WindowAdapter.java ___________________________________________________________________ Name: svn:keywords + Revision Id Modified: simulacion/src/fr/lip6/sma/simulacion/gui/WindowEvent.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/WindowEvent.java 2007-05-21 09:09:42 UTC (rev 144) +++ simulacion/src/fr/lip6/sma/simulacion/gui/WindowEvent.java 2007-05-21 09:10:36 UTC (rev 145) @@ -21,7 +21,7 @@ // knowledge of the CeCILL license and that you accept its terms. // // =========== -// $Id: LocalizedWindow.java 132 2007-05-09 07:39:21Z pguyot $ +// $Id$ // =========== // paquet @@ -36,7 +36,7 @@ * Event for the proxy windows. * * @author Paul Guyot <pau...@ac...> - * @version $Revision: 132 $ + * @version $Revision$ */ public class WindowEvent extends AWTEvent { /** Property changes on: simulacion/src/fr/lip6/sma/simulacion/gui/WindowEvent.java ___________________________________________________________________ Name: svn:keywords + Revision Id Modified: simulacion/src/fr/lip6/sma/simulacion/gui/WindowHook.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/WindowHook.java 2007-05-21 09:09:42 UTC (rev 144) +++ simulacion/src/fr/lip6/sma/simulacion/gui/WindowHook.java 2007-05-21 09:10:36 UTC (rev 145) @@ -21,7 +21,7 @@ // knowledge of the CeCILL license and that you accept its terms. // // =========== -// $Id: LocalizedWindow.java 132 2007-05-09 07:39:21Z pguyot $ +// $Id$ // =========== // paquet @@ -33,7 +33,7 @@ * Interface for method hooks for implementations. * * @author Paul Guyot <pau...@ac...> - * @version $Revision: 132 $ + * @version $Revision$ */ interface WindowHook { /** Property changes on: simulacion/src/fr/lip6/sma/simulacion/gui/WindowHook.java ___________________________________________________________________ Name: svn:keywords + Revision Id Modified: simulacion/src/fr/lip6/sma/simulacion/gui/WindowListener.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/WindowListener.java 2007-05-21 09:09:42 UTC (rev 144) +++ simulacion/src/fr/lip6/sma/simulacion/gui/WindowListener.java 2007-05-21 09:10:36 UTC (rev 145) @@ -21,7 +21,7 @@ // knowledge of the CeCILL license and that you accept its terms. // // =========== -// $Id: LocalizedWindow.java 132 2007-05-09 07:39:21Z pguyot $ +// $Id$ // =========== // paquet @@ -34,7 +34,7 @@ * Listener for the proxy windows. * * @author Paul Guyot <pau...@ac...> - * @version $Revision: 132 $ + * @version $Revision$ */ public interface WindowListener extends EventListener { /** Property changes on: simulacion/src/fr/lip6/sma/simulacion/gui/WindowListener.java ___________________________________________________________________ Name: svn:keywords + Revision Id Modified: simulacion/src/fr/lip6/sma/simulacion/gui/package.html =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/package.html 2007-05-21 09:09:42 UTC (rev 144) +++ simulacion/src/fr/lip6/sma/simulacion/gui/package.html 2007-05-21 09:10:36 UTC (rev 145) @@ -23,7 +23,7 @@ knowledge of the CeCILL license and that you accept its terms. =========== -$Id: package.html 3 2006-11-20 12:17:50Z pguyot $ +$Id$ =========== --!> <html> Property changes on: simulacion/src/fr/lip6/sma/simulacion/gui/package.html ___________________________________________________________________ Name: svn:keywords + Revision Id This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2007-05-21 09:09:44
|
Revision: 144 http://simulacion.svn.sourceforge.net/simulacion/?rev=144&view=rev Author: pguyot Date: 2007-05-21 02:09:42 -0700 (Mon, 21 May 2007) Log Message: ----------- Update to new APIs. Modified Paths: -------------- examples/simbar/src/fr/lip6/sma/simulacion/simbar/SantaFeBarApplication.java examples/simbar/src/fr/lip6/sma/simulacion/simbar/SimBarMainWindow.java examples/simbar3/etc/simbar3.xml examples/simbar3/src/fr/lip6/sma/simulacion/simbar3/BotRegularApplication.java examples/simbar3/src/fr/lip6/sma/simulacion/simbar3/SimBarMainWindow.java examples/simcafe/src/fr/lip6/sma/simulacion/simcafe/BuyerWindow.java examples/simcafe/src/fr/lip6/sma/simulacion/simcafe/SimCafeMainWindow.java examples/simcommod/.classpath examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/ButtonPanel.java examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/EndResultWindow.java examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/EnvironmentalistMainWindow.java examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/GovernmentMIPanel.java examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/GovernmentMainWindow.java examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/HarvesterMainWindow.java examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/InstructionPanel.java examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/MapInteractionPanel.java examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/PhasePanel.java examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/PlayersInfoPanel.java examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/SimCommodApplicationWindow.java examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/SimCommodRPPanel.java examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/SimCommodView.java examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/WaitWindow.java Modified: examples/simbar/src/fr/lip6/sma/simulacion/simbar/SantaFeBarApplication.java =================================================================== --- examples/simbar/src/fr/lip6/sma/simulacion/simbar/SantaFeBarApplication.java 2007-05-21 09:08:28 UTC (rev 143) +++ examples/simbar/src/fr/lip6/sma/simulacion/simbar/SantaFeBarApplication.java 2007-05-21 09:09:42 UTC (rev 144) @@ -170,9 +170,9 @@ } /** - * Method called at the beginning of the application. + * {@inheritDoc} */ - protected void init() { + protected void init() throws ServerException { super.init(); // Advertise ourselves on the network. Modified: examples/simbar/src/fr/lip6/sma/simulacion/simbar/SimBarMainWindow.java =================================================================== --- examples/simbar/src/fr/lip6/sma/simulacion/simbar/SimBarMainWindow.java 2007-05-21 09:08:28 UTC (rev 143) +++ examples/simbar/src/fr/lip6/sma/simulacion/simbar/SimBarMainWindow.java 2007-05-21 09:09:42 UTC (rev 144) @@ -56,6 +56,7 @@ import fr.lip6.sma.simulacion.app.Bundle; import fr.lip6.sma.simulacion.app.Configuration; +import fr.lip6.sma.simulacion.app.LocalizationEngine; import fr.lip6.sma.simulacion.app.map.MapPanel; import fr.lip6.sma.simulacion.app.map.MapPanelListener; import fr.lip6.sma.simulacion.avatar.Avatar; @@ -256,11 +257,12 @@ // R\xE9cup\xE9ration de l'avatar. mAvatar = inApplication.getAvatar(); - localizeContainer(mVotePanel); - localizeContainer(mParticipationPanel); - localizeContainer(mBarStatsPanel); - localizeContainer(mScorePanel); - localizeContainer(mSessionWeekPanel); + final LocalizationEngine theEngine = getLocalizationEngine(); + theEngine.localizeContainer(mVotePanel); + theEngine.localizeContainer(mParticipationPanel); + theEngine.localizeContainer(mBarStatsPanel); + theEngine.localizeContainer(mScorePanel); + theEngine.localizeContainer(mSessionWeekPanel); mWeekClip = Bundle.getAudioClip("artwork/sounds/doorbell.au"); @@ -755,27 +757,15 @@ } /** - * Ouverture du bar. + * Open the bar. * - * @param inBarAgent l'agent du bar. + * @param inBarAgent the agent for the bar. */ public final void openBar(NetworkAgent inBarAgent) { final NetworkAgent theBarAgentFinal = inBarAgent; final Runnable openTask = new Runnable() { public void run() { - mVoteLayout.add(mVotePanel, BorderLayout.CENTER); - mBarStatsLayout.add(mBarStatsPanel, BorderLayout.CENTER); - mParticipationLayout.add( - mParticipationPanel, BorderLayout.CENTER); - mScoreLayout.add(mScorePanel, BorderLayout.CENTER); - mWeekLayout.add(mSessionWeekPanel, BorderLayout.CENTER); - - localizeContainer(SimBarMainWindow.this); - - mAvatarInterfacePanel.openBar(theBarAgentFinal); - - validate(); - repaint(); + doOpenBar(theBarAgentFinal); } }; @@ -788,7 +778,28 @@ // On r\xE9initialise les statistiques. mGameModel.resetStats(); } + + /** + * Actually open the bar. + * + * @param inBarAgent the agent for the bar. + */ + private void doOpenBar(NetworkAgent inBarAgent) { + mVoteLayout.add(mVotePanel, BorderLayout.CENTER); + mBarStatsLayout.add(mBarStatsPanel, BorderLayout.CENTER); + mParticipationLayout.add( + mParticipationPanel, BorderLayout.CENTER); + mScoreLayout.add(mScorePanel, BorderLayout.CENTER); + mWeekLayout.add(mSessionWeekPanel, BorderLayout.CENTER); + getLocalizationEngine().localizeWindow(this); + + mAvatarInterfacePanel.openBar(inBarAgent); + + validate(); + repaint(); + } + /** * Fermeture du bar. */ Modified: examples/simbar3/etc/simbar3.xml =================================================================== --- examples/simbar3/etc/simbar3.xml 2007-05-21 09:08:28 UTC (rev 143) +++ examples/simbar3/etc/simbar3.xml 2007-05-21 09:09:42 UTC (rev 144) @@ -4722,7 +4722,7 @@ <property name="fr.lip6.sma.simulacion.server.http.file" value="/simbar3/"/> <!-- <property name="fr.lip6.sma.simulacion.server.http.host" value="simulacion.game-host.org"/> --> <!-- <property name="fr.lip6.sma.simulacion.server.http.host" value="10.0.2.1"/> --> - <property name="fr.lip6.sma.simulacion.server.http.host" value="localhost"/> + <property name="fr.lip6.sma.simulacion.server.http.host" value="10.0.2.1"/> <property name="fr.lip6.sma.simulacion.server.http.port" value="10001"/> <!-- <property name="fr.lip6.sma.simulacion.server.http.zeroconf.publish" value="true"/> --> <property name="fr.lip6.sma.simulacion.server" value="fr.lip6.sma.simulacion.server.http.HTTPClient"/> Modified: examples/simbar3/src/fr/lip6/sma/simulacion/simbar3/BotRegularApplication.java =================================================================== --- examples/simbar3/src/fr/lip6/sma/simulacion/simbar3/BotRegularApplication.java 2007-05-21 09:08:28 UTC (rev 143) +++ examples/simbar3/src/fr/lip6/sma/simulacion/simbar3/BotRegularApplication.java 2007-05-21 09:09:42 UTC (rev 144) @@ -143,9 +143,9 @@ } /** - * Method called to init the application. + * {@inheritDoc} */ - public void init() { + public void init() throws ServerException { super.init(); // Get the local agent. Modified: examples/simbar3/src/fr/lip6/sma/simulacion/simbar3/SimBarMainWindow.java =================================================================== --- examples/simbar3/src/fr/lip6/sma/simulacion/simbar3/SimBarMainWindow.java 2007-05-21 09:08:28 UTC (rev 143) +++ examples/simbar3/src/fr/lip6/sma/simulacion/simbar3/SimBarMainWindow.java 2007-05-21 09:09:42 UTC (rev 144) @@ -57,6 +57,7 @@ import fr.lip6.sma.simulacion.app.Bundle; import fr.lip6.sma.simulacion.app.Configuration; +import fr.lip6.sma.simulacion.app.LocalizationEngine; import fr.lip6.sma.simulacion.app.map.MapPanelListener; import fr.lip6.sma.simulacion.avatar.Avatar; import fr.lip6.sma.simulacion.avatar.AvatarDialog2D; @@ -371,10 +372,11 @@ //Get the player avatar. mAvatar = inApplication.getAvatar(); - localizeContainer(mScorePanel); - localizeContainer(mTimer); - localizeContainer(mMapPanel); - localizeContainer(mVotePanel); + final LocalizationEngine theEngine = getLocalizationEngine(); + theEngine.localizeContainer(mScorePanel); + theEngine.localizeContainer(mTimer); + theEngine.localizeContainer(mMapPanel); + theEngine.localizeContainer(mVotePanel); mWeekClip = Bundle.getAudioClip(mConfiguration .getProperty(WEEK_SOUND_PATH)); @@ -760,7 +762,7 @@ mChatInteractionLayout.add(mChatCommandPanel, BorderLayout.CENTER); - localizeContainer(SimBarMainWindow.this); + getLocalizationEngine().localizeWindow(SimBarMainWindow.this); validate(); repaint(); @@ -817,7 +819,7 @@ mScoreLayout.add(mScorePanel, BorderLayout.CENTER); mTimeLayout.add(mTimer, BorderLayout.CENTER); - localizeContainer(SimBarMainWindow.this); + getLocalizationEngine().localizeWindow(SimBarMainWindow.this); validate(); repaint(); @@ -1003,7 +1005,7 @@ mChatInteractionLayout.remove(mChatCommandPanel); } mVotePanel.setupToVote(); - localizeContainer(mVotePanel); + getLocalizationEngine().localizeContainer(mVotePanel); mMapLayout.add(mVotePanel); validate(); @@ -1089,7 +1091,7 @@ public void run() { // Composants. mVotePanel.setupToWait(); - localizeContainer(mVotePanel); + getLocalizationEngine().localizeContainer(mVotePanel); } }; if (SwingUtilities.isEventDispatchThread()) { @@ -1105,10 +1107,12 @@ private void showSuggestion() { if (mSuggestion == SUGGESTED_TO_GO) { mBubblePanel.showMessage( - localizeString("I suggest we go to the bar._Key")); + getLocalizationEngine() + .localizeString("I suggest we go to the bar._Key")); } else if (mSuggestion == SUGGESTED_TO_STAY_HOME) { mBubblePanel.showMessage( - localizeString("I suggest we stay home._Key")); + getLocalizationEngine() + .localizeString("I suggest we stay home._Key")); } } @@ -1133,7 +1137,8 @@ } } - final String finalQuestion = localizeString(theQuestion); + final String finalQuestion = + getLocalizationEngine().localizeString(theQuestion); final Map<String, Object> theParams = new Hashtable<String, Object>(); if (inWent) { theParams.put("vote", "went"); @@ -1167,9 +1172,10 @@ * Introduce ourselves to the player. */ private void introduction() { - final String theIntroductionStr = localizeString( - "Introduction%%agentname%%_Key") - .replaceAll("%%agentname%%", mLocalAgent.getAgentName()); + final String theIntroductionStr = + getLocalizationEngine().localizeString( + "Introduction%%agentname%%_Key") + .replaceAll("%%agentname%%", mLocalAgent.getAgentName()); final Map<String, Object> theParams = new Hashtable<String, Object>(); final Runnable introductionTask = new Runnable() { @@ -1204,26 +1210,31 @@ String barStateString; String theReportTemplate; String incrementString; + final LocalizationEngine theEngine = getLocalizationEngine(); if (inScoreIncrement >= 0) { incrementString = "" + inScoreIncrement; } else { - incrementString = localizeString("Report-minus-sign_Key") + incrementString = theEngine.localizeString("Report-minus-sign_Key") + (0 - inScoreIncrement); } if (inBarWasFull) { - barStateString = localizeString("The bar was full._Key"); + barStateString = theEngine.localizeString("The bar was full._Key"); if (inTeamBonus != 0) { - theReportTemplate = localizeString("Report-bonus-full_Key"); + theReportTemplate = + theEngine.localizeString("Report-bonus-full_Key"); } else { - theReportTemplate = localizeString("Report-nobonus-full_Key"); + theReportTemplate = + theEngine.localizeString("Report-nobonus-full_Key"); } } else { - barStateString = localizeString("The bar was not full._Key"); + barStateString = + theEngine.localizeString("The bar was not full._Key"); if (inTeamBonus != 0) { - theReportTemplate = localizeString("Report-bonus-notfull_Key"); + theReportTemplate = + theEngine.localizeString("Report-bonus-notfull_Key"); } else { theReportTemplate = - localizeString("Report-nobonus-notfull_Key"); + theEngine.localizeString("Report-nobonus-notfull_Key"); } } Modified: examples/simcafe/src/fr/lip6/sma/simulacion/simcafe/BuyerWindow.java =================================================================== --- examples/simcafe/src/fr/lip6/sma/simulacion/simcafe/BuyerWindow.java 2007-05-21 09:08:28 UTC (rev 143) +++ examples/simcafe/src/fr/lip6/sma/simulacion/simcafe/BuyerWindow.java 2007-05-21 09:09:42 UTC (rev 144) @@ -489,7 +489,7 @@ mListManager.addListener(this); // Traduction. - localizeComponent(this); + getLocalizationEngine().localizeWindow(this); // Redimensionnement de la fen\xEAtre. pack(); @@ -810,14 +810,14 @@ getApplication().getAvatar( ((Player) mSelectedAgent).getAvatarName()), (Player) mSelectedAgent); - localizeComponent(mMoreInfoPanel); + getLocalizationEngine().localizeComponent(mMoreInfoPanel); mMoreInfoLayout.add(mMoreInfoPanel); mMoreInfoLayout.repaint(); mMoreInfoLayout.invalidate(); mAgentInfoPanel = new NetworkPlayerInfoPanel((Player) mSelectedAgent); - localizeComponent(mAgentInfoPanel); + getLocalizationEngine().localizeComponent(mAgentInfoPanel); mPlayerInfoLayout.add(mAgentInfoPanel); mPlayerInfoLayout.repaint(); mPlayerInfoLayout.invalidate(); Modified: examples/simcafe/src/fr/lip6/sma/simulacion/simcafe/SimCafeMainWindow.java =================================================================== --- examples/simcafe/src/fr/lip6/sma/simulacion/simcafe/SimCafeMainWindow.java 2007-05-21 09:08:28 UTC (rev 143) +++ examples/simcafe/src/fr/lip6/sma/simulacion/simcafe/SimCafeMainWindow.java 2007-05-21 09:09:42 UTC (rev 144) @@ -372,7 +372,7 @@ mListManager.addListener(this); // Traduction. - localizeComponent(this); + getLocalizationEngine().localizeWindow(this); // Redimensionnement de la fen\xEAtre. pack(); @@ -646,7 +646,7 @@ ((NetworkPlayer) mSelectedAgent). getAvatarName()), (NetworkPlayer) mSelectedAgent); - localizeComponent(mMoreInfoPanel); + getLocalizationEngine().localizeComponent(mMoreInfoPanel); mMoreInfoLayout.add(mMoreInfoPanel); mMoreInfoLayout.repaint(); mMoreInfoLayout.invalidate(); Modified: examples/simcommod/.classpath =================================================================== --- examples/simcommod/.classpath 2007-05-21 09:08:28 UTC (rev 143) +++ examples/simcommod/.classpath 2007-05-21 09:09:42 UTC (rev 144) @@ -24,7 +24,7 @@ <classpathentry kind="lib" path="simulacion/lib/xml-apis.jar"/> <classpathentry kind="lib" path="simulacion/lib/xmlParserAPIs.jar"/> <classpathentry kind="lib" path="simulacion/lib/xmlrpc-2.0.jar"/> - <classpathentry kind="lib" path="simulacion/simulacion-20070224.jar"/> + <classpathentry kind="lib" path="simulacion/simulacion-20070224.jar" sourcepath="/simulacion/src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="output" path="bin"/> </classpath> Modified: examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/ButtonPanel.java =================================================================== --- examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/ButtonPanel.java 2007-05-21 09:08:28 UTC (rev 143) +++ examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/ButtonPanel.java 2007-05-21 09:09:42 UTC (rev 144) @@ -48,7 +48,7 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; -import fr.lip6.sma.simulacion.app.LocalizedWindow; +import fr.lip6.sma.simulacion.app.LocalizationEngine; import fr.lip6.sma.simulacion.server.Agent; import fr.lip6.sma.simulacion.server.AgentException; @@ -78,9 +78,9 @@ private final Set<Agent> mAgentSet; /** - * R\xE9f\xE9rence sur la fen\x90tre localis\xE9e + * Reference on the engine for the translation. */ - private final LocalizedWindow mTranslation; + private final LocalizationEngine mLocalizationEngine; /** * scrolling sur le commentaire. @@ -100,16 +100,17 @@ /** * Constructeur \xE0 partir d'un mod\xE8le. * - * @param inModel mod\xE8le pour construire cette vue. - * @param inWin r\xE9f\xE9rence sur la fen\xEAtre. - * @param inGrid grille de la carte. - * @param inAgentSet ensemble des agents. + * @param inModel mod\xE8le pour construire cette vue. + * @param inLocalizationEngine engine for the translation. + * @param inGrid grille de la carte. + * @param inAgentSet ensemble des agents. */ - public ButtonPanel(SimCommodModel inModel, LocalizedWindow inWin, + public ButtonPanel(SimCommodModel inModel, + LocalizationEngine inLocalizationEngine, SimCommodSpatialGrid inGrid, Set<Agent> inAgentSet) { mModel = inModel; mAgentSet = inAgentSet; - mTranslation = inWin; + mLocalizationEngine = inLocalizationEngine; setSize(450, 110); setLayout(null); @@ -132,7 +133,8 @@ mTextLabel.setForeground(Color.black); mTextLabel.setLocation(25, 0); mTextLabel.setOpaque(false); - mTextLabel.setText(mTranslation.localizeString("ManagementText_Key")); + mTextLabel.setText( + mLocalizationEngine.localizeString("ManagementText_Key")); mTextLabel.setVisible(false); add(mTextLabel); @@ -184,7 +186,7 @@ theForegroundColor = Color.black; } - mValidate.setText(mTranslation.localizeString(theKey)); + mValidate.setText(mLocalizationEngine.localizeString(theKey)); mValidate.setForeground(theForegroundColor); mValidate.repaint(); } @@ -200,7 +202,7 @@ } else { if (!mText.getText().equals("")) { final String theMessage = - mTranslation.localizeString("ManagementText_Key") + mLocalizationEngine.localizeString("ManagementText_Key") + mText.getText(); mText.setText(""); // Envoi du message. Modified: examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/EndResultWindow.java =================================================================== --- examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/EndResultWindow.java 2007-05-21 09:08:28 UTC (rev 143) +++ examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/EndResultWindow.java 2007-05-21 09:09:42 UTC (rev 144) @@ -49,6 +49,7 @@ import fr.lip6.sma.simulacion.app.Configuration; import fr.lip6.sma.simulacion.app.GameApplication; import fr.lip6.sma.simulacion.app.ImagePanel; +import fr.lip6.sma.simulacion.app.LocalizationEngine; /** * Classe pour la fen\xCDtre donnant les scores finaux. @@ -132,12 +133,14 @@ getContentPane().add(mMainPane, "Center"); setSize(new Dimension(300, 300)); + + final LocalizationEngine theEngine = getLocalizationEngine(); // Le nom \xE0 cot\xE9 final JLabel theAvatarLabel = new JLabel(); theAvatarLabel.setSize(80, 18); theAvatarLabel.setLocation(90, 35); - theAvatarLabel.setText(localizeString("PlayerName_Key")); + theAvatarLabel.setText(theEngine.localizeString("PlayerName_Key")); theAvatarLabel.setVisible(true); theAvatarLabel.setFont(new Font("Serif", Font.BOLD, 12)); theAvatarLabel.setHorizontalAlignment(SwingConstants.CENTER); @@ -148,7 +151,7 @@ final JLabel theMoneyLabel = new JLabel(); theMoneyLabel.setSize(100, 18); theMoneyLabel.setLocation(160, 35); - theMoneyLabel.setText(localizeString("Money_Key")); + theMoneyLabel.setText(theEngine.localizeString("Money_Key")); theMoneyLabel.setVisible(true); theMoneyLabel.setFont(new Font("Serif", Font.BOLD, 12)); theMoneyLabel.setHorizontalAlignment(SwingConstants.CENTER); Modified: examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/EnvironmentalistMainWindow.java =================================================================== --- examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/EnvironmentalistMainWindow.java 2007-05-21 09:08:28 UTC (rev 143) +++ examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/EnvironmentalistMainWindow.java 2007-05-21 09:09:42 UTC (rev 144) @@ -54,6 +54,7 @@ import javax.swing.SwingUtilities; import fr.lip6.sma.simulacion.app.GameController; +import fr.lip6.sma.simulacion.app.LocalizationEngine; import fr.lip6.sma.simulacion.avatar.Avatar; import fr.lip6.sma.simulacion.avatar.AvatarDialog2D; import fr.lip6.sma.simulacion.avatar.BubblePanel; @@ -342,22 +343,24 @@ // Vu sur les int\xE9ractions avec la carte. mIPLayout = new MapInteractionPanel(theModel, getSpatialGridView(), - getApplication(), this); + getApplication(), getLocalizationEngine()); mMapLayout.add(mIPLayout); mIPLayout.setLocation(250, 75); final InstructionPanel theInstructionLayout = new InstructionPanel( - theModel, this); + theModel, getLocalizationEngine()); mMapLayout.add(theInstructionLayout); theInstructionLayout.setLocation(20, 10); - final ButtonPanel theButtonLayout = new ButtonPanel(theModel, this, + final ButtonPanel theButtonLayout = + new ButtonPanel(theModel, getLocalizationEngine(), getSpatialGrid(), getAgentListManager().getAgentSet()); mMapLayout.add(theButtonLayout); theButtonLayout.setLocation(20, 300); // Phase de jeu. - final PhasePanel thePhaseLayout = new PhasePanel(theModel, this); + final PhasePanel thePhaseLayout = + new PhasePanel(theModel, getLocalizationEngine()); mPhaseLayout.add(thePhaseLayout); // Temps restant. @@ -376,7 +379,7 @@ getAgentListManager(), getNetworkAgents(), getApplication().getConfiguration(), - this); + getLocalizationEngine()); mPlayersInfoLayout.add(mPlayersInfoPanel); // Attitude par d\xE9faut de l'avatar. @@ -560,8 +563,8 @@ SimCommodModel.PHASE_VALIDATION); theModel.resetTime(); } - mRPPanel = new SimCommodRPPanel(theModel, this, getSpatialGrid(), - mLocalAgent); + mRPPanel = new SimCommodRPPanel(theModel, getLocalizationEngine(), + getSpatialGrid(), mLocalAgent); mRPPanel.setLocation(0, 0); mMapLayout2.add(mRPPanel); mMapLayout2.repaint(); @@ -785,6 +788,8 @@ private void doUpdatePhase() { final SimCommodModel theModel = getModel(); final int thePhase = theModel.getGamePhase(); + final LocalizationEngine theEngine = getLocalizationEngine(); + switch (thePhase) { case SimCommodModel.PHASE_HARVESTING: theModel.setGamePhase(SimCommodModel.PHASE_WAIT); @@ -827,25 +832,26 @@ break; case SimCommodModel.PHASE_HARVESTINGRESULTS: - mWaitLabel.setText(localizeString( + mWaitLabel.setText(theEngine.localizeString( "WaitPlayerHarvestingResults_Key")); endHarvestingResults(); break; case SimCommodModel.PHASE_PROPELABORATION: - mWaitLabel.setText(localizeString( + mWaitLabel.setText(theEngine.localizeString( "WaitPlayerPropElaboration_Key")); validatePropElaboration(); break; case SimCommodModel.PHASE_VALIDATION: - mWaitLabel.setText(localizeString( + mWaitLabel.setText(theEngine.localizeString( "WaitPlayerValidation_Key")); endValidation(); break; case SimCommodModel.PHASE_RESULT: - mWaitLabel.setText(localizeString("WaitPlayerResult_Key")); + mWaitLabel.setText(theEngine.localizeString( + "WaitPlayerResult_Key")); endResult(); break; @@ -886,7 +892,9 @@ */ public void showVoteProposition(List<String> inProposition) { final StringWriter theWriter = new StringWriter(); - theWriter.write(localizeString("SuggestionTokenDistribution:_Key")); + final LocalizationEngine theEngine = getLocalizationEngine(); + theWriter.write(theEngine.localizeString( + "SuggestionTokenDistribution:_Key")); int theCellID = 1; boolean first = true; for (String theVote : inProposition) { @@ -899,7 +907,8 @@ theWriter.write(" "); first = false; } - final String theXonCellYStr = localizeString("XonCellY_Key"); + final String theXonCellYStr = + theEngine.localizeString("XonCellY_Key"); final String theXonCellYInstance = MessageFormat.format( theXonCellYStr, new Object[] @@ -928,7 +937,7 @@ String inAgentCallbackMethod, Map<String, Object> inParams) { mBubblePanel.askQuestion( - localizeString("WhyProposition?_Key"), + getLocalizationEngine().localizeString("WhyProposition?_Key"), inAgentCallbackMethod, inParams); } Modified: examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/GovernmentMIPanel.java =================================================================== --- examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/GovernmentMIPanel.java 2007-05-21 09:08:28 UTC (rev 143) +++ examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/GovernmentMIPanel.java 2007-05-21 09:09:42 UTC (rev 144) @@ -51,7 +51,7 @@ import fr.lip6.sma.simulacion.app.Bundle; import fr.lip6.sma.simulacion.app.Configuration; import fr.lip6.sma.simulacion.app.ImagePanel; -import fr.lip6.sma.simulacion.app.LocalizedWindow; +import fr.lip6.sma.simulacion.app.LocalizationEngine; import fr.lip6.sma.simulacion.server.Agent; import fr.lip6.sma.simulacion.server.AgentException; @@ -124,7 +124,7 @@ /** * R\xE9f\xE9rence sur la fen\xEAtre localis\xE9e */ - private final LocalizedWindow mTranslation; + private final LocalizationEngine mLocalizationEngine; /** * Permet de savoir si on est dans le premier tour @@ -148,19 +148,19 @@ * @param inModel mod\xE8le pour construire cette vue. * @param inMap carte pour qui va \xEAtre mise \xE0 jour. * @param inConfig configuration du jeu. - * @param inWin fen\xEAtre pour la traduction. + * @param inLocalizationEngine localization engine. * @param inAgentSet ensemble des agents. */ public GovernmentMIPanel( GovernmentModel inModel, GovernmentVisuGrid inMap, Configuration inConfig, - LocalizedWindow inWin, + LocalizationEngine inLocalizationEngine, Set<Agent> inAgentSet) { mModel = inModel; mFirstTurn = true; mAgentSet = inAgentSet; - mTranslation = inWin; + mLocalizationEngine = inLocalizationEngine; mConfig = inConfig; setSize(230, 500); setLayout(null); @@ -175,7 +175,7 @@ mInstructionLabel.setWrapStyleWord(true); mInstructionLabel.setOpaque(false); mInstructionLabel.setEditable(false); - mInstructionLabel.setText(mTranslation + mInstructionLabel.setText(mLocalizationEngine .localizeString("GameMasterInstruction_Key")); add(mInstructionLabel); @@ -188,7 +188,7 @@ mValidate.setFont(new Font("Serif", Font.BOLD, 12)); mValidate.setForeground(Color.black); mValidate.addActionListener(this); - mValidate.setText(mTranslation.localizeString("NextPhase_Key")); + mValidate.setText(mLocalizationEngine.localizeString("NextPhase_Key")); mButton.add(mValidate, BorderLayout.CENTER); add(mButton); @@ -210,7 +210,8 @@ mTextLabel.setForeground(Color.black); mTextLabel.setLocation(0, 150); mTextLabel.setOpaque(false); - mTextLabel.setText(mTranslation.localizeString("ManagementText_Key")); + mTextLabel.setText( + mLocalizationEngine.localizeString("ManagementText_Key")); mTextLabel.setVisible(false); add(mTextLabel); @@ -406,7 +407,8 @@ mInfoPanel.removeAll(); } if (!mText.getText().equals("")) { - mModel.setText(mTranslation.localizeString("MessageFrom_Key") + mModel.setText( + mLocalizationEngine.localizeString("MessageFrom_Key") + mText.getText()); } mText.setText(""); @@ -458,7 +460,7 @@ if (mModel.getGamePhase() == SimCommodModel.PHASE_NEGOTIATION) { mAgentNbLabel.setText(""); } else { - mAgentNbLabel.setText(mTranslation + mAgentNbLabel.setText(mLocalizationEngine .localizeString("ReadyPlayersNb:_Key") + mModel.countPlayersReady() + "/" + mPlayersNb); } @@ -486,18 +488,19 @@ private void doUpdatePhase() { mValidate.setEnabled(true); if (mModel.getGamePhase() == SimCommodModel.PHASE_MANAGEMENT) { - mInstructionLabel.setText(mTranslation + mInstructionLabel.setText(mLocalizationEngine .localizeString("ManagementInstruction_Key")); mValidate - .setText(mTranslation.localizeString("Government_Key")); + .setText(mLocalizationEngine.localizeString("Government_Key")); mTextLabel.setVisible(true); mScrollPane.setVisible(true); mFirstTurn = false; } else if (mModel.getGamePhase() == SimCommodModel.PHASE_HARVESTING) { - mInstructionLabel.setText(mTranslation + mInstructionLabel.setText(mLocalizationEngine .localizeString("GameMasterInstruction_Key")); - mValidate.setText(mTranslation.localizeString("NextPhase_Key")); + mValidate.setText( + mLocalizationEngine.localizeString("NextPhase_Key")); if (!mFirstTurn) { mTextLabel.setVisible(false); mScrollPane.setVisible(false); @@ -526,7 +529,7 @@ if (mModel.getGamePhase() == SimCommodModel.PHASE_NEGOTIATION) { mAgentNbLabel.setText(""); } else { - mAgentNbLabel.setText(mTranslation + mAgentNbLabel.setText(mLocalizationEngine .localizeString("ReadyPlayersNb:_Key") + mModel.countPlayersReady() + "/" + mPlayersNb); } Modified: examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/GovernmentMainWindow.java =================================================================== --- examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/GovernmentMainWindow.java 2007-05-21 09:08:28 UTC (rev 143) +++ examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/GovernmentMainWindow.java 2007-05-21 09:09:42 UTC (rev 144) @@ -325,7 +325,8 @@ mWaitLayout.add(mWaitLabel); // Phase de jeu. - final PhasePanel thePhaseLayout = new PhasePanel(theModel, this); + final PhasePanel thePhaseLayout = + new PhasePanel(theModel, getLocalizationEngine()); mMapLayout.add(thePhaseLayout); // Tour de jeu. @@ -349,7 +350,7 @@ getAgentListManager(), mNetworkAgents, theConfig, - this); + getLocalizationEngine()); mPlayersInfoLayout.add(mPlayersInfoPanel); mPlayersInfoPanel.updatesPlayers(); @@ -404,7 +405,7 @@ (GovernmentModel) getModel(), (GovernmentVisuGrid) getSpatialGridView(), getApplication().getConfiguration(), - this, + getLocalizationEngine(), getAgentListManager().getAgentSet()); mMapLayout.add(mIPLayout); mIPLayout.setLocation(124, 62); @@ -600,7 +601,7 @@ case SimCommodModel.PHASE_WAIT: if (getModel().getOldPhase() == SimCommodModel.PHASE_MANAGEMENT) { - mWaitLabel.setText(localizeString( + mWaitLabel.setText(getLocalizationEngine().localizeString( "WaitPlayerManagement_Key")); endManagement(); } Modified: examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/HarvesterMainWindow.java =================================================================== --- examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/HarvesterMainWindow.java 2007-05-21 09:08:28 UTC (rev 143) +++ examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/HarvesterMainWindow.java 2007-05-21 09:09:42 UTC (rev 144) @@ -53,6 +53,7 @@ import javax.swing.SwingConstants; import javax.swing.SwingUtilities; +import fr.lip6.sma.simulacion.app.LocalizationEngine; import fr.lip6.sma.simulacion.app.WaitShowing; import fr.lip6.sma.simulacion.avatar.Avatar; import fr.lip6.sma.simulacion.avatar.AvatarDialog2D; @@ -354,24 +355,27 @@ mWaitLabel.setFont(new Font("Serif", Font.BOLD, 20)); mWaitLayout.add(mWaitLabel); + final LocalizationEngine theEngine = getLocalizationEngine(); + // Vue sur les int\xE9ractions avec la carte. mIPLayout = new MapInteractionPanel(theModel, getSpatialGridView(), - getApplication(), this); + getApplication(), theEngine); mMapLayout.add(mIPLayout); mIPLayout.setLocation(250, 75); final InstructionPanel theInstructionLayout = new InstructionPanel( - theModel, this); + theModel, theEngine); mMapLayout.add(theInstructionLayout); theInstructionLayout.setLocation(20, 10); - final ButtonPanel theButtonLayout = new ButtonPanel(theModel, this, + final ButtonPanel theButtonLayout = + new ButtonPanel(theModel, theEngine, getSpatialGrid(), getAgentListManager().getAgentSet()); mMapLayout.add(theButtonLayout); theButtonLayout.setLocation(20, 300); // Phase de jeu. - final PhasePanel thePhaseLayout = new PhasePanel(theModel, this); + final PhasePanel thePhaseLayout = new PhasePanel(theModel, theEngine); mPhaseLayout.add(thePhaseLayout); // Temps restant. @@ -394,7 +398,7 @@ getAgentListManager(), getNetworkAgents(), getApplication().getConfiguration(), - this); + getLocalizationEngine()); mPlayersInfoLayout.add(mPlayersInfoPanel); // Attitude par d\xE9faut de l'avatar. @@ -631,8 +635,8 @@ SimCommodModel.PHASE_VALIDATION); theModel.resetTime(); } - mRPPanel = new SimCommodRPPanel(theModel, this, getSpatialGrid(), - mLocalAgent); + mRPPanel = new SimCommodRPPanel(theModel, getLocalizationEngine(), + getSpatialGrid(), mLocalAgent); mRPPanel.setLocation(0, 0); mMapLayout2.add(mRPPanel); mMapLayout2.repaint(); @@ -850,6 +854,7 @@ private void updatePhase() { final SimCommodModel theModel = getModel(); final int thePhase = theModel.getGamePhase(); + final LocalizationEngine theEngine = getLocalizationEngine(); switch(thePhase) { case SimCommodModel.PHASE_HARVESTING: beginHarvesting(); @@ -892,31 +897,32 @@ switch (theModel.getOldPhase()) { case SimCommodModel.PHASE_HARVESTING: - mWaitLabel.setText(localizeString( + mWaitLabel.setText(theEngine.localizeString( "WaitPlayerHarvesting_Key")); validateHarvesting(); break; case SimCommodModel.PHASE_HARVESTINGRESULTS: - mWaitLabel.setText(localizeString( + mWaitLabel.setText(theEngine.localizeString( "WaitPlayerHarvestingResults_Key")); endHarvestingResults(); break; case SimCommodModel.PHASE_PROPELABORATION: - mWaitLabel.setText(localizeString( + mWaitLabel.setText(theEngine.localizeString( "WaitPlayerPropElaboration_Key")); endPropElaboration(); break; case SimCommodModel.PHASE_VALIDATION: - mWaitLabel.setText(localizeString( + mWaitLabel.setText(theEngine.localizeString( "WaitPlayerValidation_Key")); endValidation(); break; case SimCommodModel.PHASE_RESULT: - mWaitLabel.setText(localizeString("WaitPlayerResult_Key")); + mWaitLabel.setText(theEngine.localizeString( + "WaitPlayerResult_Key")); endResult(); break; @@ -961,7 +967,9 @@ */ public void showHarvestingProposition(List<String> inProposition) { final StringWriter theWriter = new StringWriter(); - theWriter.write(localizeString("SuggestionHarvestingPlan:_Key")); + final LocalizationEngine theEngine = getLocalizationEngine(); + theWriter.write(theEngine.localizeString( + "SuggestionHarvestingPlan:_Key")); theWriter.write(" "); final Iterator<String> theListIter = inProposition.iterator(); while (theListIter.hasNext()) { @@ -992,7 +1000,7 @@ String inAgentCallbackMethod, Map<String, Object> inParams) { mBubblePanel.askQuestion( - localizeString("WhyProposition?_Key"), + getLocalizationEngine().localizeString("WhyProposition?_Key"), inAgentCallbackMethod, inParams); } @@ -1001,12 +1009,13 @@ * {@inheritDoc} */ public void updateIncome(int inTotalIncome) { + final LocalizationEngine theEngine = getLocalizationEngine(); final HarvesterModel theModel = (HarvesterModel) getModel(); mPlayerInfoPanel.updateBudgetText(theModel.getMoney() + ""); theModel.appendToLog( - "[" + localizeString("Turn_Key") + "[" + theEngine.localizeString("Turn_Key") + theModel.getTurn() + "] " - + localizeString("ChangeMoney_Key") + + theEngine.localizeString("ChangeMoney_Key") + inTotalIncome); } } Modified: examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/InstructionPanel.java =================================================================== --- examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/InstructionPanel.java 2007-05-21 09:08:28 UTC (rev 143) +++ examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/InstructionPanel.java 2007-05-21 09:09:42 UTC (rev 144) @@ -38,7 +38,7 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; -import fr.lip6.sma.simulacion.app.LocalizedWindow; +import fr.lip6.sma.simulacion.app.LocalizationEngine; /** * Classe pour la vue sur la phase en cours. @@ -60,20 +60,21 @@ private JTextArea mInstructionLabel; /** - * R\xE9f\xE9rence sur la fen\xEAtre localis\xE9e + * Engine for the translation. */ - private final LocalizedWindow mTranslation; + private final LocalizationEngine mLocalizationEngine; /** * Constructeur \xE0 partir d'un mod\xE8le. * * @param inModel mod\xE8le pour construire cette vue. - * @param inWin fen\xEAtre pour les traductions. + * @param inLocalizationEngine engine for the translation. */ - public InstructionPanel(SimCommodModel inModel, LocalizedWindow inWin) { + public InstructionPanel(SimCommodModel inModel, + LocalizationEngine inLocalizationEngine) { mModel = inModel; - mTranslation = inWin; + mLocalizationEngine = inLocalizationEngine; setSize(450, 60); setLayout(null); @@ -130,7 +131,7 @@ theKey = ""; } - mInstructionLabel.setText(mTranslation.localizeString(theKey)); + mInstructionLabel.setText(mLocalizationEngine.localizeString(theKey)); } /** Modified: examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/MapInteractionPanel.java =================================================================== --- examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/MapInteractionPanel.java 2007-05-21 09:08:28 UTC (rev 143) +++ examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/MapInteractionPanel.java 2007-05-21 09:09:42 UTC (rev 144) @@ -44,7 +44,7 @@ import fr.lip6.sma.simulacion.app.Application; import fr.lip6.sma.simulacion.app.Bundle; import fr.lip6.sma.simulacion.app.ImagePanel; -import fr.lip6.sma.simulacion.app.LocalizedWindow; +import fr.lip6.sma.simulacion.app.LocalizationEngine; /** * Classe pour la vue permettant les interactions avec la carte. @@ -89,9 +89,9 @@ private JPanel mInfoPanel; /** - * R\xE9f\xE9rence sur la fen\xEAtre localis\xE9e + * Engine for the translation. */ - private final LocalizedWindow mTranslation; + private final LocalizationEngine mLocalizationEngine; /** * Constructeur \xE0 partir d'un mod\xE8le. @@ -99,17 +99,17 @@ * @param inModel mod\xE8le pour construire cette vue. * @param inMap carte pour qui va \xEAtre mise \xE0 jour. * @param inApplication application du jeu. - * @param inWin fen\xEAtre pour la traduction. + * @param inLocalizationEngine engine for the translation. */ public MapInteractionPanel( SimCommodModel inModel, SpatialGridView inMap, Application inApplication, - LocalizedWindow inWin) { + LocalizationEngine inLocalizationEngine) { mModel = inModel; mSpatialGridView = inMap; - mTranslation = inWin; + mLocalizationEngine = inLocalizationEngine; mApplication = inApplication; setSize(245, 201); setLayout(null); @@ -387,7 +387,7 @@ * Mise \xE0 jour du nombre de jetons utilis\xE9s. */ private void doUpdateUsedTokens() { - mRemainingPoint.setText(mTranslation + mRemainingPoint.setText(mLocalizationEngine .localizeString("RemainingPoint_Key") + (mModel.getTotalPoint() - mModel.getUsedPoint())); } @@ -424,7 +424,7 @@ mScrollInfo = null; } if (thePhase == SimCommodModel.PHASE_PROPELABORATION) { - mRemainingPoint.setText(mTranslation + mRemainingPoint.setText(mLocalizationEngine .localizeString("RemainingPoint_Key") + (mModel.getTotalPoint() - mModel.getUsedPoint())); add(mRemainingPoint); Modified: examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/PhasePanel.java =================================================================== --- examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/PhasePanel.java 2007-05-21 09:08:28 UTC (rev 143) +++ examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/PhasePanel.java 2007-05-21 09:09:42 UTC (rev 144) @@ -38,7 +38,7 @@ import javax.swing.SwingConstants; import javax.swing.SwingUtilities; -import fr.lip6.sma.simulacion.app.LocalizedWindow; +import fr.lip6.sma.simulacion.app.LocalizationEngine; import fr.lip6.sma.simulacion.simcommod.agents.Government; /** @@ -66,20 +66,21 @@ private final JLabel mSubPhaseLabel; /** - * R\xE9f\xE9rence sur la fen\xEAtre localis\xE9e + * Engine for the translation. */ - private final LocalizedWindow mTranslation; + private final LocalizationEngine mLocalizationEngine; /** * Constructeur \xE0 partir d'un mod\xE8le. * * @param inModel mod\xE8le pour construire cette vue. - * @param inWin fen\xEAtre pour la traduction. + * @param inLocalizationEngine engine for the localization. */ - public PhasePanel(SimCommodModel inModel, LocalizedWindow inWin) { + public PhasePanel(SimCommodModel inModel, + LocalizationEngine inLocalizationEngine) { mModel = inModel; - mTranslation = inWin; + mLocalizationEngine = inLocalizationEngine; if (!mModel.getAgentClass().equals(Government.CLASS)) { setSize(740, 40); } else { @@ -126,47 +127,48 @@ final int thePhase = mModel.getGamePhase(); switch (thePhase) { case SimCommodModel.PHASE_HARVESTING: - mPhaseLabel.setText(mTranslation + mPhaseLabel.setText(mLocalizationEngine .localizeString("IndividualPhase_Key")); - mSubPhaseLabel.setText(mTranslation + mSubPhaseLabel.setText(mLocalizationEngine .localizeString("HarvestingPhase_Key")); break; case SimCommodModel.PHASE_HARVESTINGRESULTS: - mPhaseLabel.setText(mTranslation + mPhaseLabel.setText(mLocalizationEngine .localizeString("IndividualPhase_Key")); - mSubPhaseLabel.setText(mTranslation + mSubPhaseLabel.setText(mLocalizationEngine .localizeString("HarvestingResultsPhase_Key")); break; case SimCommodModel.PHASE_PROPELABORATION: - mPhaseLabel.setText(mTranslation + mPhaseLabel.setText(mLocalizationEngine .localizeString("IndividualPhase_Key")); - mSubPhaseLabel.setText(mTranslation + mSubPhaseLabel.setText(mLocalizationEngine .localizeString("PropElabPhase_Key")); break; case SimCommodModel.PHASE_NEGOTIATION: - mPhaseLabel.setText(mTranslation + mPhaseLabel.setText(mLocalizationEngine .localizeString("CollectivePhase_Key")); - mSubPhaseLabel.setText(mTranslation + mSubPhaseLabel.setText(mLocalizationEngine .localizeString("NegotiationPhase_Key")); break; case SimCommodModel.PHASE_VALIDATION: - mPhaseLabel.setText(mTranslation + mPhaseLabel.setText(mLocalizationEngine .localizeString("CollectivePhase_Key")); - mSubPhaseLabel.setText(mTranslation + mSubPhaseLabel.setText(mLocalizationEngine .localizeString("ValidationPhase_Key")); break; case SimCommodModel.PHASE_RESULT: - mPhaseLabel.setText(mTranslation.localizeString("ResultPhase_Key")); + mPhaseLabel.setText(mLocalizationEngine.localizeString( + "ResultPhase_Key")); mSubPhaseLabel.setText(""); break; case SimCommodModel.PHASE_MANAGEMENT: - mPhaseLabel.setText(mTranslation + mPhaseLabel.setText(mLocalizationEngine .localizeString("ManagementPhase_Key")); mSubPhaseLabel.setText(""); break; Modified: examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/PlayersInfoPanel.java =================================================================== --- examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/PlayersInfoPanel.java 2007-05-21 09:08:28 UTC (rev 143) +++ examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/PlayersInfoPanel.java 2007-05-21 09:09:42 UTC (rev 144) @@ -54,7 +54,7 @@ import fr.lip6.sma.simulacion.app.Bundle; import fr.lip6.sma.simulacion.app.Configuration; import fr.lip6.sma.simulacion.app.ImagePanel; -import fr.lip6.sma.simulacion.app.LocalizedWindow; +import fr.lip6.sma.simulacion.app.LocalizationEngine; import fr.lip6.sma.simulacion.app.MoreSwingUtilities; import fr.lip6.sma.simulacion.server.Agent; import fr.lip6.sma.simulacion.server.AgentListManager; @@ -113,7 +113,7 @@ /** * Fen\xEAtre pour la traduction. */ - private final LocalizedWindow mTranslation; + private final LocalizationEngine mLocalizationEngine; /** * Si c'est un nouveau joueur. @@ -142,13 +142,13 @@ * @param inListManager gestionnaire de la liste des agents. * @param inNetworkAgents agents sur le r\xE9seau. * @param inConfig configuration du jeu. - * @param inWin fen\xEAtre pour la traduction. + * @param inLocalizationEngine engine for the translation. */ public PlayersInfoPanel(SimCommodModel inModel, AgentListManager inListManager, Map<String, Agent> inNetworkAgents, - Configuration inConfig, LocalizedWindow inWin) { + Configuration inConfig, LocalizationEngine inLocalizationEngine) { mModel = inModel; - mTranslation = inWin; + mLocalizationEngine = inLocalizationEngine; mListManager = inListManager; mNetworkAgents = inNetworkAgents; mConfig = inConfig; @@ -320,10 +320,10 @@ theAvatarClass.setSize(100, 18); theAvatarClass.setLocation(82, indexAgents * 42 + 10); if (theAgentClass.equals("Harvester")) { - theAvatarClass.setText(mTranslation + theAvatarClass.setText(mLocalizationEngine .localizeString("Harvester_Key")); } else { - theAvatarClass.setText(mTranslation + theAvatarClass.setText(mLocalizationEngine .localizeString("Environmentalist_Key")); } theAvatarClass.setVisible(true); @@ -508,7 +508,7 @@ */ public void actionPerformed(ActionEvent inEvent) { if (inEvent.getActionCommand().equals( - mTranslation.localizeString("SelectAll_Key"))) { + mLocalizationEngine.localizeString("SelectAll_Key"))) { mModel.initSelectedAgent(mListManager.getAgentSet()); } else { mModel.resetSelectedAgent(); Modified: examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/SimCommodApplicationWindow.java =================================================================== --- examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/SimCommodApplicationWindow.java 2007-05-21 09:08:28 UTC (rev 143) +++ examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/SimCommodApplicationWindow.java 2007-05-21 09:09:42 UTC (rev 144) @@ -311,6 +311,13 @@ closeMainWindow(); theResultWindow.setVisible(true); } + + /** + * {@inheritDoc} + */ + public String localizeString(String inString) { + return getLocalizationEngine().localizeString(inString); + } } // ========================================================================= // Modified: examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/SimCommodRPPanel.java =================================================================== --- examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/SimCommodRPPanel.java 2007-05-21 09:08:28 UTC (rev 143) +++ examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/SimCommodRPPanel.java 2007-05-21 09:09:42 UTC (rev 144) @@ -47,7 +47,7 @@ import javax.swing.JTextArea; import javax.swing.SwingUtilities; -import fr.lip6.sma.simulacion.app.LocalizedWindow; +import fr.lip6.sma.simulacion.app.LocalizationEngine; import fr.lip6.sma.simulacion.simcommod.agents.SimCommodAgent; /** @@ -96,25 +96,25 @@ private final SimCommodAgent mLocalAgent; /** - * R\xE9f\xE9rence sur la fen\xEAtre localis\xE9e + * Engine for the localization. */ - private final LocalizedWindow mTranslation; + private final LocalizationEngine mLocalizationEngine; /** * Constructeur \xE0 partir d'un mod\xE8le. * * @param inModel mod\xE8le pour construire cette vue. - * @param inWin fen\xEAtre pour la traduction. + * @param inLocalizationEngine engine for the localization. * @param inGrid grille du jeu. * @param inLocalAgent agent local. */ public SimCommodRPPanel( SimCommodModel inModel, - LocalizedWindow inWin, + LocalizationEngine inLocalizationEngine, SimCommodSpatialGrid inGrid, SimCommodAgent inLocalAgent) { mModel = inModel; - mTranslation = inWin; + mLocalizationEngine = inLocalizationEngine; setSize(250, 424); setLayout(null); mLocalAgent = inLocalAgent; @@ -129,7 +129,7 @@ mInstructionLabel.setWrapStyleWord(true); mInstructionLabel.setOpaque(false); mInstructionLabel.setEditable(false); - mInstructionLabel.setText(mTranslation + mInstructionLabel.setText(mLocalizationEngine .localizeString("SubMapInstruction_Key")); add(mInstructionLabel); @@ -143,7 +143,8 @@ mValidate.setForeground(Color.black); mValidate.addActionListener(this); mButton.add(mValidate, BorderLayout.CENTER); - mValidate.setText(mTranslation.localizeString("UpdateProposition_Key")); + mValidate.setText(mLocalizationEngine.localizeString( + "UpdateProposition_Key")); add(mButton); // Dessin de la carte secondaire. @@ -158,7 +159,7 @@ mRemainingPoint.setForeground(Color.black); mRemainingPoint.setOpaque(false); mRemainingPoint.setLocation(20, 285); - mRemainingPoint.setText(mTranslation + mRemainingPoint.setText(mLocalizationEngine .localizeString("RemainingPoint_Key") + (mModel.getTotalPoint() - mModel.getUsedPoint())); add(mRemainingPoint); @@ -174,9 +175,9 @@ * @param inEvent \xE9v\xE9nement du changement. */ public void actionPerformed(ActionEvent inEvent) { - mModel.appendToLog("[" + mTranslation.localizeString("Turn_Key") + mModel.appendToLog("[" + mLocalizationEngine.localizeString("Turn_Key") + mModel.getTurn() + "] " - + mTranslation.localizeString("UpdateMap_Key")); + + mLocalizationEngine.localizeString("UpdateMap_Key")); final Map<String, Object> theParams = new Hashtable<String, Object>(); theParams.put("from", mModel.getAgentName()); final List<String> theCellsValues = new Vector<String>(); @@ -202,7 +203,7 @@ SimCommodModel.USEDPOINT_PROPERTY_NAME)) { SwingUtilities.invokeLater(new Runnable() { public void run() { - mRemainingPoint.setText(mTranslation + mRemainingPoint.setText(mLocalizationEngine .localizeString("RemainingPoint_Key") + (mModel.getTotalPoint() - mModel.getUsedPoint())); } Modified: examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/SimCommodView.java =================================================================== --- examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/SimCommodView.java 2007-05-21 09:08:28 UTC (rev 143) +++ examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/SimCommodView.java 2007-05-21 09:09:42 UTC (rev 144) @@ -52,14 +52,6 @@ void repaintMap(); /** - * Localize a string. - * - * @param inString string to translate/localize. - * @return the localized string or inString if no translation is available. - */ - String localizeString(String inString); - - /** * Close the main window (typically this). */ void closeMainWindow(); @@ -68,6 +60,14 @@ * Show the end results. */ void showEndResult(); + + /** + * Localize a string. + * + * @param inString string to localize. + * @return the localized string. + */ + String localizeString(String inString); } // ================================================================== // Modified: examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/WaitWindow.java =================================================================== --- examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/WaitWindow.java 2007-05-21 09:08:28 UTC (rev 143) +++ examples/simcommod/src/fr/lip6/sma/simulacion/simcommod/WaitWindow.java 2007-05-21 09:09:42 UTC (rev 144) @@ -325,15 +325,17 @@ + "/" + mEnvironmentalistNb); mHarvesterCountLabel.setText(mModel.getHarvestersCount() + "/" + mHarvesterNb); - mCormasStartedZoneLabel.setText(this - .localizeString("CormasStarted_Key")); + mCormasStartedZoneLabel.setText( + getLocalizationEngine().localizeString( + "CormasStarted_Key")); } else { mEnvironmentalistCountLabel.setText( mModel.getEnvironmentalistsCount() + "/?"); mHarvesterCountLabel.setText( mModel.getHarvestersCount() + "/?"); - mCormasStartedZoneLabel.setText(this - .localizeString("CormasNotStarted_Key")); + mCormasStartedZoneLabel.setText( + getLocalizationEngine().localizeString( + "CormasNotStarted_Key")); } repaint(); } @@ -446,14 +448,15 @@ + "/" + mEnvironmentalistNb); mHarvesterCountLabel.setText(mModel.getHarvestersCount() + "/" + mHarvesterNb); - mCormasStartedZoneLabel.setText(this + mCormasStartedZoneLabel.setText( + getLocalizationEngine() .localizeString("CormasStarted_Key")); } else { mEnvironmentalistCountLabel.setText( mModel.getEnvironmentalistsCount() + "/?"); mHarvesterCountLabel.setText( mModel.getHarvestersCount() + "/?"); - mCormasStartedZoneLabel.setText(this + mCormasStartedZoneLabel.setText(getLocalizationEngine() .localizeString("CormasNotStarted_Key")); } repaint(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pg...@us...> - 2007-05-21 09:08:31
|
Revision: 143 http://simulacion.svn.sourceforge.net/simulacion/?rev=143&view=rev Author: pguyot Date: 2007-05-21 02:08:28 -0700 (Mon, 21 May 2007) Log Message: ----------- Initial work to support both Swing and JApplet environments. Modified Paths: -------------- simulacion/src/fr/lip6/sma/simulacion/app/ApplicationChooser.java simulacion/src/fr/lip6/sma/simulacion/app/ApplicationWindow.java simulacion/src/fr/lip6/sma/simulacion/app/Configuration.java simulacion/src/fr/lip6/sma/simulacion/app/LocalizationEngine.java simulacion/src/fr/lip6/sma/simulacion/app/LocalizedWindow.java simulacion/src/fr/lip6/sma/simulacion/app/WaitShowing.java simulacion/src/fr/lip6/sma/simulacion/app/map/MapPanelListener.java simulacion/src/fr/lip6/sma/simulacion/app/map/MapRegionPanel.java simulacion/src/fr/lip6/sma/simulacion/server/http/HTTPSetupFrame.java Added Paths: ----------- simulacion/src/fr/lip6/sma/simulacion/gui/ simulacion/src/fr/lip6/sma/simulacion/gui/BaseApplet.java simulacion/src/fr/lip6/sma/simulacion/gui/GraphicalUserInterface.java simulacion/src/fr/lip6/sma/simulacion/gui/ListenerProxy.java simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java simulacion/src/fr/lip6/sma/simulacion/gui/SwingApplicationGUI.java simulacion/src/fr/lip6/sma/simulacion/gui/Window.java simulacion/src/fr/lip6/sma/simulacion/gui/WindowAdapter.java simulacion/src/fr/lip6/sma/simulacion/gui/WindowEvent.java simulacion/src/fr/lip6/sma/simulacion/gui/WindowHook.java simulacion/src/fr/lip6/sma/simulacion/gui/WindowListener.java simulacion/src/fr/lip6/sma/simulacion/gui/package.html Modified: simulacion/src/fr/lip6/sma/simulacion/app/ApplicationChooser.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/app/ApplicationChooser.java 2007-05-18 05:19:16 UTC (rev 142) +++ simulacion/src/fr/lip6/sma/simulacion/app/ApplicationChooser.java 2007-05-21 09:08:28 UTC (rev 143) @@ -274,7 +274,7 @@ protected void resetComponentsLocalizedContent() { resetDefaultLocale(); initComponentsLocalizedContent(); - localizeComponent(this); + getLocalizationEngine().localizeWindow(this); } /** @@ -293,7 +293,7 @@ // Liste des applications. final List<String> theList = new Vector<String>(); for (String theName : mAppNames) { - theList.add(localizeString(theName)); + theList.add(getLocalizationEngine().localizeString(theName)); } mAppList.setListData((Vector<String>) theList); Modified: simulacion/src/fr/lip6/sma/simulacion/app/ApplicationWindow.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/app/ApplicationWindow.java 2007-05-18 05:19:16 UTC (rev 142) +++ simulacion/src/fr/lip6/sma/simulacion/app/ApplicationWindow.java 2007-05-21 09:08:28 UTC (rev 143) @@ -30,6 +30,7 @@ // imports import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; +import java.security.AccessControlException; /** * Classe de base pour les fen\xEAtres des applications Simulaci\xF3n. @@ -73,6 +74,10 @@ Class.forName("com.apple.eawt.Application"); } catch (ClassNotFoundException anIgnoredException) { theAppleClassIsThere = false; + } catch (ExceptionInInitializerError anIgnoredException) { + theAppleClassIsThere = false; + } catch (AccessControlException anIgnoredException) { + theAppleClassIsThere = false; } if (theAppleClassIsThere) { @@ -87,8 +92,12 @@ new Class[] {ApplicationWindow.class}); theEventListener = (EventListener) ourConstructor.newInstance(new Object[] {this}); + } catch (ExceptionInInitializerError anIgnoredException) { + // This space for rent. + } catch (AccessControlException anIgnoredException) { + // This space also for rent. } catch (ClassNotFoundException anIgnoredException) { - // This space for rent. + // This space also for rent. } catch (NoSuchMethodException anIgnoredException) { // This space also for rent. } catch (InstantiationException anIgnoredException) { Modified: simulacion/src/fr/lip6/sma/simulacion/app/Configuration.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/app/Configuration.java 2007-05-18 05:19:16 UTC (rev 142) +++ simulacion/src/fr/lip6/sma/simulacion/app/Configuration.java 2007-05-21 09:08:28 UTC (rev 143) @@ -35,6 +35,7 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.security.AccessControlException; import java.util.Collection; import java.util.HashMap; import java.util.Hashtable; @@ -526,7 +527,12 @@ * n'a pas \xE9t\xE9 d\xE9finie. */ public String getProperty(String inPropertyName) { - String theProperty = System.getProperty(inPropertyName); + String theProperty = null; + try { + theProperty = System.getProperty(inPropertyName); + } catch (AccessControlException inException) { + // Ignore. + } if (theProperty == null) { theProperty = mProperties.get(inPropertyName); Modified: simulacion/src/fr/lip6/sma/simulacion/app/LocalizationEngine.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/app/LocalizationEngine.java 2007-05-18 05:19:16 UTC (rev 142) +++ simulacion/src/fr/lip6/sma/simulacion/app/LocalizationEngine.java 2007-05-21 09:08:28 UTC (rev 143) @@ -45,6 +45,8 @@ import javax.swing.border.TitledBorder; import javax.swing.text.JTextComponent; +import fr.lip6.sma.simulacion.gui.Window; + /** * Singleton class to localize strings. * @@ -322,9 +324,18 @@ } /** - * Traduit un composant fra\xEEchement initialis\xE9. Cette m\xE9thode appelle les - * m\xE9thodes pr\xE9c\xE9dentes si la classe correspond. + * Translate a window. * + * @param inWindow widget to translate. + */ + public void localizeWindow(Window inWindow) { + localizeComponent(inWindow.getImplementation()); + } + + /** + * Translate a freshly initialized component. This method calls the previous + * methods depending on the class. + * * @param inComponent widget to translate. */ public void localizeComponent(Component inComponent) { Modified: simulacion/src/fr/lip6/sma/simulacion/app/LocalizedWindow.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/app/LocalizedWindow.java 2007-05-18 05:19:16 UTC (rev 142) +++ simulacion/src/fr/lip6/sma/simulacion/app/LocalizedWindow.java 2007-05-21 09:08:28 UTC (rev 143) @@ -29,26 +29,19 @@ // imports import java.awt.Component; -import java.awt.Container; import java.awt.Dimension; -import java.awt.Frame; import java.awt.Point; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import javax.swing.AbstractButton; import javax.swing.JComponent; -import javax.swing.JFrame; -import javax.swing.JLabel; import javax.swing.JLayeredPane; import javax.swing.JMenuBar; -import javax.swing.JProgressBar; -import javax.swing.MenuElement; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; -import javax.swing.border.CompoundBorder; -import javax.swing.text.JTextComponent; +import fr.lip6.sma.simulacion.gui.Window; +import fr.lip6.sma.simulacion.gui.WindowAdapter; +import fr.lip6.sma.simulacion.gui.WindowEvent; + /** * Classe pour une fen\xEAtre dans la langue de l'utilisateur. C'est la classe de * base pour presque toutes les fen\xEAtres des applications Simulaci\xF3n. @@ -58,7 +51,7 @@ * * @see "aucun test d\xE9fini." */ -public class LocalizedWindow extends JFrame { +public class LocalizedWindow extends Window { /** * Engine to localize strings. */ @@ -98,8 +91,17 @@ } /** - * R\xE9initialise la traduction. + * Accessor on the localization engine. + * + * @return a reference on the localization engine. */ + protected final LocalizationEngine getLocalizationEngine() { + return mLocalizationEngine; + } + + /** + * Reset the translation. + */ protected void resetDefaultLocale() { mLocalizationEngine.resetDefaultLocale(); } @@ -134,137 +136,8 @@ // enfin, la fen\xEAtre ne peut \xEAtre redimensionn\xE9e. setResizable(false); } - - /** - * Translate a string. - * - * @param inKeyString string to translate. - * @return translated string or the original string if the key doesn't - * exist. - */ - public final String localizeString(String inKeyString) { - return mLocalizationEngine.localizeString(inKeyString); - } - - /** - * Traduit le texte de la bulle d'aide d'un composant swing. Cette m\xE9thode - * r\xE9cup\xE8re le texte original et l'utilise comme cl\xE9 pour r\xE9cup\xE9rer la - * traduction. Si aucune traduction n'est disponible, le texte original est - * utilis\xE9. - * - * @param inJComponent - * composant \xE0 traduire - */ - protected final void localizeJComponent(JComponent inJComponent) { - mLocalizationEngine.localizeJComponent(inJComponent); - } - - // CSOFF: IllegalType - /** - * Traduit le texte d'un AbstractButton fra\xEEchement initialis\xE9. Cette - * m\xE9thode r\xE9cup\xE8re le texte original et l'utilise comme cl\xE9 pour r\xE9cup\xE9rer - * la traduction. Si aucune traduction n'est disponible, le texte original - * est utilis\xE9. - * - * @param inButton - * objet \xE0 traduire - */ - protected final void localizeAbstractButton(AbstractButton inButton) { - mLocalizationEngine.localizeAbstractButton(inButton); - } /** - * Translate the title of titled borders when they are embedded in - * border compounds. - * - * @param inBorder The compound border to (perhaps) translate. - */ - protected final void localizeCompoundBorder(CompoundBorder inBorder) { - mLocalizationEngine.localizeCompoundBorder(inBorder); - } - - // CSON: IllegalType - - /** - * Traduit le texte d'une JProgressBar fra\xEEchement initialis\xE9. Cette - * m\xE9thode r\xE9cup\xE8re le texte original et l'utilise comme cl\xE9 pour r\xE9cup\xE9rer - * la traduction. Si aucune traduction n'est disponible, le texte original - * est utilis\xE9. - * - * @param inPBar - * objet \xE0 traduire - */ - protected final void localizeJProgressBar(JProgressBar inPBar) { - mLocalizationEngine.localizeJProgressBar(inPBar); - } - - /** - * Traduit le texte d'une \xE9tiquette JLabel fra\xEEchement initialis\xE9e. Cette - * m\xE9thode fonctionne comme la pr\xE9c\xE9dente. - * - * @param inLabel - * objet \xE0 traduire - */ - protected final void localizeLabel(JLabel inLabel) { - mLocalizationEngine.localizeLabel(inLabel); - } - - /** - * Traduit le texte d'un objet inTextComponent fra\xEEchement initialis\xE9. Cette - * m\xE9thode fonctionne comme la pr\xE9c\xE9dente. - * - * @param inTextComponent - * objet \xE0 traduire - */ - protected final void localizeTextComponent(JTextComponent inTextComponent) { - mLocalizationEngine.localizeTextComponent(inTextComponent); - } - - /** - * Traduit le texte d'une Frame fra\xEEchement initialis\xE9e. Cette m\xE9thode - * fonctionne comme la pr\xE9c\xE9dente. - * - * @param inFrame - * objet \xE0 traduire - */ - protected void localizeFrame(Frame inFrame) { - mLocalizationEngine.localizeFrame(inFrame); - } - - /** - * Traduit un conteneur fra\xEEchement initialis\xE9. Cette m\xE9thode it\xE8re sur tous - * les \xE9l\xE9ments du conteneurs et appelle les pr\xE9c\xE9dentes pour ces \xE9l\xE9ments. - * - * @param inContainer - * objet \xE0 traduire - */ - protected void localizeContainer(Container inContainer) { - mLocalizationEngine.localizeContainer(inContainer); - } - - /** - * Traduit un \xE9l\xE9ment de menu fra\xEEchement initialis\xE9. Cette m\xE9thode appelle - * les m\xE9thodes pr\xE9c\xE9dentes si la classe correspond. - * - * @param inMenuElement - * objet \xE0 traduire - */ - protected final void localizeMenuElement(MenuElement inMenuElement) { - mLocalizationEngine.localizeMenuElement(inMenuElement); - } - - /** - * Traduit un composant fra\xEEchement initialis\xE9. Cette m\xE9thode appelle les - * m\xE9thodes pr\xE9c\xE9dentes si la classe correspond. - * - * @param inComponent - * objet \xE0 traduire - */ - protected final void localizeComponent(Component inComponent) { - mLocalizationEngine.localizeComponent(inComponent); - } - - /** * M\xE9thode appel\xE9e lorsque la fen\xEAtre est rendue visible. * * On d\xE9place tout si le menu est \xE0 l'int\xE9rieur de l'application. @@ -299,7 +172,7 @@ } // Traduction. - localizeComponent(this); + mLocalizationEngine.localizeWindow(this); mShown = true; } Modified: simulacion/src/fr/lip6/sma/simulacion/app/WaitShowing.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/app/WaitShowing.java 2007-05-18 05:19:16 UTC (rev 142) +++ simulacion/src/fr/lip6/sma/simulacion/app/WaitShowing.java 2007-05-21 09:08:28 UTC (rev 143) @@ -32,6 +32,8 @@ import java.awt.event.HierarchyEvent; import java.awt.event.HierarchyListener; +import fr.lip6.sma.simulacion.gui.Window; + /** * Classe pour attendre qu'un composant soit affich\xE9. * @@ -78,6 +80,15 @@ } /** + * Synchronous wait. + * + * @param inWindow window to wait for. + */ + public static void wait(Window inWindow) { + wait(inWindow.getImplementation()); + } + + /** * Attente asynchrone. * * @param inComponent composant \xE0 surveiller. @@ -97,6 +108,16 @@ } /** + * Asynchronous wait. + * + * @param inWindow window to wait for. + * @param inCallback callback. + */ + public static void wait(Window inWindow, Runnable inCallback) { + wait(inWindow.getImplementation(), inCallback); + } + + /** * Quelque chose a chang\xE9 dans la hi\xE9rarchie du composant. * * @param inEvent \xE9v\xE9nement du changement. Modified: simulacion/src/fr/lip6/sma/simulacion/app/map/MapPanelListener.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/app/map/MapPanelListener.java 2007-05-18 05:19:16 UTC (rev 142) +++ simulacion/src/fr/lip6/sma/simulacion/app/map/MapPanelListener.java 2007-05-21 09:08:28 UTC (rev 143) @@ -37,15 +37,6 @@ */ public interface MapPanelListener { /** - * M\xE9thode invoqu\xE9e pour traduire une cha\xEEne. - * - * @param inKeyString cha\xEEne \xE0 traduire. - * @return la cha\xEEne traduite ou la cha\xEEne \xE0 traduire si aucune traduction - * existe. - */ - String localizeString(String inKeyString); - - /** * M\xE9thode invoqu\xE9e lorsque l'ensemble des joueurs choisis sur la carte * change. */ Modified: simulacion/src/fr/lip6/sma/simulacion/app/map/MapRegionPanel.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/app/map/MapRegionPanel.java 2007-05-18 05:19:16 UTC (rev 142) +++ simulacion/src/fr/lip6/sma/simulacion/app/map/MapRegionPanel.java 2007-05-21 09:08:28 UTC (rev 143) @@ -38,6 +38,7 @@ import java.util.Set; import fr.lip6.sma.simulacion.app.Configuration; +import fr.lip6.sma.simulacion.app.LocalizationEngine; /** * Classe de base pour une carte o\xF9 les joueurs sont pr\xE9sent\xE9s dans des r\xE9gions @@ -53,6 +54,11 @@ * R\xE9f\xE9rence sur la configuration globale. */ private final Configuration mConfiguration; + + /** + * Reference on the localization engine. + */ + private final LocalizationEngine mLocalizationEngine; /** * Position de l'agent local sur la carte, <code>null</code> si l'agent @@ -117,6 +123,8 @@ mConfiguration .getAgentProperty(inLocalAgentName, "location")); } + + mLocalizationEngine = LocalizationEngine.getEngine(inConfiguration); mAgentsLocations = new Hashtable<String, Point>(); mAgentsRects = new Hashtable<String, Rectangle>(); @@ -262,7 +270,7 @@ // Est-ce l'agent local? if ((mLocalAgentRect != null) && mLocalAgentRect.contains(thePoint)) { - theResult = getMapListener().localizeString("Home_Key"); + theResult = mLocalizationEngine.localizeString("Home_Key"); } else { theResult = getHouseOwnerName(thePoint); } Added: simulacion/src/fr/lip6/sma/simulacion/gui/BaseApplet.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/BaseApplet.java (rev 0) +++ simulacion/src/fr/lip6/sma/simulacion/gui/BaseApplet.java 2007-05-21 09:08:28 UTC (rev 143) @@ -0,0 +1,107 @@ +// ============================== +// File: BaseApplet.java +// Project: Simulaci\xF3n +// Written by: Paul Guyot (pau...@ac...) +// +// Created on: 20/5/2007 +// Tabs: 4 spaces +// +// This software is governed by the CeCILL license under French law and abiding +// by the rules of distribution of free software. You can use, modify and/ or +// redistribute the software under the terms of the CeCILL license as +// circulated by CEA, CNRS and INRIA at the following URL +// "http://www.cecill.info". +// +// As a counterpart to the access to the source code and rights to copy, modify +// and redistribute granted by the license, users are provided only with a +// limited warranty and the software's author, the holder of the economic +// rights, and the successive licensors have only limited liability. +// +// The fact that you are presently reading this means that you have had +// knowledge of the CeCILL license and that you accept its terms. +// +// =========== +// $Id: AppletMode.java 132 2007-05-09 07:39:21Z pguyot $ +// =========== + +// paquet +package fr.lip6.sma.simulacion.gui; + +// imports +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import javax.swing.JApplet; + +/** + * Base class for the applet. + * The main class can either be defined as a property in the web page or + * passed as a parameter to the constructor. + * + * @author Paul Guyot <pau...@ac...> + * @version $Revision: 132 $ + */ +public abstract class BaseApplet extends JApplet { + /** + * Name of the main class. + */ + private final Class mMainClass; + + /** + * Constructor from a class. + * + * @param inMainClass class with the main entry point. + */ + protected BaseApplet(Class inMainClass) { + // Create the applet GUI. + new SwingAppletGUI(this); + + mMainClass = inMainClass; + } + + /** + * Start the applet. + */ + public void start() { + // Launch the application. + Method theMainMethod = null; + final String[] theParams = new String[0]; + + try { + theMainMethod = + mMainClass.getMethod( + "main", new Class [] {theParams.getClass()}); + } catch (NoSuchMethodException anException) { + anException.printStackTrace(); + } + + getContentPane().setLayout(null); + + if (theMainMethod != null) { + final Method theMethod = theMainMethod; + final Thread theExecThread = new Thread() { + public void run() { + try { + theMethod.invoke(mMainClass, new Object[] {theParams}); + } catch (IllegalAccessException anException) { + anException.printStackTrace(); + System.exit(1); + } catch (InvocationTargetException anException) { + anException.printStackTrace(); + System.exit(1); + } + } + }; + + theExecThread.start(); + } + } +} + +// ======================================================================== // +// The idea that an arbitrary naive human should be able to properly use a // +// given tool without training or understanding is even more wrong for // +// computing than it is for other tools (e.g. automobiles, airplanes, guns, // +// power saws). // +// -- Doug Gwyn // +// ======================================================================== // Property changes on: simulacion/src/fr/lip6/sma/simulacion/gui/BaseApplet.java ___________________________________________________________________ Name: svn:executable + * Added: simulacion/src/fr/lip6/sma/simulacion/gui/GraphicalUserInterface.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/GraphicalUserInterface.java (rev 0) +++ simulacion/src/fr/lip6/sma/simulacion/gui/GraphicalUserInterface.java 2007-05-21 09:08:28 UTC (rev 143) @@ -0,0 +1,95 @@ +// ============================== +// File: GraphicalUserInterface.java +// Project: Simulaci\xF3n +// Written by: Paul Guyot (pau...@ac...) +// +// Created on: 20/5/2007 +// Tabs: 4 spaces +// +// This software is governed by the CeCILL license under French law and abiding +// by the rules of distribution of free software. You can use, modify and/ or +// redistribute the software under the terms of the CeCILL license as +// circulated by CEA, CNRS and INRIA at the following URL +// "http://www.cecill.info". +// +// As a counterpart to the access to the source code and rights to copy, modify +// and redistribute granted by the license, users are provided only with a +// limited warranty and the software's author, the holder of the economic +// rights, and the successive licensors have only limited liability. +// +// The fact that you are presently reading this means that you have had +// knowledge of the CeCILL license and that you accept its terms. +// +// =========== +// $Id: AppletMode.java 132 2007-05-09 07:39:21Z pguyot $ +// =========== + +// paquet +package fr.lip6.sma.simulacion.gui; + +// imports +import javax.swing.RootPaneContainer; + +/** + * Base class for the various GUI modes. + * + * @author Paul Guyot <pau...@ac...> + * @version $Revision: 132 $ + */ +public abstract class GraphicalUserInterface { + /** + * Reference on the GUI (single instance). + */ + private static GraphicalUserInterface gSingleInstance; + + /** + * Protected constructor. + */ + protected GraphicalUserInterface() { + if (gSingleInstance != null) { + throw new IllegalStateException("Cannot have more than one GUI"); + } + gSingleInstance = this; + } + + /** + * Get the GUI. + * + * @return a reference on the single instance. + */ + public static synchronized GraphicalUserInterface getGUI() { + if (gSingleInstance == null) { + createGUI(); + } + + return gSingleInstance; + } + + /** + * Create a window. + * + * @param inHook hook for the subclass method calls. + * @return a new window. + */ + public abstract RootPaneContainer createWindow(WindowHook inHook); + + /** + * Create the GUI. + * For the moment, we create a SwingApplicationGUI. + */ + private static void createGUI() { + new SwingApplicationGUI(); + } +} + +// ========================================================================= // +// If just one piece of mail gets lost, well, they'll just think they forgot // +// to send it. But if *two* pieces of mail get lost, hell, they'll just // +// think the other guy hasn't gotten around to answering his mail. And if // +// *fifty* pieces of mail get lost, can you imagine it, if *fifty* pieces of // +// mail get lost, why they'll think someone *else* is broken! And if 1Gb of // +// mail gets lost, they'll just *know* that Arpa [ucbarpa.berkeley.edu] is // +// down and think it's a conspiracy to keep them from their God given right // +// to receive Net Mail ... // +// -- Casey Leedom // +// ========================================================================= // Property changes on: simulacion/src/fr/lip6/sma/simulacion/gui/GraphicalUserInterface.java ___________________________________________________________________ Name: svn:executable + * Added: simulacion/src/fr/lip6/sma/simulacion/gui/ListenerProxy.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/ListenerProxy.java (rev 0) +++ simulacion/src/fr/lip6/sma/simulacion/gui/ListenerProxy.java 2007-05-21 09:08:28 UTC (rev 143) @@ -0,0 +1,190 @@ +// ============================== +// File: ListenerProxy.java +// Project: Simulaci\xF3n +// Written by: Paul Guyot (pau...@ac...) +// +// Created on: 20/5/2007 +// Tabs: 4 spaces +// +// This software is governed by the CeCILL license under French law and abiding +// by the rules of distribution of free software. You can use, modify and/ or +// redistribute the software under the terms of the CeCILL license as +// circulated by CEA, CNRS and INRIA at the following URL +// "http://www.cecill.info". +// +// As a counterpart to the access to the source code and rights to copy, modify +// and redistribute granted by the license, users are provided only with a +// limited warranty and the software's author, the holder of the economic +// rights, and the successive licensors have only limited liability. +// +// The fact that you are presently reading this means that you have had +// knowledge of the CeCILL license and that you accept its terms. +// +// =========== +// $Id: LocalizedWindow.java 132 2007-05-09 07:39:21Z pguyot $ +// =========== + +// paquet +package fr.lip6.sma.simulacion.gui; + +// imports +import javax.swing.event.InternalFrameEvent; +import javax.swing.event.InternalFrameListener; + +/** + * Proxy that redirects to either JFrame (application mode) or JInternalFrame + * (applet mode). + * + * @author Paul Guyot <pau...@ac...> + * @version $Revision: 132 $ + */ +final class ListenerProxy + implements InternalFrameListener, java.awt.event.WindowListener { + /** + * Reference on the window. + */ + private final Window mWindow; + + /** + * Reference on the listener. + */ + private final WindowListener mListener; + + /** + * Constructor from a window and a window listener. + * + * @param inWindow window proxy. + * @param inListener listener to forward events to. + */ + ListenerProxy( + Window inWindow, WindowListener inListener) { + mWindow = inWindow; + mListener = inListener; + } + + /** + * {@inheritDoc} + */ + public void windowActivated(java.awt.event.WindowEvent inEvent) { + mListener.windowActivated( + new WindowEvent(mWindow, inEvent)); + } + + /** + * {@inheritDoc} + */ + public void windowClosed(java.awt.event.WindowEvent inEvent) { + mListener.windowClosed( + new WindowEvent(mWindow, inEvent)); + } + + /** + * {@inheritDoc} + */ + public void windowClosing(java.awt.event.WindowEvent inEvent) { + mListener.windowClosing( + new WindowEvent(mWindow, inEvent)); + } + + /** + * {@inheritDoc} + */ + public void windowDeactivated(java.awt.event.WindowEvent inEvent) { + mListener.windowDeactivated( + new WindowEvent(mWindow, inEvent)); + } + + /** + * {@inheritDoc} + */ + public void windowDeiconified(java.awt.event.WindowEvent inEvent) { + mListener.windowDeiconified( + new WindowEvent(mWindow, inEvent)); + } + + /** + * {@inheritDoc} + */ + public void windowIconified(java.awt.event.WindowEvent inEvent) { + mListener.windowIconified( + new WindowEvent(mWindow, inEvent)); + } + + /** + * {@inheritDoc} + */ + public void windowOpened(java.awt.event.WindowEvent inEvent) { + mListener.windowOpened( + new WindowEvent(mWindow, inEvent)); + } + + /** + * {@inheritDoc} + */ + public void internalFrameActivated(InternalFrameEvent inEvent) { + mListener.windowActivated( + new WindowEvent(mWindow, inEvent)); + } + + /** + * {@inheritDoc} + */ + public void internalFrameClosed(InternalFrameEvent inEvent) { + mListener.windowClosed( + new WindowEvent(mWindow, inEvent)); + } + + /** + * {@inheritDoc} + */ + public void internalFrameClosing(InternalFrameEvent inEvent) { + mListener.windowClosing( + new WindowEvent(mWindow, inEvent)); + } + + /** + * {@inheritDoc} + */ + public void internalFrameDeactivated(InternalFrameEvent inEvent) { + mListener.windowDeactivated( + new WindowEvent(mWindow, inEvent)); + } + + /** + * {@inheritDoc} + */ + public void internalFrameDeiconified(InternalFrameEvent inEvent) { + mListener.windowDeiconified( + new WindowEvent(mWindow, inEvent)); + } + + /** + * {@inheritDoc} + */ + public void internalFrameIconified(InternalFrameEvent inEvent) { + mListener.windowIconified( + new WindowEvent(mWindow, inEvent)); + } + + /** + * {@inheritDoc} + */ + public void internalFrameOpened(InternalFrameEvent inEvent) { + mListener.windowOpened( + new WindowEvent(mWindow, inEvent)); + } +} + +// ============================================= // +// Welcome to boggle - do you want instructions? // +// // +// D G G O // +// // +// O Y A N // +// // +// A D B T // +// // +// K I S P // +// Enter words: // +// > // +// ============================================= // Property changes on: simulacion/src/fr/lip6/sma/simulacion/gui/ListenerProxy.java ___________________________________________________________________ Name: svn:executable + * Added: simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java (rev 0) +++ simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java 2007-05-21 09:08:28 UTC (rev 143) @@ -0,0 +1,102 @@ +// ============================== +// File: SwingAppletGUI.java +// Project: Simulaci\xF3n +// Written by: Paul Guyot (pau...@ac...) +// +// Created on: 20/5/2007 +// Tabs: 4 spaces +// +// This software is governed by the CeCILL license under French law and abiding +// by the rules of distribution of free software. You can use, modify and/ or +// redistribute the software under the terms of the CeCILL license as +// circulated by CEA, CNRS and INRIA at the following URL +// "http://www.cecill.info". +// +// As a counterpart to the access to the source code and rights to copy, modify +// and redistribute granted by the license, users are provided only with a +// limited warranty and the software's author, the holder of the economic +// rights, and the successive licensors have only limited liability. +// +// The fact that you are presently reading this means that you have had +// knowledge of the CeCILL license and that you accept its terms. +// +// =========== +// $Id: AppletMode.java 132 2007-05-09 07:39:21Z pguyot $ +// =========== + +// paquet +package fr.lip6.sma.simulacion.gui; + +// imports +import javax.swing.JInternalFrame; +import javax.swing.RootPaneContainer; + +/** + * Class for the swing applet GUI. + * + * @author Paul Guyot <pau...@ac...> + * @version $Revision: 132 $ + */ +final class SwingAppletGUI extends GraphicalUserInterface { + /** + * Reference on the base applet. + */ + private final BaseApplet mApplet; + + /** + * Constructor from the base applet. + * + * @param inApplet reference on the base applet. + */ + SwingAppletGUI(BaseApplet inApplet) { + mApplet = inApplet; + } + + /** + * Create a window. + * + * @param inHook hook for the subclass method calls. + * @return a new window. + */ + public RootPaneContainer createWindow(final WindowHook inHook) { + final JInternalFrame theResult = new JInternalFrame() { + /** + * If we've been added to the applet. + */ + private boolean mAdded; + + public void addNotify() { + super.addNotify(); + inHook.addNotify(); + } + + public void removeNotify() { + super.removeNotify(); + inHook.removeNotify(); + } + + public void setVisible(boolean inVisible) { + if (inVisible && !mAdded) { + mAdded = true; + mApplet.add(this); + } + + super.setVisible(inVisible); + } + }; + + return theResult; + } +} + +// ========================================================================= // +// If just one piece of mail gets lost, well, they'll just think they forgot // +// to send it. But if *two* pieces of mail get lost, hell, they'll just // +// think the other guy hasn't gotten around to answering his mail. And if // +// *fifty* pieces of mail get lost, can you imagine it, if *fifty* pieces of // +// mail get lost, why they'll think someone *else* is broken! And if 1Gb of // +// mail gets lost, they'll just *know* that Arpa [ucbarpa.berkeley.edu] is // +// down and think it's a conspiracy to keep them from their God given right // +// to receive Net Mail ... // +// -- Casey Leedom // +// ========================================================================= // Property changes on: simulacion/src/fr/lip6/sma/simulacion/gui/SwingAppletGUI.java ___________________________________________________________________ Name: svn:executable + * Added: simulacion/src/fr/lip6/sma/simulacion/gui/SwingApplicationGUI.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/SwingApplicationGUI.java (rev 0) +++ simulacion/src/fr/lip6/sma/simulacion/gui/SwingApplicationGUI.java 2007-05-21 09:08:28 UTC (rev 143) @@ -0,0 +1,79 @@ +// ============================== +// File: SwingApplicationGUI.java +// Project: Simulaci\xF3n +// Written by: Paul Guyot (pau...@ac...) +// +// Created on: 20/5/2007 +// Tabs: 4 spaces +// +// This software is governed by the CeCILL license under French law and abiding +// by the rules of distribution of free software. You can use, modify and/ or +// redistribute the software under the terms of the CeCILL license as +// circulated by CEA, CNRS and INRIA at the following URL +// "http://www.cecill.info". +// +// As a counterpart to the access to the source code and rights to copy, modify +// and redistribute granted by the license, users are provided only with a +// limited warranty and the software's author, the holder of the economic +// rights, and the successive licensors have only limited liability. +// +// The fact that you are presently reading this means that you have had +// knowledge of the CeCILL license and that you accept its terms. +// +// =========== +// $Id: AppletMode.java 132 2007-05-09 07:39:21Z pguyot $ +// =========== + +// paquet +package fr.lip6.sma.simulacion.gui; + +// imports +import javax.swing.JFrame; +import javax.swing.RootPaneContainer; + +/** + * Class for the swing application GUI. + * + * @author Paul Guyot <pau...@ac...> + * @version $Revision: 132 $ + */ +public class SwingApplicationGUI extends GraphicalUserInterface { + /** + * Default constructor. + */ + SwingApplicationGUI() { + // This space for rent. + } + + /** + * Create a window. + * + * @param inHook hook for the subclass method calls. + * @return a new window. + */ + public RootPaneContainer createWindow(final WindowHook inHook) { + return new JFrame() { + public void addNotify() { + super.addNotify(); + inHook.addNotify(); + } + + public void removeNotify() { + super.removeNotify(); + inHook.removeNotify(); + } + }; + } +} + +// ========================================================================= // +// If just one piece of mail gets lost, well, they'll just think they forgot // +// to send it. But if *two* pieces of mail get lost, hell, they'll just // +// think the other guy hasn't gotten around to answering his mail. And if // +// *fifty* pieces of mail get lost, can you imagine it, if *fifty* pieces of // +// mail get lost, why they'll think someone *else* is broken! And if 1Gb of // +// mail gets lost, they'll just *know* that Arpa [ucbarpa.berkeley.edu] is // +// down and think it's a conspiracy to keep them from their God given right // +// to receive Net Mail ... // +// -- Casey Leedom // +// ========================================================================= // Property changes on: simulacion/src/fr/lip6/sma/simulacion/gui/SwingApplicationGUI.java ___________________________________________________________________ Name: svn:executable + * Added: simulacion/src/fr/lip6/sma/simulacion/gui/Window.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/Window.java (rev 0) +++ simulacion/src/fr/lip6/sma/simulacion/gui/Window.java 2007-05-21 09:08:28 UTC (rev 143) @@ -0,0 +1,581 @@ +// ============================== +// File: Window.java +// Project: Simulaci\xF3n +// Written by: Paul Guyot (pau...@ac...) +// +// Created on: 20/5/2007 +// Tabs: 4 spaces +// +// This software is governed by the CeCILL license under French law and abiding +// by the rules of distribution of free software. You can use, modify and/ or +// redistribute the software under the terms of the CeCILL license as +// circulated by CEA, CNRS and INRIA at the following URL +// "http://www.cecill.info". +// +// As a counterpart to the access to the source code and rights to copy, modify +// and redistribute granted by the license, users are provided only with a +// limited warranty and the software's author, the holder of the economic +// rights, and the successive licensors have only limited liability. +// +// The fact that you are presently reading this means that you have had +// knowledge of the CeCILL license and that you accept its terms. +// +// =========== +// $Id: LocalizedWindow.java 132 2007-05-09 07:39:21Z pguyot $ +// =========== + +// paquet +package fr.lip6.sma.simulacion.gui; + +// imports +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FocusTraversalPolicy; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.awt.event.MouseListener; + +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.JLayeredPane; +import javax.swing.JMenuBar; +import javax.swing.JRootPane; +import javax.swing.RootPaneContainer; +import javax.swing.WindowConstants; + +/** + * Proxy that redirects to either JFrame (application mode) or JInternalFrame + * (applet mode). + * + * @author Paul Guyot <pau...@ac...> + * @version $Revision: 132 $ + */ +public class Window implements RootPaneContainer, WindowConstants, WindowHook { + /** + * Actual implementation. + */ + private final RootPaneContainer mImplementation; + + /** + * Default constructor. + */ + public Window() { + // Ask the GUI for a window implementation. + mImplementation = GraphicalUserInterface.getGUI().createWindow(this); + } + + /** + * Accessor on the implementation. + * + * @return the implementation. + */ + public Component getImplementation() { + Component theResult; + if (mImplementation instanceof Component) { + theResult = (Component) mImplementation; + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + + return theResult; + } + + /** + * Pack the window. + * + * @see JFrame#pack() + * @see JInternalFrame#pack() + */ + public void pack() { + if (mImplementation instanceof JFrame) { + ((JFrame) mImplementation).pack(); + } else if (mImplementation instanceof JInternalFrame) { + ((JInternalFrame) mImplementation).pack(); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + } + + /** + * Sets the operation that will happen by default when the user initiates a + * "close" on this window. + * + * @param inOperation operation. + * @see JFrame#setDefaultCloseOperation(int) + * @see JInternalFrame#setDefaultCloseOperation(int) + */ + public void setDefaultCloseOperation(int inOperation) { + if (mImplementation instanceof JFrame) { + ((JFrame) mImplementation).setDefaultCloseOperation(inOperation); + } else if (mImplementation instanceof JInternalFrame) { + ((JInternalFrame) mImplementation) + .setDefaultCloseOperation(inOperation); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + } + + /** + * Add a window listener to this window. + * + * @param inWindowListener listener to add. + * @see java.awt.Window#addWindowListener(java.awt.event.WindowListener) + * @see JInternalFrame#addInternalFrameListener + */ + public void addWindowListener(WindowListener inWindowListener) { + if (mImplementation instanceof JFrame) { + ((JFrame) mImplementation).addWindowListener( + new ListenerProxy(this, inWindowListener)); + } else if (mImplementation instanceof JInternalFrame) { + ((JInternalFrame) mImplementation).addInternalFrameListener( + new ListenerProxy(this, inWindowListener)); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + } + + /** + * Add a mouase listener to this window. + * + * @param inMouseListener listener to add. + * @see java.awt.Window#addMouseListener(MouseListener) + * @see JInternalFrame#addMouseListener(MouseListener) + */ + public void addMouseListener(MouseListener inMouseListener) { + if (mImplementation instanceof JFrame) { + ((JFrame) mImplementation).addMouseListener(inMouseListener); + } else if (mImplementation instanceof JInternalFrame) { + ((JInternalFrame) mImplementation).addMouseListener( + inMouseListener); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + } + + /** + * Sets whether this window is resizable by the user. + * + * @param inResizable if this window should be resizable by the user. + * @see JFrame#setResizable(boolean) + * @see JInternalFrame#setResizable(boolean) + */ + public void setResizable(boolean inResizable) { + if (mImplementation instanceof JFrame) { + ((JFrame) mImplementation).setResizable(inResizable); + } else if (mImplementation instanceof JInternalFrame) { + ((JInternalFrame) mImplementation).setResizable(inResizable); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + } + + /** + * {@inheritDoc} + */ + public Container getContentPane() { + return mImplementation.getContentPane(); + } + + /** + * {@inheritDoc} + */ + public Component getGlassPane() { + return mImplementation.getGlassPane(); + } + + /** + * {@inheritDoc} + */ + public JLayeredPane getLayeredPane() { + return mImplementation.getLayeredPane(); + } + + /** + * {@inheritDoc} + */ + public JRootPane getRootPane() { + return mImplementation.getRootPane(); + } + + /** + * {@inheritDoc} + */ + public void setContentPane(Container inContentPane) { + mImplementation.setContentPane(inContentPane); + } + + /** + * {@inheritDoc} + */ + public void setGlassPane(Component inGlassPane) { + mImplementation.setGlassPane(inGlassPane); + } + + /** + * {@inheritDoc} + */ + public void setLayeredPane(JLayeredPane inLayeredPane) { + mImplementation.setLayeredPane(inLayeredPane); + } + + /** + * {@inheritDoc} + */ + public void addNotify() { + // This space for rent. + } + + /** + * {@inheritDoc} + */ + public void removeNotify() { + // This space for rent. + } + + /** + * Get the menu bar for this window. + * + * @return the menu bar for this window. + */ + public JMenuBar getJMenuBar() { + JMenuBar theMenuBar; + if (mImplementation instanceof JFrame) { + theMenuBar = ((JFrame) mImplementation).getJMenuBar(); + } else if (mImplementation instanceof JInternalFrame) { + theMenuBar = ((JInternalFrame) mImplementation).getJMenuBar(); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + + return theMenuBar; + } + + /** + * Set the menu bar for this window. + * + * @param inMenuBar the menu bar for this window. + */ + public void setJMenuBar(JMenuBar inMenuBar) { + if (mImplementation instanceof JFrame) { + ((JFrame) mImplementation).setJMenuBar(inMenuBar); + } else if (mImplementation instanceof JInternalFrame) { + ((JInternalFrame) mImplementation).setJMenuBar(inMenuBar); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + } + + /** + * Get the size of this window. + * + * @return the size of this window. + */ + public Dimension getSize() { + Dimension theResult; + if (mImplementation instanceof JFrame) { + theResult = ((JFrame) mImplementation).getSize(); + } else if (mImplementation instanceof JInternalFrame) { + theResult = ((JInternalFrame) mImplementation).getSize(); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + + return theResult; + } + + /** + * Set the size of this window. + * + * @param inSize the new size for this window. + * @see Component#setSize(Dimension) + */ + public void setSize(Dimension inSize) { + if (mImplementation instanceof Component) { + ((Component) mImplementation).setSize(inSize); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + } + + /** + * Set the size of this window. + * + * @param inWidth new width for this window. + * @param inHeight new height. + * @see Component#setSize(int, int) + */ + public void setSize(int inWidth, int inHeight) { + if (mImplementation instanceof Component) { + ((Component) mImplementation).setSize(inWidth, inHeight); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + } + + /** + * Get the height of this window. + * + * @return the height of this window. + * @see Component#getHeight() + */ + public int getHeight() { + int theResult; + if (mImplementation instanceof Component) { + theResult = ((Component) mImplementation).getHeight(); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + + return theResult; + } + + /** + * Get the width of this window. + * + * @return the width of this window. + * @see Component#getWidth() + */ + public int getWidth() { + int theResult; + if (mImplementation instanceof Component) { + theResult = ((Component) mImplementation).getWidth(); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + + return theResult; + } + + /** + * Get the toolkit for this window. + * + * @return the toolkit for this window. + * @see Component#getToolkit() + */ + public Toolkit getToolkit() { + Toolkit theResult; + if (mImplementation instanceof Component) { + theResult = ((Component) mImplementation).getToolkit(); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + + return theResult; + } + + /** + * Get the location of this window. + * + * @return the location of this window. + * @see Component#getLocation() + */ + public Point getLocation() { + Point theResult; + if (mImplementation instanceof Component) { + theResult = ((Component) mImplementation).getLocation(); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + + return theResult; + } + + /** + * Set this window visibility. + * + * @param inVisible the new visibility + * @see Component#setVisible(boolean) + */ + public void setVisible(boolean inVisible) { + if (mImplementation instanceof Component) { + ((Component) mImplementation).setVisible(inVisible); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + } + + /** + * Remove (or reset) the decoration for this window. + * + * @param inUndecorated if this window should be undecorated. + * @see JFrame#setUndecorated(boolean) + */ + public void setUndecorated(boolean inUndecorated) { + if (mImplementation instanceof JFrame) { + ((JFrame) mImplementation).setUndecorated(inUndecorated); + } else if (mImplementation instanceof JInternalFrame) { +// ((JInternalFrame) mImplementation).setUndecorated(inUndecorated); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + } + + /** + * Dispose this window. + * + * @see JFrame#dispose() + * @see JInternalFrame#dispose() + */ + public void dispose() { + if (mImplementation instanceof JFrame) { + ((JFrame) mImplementation).dispose(); + } else if (mImplementation instanceof JInternalFrame) { + ((JInternalFrame) mImplementation).dispose(); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + } + + /** + * Set the location of this window. + * + * @param inLocation new location for the window. + * @see Component#setLocation(Point) + */ + public void setLocation(Point inLocation) { + if (mImplementation instanceof Component) { + ((Component) mImplementation).setLocation(inLocation); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + } + + /** + * Set the location of this window. + * + * @param inXCoord new x coordinate + * @param inYCoord new y coordinate + * @see Component#setLocation(int, int) + */ + public void setLocation(int inXCoord, int inYCoord) { + if (mImplementation instanceof Component) { + ((Component) mImplementation).setLocation(inXCoord, inYCoord); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + } + + /** + * Set the bounds of this window. + * + * @param inBounds new bounds for the window. + */ + public void setBounds(Rectangle inBounds) { + if (mImplementation instanceof JFrame) { + ((JFrame) mImplementation).setBounds(inBounds); + } else if (mImplementation instanceof JInternalFrame) { + ((JInternalFrame) mImplementation).setBounds(inBounds); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + } + + /** + * Set the title of this window. + * + * @param inTitle new title for the window. + */ + public void setTitle(String inTitle) { + if (mImplementation instanceof JFrame) { + ((JFrame) mImplementation).setTitle(inTitle); + } else if (mImplementation instanceof JInternalFrame) { + ((JInternalFrame) mImplementation).setTitle(inTitle); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + } + + /** + * Mark this window to be repainted. + * + * @see Component#repaint() + */ + public void repaint() { + if (mImplementation instanceof Component) { + ((Component) mImplementation).repaint(); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + } + + /** + * Validate this window. + * + * @see Component#validate() + */ + public void validate() { + if (mImplementation instanceof Component) { + ((Component) mImplementation).validate(); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + } + + /** + * Set the focus traversal policy. + * + * @param inPolicy new policy + * @see Container#setFocusTraversalPolicy(FocusTraversalPolicy) + */ + public void setFocusTraversalPolicy(FocusTraversalPolicy inPolicy) { + if (mImplementation instanceof Component) { + ((Container) mImplementation).setFocusTraversalPolicy(inPolicy); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + } + + /** + * Sets whether this window is the root of a focus traversal cycle. + * + * @param inIsRoot new value + * @see Container#setFocusCycleRoot(boolean) + */ + public void setFocusCycleRoot(boolean inIsRoot) { + if (mImplementation instanceof Container) { + ((Container) mImplementation).setFocusCycleRoot(inIsRoot); + } else { + throw new UnsupportedOperationException( + "Unsupported window implementation"); + } + } +} + +// ========================================================================= // +// If just one piece of mail gets lost, well, they'll just think they forgot // +// to send it. But if *two* pieces of mail get lost, hell, they'll just // +// think the other guy hasn't gotten around to answering his mail. And if // +// *fifty* pieces of mail get lost, can you imagine it, if *fifty* pieces of // +// mail get lost, why they'll think someone *else* is broken! And if 1Gb of // +// mail gets lost, they'll just *know* that Arpa [ucbarpa.berkeley.edu] is // +// down and think it's a conspiracy to keep them from their God given right // +// to receive Net Mail ... // +// -- Casey Leedom // +// ========================================================================= // Property changes on: simulacion/src/fr/lip6/sma/simulacion/gui/Window.java ___________________________________________________________________ Name: svn:executable + * Added: simulacion/src/fr/lip6/sma/simulacion/gui/WindowAdapter.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/WindowAdapter.java (rev 0) +++ simulacion/src/fr/lip6/sma/simulacion/gui/WindowAdapter.java 2007-05-21 09:08:28 UTC (rev 143) @@ -0,0 +1,100 @@ +// ============================== +// File: WindowAdapter.java +// Project: Simulaci\xF3n +// Written by: Paul Guyot (pau...@ac...) +// +// Created on: 20/5/2007 +// Tabs: 4 spaces +// +// This software is governed by the CeCILL license under French law and abiding +// by the rules of distribution of free software. You can use, modify and/ or +// redistribute the software under the terms of the CeCILL license as +// circulated by CEA, CNRS and INRIA at the following URL +// "http://www.cecill.info". +// +// As a counterpart to the access to the source code and rights to copy, modify +// and redistribute granted by the license, users are provided only with a +// limited warranty and the software's author, the holder of the economic +// rights, and the successive licensors have only limited liability. +// +// The fact that you are presently reading this means that you have had +// knowledge of the CeCILL license and that you accept its terms. +// +// =========== +// $Id: LocalizedWindow.java 132 2007-05-09 07:39:21Z pguyot $ +// =========== + +// paquet +package fr.lip6.sma.simulacion.gui; + +/** + * Adapter for the proxy windows. + * + * @author Paul Guyot <pau...@ac...> + * @version $Revision: 132 $ + */ +public class WindowAdapter implements WindowListener { + /** + * Default constructor. + */ + public WindowAdapter() { + // This space for rent. + } + + /** + * {@inheritDoc} + */ + public void windowActivated(WindowEvent inEvent) { + // This space for rent. + } + + /** + * {@inheritDoc} + */ + public void windowClosed(WindowEvent inEvent) { + // This space for rent. + } + + /** + * {@inheritDoc} + */ + public void windowClosing(WindowEvent inEvent) { + // This space for rent. + } + + /** + * {@inheritDoc} + */ + public void windowDeactivated(WindowEvent inEvent) { + // This space for rent. + } + + /** + * {@inheritDoc} + */ + public void windowDeiconified(WindowEvent inEvent) { + // This space for rent. + } + + /** + * {@inheritDoc} + */ + public void windowIconified(WindowEvent inEvent) { + // This space for rent. + } + + /** + * {@inheritDoc} + */ + public void windowOpened(WindowEvent inEvent) { + // This space for rent. + } +} + +// ======================================================================= // +// Too often people have come to me and said, "If I had just one wish for // +// anything in all the world, I would wish for more user-defined equations // +// in the HP-51820A Waveform Generator Software." // +// -- Instrument News // +// [Once is too often. Ed.] // +// ======================================================================= // Property changes on: simulacion/src/fr/lip6/sma/simulacion/gui/WindowAdapter.java ___________________________________________________________________ Name: svn:executable + * Added: simulacion/src/fr/lip6/sma/simulacion/gui/WindowEvent.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/gui/WindowEvent.java (rev 0) +++ simulacion/src/fr/lip6/sma/simulacion/gui/WindowEvent.java 2007-05-21 09:08:28 UTC (rev 143) @@ -0,0 +1,204 @@ +// ============================== +// File: WindowEvent.java +// Project: Simulaci\xF3n +// Written by: Paul Guyot (pau...@ac...) +// +// Created on: 20/5/2007 +// Tabs: 4 spaces +// +// This software is governed by the CeCILL license under French law and abiding +// by the rules of distribution of free software. You can use, modify and/ or +// redistribute the software under the terms of the CeCILL license as +// circulated by CEA, CNRS and INRIA at the following URL +// "http://www.cecill.info". +// +// As a counterpart to the access to the source code and rights to copy, modify +// and redistribute granted by the license, users are provided only with a +// limited warranty and the software's author, the holder of the economic +// rights, and the successive licensors have only limited liability. +// +// The fact that you are presently reading this means that you have had +// knowledge of the CeCILL license and that you accept its terms. +// +// =========== +// $Id: LocalizedWindow.java 132 2007-05-09 07:39:21Z pguyot $ +// =========== + +// paquet +package fr.lip6.sma.simulacion.gui; + +// imports +import java.awt.AWTEvent; + +import javax.swing.event.InternalFrameEvent; + +/** + * Event for the proxy windows. + * + * @author Paul Guyot <pau...@ac...> + * @version $Revision: 132 $ + */ +public class WindowEvent extends AWTEvent { + /** + * Type of the event. + */ + public enum Type { + /** the "window activated" event type */ + WINDOW_ACTIVATED(1), + /** the "window closed" event type */ + WINDOW_CLOSED(2), + /** the "window closing" event type */ + WINDOW_CLOSING(3), + /** the "window deactivated" event type */ + WINDOW_DEACTIVATED(4), + /** the "window deiconified" event type */ + WINDOW_DEICONIFIED(5), + /** the "window iconified" event type */ + WINDOW_ICONIFIED(6), + /** the "window closed" event type */ + WINDOW_OPENED(7), + /** unknown event type */ + UNKNOWN(8); + + /** + * Value of this const. + */ + private final int mValue; + + /** + * Constructor from an integer. + * + * @param inValue integer value. + */ + Type(int inValue) { + mValue = inValue; + } + + /** + * Accessor on the value. + * + * @return the value of this type. + */ + int getValue() { + return mValue; + } + + /** + * Get the equivalent of a java.awt.WindowEvent ID. + * + * @param inEventID ID of the window event. + * @return the equivalent. + */ + static Type getWindowEventEquivalent(int inEventID) { + Type theResult; + switch (inEventID) { + case java.awt.event.WindowEvent.WINDOW_ACTIVATED: + theResult = WINDOW_ACTIVATED; + break; + case java.awt.event.WindowEvent.WINDOW_CLOSED: + theResult = WINDOW_CLOSED; + break; + case java.awt.event.WindowEvent.WINDOW_CLOSING: + theResult = WINDOW_CLOSING; + break; + case java.awt.event.WindowEvent.WINDOW_DEACTIVATED: + theResult = WINDOW_DEACTIVATED; + break; + case java.awt.event.WindowEvent.WINDOW_DEICONIFIED: + theResult = WINDOW_DEICONIFIED; + break; + case java.awt.event.WindowEvent.WINDOW_ICONIFIED: + theResult = WINDOW_ICONIFIED; + break; + case java.awt.event.WindowEvent.WINDOW_OPENED: + theResult = WINDOW_OPENED; + break; + default: + theResult = UNKNOWN; + } + return theResult; + } + + /** + * Get the equivalent of a java.awt.WindowEvent ID. + * + * @param inEventID ID of the window event. + * @return the equivalent. + */ + static Type getInternalFrameEventEquivalent(int inEventID) { + Type theResult; + switch (inEventID) { + case InternalFrameEvent.INTERNAL_FRAME_ACTIVATED: + theResult = WINDOW_ACTIVATED; + break; + case InternalFrameEvent.INTERNAL_FRAME_CLOSED: + theResult = WINDOW_CLOSED; + break; + case InternalFrameEvent.INTERNAL_FRAME_CLOSING: + theResult = WINDOW_CLOSIN... [truncated message content] |
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. |
From: <pg...@us...> - 2007-05-17 22:38:14
|
Revision: 141 http://simulacion.svn.sourceforge.net/simulacion/?rev=141&view=rev Author: pguyot Date: 2007-05-17 15:38:11 -0700 (Thu, 17 May 2007) Log Message: ----------- Factorized the sax-based parsing common parts. Modified Paths: -------------- simulacion/src/fr/lip6/sma/simulacion/app/Configuration.java Added Paths: ----------- simulacion/src/fr/lip6/sma/simulacion/app/AbstractSAXReader.java Added: simulacion/src/fr/lip6/sma/simulacion/app/AbstractSAXReader.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/app/AbstractSAXReader.java (rev 0) +++ simulacion/src/fr/lip6/sma/simulacion/app/AbstractSAXReader.java 2007-05-17 22:38:11 UTC (rev 141) @@ -0,0 +1,249 @@ +// ============================== +// File: Configuration.java +// Project: Simulaci\xF3n +// Written by: Paul Guyot (pau...@ac...) +// +// Created on: 27/4/2003 +// Tabs: 4 spaces +// +// This software is governed by the CeCILL license under French law and abiding +// by the rules of distribution of free software. You can use, modify and/ or +// redistribute the software under the terms of the CeCILL license as +// circulated by CEA, CNRS and INRIA at the following URL +// "http://www.cecill.info". +// +// As a counterpart to the access to the source code and rights to copy, modify +// and redistribute granted by the license, users are provided only with a +// limited warranty and the software's author, the holder of the economic +// rights, and the successive licensors have only limited liability. +// +// The fact that you are presently reading this means that you have had +// knowledge of the CeCILL license and that you accept its terms. +// +// =========== +// $Id$ +// =========== + +// package +package fr.lip6.sma.simulacion.app; + +// imports +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + +import org.xml.sax.Attributes; +import org.xml.sax.Locator; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; +import org.xml.sax.helpers.DefaultHandler; + +/** + * Classe pour g\xE9rer la configuration (charg\xE9e \xE0 partir d'un fichier XML). + * + * @author Paul Guyot <pau...@ac...> + * @version $Revision$ + */ +public abstract class AbstractSAXReader extends DefaultHandler { + /** + * Reference to the local object in the parsing process. <code>null</code> + * if no object has been parsed yet. + */ + private Locator mLocator; + + /** + * Parser. + */ + private final SAXParser mParser; + + /** + * Default constructor. + * + * @param inValidating if the parser should validate. + * @throws ParserConfigurationException if there is a problem with the + * creation of the parser. + * @throws SAXException if there is a problem with the creation of the + * parser. + */ + protected AbstractSAXReader(boolean inValidating) + throws ParserConfigurationException, SAXException { + final SAXParserFactory theParserFactory = + SAXParserFactory.newInstance(); + theParserFactory.setNamespaceAware(true); + theParserFactory.setValidating(inValidating); + + mParser = theParserFactory.newSAXParser(); + } + + /** + * Accessor on the parser. + * + * @return a reference on the parser. + */ + protected final SAXParser getParser() { + return mParser; + } + + /** + * {@inheritDoc} + */ + public final void setDocumentLocator(Locator inLocator) { + mLocator = inLocator; + } + + /** + * Accessor on the locator object. + * + * @return the locator object, for throwing exceptions. + */ + protected final Locator getDocumentLocator() { + return mLocator; + } + + /** + * Throw an exception if the found tag is different from the expected tag. + * + * @param inFoundTag tag we got. + * @param inExpectedTag tag we expected. + * @throws SAXParseException with information about the error if the found + * tag and the expected tag differ. + */ + protected final void checkTag(String inFoundTag, String inExpectedTag) + throws SAXParseException { + if (!inExpectedTag.equals(inFoundTag)) { + throw new SAXParseException( + "Invalid tag. Expected <" + inExpectedTag + ">, got <" + + inFoundTag + ">", + mLocator); + } + } + + /** + * Throw an exception with an error message. + * + * @param inErrorMsg message for the expection. + * @throws SAXParseException with information about the error. + */ + protected final void reportError(String inErrorMsg) + throws SAXParseException { + throw new SAXParseException(inErrorMsg, mLocator); + } + + /** + * Throw an exception with an error message specifying that one tag is + * sufficient. + * + * @param inTagName name of the tag. + * @throws SAXParseException with information about the error. + */ + protected final void reportAtMostError(String inTagName) + throws SAXParseException { + throw new SAXParseException( + "One tag <" + inTagName + "> is sufficient", mLocator); + } + + /** + * Throw an exception with an error message specifying that at least one tag + * is required within another tag. + * + * @param inTag tag that we expected (child). + * @param inParentTag parent of the tag. + * @throws SAXParseException with information about the error. + */ + protected final void reportAtLeastError(String inTag, String inParentTag) + throws SAXParseException { + throw new SAXParseException( + "At least one <" + inTag + "> tag is required within a <" + + inParentTag + "> tag", mLocator); + } + + /** + * Throw an exception with an error message specifying that a tag with + * a given ID already exists. + * + * @param inTagName name of the tag. + * @param inAttrName name of the attribute. + * @param inAttrValue value of the attribute. + * @throws SAXParseException with information about the error. + */ + protected final void reportDuplicateTagError( + String inTagName, String inAttrName, String inAttrValue) + throws SAXParseException { + throw new SAXParseException( + "Duplicate tag <" + inTagName + "> whose attribute " + + inAttrName + " is " + inAttrName, mLocator); + } + + /** + * Get an attribute, throwing an exception if it's not present. + * + * @param inTagName name of the tag. + * @param inAttributeName name of the attribute. + * @param inAttributes attributes. + * @return the value of the attribute. + * @throws SAXParseException if the attribute could not be found. + */ + protected final String getAttributeAlways( + String inTagName, + String inAttributeName, + Attributes inAttributes) + throws SAXParseException { + final String theResult = inAttributes.getValue("", inAttributeName); + + if (theResult == null) { + throw new SAXParseException( + "Attribute \"" + inAttributeName + + "\" is required for tag <" + inTagName + ">", + mLocator); + } + + return theResult; + } + + /** + * Return the index of a given tag in a list and throws an exception if this + * tag is not in the list. + * + * @param inTagName name of the tag. + * @param inArray array of expected tags. + * @return the index in the array. + * @throws SAXParseException if the given tag is not in the list. + */ + protected final int getTagIndexAlways( + String inTagName, + String[] inArray) throws SAXParseException { + // Result, -1 until it's found. + int theResult = -1; + + final int nbTags = inArray.length; + int indexTags; + // Let's iterate in the list. + for (indexTags = 0; indexTags < nbTags; indexTags++) { + if (inTagName.equals(inArray[indexTags])) { + theResult = indexTags; + break; + } + } + + if (theResult < 0) { + // Not found. We throw an exception. + String theListErrorMessage = "<" + inArray[0] + ">"; + if (nbTags > 1) { + for (indexTags = 1; indexTags < nbTags; indexTags++) { + theListErrorMessage += " or <" + inArray[indexTags] + ">"; + } + } + throw new SAXParseException( + "Invalid tag. Expected <" + theListErrorMessage + ">, got <" + + inTagName + "> instead", + mLocator); + } + + return theResult; + } +} + +// ================================================= // +// [It is] best to confuse only one issue at a time. // +// -- K&R // +// ================================================= // Property changes on: simulacion/src/fr/lip6/sma/simulacion/app/AbstractSAXReader.java ___________________________________________________________________ Name: svn:executable + * Name: svn:keywords + Revision Id Modified: simulacion/src/fr/lip6/sma/simulacion/app/Configuration.java =================================================================== --- simulacion/src/fr/lip6/sma/simulacion/app/Configuration.java 2007-05-17 00:33:12 UTC (rev 140) +++ simulacion/src/fr/lip6/sma/simulacion/app/Configuration.java 2007-05-17 22:38:11 UTC (rev 141) @@ -47,14 +47,10 @@ import javax.swing.JFileChooser; import javax.swing.filechooser.FileFilter; import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; import org.xml.sax.Attributes; -import org.xml.sax.Locator; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; -import org.xml.sax.helpers.DefaultHandler; import fr.lip6.sma.simulacion.app.configuration.AgentConfig; import fr.lip6.sma.simulacion.app.configuration.AgentConfigImpl; @@ -73,7 +69,7 @@ * @author Paul Guyot <pau...@ac...> * @version $Revision$ */ -public final class Configuration extends DefaultHandler { +public final class Configuration extends AbstractSAXReader { /** * Type for avatar views. */ @@ -113,55 +109,60 @@ */ private static Configuration gConfiguration; - /** Apr\xE8s toute balise */ - private static final int END = -1; - /** Avant toute balise */ - private static final int BEGIN = 0; - /** Dans la balise simulacion */ - private static final int ELEMENT_S = 1; - /** Dans une balise class de la balise simulacion */ - private static final int ELEMENT_SC = 11; - /** Dans une balise property de la balise class */ - private static final int ELEMENT_SCP = 111; - /** Dans une balise aGent de la balise simulacion */ - private static final int ELEMENT_SG = 12; - /** Dans une balise property de la balise agent */ - private static final int ELEMENT_SGP = 121; - /** Dans une balise avatar de la balise simulacion */ - private static final int ELEMENT_SV = 13; - /** Dans une balise view d'une balise avatar */ - private static final int ELEMENT_SVV = 131; - /** Dans une balise attitude d'une balise view */ - private static final int ELEMENT_SVVA = 1311; - /** Dans une balise layer d'une balise attitude */ - private static final int ELEMENT_SVVAL = 13111; - /** Dans une balise slice d'une balise layer */ - private static final int ELEMENT_SVVALS = 131111; - /** Dans une balise image d'une balise eyes */ - private static final int ELEMENT_SVVALSI = 1311111; - /** Dans une balise locale de la balise simulacion */ - private static final int ELEMENT_SL = 14; - /** Dans une balise string d'une balise locale */ - private static final int ELEMENT_SLS = 141; - /** Dans une balise media de la balise simulacion */ - private static final int ELEMENT_SM = 15; - /** Dans une balise image d'une balise media */ - private static final int ELEMENT_SMI = 151; - /** Dans une balise properties de la balise simulacion */ - private static final int ELEMENT_SP = 16; - /** Dans une balise property d'une balise properties */ - private static final int ELEMENT_SPP = 161; - /** In a files tag */ - private static final int ELEMENT_SF = 17; - /** In a file tag */ - private static final int ELEMENT_SFF = 171; - /** In a directory tag */ - private static final int ELEMENT_SFD = 172; - /** + * Enumeration for the state of the parser. + */ + private enum State { + /** Apr\xE8s toute balise */ + END, + /** Avant toute balise */ + BEGIN, + /** Dans la balise simulacion */ + ELEMENT_S, + /** Dans une balise class de la balise simulacion */ + ELEMENT_SC, + /** Dans une balise property de la balise class */ + ELEMENT_SCP, + /** Dans une balise aGent de la balise simulacion */ + ELEMENT_SG, + /** Dans une balise property de la balise agent */ + ELEMENT_SGP, + /** Dans une balise avatar de la balise simulacion */ + ELEMENT_SV, + /** Dans une balise view d'une balise avatar */ + ELEMENT_SVV, + /** Dans une balise attitude d'une balise view */ + ELEMENT_SVVA, + /** Dans une balise layer d'une balise attitude */ + ELEMENT_SVVAL, + /** Dans une balise slice d'une balise layer */ + ELEMENT_SVVALS, + /** Dans une balise image d'une balise eyes */ + ELEMENT_SVVALSI, + /** Dans une balise locale de la balise simulacion */ + ELEMENT_SL, + /** Dans une balise string d'une balise locale */ + ELEMENT_SLS, + /** Dans une balise media de la balise simulacion */ + ELEMENT_SM, + /** Dans une balise image d'une balise media */ + ELEMENT_SMI, + /** Dans une balise properties de la balise simulacion */ + ELEMENT_SP, + /** Dans une balise property d'une balise properties */ + ELEMENT_SPP, + /** In a files tag */ + ELEMENT_SF, + /** In a file tag */ + ELEMENT_SFF, + /** In a directory tag */ + ELEMENT_SFD; + } + + /** * Etat de l'analyseur de la configuration. */ - private int mState; + private State mState; /** * Nombre d'images pour la zolie animation. @@ -313,21 +314,22 @@ private Map<String, MultipleAccessBufferedInputStream> mFileStreams; /** - * R\xE9f\xE9rence sur l'objet pour localiser les \xE9v\xE9nements. - * <code>null</code> tant qu'il n'a pas \xE9t\xE9 pr\xE9cis\xE9 par l'analyseur - * (c'est facultatif pour l'analyseur de nous le pr\xE9senter) - */ - private Locator mLocator; - - /** * Constructeur \xE0 partir du chemin du fichier de configuration. * Lit le fichier XML et lance la lecture de la configuration. * * @param inPath chemin du fichier de configuration. + * @throws ParserConfigurationException if there is a problem with the + * creation of the parser. + * @throws SAXException if there is a problem with the creation of the + * parser. + * @throws IOException if there is a problem with the stream. */ - private Configuration(String inPath) { + private Configuration(String inPath) + throws ParserConfigurationException, SAXException, IOException { + super(false); + // Intialisation avant le traitement. - mState = BEGIN; + mState = State.BEGIN; mImageCount = 0; mMediaImages = new Vector<String>(); mPlayerAgentClasses = new Vector<String>(); @@ -336,28 +338,7 @@ mFileCollections = new HashMap<String, Map<String, MultipleAccessBufferedInputStream>>(); - // Lecture de la configuration. - try { - // R\xE9cup\xE9ration de la fabrique d'analyseur XML - final SAXParserFactory theParserFactory = - SAXParserFactory.newInstance(); - theParserFactory.setNamespaceAware(true); - theParserFactory.setValidating(false); - - // On analyse. - final SAXParser theParser = theParserFactory.newSAXParser(); - - theParser.parse(Bundle.getResourceAsStream(inPath), this); - } catch (ParserConfigurationException anException) { - anException.printStackTrace(); - System.exit(1); - } catch (SAXException anException) { - anException.printStackTrace(); - System.exit(1); - } catch (IOException anException) { - anException.printStackTrace(); - System.exit(1); - } + getParser().parse(Bundle.getResourceAsStream(inPath), this); } /** @@ -383,7 +364,17 @@ */ public static synchronized Configuration getConfiguration(String inPath) { if (gConfiguration == null) { - gConfiguration = new Configuration(inPath); + Configuration theConfig = null; + try { + theConfig = new Configuration(inPath); + } catch (ParserConfigurationException anException) { + anException.printStackTrace(); + } catch (SAXException anException) { + anException.printStackTrace(); + } catch (IOException anException) { + anException.printStackTrace(); + } + gConfiguration = theConfig; } return gConfiguration; @@ -825,16 +816,6 @@ mOverrideLocale = new Locale(inLanguageCode); } } - - /** - * D\xE9termine l'objet pour localiser les \xE9v\xE9nements relatifs au document. - * Cet objet permet de cr\xE9er des exceptions plus pr\xE9cises. - * - * @param inLocator objet pour localiser les \xE9v\xE9nements. - */ - public void setDocumentLocator(Locator inLocator) { - mLocator = inLocator; - } /** * Get the list of file collections extending the present configuration. @@ -892,9 +873,7 @@ case 0: { if (mClasses != null) { - throw new SAXParseException( - "une seule balise <simulacion> suffit", - mLocator); + reportAtMostError("simulacion"); } mClasses = new Hashtable<String, ClassConfig>(); @@ -903,7 +882,7 @@ Map<String, AvatarViewsConfig>>(); mLocales = new Hashtable<String, Map<String, String>>(); - mState = ELEMENT_S; + mState = State.ELEMENT_S; break; } @@ -978,100 +957,97 @@ switch (mState) { case ELEMENT_S: - mState = END; + mState = State.END; break; case ELEMENT_SC: mClassProperties = null; mClassName = null; - mState = ELEMENT_S; + mState = State.ELEMENT_S; break; case ELEMENT_SCP: - mState = ELEMENT_SC; + mState = State.ELEMENT_SC; break; case ELEMENT_SG: mAgentProperties = null; - mState = ELEMENT_S; + mState = State.ELEMENT_S; break; case ELEMENT_SGP: - mState = ELEMENT_SG; + mState = State.ELEMENT_SG; break; case ELEMENT_SV: mAvatarViews = null; - mState = ELEMENT_S; + mState = State.ELEMENT_S; break; case ELEMENT_SVV: mViewAttitudes = null; - mState = ELEMENT_SV; + mState = State.ELEMENT_SV; break; case ELEMENT_SVVA: - mState = ELEMENT_SVV; + mState = State.ELEMENT_SVV; // V\xE9rification que j'ai au moins une tranche. if (mAttitude.size() == 0) { - throw new SAXParseException( - "au moins une balise <slice> attendue au " - + "sein d'une balise <attitude>", - mLocator); + reportAtLeastError("slice", "attitude"); } mAttitude = null; break; case ELEMENT_SVVAL: mSlicesVector = null; - mState = ELEMENT_SVVA; + mState = State.ELEMENT_SVVA; break; case ELEMENT_SVVALS: mImagesVector = null; - mState = ELEMENT_SVVAL; + mState = State.ELEMENT_SVVAL; break; case ELEMENT_SVVALSI: - mState = ELEMENT_SVVALS; + mState = State.ELEMENT_SVVALS; break; case ELEMENT_SL: mLocaleStrings = null; - mState = ELEMENT_S; + mState = State.ELEMENT_S; break; case ELEMENT_SLS: - mState = ELEMENT_SL; + mState = State.ELEMENT_SL; break; case ELEMENT_SM: - mState = ELEMENT_S; + mState = State.ELEMENT_S; break; case ELEMENT_SMI: - mState = ELEMENT_SM; + mState = State.ELEMENT_SM; break; case ELEMENT_SP: - mState = ELEMENT_S; + mState = State.ELEMENT_S; break; case ELEMENT_SPP: - mState = ELEMENT_SP; + mState = State.ELEMENT_SP; break; case ELEMENT_SF: mFileStreams = null; - mState = ELEMENT_S; + mState = State.ELEMENT_S; break; case ELEMENT_SFF: - mState = ELEMENT_SF; + mState = State.ELEMENT_SF; break; case ELEMENT_SFD: - mState = ELEMENT_SF; + mState = State.ELEMENT_SF; break; default: @@ -1110,9 +1086,7 @@ // V\xE9rification que la classe n'existe pas d\xE9j\xE0. if (mClasses.get(theClassName) != null) { - throw new SAXParseException( - "la classe " + theClassName - + " est d\xE9j\xE0 d\xE9finie.", mLocator); + reportDuplicateTagError("class", "name", theClassName); } // Cr\xE9ation du tableau des propri\xE9t\xE9s. @@ -1126,7 +1100,7 @@ // Ajout du tableau dans la liste des classes. mClasses.put(theClassName, theClass); - mState = ELEMENT_SC; + mState = State.ELEMENT_SC; break; } @@ -1139,9 +1113,7 @@ // V\xE9rification que l'agent n'existe pas d\xE9j\xE0. if (mAgents.get(theAgentName) != null) { - throw new SAXParseException( - "l'agent " + theAgentName - + " est d\xE9j\xE0 d\xE9fini.", mLocator); + reportDuplicateTagError("agent", "name", theAgentName); } // R\xE9cup\xE9ration de la classe de l'agent. @@ -1165,7 +1137,7 @@ // Ajout du tableau dans la liste des classes. mAgents.put(theAgentName, theAgent); - mState = ELEMENT_SG; + mState = State.ELEMENT_SG; break; } @@ -1178,9 +1150,7 @@ // V\xE9rification que l'avatar n'existe pas d\xE9j\xE0. if (mAvatars.get(theAvatarName) != null) { - throw new SAXParseException( - "l'avatar " + theAvatarName - + " est d\xE9j\xE0 d\xE9fini.", mLocator); + reportDuplicateTagError("avatar", "name", theAvatarName); } // Cr\xE9ation du tableau des vues. @@ -1194,7 +1164,7 @@ // Ajout du tableau dans la liste des avatars. mAvatars.put(theAvatarName, theProperties); - mState = ELEMENT_SV; + mState = State.ELEMENT_SV; break; } @@ -1207,9 +1177,7 @@ // V\xE9rification que la traduction n'existe pas d\xE9j\xE0. if (mLocales.get(theLocaleCode) != null) { - throw new SAXParseException( - "la traduction " + theLocaleCode - + " est d\xE9j\xE0 d\xE9finie.", mLocator); + reportDuplicateTagError("locale", "code", theLocaleCode); } // Cr\xE9ation du tableau. @@ -1218,18 +1186,18 @@ // Ajout du tableau. mLocales.put(theLocaleCode, mLocaleStrings); - mState = ELEMENT_SL; + mState = State.ELEMENT_SL; break; } case 4: // media - mState = ELEMENT_SM; + mState = State.ELEMENT_SM; break; case 5: // properties - mState = ELEMENT_SP; + mState = State.ELEMENT_SP; break; case 6: @@ -1240,7 +1208,7 @@ mFileStreams = new HashMap<String, MultipleAccessBufferedInputStream>(); mFileCollections.put(theName, mFileStreams); - mState = ELEMENT_SF; + mState = State.ELEMENT_SF; break; } @@ -1277,10 +1245,8 @@ // V\xE9rification que la propri\xE9t\xE9 n'existe pas d\xE9j\xE0. if (mAgentProperties.get(thePropertyName) != null) { - throw new SAXParseException( - "la propri\xE9t\xE9 " + thePropertyName - + " est d\xE9j\xE0 d\xE9finie.", - mLocator); + reportDuplicateTagError( + "property", "name", thePropertyName); } // R\xE9cup\xE9ration de la valeur. @@ -1290,7 +1256,7 @@ // Ajout \xE0 la liste des propri\xE9t\xE9s. mAgentProperties.put(thePropertyName, thePropertyValue); - mState = ELEMENT_SGP; + mState = State.ELEMENT_SGP; break; } @@ -1327,10 +1293,8 @@ // V\xE9rification que la propri\xE9t\xE9 n'existe pas d\xE9j\xE0. if (mClassProperties.get(thePropertyName) != null) { - throw new SAXParseException( - "la propri\xE9t\xE9 " + thePropertyName - + " est d\xE9j\xE0 d\xE9finie.", - mLocator); + reportDuplicateTagError( + "property", "name", thePropertyName); } // R\xE9cup\xE9ration de la valeur par d\xE9faut. @@ -1349,7 +1313,7 @@ mPlayerAgentClasses.add(mClassName); } - mState = ELEMENT_SCP; + mState = State.ELEMENT_SCP; break; } @@ -1422,9 +1386,7 @@ // V\xE9rification que la vue n'existe pas d\xE9j\xE0. if (mAvatarViews.get(theViewName) != null) { - throw new SAXParseException( - "la vue " + theViewName + " est d\xE9j\xE0 d\xE9finie.", - mLocator); + reportDuplicateTagError("view", "name", theViewName); } // Cr\xE9ation du tableau. @@ -1434,7 +1396,7 @@ // Ajout du tableau. mAvatarViews.put(theViewName, mViewAttitudes); - mState = ELEMENT_SVV; + mState = State.ELEMENT_SVV; break; } @@ -1464,9 +1426,7 @@ // V\xE9rification que la vue n'existe pas d\xE9j\xE0. if (mAvatarViews.get(theAttitudeName) != null) { - throw new SAXParseException( - "l'attitude " + theAttitudeName - + " est d\xE9j\xE0 d\xE9finie.", mLocator); + reportDuplicateTagError("attitude", "name", theAttitudeName); } // Cr\xE9ation du tableau pour les deux vecteurs. @@ -1475,7 +1435,7 @@ // Ajout \xE0 la liste des attitudes. mViewAttitudes.put(theAttitudeName, mAttitude); - mState = ELEMENT_SVVA; + mState = State.ELEMENT_SVVA; break; } @@ -1512,7 +1472,7 @@ .LAYER_VERTICAL_ORIENTATION))) { throw new SAXParseException( "orientation de type inconnu (" + theOrientation - + ").", mLocator); + + ").", getDocumentLocator()); } // Tableau pour la couche. @@ -1531,7 +1491,7 @@ // Ajout au tableau de l'attitude. mAttitude.add(theLayerConfig); - mState = ELEMENT_SVVAL; + mState = State.ELEMENT_SVVAL; break; } @@ -1558,7 +1518,7 @@ mImagesVector = new Vector<String>(); mSlicesVector.add(mImagesVector); - mState = ELEMENT_SVVALS; + mState = State.ELEMENT_SVVALS; break; } @@ -1589,7 +1549,7 @@ mImagesVector.add(thePath); mImageCount++; - mState = ELEMENT_SVVALSI; + mState = State.ELEMENT_SVVALSI; break; } @@ -1626,7 +1586,7 @@ // Ajout \xE0 la liste. mLocaleStrings.put(theKey, theValue); - mState = ELEMENT_SLS; + mState = State.ELEMENT_SLS; break; } @@ -1665,7 +1625,7 @@ mMediaImages.add(thePath); mImageCount++; - mState = ELEMENT_SMI; + mState = State.ELEMENT_SMI; break; } @@ -1702,9 +1662,8 @@ // V\xE9rification que la propri\xE9t\xE9 n'existe pas d\xE9j\xE0. if (mProperties.containsKey(thePropertyName)) { - throw new SAXParseException( - "la propri\xE9t\xE9 " + thePropertyName + " existe d\xE9j\xE0", - mLocator); + reportDuplicateTagError( + "property", "name", thePropertyName); } // R\xE9cup\xE9ration de la valeur. @@ -1714,7 +1673,7 @@ // Ajout au tableau. mProperties.put(thePropertyName, thePropertyValue); - mState = ELEMENT_SPP; + mState = State.ELEMENT_SPP; break; } @@ -1764,7 +1723,7 @@ } mFileStreams.put(theName, theStream); - mState = ELEMENT_SFF; + mState = State.ELEMENT_SFF; break; } @@ -1777,7 +1736,7 @@ "We should parse directory, " + "but the code isn't there yet."); -// mState = ELEMENT_SFD; +// mState = State.ELEMENT_SFD; // break; } @@ -1790,76 +1749,6 @@ throw new IllegalStateException(); } } - - /** - * R\xE9cup\xE8re un attribut donn\xE9 en lan\x8Dant une exception s'il n'est pas - * pr\xE9sent. - * - * @param inTagName nom de la balise - * @param inAttributeName nom de l'attribut - * @param inAttributes attributs - * @return la valeur de l'attribut en question - * @throws SAXParseException si l'attribut n'est pas pr\xE9sent - */ - private String getAttributeAlways( - String inTagName, - String inAttributeName, - Attributes inAttributes) - throws SAXParseException { - final String theResult = inAttributes.getValue("", inAttributeName); - - if (theResult == null) { - throw new SAXParseException( - "attribut \"" + inAttributeName - + "\" requis pour la balise <" + inTagName + ">", - mLocator); - } - - return theResult; - } - - /** - * D\xE9termine l'indice de la balise dans une liste et lance une exception - * si la balise n'est pas dans la liste. - * - * @param inTagName nom de la balise - * @param inList liste de balises attendues - * @return l'indice dans le tableau pr\xE9c\xE9dent - * @throws SAXParseException si la balise est aucun de ces \xE9l\xE9ments - */ - private int getTagIndexAlways( - String inTagName, - String[] inList) throws SAXParseException { - // R\xE9sultat, -1 tant que ce n'est pas trouv\xE9. - int theResult = -1; - - final int nbTags = inList.length; - int indexTags; - // It\xE9ration dans la liste. - for (indexTags = 0; indexTags < nbTags; indexTags++) { - if (inTagName.equals(inList[indexTags])) { - theResult = indexTags; - break; - } - } - - if (theResult < 0) { - // Non trouv\xE9e. - // On lance une exception. - String theListErrorMessage = "<" + inList[0] + ">"; - if (nbTags > 1) { - for (indexTags = 1; indexTags < nbTags; indexTags++) { - theListErrorMessage += " ou <" + inList[indexTags] + ">"; - } - } - throw new SAXParseException( - "balise " + theListErrorMessage + "attendue, <" - + inTagName + "> trouv\xE9e \xE0 la place", - mLocator); - } - - return theResult; - } /** * Method to choose a configuration file. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |