From: <jom...@us...> - 2014-10-07 18:23:25
|
Revision: 1814 http://sourceforge.net/p/jason/svn/1814 Author: jomifred Date: 2014-10-07 18:23:22 +0000 (Tue, 07 Oct 2014) Log Message: ----------- improve write ant scripts API Modified Paths: -------------- trunk/src/jason/asSemantics/Agent.java trunk/src/jason/infra/centralised/CentralisedMASLauncherAnt.java trunk/src/jason/jeditplugin/Config.java trunk/src/jason/jeditplugin/JasonID.java trunk/src/jason/jeditplugin/MASLauncherInfraTier.java trunk/src/jason/mas2j/parser/MAS2JavaParser.jcc trunk/src/jason/mas2j/parser/mas2j.java trunk/src/jason/util/ConfigGUI.java Modified: trunk/src/jason/asSemantics/Agent.java =================================================================== --- trunk/src/jason/asSemantics/Agent.java 2014-09-30 18:25:07 UTC (rev 1813) +++ trunk/src/jason/asSemantics/Agent.java 2014-10-07 18:23:22 UTC (rev 1814) @@ -102,7 +102,7 @@ private boolean hasCustomSelOp = true; - private static ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(20); //null; + private static ScheduledExecutorService scheduler = null; //private QueryCache qCache = null; private QueryCacheSimple qCache = null; @@ -344,9 +344,16 @@ return logger; } - public ScheduledExecutorService getScheduler() { - //if (scheduler == null) - // scheduler = Executors.newScheduledThreadPool(2); + public static synchronized ScheduledExecutorService getScheduler() { + if (scheduler == null) { + int n; + try { + n = new Integer( Config.get().get(Config.NB_TH_SCH).toString() ); + } catch (Exception e) { + n = 2; + } + scheduler = Executors.newScheduledThreadPool(n); + } return scheduler; } Modified: trunk/src/jason/infra/centralised/CentralisedMASLauncherAnt.java =================================================================== --- trunk/src/jason/infra/centralised/CentralisedMASLauncherAnt.java 2014-09-30 18:25:07 UTC (rev 1813) +++ trunk/src/jason/infra/centralised/CentralisedMASLauncherAnt.java 2014-10-07 18:23:22 UTC (rev 1814) @@ -26,6 +26,8 @@ protected boolean stop = false; protected Process masProcess = null; protected OutputStream processOut; + + protected boolean useBuildFileName = true; public static String bindir = "bin"+File.separator; @@ -118,8 +120,8 @@ /** returns the operating system command that runs the MAS */ public String[] getStartCommandArray() { - String build = bindir+"build.xml"; - if (hasCBuild()) build = bindir+"c-build.xml"; + String build = bindir+getBuildFileName();; + if (hasCBuild()) build = bindir+getCustomBuildFileName(); return new String[] { Config.get().getJavaHome() + "bin" + File.separator + "java", "-classpath", @@ -127,8 +129,25 @@ "-e", "-f", build, task}; } + public String getBuildFileName() { + if (useBuildFileName) { + return "build.xml"; + } else { + return project.getSocName()+".xml"; + } + } + public String getCustomBuildFileName() { + if (useBuildFileName) { + return "c-build.xml"; + } else { + return "c-"+project.getSocName()+".xml"; + } + } + /** write the scripts necessary to run the project */ - public boolean writeScripts(boolean debug) { + public boolean writeScripts(boolean debug, boolean useBuildFileName) { + this.useBuildFileName = useBuildFileName; + //if (hasCBuild()) { // System.out.println("The build.xml file is not being created, the user c-build.xml file is used instead."); // return true; // if the user has a c-build.xml file, use his build @@ -147,7 +166,7 @@ } // write the script - FileWriter out = new FileWriter(project.getDirectory() + File.separator + bindir + "build.xml"); + FileWriter out = new FileWriter(project.getDirectory() + File.separator + bindir + getBuildFileName()); out.write(script); out.close(); return true; @@ -239,7 +258,7 @@ } protected boolean hasCBuild() { - return new File(project.getDirectory() + File.separator + bindir + "c-build.xml").exists(); + return new File(project.getDirectory() + File.separator + bindir + getCustomBuildFileName()).exists(); } } Modified: trunk/src/jason/jeditplugin/Config.java =================================================================== --- trunk/src/jason/jeditplugin/Config.java 2014-09-30 18:25:07 UTC (rev 1813) +++ trunk/src/jason/jeditplugin/Config.java 2014-10-07 18:23:22 UTC (rev 1814) @@ -86,6 +86,8 @@ public static final String SHORT_UNNAMED_VARS = "shortUnnamedVars"; public static final String START_WEB_MI = "startWebMindInspector"; + public static final String NB_TH_SCH = "numberOfThreadsForScheduler"; + private static Config singleton = null; public static Config get() { @@ -321,6 +323,10 @@ if (getProperty(START_WEB_MI) == null) { put(START_WEB_MI, "true"); } + + if (getProperty(NB_TH_SCH) == null) { + put(NB_TH_SCH, "2"); + } // Default infrastructures put("infrastructure.Centralised", CentralisedFactory.class.getName()); Modified: trunk/src/jason/jeditplugin/JasonID.java =================================================================== --- trunk/src/jason/jeditplugin/JasonID.java 2014-09-30 18:25:07 UTC (rev 1813) +++ trunk/src/jason/jeditplugin/JasonID.java 2014-10-07 18:23:22 UTC (rev 1814) @@ -525,7 +525,7 @@ masLauncher = project.getInfrastructureFactory().createMASLauncher(); masLauncher.setProject(project); masLauncher.setListener(JasonID.this); - if (masLauncher.writeScripts(debug)) { + if (masLauncher.writeScripts(debug, true)) { new Thread(masLauncher, "MAS-Launcher").start(); } } catch (Exception ex) { @@ -665,7 +665,7 @@ return; CentralisedMASLauncherAnt script = new CentralisedMASLauncherAnt(task); script.setProject(project); - if (script.writeScripts(false)) { + if (script.writeScripts(false, true)) { new Thread(script, "Ant-Task").start(); } Modified: trunk/src/jason/jeditplugin/MASLauncherInfraTier.java =================================================================== --- trunk/src/jason/jeditplugin/MASLauncherInfraTier.java 2014-09-30 18:25:07 UTC (rev 1813) +++ trunk/src/jason/jeditplugin/MASLauncherInfraTier.java 2014-10-07 18:23:22 UTC (rev 1814) @@ -33,7 +33,7 @@ * Writes the script(s), normally Ant scripts, used to launch the * MAS. */ - public boolean writeScripts(boolean debug); + public boolean writeScripts(boolean debug, boolean useBuildFileName); /** * Stops the MAS execution. Modified: trunk/src/jason/mas2j/parser/MAS2JavaParser.jcc =================================================================== --- trunk/src/jason/mas2j/parser/MAS2JavaParser.jcc 2014-09-30 18:25:07 UTC (rev 1813) +++ trunk/src/jason/mas2j/parser/MAS2JavaParser.jcc 2014-10-07 18:23:22 UTC (rev 1814) @@ -80,7 +80,7 @@ System.out.println("mas2j: "+name+" parsed successfully!\n"); MASLauncherInfraTier launcher = project.getInfrastructureFactory().createMASLauncher(); launcher.setProject(project); - launcher.writeScripts(debugmas); + launcher.writeScripts(debugmas, true); if (runmas) { new Thread(launcher, "MAS-Launcher").start(); Modified: trunk/src/jason/mas2j/parser/mas2j.java =================================================================== --- trunk/src/jason/mas2j/parser/mas2j.java 2014-09-30 18:25:07 UTC (rev 1813) +++ trunk/src/jason/mas2j/parser/mas2j.java 2014-10-07 18:23:22 UTC (rev 1814) @@ -50,7 +50,7 @@ System.out.println("mas2j: "+name+" parsed successfully!\n"); MASLauncherInfraTier launcher = project.getInfrastructureFactory().createMASLauncher(); launcher.setProject(project); - launcher.writeScripts(debugmas); + launcher.writeScripts(debugmas, true); if (runmas) { new Thread(launcher, "MAS-Launcher").start(); Modified: trunk/src/jason/util/ConfigGUI.java =================================================================== --- trunk/src/jason/util/ConfigGUI.java 2014-09-30 18:25:07 UTC (rev 1813) +++ trunk/src/jason/util/ConfigGUI.java 2014-10-07 18:23:22 UTC (rev 1814) @@ -107,6 +107,13 @@ f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel pBt = new JPanel(new FlowLayout()); + JButton bQuit = new JButton("Exit without saving"); + bQuit.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + System.exit(0); + } + }); + pBt.add(bQuit); JButton bSave = new JButton("Save configuration and Exit"); bSave.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { @@ -115,14 +122,7 @@ } }); pBt.add(bSave); - JButton bQuit = new JButton("Exit without saving"); - bQuit.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent arg0) { - System.exit(0); - } - }); - pBt.add(bQuit); - + JPanel p = new JPanel(new BorderLayout()); p.add(BorderLayout.CENTER, jid.getJasonConfigPanel()); p.add(BorderLayout.SOUTH, pBt); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |