sylvain     01/12/20 10:14:18

  Modified:    src/org/apache/cocoon/components/language/generator
                        ProgramGeneratorImpl.java
  Log:
  Fix a bug so that context prefix location is properly removed from generated source 
file paths (in short : now it works again as in 2.0 ;)
  
  Revision  Changes    Path
  1.26      +12 -2     
xml-cocoon2/src/org/apache/cocoon/components/language/generator/ProgramGeneratorImpl.java
  
  Index: ProgramGeneratorImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/org/apache/cocoon/components/language/generator/ProgramGeneratorImpl.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- ProgramGeneratorImpl.java 2001/12/11 13:06:04     1.25
  +++ ProgramGeneratorImpl.java 2001/12/20 18:14:18     1.26
  @@ -39,7 +39,7 @@
   /**
    * The default implementation of <code>ProgramGenerator</code>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Ricardo Rocha</a>
  - * @version CVS $Revision: 1.25 $ $Date: 2001/12/11 13:06:04 $
  + * @version CVS $Revision: 1.26 $ $Date: 2001/12/20 18:14:18 $
    */
   public class ProgramGeneratorImpl extends AbstractLoggable
       implements ProgramGenerator, Contextualizable, Composable, Configurable, 
ThreadSafe, Disposable {
  @@ -86,8 +86,18 @@
           if (this.contextDir == null) {
               org.apache.cocoon.environment.Context ctx =
                   (org.apache.cocoon.environment.Context) 
context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
  +            
  +            // Determine the context directory, preferably as a file
  +            // FIXME (SW) - this is purposely redundant with some code in 
CocoonServlet
  +            //              to have the same rootPath. How to avoid this ?
               try {
  -                this.contextDir = ctx.getResource("/").toExternalForm();
  +                String rootPath = ctx.getRealPath("/");
  +                if (rootPath != null) {
  +                    this.contextDir = new File(rootPath).toURL().toExternalForm();
  +                } else {
  +                    String webInf = ctx.getResource("/WEB-INF").toExternalForm();
  +                    this.contextDir = webInf.substring(0,webInf.length() - 
"WEB-INF".length());
  +                }
                   getLogger().debug("Context directory is " + this.contextDir);
               } catch (MalformedURLException e) {
                   getLogger().warn("Could not get context directory", e);
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to