org.apache.cocoon.components.language.programming
Class AbstractProgrammingLanguage

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.components.language.programming.AbstractProgrammingLanguage
All Implemented Interfaces:
Component, LogEnabled, Parameterizable, ProgrammingLanguage
Direct Known Subclasses:
CompiledProgrammingLanguage, JavascriptLanguage, PythonLanguage

public abstract class AbstractProgrammingLanguage
extends AbstractLogEnabled
implements ProgrammingLanguage, Parameterizable

Base implementation of ProgrammingLanguage. This class sets the CodeFormatter instance and deletes source program files after unloading.

Version:
CVS $Id: AbstractProgrammingLanguage.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Ricardo Rocha, Vadim Gritsenko

Field Summary
protected  Class codeFormatter
          The source code formatter
protected  String languageName
           
 
Fields inherited from interface org.apache.cocoon.components.language.programming.ProgrammingLanguage
ROLE
 
Constructor Summary
AbstractProgrammingLanguage()
           
 
Method Summary
protected abstract  void doUnload(Object program, String filename, File baseDirectory)
          Unload a previously loaded program
 CodeFormatter getCodeFormatter()
          Return this language's source code formatter.
 String getLanguageName()
          Get Language Name
 CompiledComponent instantiate(Program program)
          Create a new instance for the given class
 void parameterize(Parameters params)
          Set the configuration parameters.
 void setLanguageName(String name)
          Set Language Name
 void unload(Object program, String filename, File baseDirectory)
          Unload from memory and invalidate a given program
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
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.language.programming.ProgrammingLanguage
getSourceExtension, load, preload, quoteString
 

Field Detail

codeFormatter

protected Class codeFormatter
The source code formatter


languageName

protected String languageName
Constructor Detail

AbstractProgrammingLanguage

public AbstractProgrammingLanguage()
Method Detail

parameterize

public void parameterize(Parameters params)
                  throws ParameterException
Set the configuration parameters. This method instantiates the sitemap-specified source code formatter

Specified by:
parameterize in interface Parameterizable
Parameters:
params - The configuration parameters
Throws:
ParameterException - If the language compiler cannot be loaded

getCodeFormatter

public CodeFormatter getCodeFormatter()
Return this language's source code formatter. A new formatter instance is created on each invocation.

Specified by:
getCodeFormatter in interface ProgrammingLanguage
Returns:
The language source code formatter

doUnload

protected abstract void doUnload(Object program,
                                 String filename,
                                 File baseDirectory)
                          throws LanguageException
Unload a previously loaded program

Parameters:
program - A previously loaded object program
Throws:
LanguageException - If an error occurs during unloading

unload

public final void unload(Object program,
                         String filename,
                         File baseDirectory)
                  throws LanguageException
Description copied from interface: ProgrammingLanguage
Unload from memory and invalidate a given program

Specified by:
unload in interface ProgrammingLanguage
Parameters:
program - The program
filename - The name of the file this program was loaded from
baseDirectory - The directory containing the program file
Throws:
LanguageException - If an error occurs

setLanguageName

public final void setLanguageName(String name)
Description copied from interface: ProgrammingLanguage
Set Language Name

Specified by:
setLanguageName in interface ProgrammingLanguage
Parameters:
name - The name of the language

getLanguageName

public final String getLanguageName()
Description copied from interface: ProgrammingLanguage
Get Language Name

Specified by:
getLanguageName in interface ProgrammingLanguage
Returns:
The name of the language

instantiate

public CompiledComponent instantiate(Program program)
                              throws LanguageException
Create a new instance for the given class

Specified by:
instantiate in interface ProgrammingLanguage
Parameters:
program - The Java class
Returns:
A new class instance
Throws:
LanguageException - If an instantiation error occurs


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