X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2Fmircoders%2Flocalizer%2Fbasic%2FMirBasicProducerLocalizer.java;h=24b9982f37a87801f89162a0740a7afb0b6e71dc;hb=04bf29aa1f1abf43e96d0272b2a286f0c1f9fea8;hp=a54ba004e85c995e9486ee6e18f4cab11909f7d2;hpb=a459f111d85598df56c6ab711cec11632676b39c;p=mir.git diff --git a/source/mircoders/localizer/basic/MirBasicProducerLocalizer.java b/source/mircoders/localizer/basic/MirBasicProducerLocalizer.java index a54ba004..24b9982f 100755 --- a/source/mircoders/localizer/basic/MirBasicProducerLocalizer.java +++ b/source/mircoders/localizer/basic/MirBasicProducerLocalizer.java @@ -18,13 +18,13 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * In addition, as a special exception, The Mir-coders gives permission to link - * the code of this program with any library licensed under the Apache Software License, - * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library - * (or with modified versions of the above that use the same license as the above), - * and distribute linked combinations including the two. You must obey the - * GNU General Public License in all respects for all of the code used other than - * the above mentioned libraries. If you modify this file, you may extend this - * exception to your version of the file, but you are not obligated to do so. + * the code of this program with any library licensed under the Apache Software License, + * The Sun (tm) Java Advanced Imaging library (JAI), The Sun JIMI library + * (or with modified versions of the above that use the same license as the above), + * and distribute linked combinations including the two. You must obey the + * GNU General Public License in all respects for all of the code used other than + * the above mentioned libraries. If you modify this file, you may extend this + * exception to your version of the file, but you are not obligated to do so. * If you do not wish to do so, delete this exception statement from your version. */ package mircoders.localizer.basic; @@ -45,6 +45,7 @@ import mir.producer.reader.DefaultProducerNodeBuilders; import mir.producer.reader.ProducerConfigReader; import mir.producer.reader.ProducerNodeBuilderLibrary; import mir.util.FileMonitor; +import mir.util.StringRoutines; import mircoders.global.MirGlobal; import mircoders.global.ProducerEngine; import mircoders.localizer.MirLocalizerExc; @@ -55,7 +56,9 @@ import mircoders.producer.reader.SupplementalProducerNodeBuilders; public class MirBasicProducerLocalizer implements MirProducerLocalizer { private List producerFactories; private Map nameToFactory; - private List allNewProducerTasks; + + private Map producerRecipes; + private List producerRecipeNames; protected FileMonitor fileMonitor; protected EntityAdapterModel model; @@ -68,8 +71,32 @@ public class MirBasicProducerLocalizer implements MirProducerLocalizer { try { logger = new LoggerWrapper("Localizer.Basic.Producer"); + producerRecipes = new HashMap(); + producerRecipeNames = new Vector(); + + String[] recipes = MirGlobal.config().getStringArray("Mir.Localizer.Producer.ProducerRecipes"); + for (int i = 0; i0) { + producerRecipes.put("allnew", ProducerEngine.ProducerTask.parseProducerTaskList(allNewProducers)); + producerRecipeNames.add("allnew"); + } producerFactories = new Vector(); model = MirGlobal.localizer().dataModel().adapterModel(); @@ -83,6 +110,17 @@ public class MirBasicProducerLocalizer implements MirProducerLocalizer { } } + public List getRecipeNames() throws MirLocalizerExc, MirLocalizerFailure { + return producerRecipeNames; + } + + public void produceRecipe(String aName) throws MirLocalizerExc, MirLocalizerFailure { + if (producerRecipes.containsKey(aName)) + MirGlobal.producerEngine().addTasks((List) producerRecipes.get(aName)); + else + throw new MirLocalizerExc("Unknown recipe name: " + aName); + } + public List factories() throws MirLocalizerExc { if (fileMonitor==null || producerFactories == null || fileMonitor.hasChanged()) { try { @@ -110,6 +148,16 @@ public class MirBasicProducerLocalizer implements MirProducerLocalizer { return producerFactories; }; + public ProducerFactory getFactoryForName(String aName) { + try { + factories(); + } + catch (Throwable t) { + } + + return (ProducerFactory) nameToFactory.get(aName); + } + protected void setupProducerNodeBuilderLibrary(ProducerNodeBuilderLibrary aLibrary) throws MirLocalizerFailure { try { DefaultProducerNodeBuilders.registerBuilders( @@ -126,29 +174,12 @@ public class MirBasicProducerLocalizer implements MirProducerLocalizer { ProducerConfigReader reader; ProducerNodeBuilderLibrary library = new ProducerNodeBuilderLibrary(); setupProducerNodeBuilderLibrary(library); - List usedFiles = new Vector(); - Iterator i; aFileMonitor.clear(); reader = new ProducerConfigReader(); - reader.parseFile(MirGlobal.config().getString("Home") + File.separatorChar + MirGlobal.config().getString("Mir.Localizer.ProducerConfigFile"), library, aFactories, usedFiles); - - i = usedFiles.iterator(); - while (i.hasNext()) - aFileMonitor.addFile((File) i.next()); - } - - public void produceAllNew() { - MirGlobal.producerEngine().addTasks(allNewProducerTasks); - }; - public ProducerFactory getFactoryForName(String aName) { - try { - factories(); - } - catch (Throwable t) { - } - - return (ProducerFactory) nameToFactory.get(aName); + File inputFile = new File(MirGlobal.config().getString("Home"), MirGlobal.config().getString("Mir.Localizer.ProducerConfigFile")); + aFileMonitor.addFile(inputFile); + reader.parse(inputFile, library, aFactories); } }