ovidiu      02/03/24 23:29:21

  Added:       
src/scratchpad/schecoon/src/org/apache/cocoon/components/treeprocessor/sitemap
                        ContinueNode.java
  Log:
  Added. Handles <map:continue with="..."> nodes.
  
  Revision  Changes    Path
  1.1                  
xml-cocoon2/src/scratchpad/schecoon/src/org/apache/cocoon/components/treeprocessor/sitemap/ContinueNode.java
  
  Index: ContinueNode.java
  ===================================================================
  package org.apache.cocoon.components.treeprocessor.sitemap;
  
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.Composable;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.cocoon.components.flow.ContinuationsManager;
  import org.apache.cocoon.components.flow.Interpreter;
  import org.apache.cocoon.components.flow.InterpreterSelector;
  import org.apache.cocoon.components.treeprocessor.AbstractProcessingNode;
  import org.apache.cocoon.components.treeprocessor.InvokeContext;
  import org.apache.cocoon.components.treeprocessor.MapStackResolver;
  import org.apache.cocoon.environment.Environment;
  import org.apache.cocoon.sitemap.PatternException;
  
  public class ContinueNode
    extends AbstractProcessingNode
    implements Configurable, Composable
  {
    protected String continuationId;
    protected MapStackResolver continuationIdResolver;
    protected ComponentManager manager;
  
    public ContinueNode(String contId)
    {
      this.continuationId = contId;
    }
  
    public void configure(Configuration config)
      throws ConfigurationException
    {
      try {
        if (MapStackResolver.needsResolve(continuationId)) {
          // This should happen all the time, but who knows...
          this.continuationIdResolver
            = MapStackResolver.getResolver(continuationId);
        }
      }
      catch (PatternException ex) {
        throw new ConfigurationException(ex.toString());
      }
    }
  
    public void compose(ComponentManager manager)
    {
      this.manager = manager;
    }
  
    public boolean invoke(Environment env, InvokeContext context)
        throws Exception
    {
      String contId = continuationId;
  
      if (continuationIdResolver != null) {
        contId = continuationIdResolver.resolve(context.getMapStack());
      }
  
      InterpreterSelector selector
        = (InterpreterSelector)manager.lookup(Interpreter.ROLE);
  
      // FIXME: How to detect the language associated with the
      // continuation object? Use the default language for now, but it
      // should be fixed ASAP.
      String language = selector.getDefaultLanguage();
  
      // Obtain the Interpreter instance for this language
      Interpreter interpreter = (Interpreter)selector.select(language);
  
      interpreter.handleContinuation(contId, env, context);
      return true;
    }
  }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to