org.apache.cocoon.components.language.programming.java
Class JavaLanguage

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
              extended by org.apache.cocoon.components.language.programming.java.JavaLanguage
All Implemented Interfaces:
Disposable, Initializable, Component, Contextualizable, LogEnabled, Parameterizable, Serviceable, ThreadSafe, ProgrammingLanguage
Direct Known Subclasses:
CompiledJavascriptLanguage

public class JavaLanguage
extends CompiledProgrammingLanguage
implements Initializable, ThreadSafe, Serviceable, Disposable

The Java programming language processor

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

Field Summary
protected  ServiceManager manager
          The service manager
 
Fields inherited from class org.apache.cocoon.components.language.programming.CompiledProgrammingLanguage
compilerClass, deleteSources
 
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
JavaLanguage()
           
 
Method Summary
protected  void compile(String name, File baseDirectory, String encoding)
          Compile a source file yielding a loadable class file.
 void dispose()
          dispose
 void doUnload(Object program)
          Unload a previously loaded class.
 String getObjectExtension()
          Return the language's canonical object file extension.
 String getSourceExtension()
          Return the language's canonical source file extension.
 void initialize()
           
protected  Class loadProgram(String name, File baseDirectory)
          Actually load an object program from a class file.
 void parameterize(Parameters params)
          Set the configuration parameters.
 String quoteString(String constant)
          Escape a String according to the Java string constant encoding rules.
 void service(ServiceManager manager)
          Set the global service manager.
 
Methods inherited from class org.apache.cocoon.components.language.programming.CompiledProgrammingLanguage
contextualize, doUnload, load, preload
 
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
 

Field Detail

manager

protected ServiceManager manager
The service manager

Constructor Detail

JavaLanguage

public JavaLanguage()
Method Detail

getSourceExtension

public String getSourceExtension()
Return the language's canonical source file extension.

Specified by:
getSourceExtension in interface ProgrammingLanguage
Returns:
The source file extension

getObjectExtension

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

Specified by:
getObjectExtension in class CompiledProgrammingLanguage
Returns:
The object file extension

parameterize

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

Specified by:
parameterize in interface Parameterizable
Overrides:
parameterize in class CompiledProgrammingLanguage
Parameters:
params - The configuration parameters
Throws:
ParameterException - If the class loader manager cannot be instantiated or looked up.

service

public void service(ServiceManager manager)
             throws ServiceException
Set the global service manager.

Specified by:
service in interface Serviceable
Parameters:
manager - The global service manager
Throws:
ServiceException

initialize

public void initialize()
                throws Exception
Specified by:
initialize in interface Initializable
Throws:
Exception

loadProgram

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

Specified by:
loadProgram in class CompiledProgrammingLanguage
Parameters:
name - 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 void compile(String name,
                       File baseDirectory,
                       String encoding)
                throws LanguageException
Compile a source file yielding a loadable class file.

Specified by:
compile in class CompiledProgrammingLanguage
Parameters:
name - 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

doUnload

public void doUnload(Object program)
              throws LanguageException
Unload a previously loaded class. This method simply reinstantiates the class loader to ensure that a new version of the same class will be correctly loaded in a future loading operation

Specified by:
doUnload in class CompiledProgrammingLanguage
Parameters:
program - A previously loaded class
Throws:
LanguageException - If an error occurs during unloading

quoteString

public String quoteString(String constant)
Escape a String according to the Java string constant encoding rules.

Specified by:
quoteString in interface ProgrammingLanguage
Parameters:
constant - The string to be escaped
Returns:
The escaped string

dispose

public void dispose()
dispose

Specified by:
dispose in interface Disposable


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