org.apache.cocoon.components.flow
Class AbstractInterpreter

java.lang.Object
  extended byorg.apache.cocoon.util.AbstractLogEnabled
      extended byorg.apache.cocoon.components.flow.AbstractInterpreter
All Implemented Interfaces:
Configurable, Contextualizable, Disposable, org.apache.cocoon.components.flow.Interpreter, Serviceable, SingleThreaded

public abstract class AbstractInterpreter
extends org.apache.cocoon.util.AbstractLogEnabled
implements Serviceable, Contextualizable, org.apache.cocoon.components.flow.Interpreter, SingleThreaded, Configurable, Disposable

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

Since:
March 15, 2002
Version:
$Id: AbstractInterpreter.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Nested Class Summary
 
Nested classes inherited from class org.apache.cocoon.components.flow.Interpreter
org.apache.cocoon.components.flow.Interpreter.Argument
 
Field Summary
protected  Context avalonContext
           
protected  long checkTime
          Interval between two checks for modified script files.
protected  org.apache.cocoon.components.flow.ContinuationsManager continuationsMgr
           
protected  ServiceManager manager
           
protected  ArrayList needResolve
          List of source locations that need to be resolved.
protected  org.apache.cocoon.el.objectmodel.ObjectModel newObjectModel
           
protected  org.apache.cocoon.processing.ProcessInfoProvider processInfoProvider
           
protected  boolean reloadScripts
          Whether reloading of scripts should be done.
protected  org.apache.cocoon.configuration.Settings settings
          The settings of Cocoon.
 
Fields inherited from interface org.apache.cocoon.components.flow.Interpreter
ROLE
 
Constructor Summary
AbstractInterpreter()
           
 
Method Summary
 void configure(Configuration config)
           
 void contextualize(Context aContext)
           
 void dispose()
           
 void forwardTo(String uri, Object bizData, org.apache.cocoon.components.flow.WebContinuation continuation, org.apache.cocoon.environment.Redirector redirector)
           
 String getInterpreterID()
          Get the unique ID for this interpreter, which can be used to distinguish user value scopes attached to the session.
 String getScriptExtension()
           
 void register(String source)
          Registers a source file with the interpreter.
 void service(ServiceManager sm)
           
 void setInterpreterID(String interpreterID)
          Set the unique ID for this interpreter, which can be used to distinguish user value scopes attached to the session.
 
Methods inherited from class org.apache.cocoon.util.AbstractLogEnabled
getLogger, setLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.cocoon.components.flow.Interpreter
callFunction, handleContinuation
 

Field Detail

avalonContext

protected Context avalonContext

needResolve

protected ArrayList needResolve
List of source locations that need to be resolved.


manager

protected ServiceManager manager

continuationsMgr

protected org.apache.cocoon.components.flow.ContinuationsManager continuationsMgr

processInfoProvider

protected org.apache.cocoon.processing.ProcessInfoProvider processInfoProvider

newObjectModel

protected org.apache.cocoon.el.objectmodel.ObjectModel newObjectModel

settings

protected org.apache.cocoon.configuration.Settings settings
The settings of Cocoon.


reloadScripts

protected boolean reloadScripts
Whether reloading of scripts should be done. Specified through the "reload-scripts" attribute in flow.xmap.


checkTime

protected long checkTime
Interval between two checks for modified script files. Specified through the "check-time" XML attribute in flow.xmap.

Constructor Detail

AbstractInterpreter

public AbstractInterpreter()
Method Detail

setInterpreterID

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.

Specified by:
setInterpreterID in interface org.apache.cocoon.components.flow.Interpreter

getInterpreterID

public String getInterpreterID()
Get the unique ID for this interpreter, which can be used to distinguish user value scopes attached to the session.

Specified by:
getInterpreterID in interface org.apache.cocoon.components.flow.Interpreter
Returns:
a unique ID for this interpreter

configure

public void configure(Configuration config)
               throws ConfigurationException
Specified by:
configure in interface Configurable
Throws:
ConfigurationException
See Also:
Configurable.configure(org.apache.avalon.framework.configuration.Configuration)

service

public void service(ServiceManager sm)
             throws ServiceException
Specified by:
service in interface Serviceable
Throws:
ServiceException
See Also:
Serviceable.service(org.apache.avalon.framework.service.ServiceManager)

contextualize

public void contextualize(Context aContext)
                   throws ContextException
Specified by:
contextualize in interface Contextualizable
Throws:
ContextException
See Also:
Contextualizable.contextualize(org.apache.avalon.framework.context.Context)

dispose

public void dispose()
Specified by:
dispose in interface Disposable
See Also:
Disposable.dispose()

register

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.

Specified by:
register in interface org.apache.cocoon.components.flow.Interpreter
Parameters:
source - the location of the script
See Also:
Environment, DelayedRefreshSourceWrapper

forwardTo

public void forwardTo(String uri,
                      Object bizData,
                      org.apache.cocoon.components.flow.WebContinuation continuation,
                      org.apache.cocoon.environment.Redirector redirector)
               throws Exception
Specified by:
forwardTo in interface org.apache.cocoon.components.flow.Interpreter
Throws:
Exception
See Also:
Interpreter.forwardTo(java.lang.String, java.lang.Object, org.apache.cocoon.components.flow.WebContinuation, org.apache.cocoon.environment.Redirector)

getScriptExtension

public String getScriptExtension()
Specified by:
getScriptExtension in interface org.apache.cocoon.components.flow.Interpreter
See Also:
Interpreter.getScriptExtension()


Copyright © 1999-2008 The Apache Software Foundation. All Rights Reserved.