X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=source%2Fmircoders%2Flocalizer%2Fbasic%2FMirBasicProducerLocalizer.java;h=24b9982f37a87801f89162a0740a7afb0b6e71dc;hb=04bf29aa1f1abf43e96d0272b2a286f0c1f9fea8;hp=423fe65eb8f06f6a81782cb6a3b4916068f98b40;hpb=3da84ce0196319b33211328515e3ca12b422c95c;p=mir.git diff --git a/source/mircoders/localizer/basic/MirBasicProducerLocalizer.java b/source/mircoders/localizer/basic/MirBasicProducerLocalizer.java index 423fe65e..24b9982f 100755 --- a/source/mircoders/localizer/basic/MirBasicProducerLocalizer.java +++ b/source/mircoders/localizer/basic/MirBasicProducerLocalizer.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001, 2002 The Mir-coders group + * Copyright (C) 2001, 2002 The Mir-coders group * * This file is part of Mir. * @@ -18,17 +18,15 @@ * 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 the com.oreilly.servlet library, 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. + * 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; import java.io.File; @@ -47,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; @@ -57,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; @@ -70,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(); @@ -85,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 { @@ -105,13 +141,23 @@ public class MirBasicProducerLocalizer implements MirProducerLocalizer { } catch (Throwable t) { logger.error("MirBasicProducerLocalizer.factories(): Unable to setup factories: "+t.getMessage()); - t.printStackTrace(logger.asPrintWriter(logger.DEBUG_MESSAGE)); + t.printStackTrace(logger.asPrintWriter(LoggerWrapper.DEBUG_MESSAGE)); } } 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( @@ -128,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); } }