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

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

public abstract class CompiledProgrammingLanguage
extends AbstractProgrammingLanguage
implements Contextualizable

A compiled programming language. This class extends AbstractProgrammingLanguage adding support for compilation and object program files

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

Field Summary
protected  String classpath
          The local classpath
protected  Class compilerClass
          The compiler
protected  boolean deleteSources
          The source deletion option
 
Fields inherited from class org.apache.cocoon.components.language.programming.AbstractProgrammingLanguage
codeFormatter, languageName
 
Fields inherited from interface org.apache.cocoon.components.language.programming.ProgrammingLanguage
ROLE
 
Constructor Summary
CompiledProgrammingLanguage()
           
 
Method Summary
protected abstract  void compile(String filename, File baseDirectory, String encoding)
          Compile a source file yielding a loadable object file.
 void contextualize(Context context)
          Set the context
abstract  void doUnload(Object program)
          Unload a previously loaded program
protected  void doUnload(Object program, String filename, File baseDirectory)
          Unload a previously loaded program given its original filesystem location
abstract  String getObjectExtension()
          Return the language's canonical object file extension.
 Program load(String filename, File baseDirectory, String encoding)
          Load an object program from a file.
protected abstract  Class loadProgram(String filename, File baseDirectory)
          Actually load an object program from a file.
 void parameterize(Parameters params)
          Set the configuration parameters.
 Program preload(String filename, File baseDirectory, String encoding)
          Preload an object program from a file.
 
Methods inherited from class org.apache.cocoon.components.language.programming.AbstractProgrammingLanguage
getCodeFormatter, getLanguageName, instantiate, setLanguageName, unload
 
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, quoteString
 

Field Detail

compilerClass

protected Class compilerClass
The compiler


classpath

protected String classpath
The local classpath


deleteSources

protected boolean deleteSources
The source deletion option

Constructor Detail

CompiledProgrammingLanguage

public CompiledProgrammingLanguage()
Method Detail

parameterize

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

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

contextualize

public void contextualize(Context context)
                   throws ContextException
Set the context

Specified by:
contextualize in interface Contextualizable
Parameters:
context - The context
Throws:
ContextException

getObjectExtension

public abstract String getObjectExtension()
Return the language's canonical object file extension.

Returns:
The object file extension

doUnload

public abstract void doUnload(Object program)
                       throws LanguageException
Unload a previously loaded program

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

doUnload

protected final void doUnload(Object program,
                              String filename,
                              File baseDirectory)
                       throws LanguageException
Unload a previously loaded program given its original filesystem location

Specified by:
doUnload in class AbstractProgrammingLanguage
Parameters:
program - The previously loaded object program
filename - The base filename of the object program
baseDirectory - The directory contaning the object program file
Throws:
LanguageException - If an error occurs

loadProgram

protected abstract Class loadProgram(String filename,
                                     File baseDirectory)
                              throws LanguageException
Actually load an object program from a file.

Parameters:
filename - The object program base file name
baseDirectory - The directory containing the object program file
Returns:
The loaded object program
Throws:
LanguageException - If an error occurs during loading

compile

protected abstract void compile(String filename,
                                File baseDirectory,
                                String encoding)
                         throws LanguageException
Compile a source file yielding a loadable object file.

Parameters:
filename - The object program base file name
baseDirectory - The directory containing the object program file
encoding - The encoding expected in the source file or null if it is the platform's default encoding
Throws:
LanguageException - If an error occurs during compilation

preload

public Program preload(String filename,
                       File baseDirectory,
                       String encoding)
                throws LanguageException
Preload an object program from a file. This method does not compiles the corresponding source file.

Specified by:
preload in interface ProgrammingLanguage
Parameters:
filename - The object program base file name
baseDirectory - The directory containing the object program file
encoding - The encoding expected in the source file or null if it is the platform's default encoding
Returns:
The loaded object program
Throws:
LanguageException - If an error occurs during compilation

load

public Program load(String filename,
                    File baseDirectory,
                    String encoding)
             throws LanguageException
Load an object program from a file. This method compiles the corresponding source file if necessary.

Specified by:
load in interface ProgrammingLanguage
Parameters:
filename - The object program base file name
baseDirectory - The directory containing the object program file
encoding - The encoding expected in the source file or null if it is the platform's default encoding
Returns:
The loaded object program
Throws:
LanguageException - If an error occurs during compilation


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