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/org/apache/cocoon/components/language/generator ProgramGeneratorImpl.java
Date Sun, 05 Aug 2001 18:23:36 GMT
vgritsenko    01/08/05 11:23:36

  Modified:    src/org/apache/cocoon/components/language/generator Tag:
                        cocoon_20_branch ProgramGeneratorImpl.java
  Log:
  Exclude servlet context from generated package names
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.5.2.11  +24 -6     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.5.2.10
  retrieving revision 1.5.2.11
  diff -u -r1.5.2.10 -r1.5.2.11
  --- ProgramGeneratorImpl.java	2001/07/29 04:19:02	1.5.2.10
  +++ ProgramGeneratorImpl.java	2001/08/05 18:23:36	1.5.2.11
  @@ -12,6 +12,7 @@
   import java.io.FileNotFoundException;
   import java.io.FileReader;
   import java.io.IOException;
  +import java.net.MalformedURLException;
   import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.component.ComponentException;
  @@ -49,7 +50,7 @@
   /**
    * The default implementation of <code>ProgramGenerator</code>
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Revision: 1.5.2.10 $ $Date: 2001/07/29 04:19:02 $
  + * @version CVS $Revision: 1.5.2.11 $ $Date: 2001/08/05 18:23:36 $
    */
   public class ProgramGeneratorImpl extends AbstractLoggable
       implements ProgramGenerator, Contextualizable, Composable, Configurable, ThreadSafe,
Disposable {
  @@ -84,11 +85,25 @@
       /** The root package */
       protected String rootPackage;
   
  +    /** Servlet Context Directory */
  +    protected String contextDir;
  +
       /** Contextualize this class */
       public void contextualize(Context context) throws ContextException {
           if (this.workDir == null) {
               this.workDir = (File) context.get(Constants.CONTEXT_WORK_DIR);
           }
  +
  +        if (this.contextDir == null) {
  +            org.apache.cocoon.environment.Context ctx =
  +                (org.apache.cocoon.environment.Context) context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
  +            try {
  +                this.contextDir = ctx.getResource("").toExternalForm();
  +            } catch (MalformedURLException e) {
  +                getLogger().warn("Could not get context directory", e);
  +                this.contextDir = "";
  +            }
  +        }
       }
   
       /**
  @@ -143,11 +158,14 @@
           // Set filenames
           StringBuffer contextFilename = new StringBuffer(this.rootPackage.replace('.', File.separatorChar));
           contextFilename.append(File.separator);
  -        /*
  -         * VG: Filename here is relative to (sub)sitemap - cannot be used
  -         * to generate classname.
  -         */
  -        contextFilename.append(source.getSystemId());
  +        String id = source.getSystemId();
  +        if(id.startsWith(this.contextDir)) {
  +            // VG: File is located under contextDir, using relative file name
  +            contextFilename.append(id.substring(this.contextDir.length()));
  +        } else {
  +            // VG: File is located outside of contextDir, using systemId
  +            contextFilename.append(id);
  +        }
           String normalizedName = IOUtils.normalizedFilename(contextFilename.toString());
   
           // Ensure no 2 requests for the same file overlap
  
  
  

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