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

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLoggable
        |
        +--org.apache.cocoon.components.language.programming.AbstractProgrammingLanguage
              |
              +--org.apache.cocoon.components.language.programming.CompiledProgrammingLanguage
                    |
                    +--org.apache.cocoon.components.language.programming.java.JavaLanguage
All Implemented Interfaces:
org.apache.avalon.framework.component.Component, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.logger.Loggable, ProgrammingLanguage, org.apache.avalon.framework.thread.ThreadSafe
Direct Known Subclasses:
JavascriptLanguage

public class JavaLanguage
extends CompiledProgrammingLanguage
implements org.apache.avalon.framework.thread.ThreadSafe, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.activity.Disposable

The Java programming language processor

Version:
CVS $Revision: 1.2.2.9 $ $Date: 2001/10/25 19:31:24 $
Author:
Ricardo Rocha

Field Summary
protected  org.apache.avalon.framework.component.ComponentManager manager
          The component manager
 
Fields inherited from class org.apache.cocoon.components.language.programming.CompiledProgrammingLanguage
classpath, 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(java.lang.String name, java.io.File baseDirectory, java.lang.String encoding)
          Compile a source file yielding a loadable class file.
 void compose(org.apache.avalon.framework.component.ComponentManager manager)
          Set the global component manager.
 void dispose()
          dispose
 void doUnload(java.lang.Object program)
          Unload a previously loaded class.
 java.lang.String getName()
          Return the language name
 java.lang.String getObjectExtension()
          Return the language's canonical object file extension.
 java.lang.String getSourceExtension()
          Return the language's canonical source file extension.
 CompiledComponent instantiate(java.lang.Class program)
          Create a new instance for the given class
protected  java.lang.Class loadProgram(java.lang.String name, java.io.File baseDirectory)
          Actually load an object program from a class file.
 java.lang.String quoteString(java.lang.String constant)
          Escape a String according to the Java string constant encoding rules.
protected  void setParameters(org.apache.avalon.framework.parameters.Parameters params)
          Set the configuration parameters.
 
Methods inherited from class org.apache.cocoon.components.language.programming.CompiledProgrammingLanguage
contextualize, doUnload, load
 
Methods inherited from class org.apache.cocoon.components.language.programming.AbstractProgrammingLanguage
configure, getCodeFormatter, getLanguageName, setLanguageName, unload
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable
getLogger, setLogger, 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 org.apache.avalon.framework.component.ComponentManager manager
The component manager
Constructor Detail

JavaLanguage

public JavaLanguage()
Method Detail

getName

public java.lang.String getName()
Return the language name
Returns:
The language name

getSourceExtension

public java.lang.String getSourceExtension()
Return the language's canonical source file extension.
Returns:
The source file extension

getObjectExtension

public java.lang.String getObjectExtension()
Return the language's canonical object file extension.
Overrides:
getObjectExtension in class CompiledProgrammingLanguage
Returns:
The object file extension

setParameters

protected void setParameters(org.apache.avalon.framework.parameters.Parameters params)
                      throws java.lang.Exception
Set the configuration parameters. This method instantiates the sitemap-specified ClassLoaderManager
Overrides:
setParameters in class CompiledProgrammingLanguage
Parameters:
params - The configuration parameters
Throws:
java.lang.Exception - If the class loader manager cannot be instantiated

compose

public void compose(org.apache.avalon.framework.component.ComponentManager manager)
Set the global component manager. This methods initializes the class loader manager if it was not (successfully) specified in the language parameters
Specified by:
compose in interface org.apache.avalon.framework.component.Composable
Parameters:
manager - The global component manager

loadProgram

protected java.lang.Class loadProgram(java.lang.String name,
                                      java.io.File baseDirectory)
                               throws LanguageException
Actually load an object program from a class file.
Overrides:
loadProgram in class CompiledProgrammingLanguage
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 void compile(java.lang.String name,
                       java.io.File baseDirectory,
                       java.lang.String encoding)
                throws LanguageException
Compile a source file yielding a loadable class file.
Overrides:
compile in class CompiledProgrammingLanguage
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

instantiate

public CompiledComponent instantiate(java.lang.Class program)
                              throws LanguageException
Create a new instance for the given class
Parameters:
program - The Java class
Returns:
A new class instance
Throws:
LanguageException - If an instantiation error occurs

doUnload

public void doUnload(java.lang.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
Overrides:
doUnload in class CompiledProgrammingLanguage
Parameters:
program - A previously loaded class
Throws:
LanguageException - If an error occurs during unloading

quoteString

public java.lang.String quoteString(java.lang.String constant)
Escape a String according to the Java string constant encoding rules.
Parameters:
constant - The string to be escaped
Returns:
The escaped string

dispose

public void dispose()
dispose
Specified by:
dispose in interface org.apache.avalon.framework.activity.Disposable


Copyright © 1999-2001 Apache Software Foundation. All Rights Reserved.