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/treeprocessor/sitemap ScriptNode.java
Date Thu, 14 Mar 2002 03:52:04 GMT
ovidiu      02/03/13 19:52:04

  Modified:    src/scratchpad/schecoon/src/org/apache/cocoon/components/treeprocessor/sitemap
                        ScriptNode.java
  Log:
  Removed debug statements.
  
  Revision  Changes    Path
  1.2       +56 -14    xml-cocoon2/src/scratchpad/schecoon/src/org/apache/cocoon/components/treeprocessor/sitemap/ScriptNode.java
  
  Index: ScriptNode.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/schecoon/src/org/apache/cocoon/components/treeprocessor/sitemap/ScriptNode.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ScriptNode.java	13 Mar 2002 19:05:24 -0000	1.1
  +++ ScriptNode.java	14 Mar 2002 03:52:04 -0000	1.2
  @@ -1,41 +1,83 @@
   package org.apache.cocoon.components.treeprocessor.sitemap;
   
  -import org.apache.avalon.framework.activity.Initializable;
   
  -import org.apache.cocoon.environment.Environment;
   
  -import org.apache.cocoon.sitemap.PatternException;
   
  +
  +
  +
  +import java.util.List;
  +import java.util.Map;
  +import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.component.ComponentException;
  +import org.apache.avalon.framework.component.ComponentManager;
  +import org.apache.avalon.framework.component.ComponentSelector;
  +import org.apache.avalon.framework.component.Composable;
  +import org.apache.cocoon.components.flow.Interpreter;
   import org.apache.cocoon.components.treeprocessor.AbstractProcessingNode;
   import org.apache.cocoon.components.treeprocessor.CategoryNode;
   import org.apache.cocoon.components.treeprocessor.InvokeContext;
   import org.apache.cocoon.components.treeprocessor.MapStackResolver;
   import org.apache.cocoon.components.treeprocessor.ParameterizableProcessingNode;
   import org.apache.cocoon.components.treeprocessor.ProcessingNode;
  -
  -import java.util.List;
  -import java.util.Map;
  +import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.sitemap.PatternException;
   
   public class ScriptNode extends AbstractProcessingNode
  -    implements Initializable, ParameterizableProcessingNode
  +    implements Composable, Initializable
   {
  -  Map parameters;
  -  
  -  public void setParameters(Map parameterMap)
  +  String source;
  +  String language;
  +
  +  public ScriptNode(String source, String language)
     {
  -    this.parameters = parameterMap;
  -    System.out.println("ScriptNode parameters = " + parameters);
  +    this.source = source;
  +    this.language = language;
     }
  -
  +  
     public void initialize()
     {
       System.out.println("ScriptNode initialize");
     }
   
  +  /**
  +   * This method should never be called by the TreeProcessor, since a
  +   * <map:script> element should not be in an "executable" sitemap
  +   * node.
  +   *
  +   * @param env an <code>Environment</code> value
  +   * @param context an <code>InvokeContext</code> value
  +   * @return a <code>boolean</code> value
  +   * @exception Exception if an error occurs
  +   */
     public boolean invoke(Environment env, InvokeContext context)
       throws Exception
     {
  -    System.out.println("ScriptNode invoke");
       return true;
  +  }
  +
  +  /**
  +   * This method is the only chance a ScriptNode object has a chance
  +   * to know about its environment and do something useful (since
  +   * <code>invoke</code> is never called). Thus, once we obtain the
  +   * ComponentManager, obtain the appropriate <code>Interpreter</code>
  +   * instance for the language, and load the script.
  +   *
  +   * @param manager a <code>ComponentManager</code> value
  +   */
  +  public void compose(ComponentManager manager)
  +    throws ComponentException
  +  {
  +    try {
  +      ComponentSelector selector
  +        = (ComponentSelector)manager.lookup(Interpreter.ROLE);
  +      // Obtain the Interpreter instance for this language
  +      Interpreter interpreter = (Interpreter)selector.select(language);
  +    }
  +    catch (ComponentException ex) {
  +      System.out.println("ScriptNode: Couldn't read the source file "
  +                         + source + " in language " + language);
  +      throw ex;
  +    }
     }
   }
  
  
  

----------------------------------------------------------------------
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