cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From giac...@apache.org
Subject cvs commit: xml-cocoon2/src/org/apache/cocoon Main.java
Date Mon, 14 May 2001 08:38:30 GMT
giacomo     01/05/14 01:38:30

  Modified:    src/org/apache/cocoon Main.java
  Log:
  Forgot to commit it last time
  
  Revision  Changes    Path
  1.2       +46 -4     xml-cocoon2/src/org/apache/cocoon/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Main.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Main.java	2001/05/09 20:49:28	1.1
  +++ Main.java	2001/05/14 08:38:25	1.2
  @@ -17,6 +17,7 @@
   import java.io.PrintStream;
   import java.net.MalformedURLException;
   import java.util.ArrayList;
  +import java.util.Arrays;
   import java.util.Collection;
   import java.util.HashMap;
   import java.util.Iterator;
  @@ -26,6 +27,7 @@
   import org.apache.cocoon.environment.Environment;
   import org.apache.cocoon.environment.commandline.FileSavingEnvironment;
   import org.apache.cocoon.environment.commandline.LinkSamplingEnvironment;
  +import org.apache.cocoon.environment.commandline.CommandlineContext;
   import org.apache.cocoon.util.IOUtils;
   import org.apache.cocoon.util.JavaArchiveFilter;
   import org.apache.cocoon.util.MIMEUtils;
  @@ -45,7 +47,7 @@
    * Command line entry point.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2001/05/09 20:49:28 $
  + * @version CVS $Revision: 1.2 $ $Date: 2001/05/14 08:38:25 $
    */
   
   public class Main {
  @@ -206,11 +208,13 @@
               File context = getDir(contextDir, "context");
               File conf = getConfigurationFile(context);
               DefaultContext appContext = new DefaultContext();
  -            //appContext.put(Constants.CONTEXT_SERVLET_CONTEXT, contextDir);
  -            appContext.put(Constants.CONTEXT_ROOT_PATH, contextDir);
               appContext.put(Constants.CONTEXT_CLASS_LOADER, Main.class.getClassLoader());
  -            appContext.put(Constants.CONTEXT_CONFIG_URL, conf.toURL());
  +            appContext.put(Constants.CONTEXT_ENVIRONMENT_CONTEXT, new CommandlineContext(contextDir));
  +            appContext.put(Constants.CONTEXT_CLASSPATH, getClassPath(contextDir));
               appContext.put(Constants.CONTEXT_WORK_DIR, work);
  +            appContext.put(Constants.CONTEXT_UPLOAD_DIR, contextDir + "image-dir");
  +            appContext.put(Constants.CONTEXT_CONFIG_URL, conf.toURL());
  +            appContext.put(Constants.CONTEXT_ROOT_PATH, contextDir);
               Cocoon c = new Cocoon();
               c.setLogger(log);
               c.contextualize(appContext);
  @@ -467,5 +471,43 @@
           cocoon.process(env);
           return env.getContentType();
       }
  +
  +    /**
  +     * This builds the important ClassPath used by this class.  It
  +     * does so in a neutral way.
  +     * It iterates in alphabetical order through every file in the
  +     * lib directory and adds it to the classpath.
  +     *
  +     * Also, we add the files to the ClassLoader for the Cocoon system.
  +     * In order to protect ourselves from skitzofrantic classloaders,
  +     * we need to work with a known one.
  +     *
  +     * @param context  The context path
  +     */
  +     protected static String getClassPath(final String context) {
  +        StringBuffer buildClassPath = new StringBuffer();
  +        String classDir = context + "/WEB-INF/classes";
  +        File root = new File(context + "/WEB-INF/lib");
  +
  +        buildClassPath.append(classDir);
  +
  +        if (root.isDirectory()) {
  +            File[] libraries = root.listFiles();
  +            Arrays.sort(libraries);
  +            for (int i = 0; i < libraries.length; i++) {
  +                buildClassPath.append(File.pathSeparatorChar)
  +                              .append(IOUtils.getFullFilename(libraries[i]));
  +            }
  +        }
  +
  +        buildClassPath.append(File.pathSeparatorChar)
  +                      .append(System.getProperty("java.class.path"));
  +
  +//        buildClassPath.append(File.pathSeparatorChar)
  +//                      .append(getExtraClassPath(context));
  +
  +        log.debug("Context classpath: " + buildClassPath.toString());
  +        return buildClassPath.toString();
  +     }
   }
   
  
  
  

----------------------------------------------------------------------
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