cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/language/programming/java JavaLanguage.java
Date Tue, 12 Feb 2002 16:16:07 GMT
vgritsenko    02/02/12 08:16:07

  Modified:    src/java/org/apache/cocoon/components/language/programming/java
                        JavaLanguage.java
  Log:
  Optimize classpath building
  
  Revision  Changes    Path
  1.8       +31 -31    xml-cocoon2/src/java/org/apache/cocoon/components/language/programming/java/JavaLanguage.java
  
  Index: JavaLanguage.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/programming/java/JavaLanguage.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JavaLanguage.java	9 Feb 2002 03:43:01 -0000	1.7
  +++ JavaLanguage.java	12 Feb 2002 16:16:07 -0000	1.8
  @@ -56,6 +56,7 @@
   package org.apache.cocoon.components.language.programming.java;
   
   import org.apache.avalon.framework.activity.Disposable;
  +import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.component.Composable;
   import org.apache.avalon.framework.parameters.ParameterException;
  @@ -79,10 +80,10 @@
    * The Java programming language processor
    *
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Id: JavaLanguage.java,v 1.7 2002/02/09 03:43:01 vgritsenko Exp $
  + * @version CVS $Id: JavaLanguage.java,v 1.8 2002/02/12 16:16:07 vgritsenko Exp $
    */
   public class JavaLanguage extends CompiledProgrammingLanguage
  -        implements ThreadSafe, Composable, Disposable {
  +        implements Initializable, ThreadSafe, Composable, Disposable {
   
       /** The class loader */
       private ClassLoaderManager classLoaderManager;
  @@ -90,6 +91,9 @@
       /** The component manager */
       protected ComponentManager manager = null;
   
  +    /** Classpath */
  +    private String classpath;
  +
       /**
        * Return the language's canonical source file extension.
        *
  @@ -149,6 +153,27 @@
           }
       }
   
  +    public void initialize() throws Exception {
  +
  +        // Initialize the classpath
  +        String systemBootClasspath = System.getProperty("sun.boot.class.path");
  +        String systemClasspath = System.getProperty("java.class.path");
  +        String systemExtDirs = System.getProperty("java.ext.dirs");
  +        String systemExtClasspath = null;
  +
  +        try {
  +            systemExtClasspath = expandDirs(systemExtDirs);
  +        } catch (Exception e) {
  +            getLogger().warn("Could not expand Directory:" + systemExtDirs, e);
  +        }
  +
  +        this.classpath =
  +            ((super.classpath != null) ? File.pathSeparator + super.classpath : "") +
  +            ((systemBootClasspath != null) ? File.pathSeparator + systemBootClasspath :
"") +
  +            ((systemClasspath != null) ? File.pathSeparator + systemClasspath : "") +
  +            ((systemExtClasspath != null) ? File.pathSeparator + systemExtClasspath : "");
  +    }
  +
       /**
        * Actually load an object program from a class file.
        *
  @@ -161,10 +186,8 @@
               throws LanguageException {
           try {
               this.classLoaderManager.addDirectory(baseDirectory);
  -            return
  -                    this.classLoaderManager.loadClass(name.replace(File.separatorChar,
'.'));
  +            return this.classLoaderManager.loadClass(name.replace(File.separatorChar, '.'));
           } catch (Exception e) {
  -            getLogger().warn("Could not load class for program '" + name + "'", e);
               throw new LanguageException("Could not load class for program '" + name + "'
due to a " + e.getClass().getName() + ": " + e.getMessage());
           }
       }
  @@ -178,12 +201,10 @@
        * <code>null</code> if it is the platform's default encoding
        * @exception LanguageException If an error occurs during compilation
        */
  -    protected void compile(
  -            String name, File baseDirectory, String encoding
  -            ) throws LanguageException {
  +    protected void compile(String name, File baseDirectory, String encoding)
  +            throws LanguageException {
   
           try {
  -
               AbstractJavaCompiler compiler = (AbstractJavaCompiler) this.compilerClass.newInstance();
               // AbstractJavaCompiler is Loggable
               compiler.setLogger(getLogger());
  @@ -198,36 +219,15 @@
                       .append(".").append(this.getSourceExtension()).toString();
   
               compiler.setFile(filename_abs);
  -
               compiler.setSource(pathname);
  -
               compiler.setDestination(baseDirectory.getCanonicalPath());
  -
  -            String systemBootClasspath = System.getProperty("sun.boot.class.path");
  -            String systemClasspath = System.getProperty("java.class.path");
  -            String systemExtDirs = System.getProperty("java.ext.dirs");
  -            String systemExtClasspath = null;
  -
  -            try {
  -                systemExtClasspath = expandDirs(systemExtDirs);
  -            } catch (Exception e) {
  -                getLogger().warn("Could not expand Directory:" + systemExtDirs, e);
  -            }
  -
  -            compiler.setClasspath(
  -                    baseDirectory.getCanonicalPath() +
  -                    ((classpath != null) ? File.pathSeparator + classpath : "") +
  -                    ((systemBootClasspath != null) ? File.pathSeparator + systemBootClasspath
: "") +
  -                    ((systemClasspath != null) ? File.pathSeparator + systemClasspath :
"") +
  -                    ((systemExtClasspath != null) ? File.pathSeparator + systemExtClasspath
: "")
  -            );
  +            compiler.setClasspath(baseDirectory.getCanonicalPath() + this.classpath);
   
               if (encoding != null) {
                   compiler.setEncoding(encoding);
               }
   
               getLogger().debug("Compiling " + filename_abs);
  -
               if (!compiler.compile()) {
                   StringBuffer message = new StringBuffer("Error compiling ");
                   message.append(filename);
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message