Save This Page
Home » cocoon-2.1.11-src » org.apache » cocoon » components » flow » [javadoc | source]
org.apache.cocoon.components.flow
abstract public class: AbstractInterpreter [javadoc | source]
java.lang.Object
   org.apache.avalon.framework.logger.AbstractLogEnabled
      org.apache.cocoon.components.flow.AbstractInterpreter

All Implemented Interfaces:
    org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.thread.SingleThreaded, org.apache.avalon.framework.service.Serviceable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.component.Component, org.apache.avalon.framework.context.Contextualizable, Interpreter

Direct Known Subclasses:
    CompilingInterpreter, SchemeInterpreter, JavaScriptInterpreter, FOM_JavaScriptInterpreter, ApplesProcessor, JavaInterpreter

Abstract superclass for various scripting languages used by Cocoon for flow control. Defines some useful behavior like the ability to reload script files if they get modified (useful when doing development), and passing the control to Cocoon's sitemap for result page generation.

Flow intrepreters belonging to different sitemaps should be isolated. To achieve this, class implements the org.apache.avalon.framework.thread.SingleThreaded . Since the sitemap engine looks up the flow intepreter once at sitemap build time, this ensures that each sitemap will use a different instance of this class. But that instance will handle all flow calls for a given sitemap, and must therefore be thread safe.

Field Summary
protected  Context avalonContext     
protected  ArrayList needResolve    List of source locations that need to be resolved. 
protected  Context context     
protected  ServiceManager manager     
protected  ContinuationsManager continuationsMgr     
protected  boolean reloadScripts    Whether reloading of scripts should be done. Specified through the "reload-scripts" attribute in flow.xmap
protected  long checkTime    Interval between two checks for modified script files. Specified through the "check-time" XML attribute in flow.xmap
Constructor:
 public AbstractInterpreter() 
Method from org.apache.cocoon.components.flow.AbstractInterpreter Summary:
configure,   contextualize,   dispose,   forwardTo,   getInterpreterID,   process,   register,   service,   setInterpreterID
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.cocoon.components.flow.AbstractInterpreter Detail:
 public  void configure(Configuration config) throws ConfigurationException 
 public  void contextualize(Context context) throws ContextException 
 public  void dispose() 
 public  void forwardTo(String uri,
    Object bizData,
    WebContinuation continuation,
    Redirector redirector) throws Exception 
 public String getInterpreterID() 
    Get the unique ID for this interpreter, which can be used to distinguish user value scopes attached to the session.
 public  void process(String uri,
    Object biz,
    OutputStream out) throws Exception 
    Call the Cocoon sitemap for the given URI, sending the output of the eventually matched pipeline to the specified outputstream.
 public  void register(String source) 
    Registers a source file with the interpreter. Using this method an implementation keeps track of all the script files which are compiled. This allows them to reload the script files which get modified on the file system.

    The parsing/compilation of a script file by an interpreter happens in two phases. In the first phase the file's location is registered in the needResolve array.

    The second is possible only when a Cocoon Environment is passed to the Interpreter. This allows the file location to be resolved using Cocoon's SourceFactory class.

    Once a file's location can be resolved, it is removed from the needResolve array and placed in the scripts hash table. The key in this hash table is the file location string, and the value is a DelayedRefreshSourceWrapper instance which keeps track of when the file needs to re-read.

 public  void service(ServiceManager sm) throws ServiceException 
    Serviceable
 public  void setInterpreterID(String interpreterID) 
    Set the unique ID for this interpreter, which can be used to distinguish user value scopes attached to the session.