vgritsenko    2002/09/20 19:13:21

  Modified:    src/java/org/apache/cocoon/components/language/generator
                        Tag: cocoon_2_0_3_branch ProgramGenerator.java
                        ProgramGeneratorImpl.java
  Log:
  Load programs from the Source, not from the 'File' (it's not file really, it's a 
source).
  Deprecate previous method.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.7.2.1   +33 -3     
xml-cocoon2/src/java/org/apache/cocoon/components/language/generator/ProgramGenerator.java
  
  Index: ProgramGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/generator/ProgramGenerator.java,v
  retrieving revision 1.7
  retrieving revision 1.7.2.1
  diff -u -r1.7 -r1.7.2.1
  --- ProgramGenerator.java     22 Feb 2002 07:00:07 -0000      1.7
  +++ ProgramGenerator.java     21 Sep 2002 02:13:20 -0000      1.7.2.1
  @@ -54,6 +54,7 @@
   import org.apache.avalon.framework.component.ComponentManager;
   
   import org.apache.cocoon.environment.SourceResolver;
  +import org.apache.cocoon.environment.Source;
   
   /**
    * This interface defines a loader for programs automatically built from XML
  @@ -78,6 +79,7 @@
        * the program must be written
        * @return The loaded object
        * @exception Exception If an error occurs during generation or loading
  +     * @deprecated Pass Source object instead of file name.
        */
       CompiledComponent load(
               ComponentManager newManager,
  @@ -87,10 +89,38 @@
               SourceResolver resolver) throws Exception;
   
       /**
  -     * Release a program built from an XML document written in a
  +     * Load a program built from an XML document written in a
  +     * <code>MarkupLanguage</code>
  +     *
  +     * @param newManager  The ComponentManager that it will be loaded with
  +     * @param source The input document's <code>File</code> name
  +     * @param markupLanguage The <code>MarkupLanguage</code> in which the input
  +     * document is written
  +     * @param programmingLanguage The <code>ProgrammingLanguage</code> in which
  +     * the program must be written
  +     * @return The loaded object
  +     * @exception Exception If an error occurs during generation or loading
  +     */
  +    CompiledComponent load(
  +            ComponentManager newManager,
  +            Source source,
  +            String markupLanguage,
  +            String programmingLanguage,
  +            SourceResolver resolver) throws Exception;
  +
  +    /**
  +     * Release a program instance built from an XML document written in a
        * <code>MarkupLanguage</code>.
        *
  -     * @param CompiledSheet
  +     * @param component to be released.
        */
       void release(CompiledComponent component);
  +
  +    /**
  +     * Remove a program from the generator's cache and dipose all
  +     * instances of this program.
  +     *
  +     * @param source of the program to be removed.
  +     */
  +    void remove(Source source);
   }
  
  
  
  1.15.2.4  +35 -3     
xml-cocoon2/src/java/org/apache/cocoon/components/language/generator/ProgramGeneratorImpl.java
  
  Index: ProgramGeneratorImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/generator/ProgramGeneratorImpl.java,v
  retrieving revision 1.15.2.3
  retrieving revision 1.15.2.4
  diff -u -r1.15.2.3 -r1.15.2.4
  --- ProgramGeneratorImpl.java 11 Sep 2002 12:43:58 -0000      1.15.2.3
  +++ ProgramGeneratorImpl.java 21 Sep 2002 02:13:20 -0000      1.15.2.4
  @@ -195,8 +195,7 @@
               // VG: File is located outside of contextDir, using systemId
               contextFilename.append(systemId);
           }
  -        String normalizedName = 
IOUtils.normalizedFilename(contextFilename.toString());
  -        return normalizedName;
  +        return IOUtils.normalizedFilename(contextFilename.toString());
       }
   
       /**
  @@ -216,6 +215,25 @@
           throws Exception {
   
           final Source source = resolver.resolve(fileName);
  +        return load(newManager, source, markupLanguageName, 
programmingLanguageName, resolver);
  +    }
  +
  +    /**
  +     * Load a program built from an XML document written in a 
<code>MarkupLanguage</code>
  +     *
  +     * @param source The input document's <code>File</code>
  +     * @param markupLanguageName The <code>MarkupLanguage</code> in which the input 
document is written
  +     * @param programmingLanguageName The <code>ProgrammingLanguage</code> in which 
the program must be written
  +     * @return The loaded program instance
  +     * @exception Exception If an error occurs during generation or loading
  +     */
  +    public CompiledComponent load(ComponentManager newManager,
  +                                  Source source,
  +                                  String markupLanguageName,
  +                                  String programmingLanguageName,
  +                                  SourceResolver resolver)
  +        throws Exception {
  +
           final String id = source.getSystemId();
   
           ProgrammingLanguage programmingLanguage = null;
  @@ -402,8 +420,22 @@
           return program;
       }
   
  +    /**
  +     * Releases the program instance.
  +     * @param component program instance to be released
  +     */
       public void release(CompiledComponent component) {
           this.cache.release(component);
  +    }
  +
  +    /**
  +     * Removes named program from the program generator's cache.
  +     * Disposes all created instances of the program.
  +     * @param source of the program to be removed
  +     */
  +    public void remove(Source source) {
  +        final String normalizedName = getNormalizedName(source.getSystemId());
  +        this.cache.removeGenerator(normalizedName);
       }
   
       /**
  
  
  

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