cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ovi...@apache.org
Subject cvs commit: xml-cocoon2/src/scratchpad/schecoon/src/org/apache/cocoon/components/flow InterpreterSelector.java
Date Wed, 10 Apr 2002 06:18:51 GMT
ovidiu      02/04/09 23:18:51

  Modified:    src/scratchpad/schecoon/src/org/apache/cocoon/components/flow
                        InterpreterSelector.java
  Log:
  Make use of the ExcaliburComponentSelector configure method to
  initialize the components, instead of doing the work ourselves.
  
  Revision  Changes    Path
  1.9       +22 -42    xml-cocoon2/src/scratchpad/schecoon/src/org/apache/cocoon/components/flow/InterpreterSelector.java
  
  Index: InterpreterSelector.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/schecoon/src/org/apache/cocoon/components/flow/InterpreterSelector.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- InterpreterSelector.java	10 Apr 2002 00:36:46 -0000	1.8
  +++ InterpreterSelector.java	10 Apr 2002 06:18:51 -0000	1.9
  @@ -3,8 +3,7 @@
   import org.apache.avalon.excalibur.component.ExcaliburComponentSelector;
   import org.apache.avalon.excalibur.logger.LogKitManageable;
   import org.apache.avalon.excalibur.logger.LogKitManager;
  -import org.apache.avalon.framework.component.ComponentManager;
  -import org.apache.avalon.framework.component.Composable;
  +import org.apache.avalon.framework.component.ComponentException;
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  @@ -13,10 +12,9 @@
   import org.apache.log.Logger;
   
   public class InterpreterSelector extends ExcaliburComponentSelector
  -  implements Configurable, ThreadSafe, Composable, LogKitManageable
  +  implements Configurable, ThreadSafe, LogKitManageable
   {
     LogKitManager logkit;
  -  ComponentManager manager;
     String defaultLanguage;
     
     ClassLoader loader = Thread.currentThread().getContextClassLoader();
  @@ -29,6 +27,8 @@
     public void configure(Configuration config)
       throws ConfigurationException
     {
  +    super.configure(config);
  +
       defaultLanguage = config.getAttribute("default", null);
       boolean reloadScripts = config.getAttributeAsBoolean("reload-scripts", false);
       long checkTime = config.getAttributeAsLong("check-time", 1000L);
  @@ -38,52 +38,32 @@
         loggerUsed = logkit.getLogger(loggerName);
       }
   
  -    Configuration[] components = config.getChildren("language");
  -    if (components.length == 0)
  +    // Finish the initialization of the already created components
  +    Configuration[] configurations = config.getChildren("component-instance");
  +    if (configurations.length == 0)
         throw new ConfigurationException("No languages defined!");
   
  -    for (int i = 0; i < components.length; i++) {
  -      Configuration component = components[i];
  -      String name = component.getAttribute("name");
  -      String className = component.getChild("class").getValue();
  -      String loadOnStartup
  -        = component.getChild("load-on-startup", true).getValue(null);
  +    for (int i = 0; i < configurations.length; i++) {
  +      Configuration conf = configurations[i];
  +      String hint = conf.getAttribute("name").trim();
  +      Interpreter interp;
   
  -      Class clazz;
         try {
  -        clazz = loader.loadClass(className);
  -        addComponent(name, clazz, component);
  -
  -        // Setup various configuration options on the scripting
  -        // language Cocoon component
  -        Interpreter interp = (Interpreter)this.select(name);
  -        if (interp instanceof AbstractInterpreter) {
  -          ((AbstractInterpreter)interp).setReloadScripts(reloadScripts);
  -          ((AbstractInterpreter)interp).setCheckTime(checkTime);
  -          if (loadOnStartup != null)
  -            ((AbstractInterpreter)interp).register(loadOnStartup);
  -        }
  -        if (interp instanceof Composable)
  -          ((Composable)interp).compose(manager);
  -
  -        if (interp instanceof Loggable)
  -          ((Loggable)interp).setLogger(loggerUsed);
  +        interp = (Interpreter)this.select(hint);
         }
  -      catch (Exception ex) {
  -        throw new ConfigurationException("Cannot load class " + className);
  +      catch (ComponentException ex) {
  +        throw new ConfigurationException("Could not find component for hint "
  +                                         + hint + ": " + ex.toString());
         }
   
  -      // If there's no default language specified through the
  -      // `default' attribute, set up as default the first language in
  -      // the sequence.
  -      if (defaultLanguage == null && i == 0)
  -        defaultLanguage = name;
  -    }
  -  }
  +      if (interp instanceof AbstractInterpreter) {
  +        ((AbstractInterpreter)interp).setReloadScripts(reloadScripts);
  +        ((AbstractInterpreter)interp).setCheckTime(checkTime);
  +      }
   
  -  public void compose(ComponentManager manager)
  -  {
  -    this.manager = manager;
  +      if (i == 0 && defaultLanguage == null)
  +        defaultLanguage = hint;
  +    }
     }
   
     public String getDefaultLanguage()
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message