vgritsenko 02/02/06 20:58:24
Modified: src/java/org/apache/cocoon/generation
ServerPagesGenerator.java
Log:
Make ServerPagesGenerator generator of *ServerPages* ;-)
Fix language selection.
Revision Changes Path
1.11 +41 -48
xml-cocoon2/src/java/org/apache/cocoon/generation/ServerPagesGenerator.java
Index: ServerPagesGenerator.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/ServerPagesGenerator.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ServerPagesGenerator.java 6 Feb 2002 01:49:21 -0000 1.10
+++ ServerPagesGenerator.java 7 Feb 2002 04:58:24 -0000 1.11
@@ -54,17 +54,18 @@
*/
package org.apache.cocoon.generation;
-import org.apache.avalon.excalibur.collections.ArrayStack;
-import org.apache.avalon.excalibur.pool.Recyclable;
-
import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.logger.Loggable;
-import org.apache.avalon.framework.parameters.Parameterizable;
import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.excalibur.collections.ArrayStack;
+import org.apache.avalon.excalibur.pool.Recyclable;
+
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.ResourceNotFoundException;
import org.apache.cocoon.caching.CacheValidity;
@@ -78,17 +79,11 @@
import org.apache.cocoon.xml.AbstractXMLPipe;
import org.xml.sax.Attributes;
-import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import java.io.IOException;
-
import java.util.HashMap;
-import java.util.LinkedList;
import java.util.Map;
-import org.apache.avalon.framework.configuration.Configurable;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
/**
* This class acts as a proxy to a dynamically loaded<code>Generator</code>
@@ -106,11 +101,10 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Ricardo Rocha</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a>
- * @version CVS $Id: ServerPagesGenerator.java,v 1.10 2002/02/06 01:49:21
vgritsenko Exp $
+ * @version CVS $Id: ServerPagesGenerator.java,v 1.11 2002/02/07 04:58:24
vgritsenko Exp $
*/
public class ServerPagesGenerator extends ServletGenerator
- implements Parameterizable, Recyclable, Disposable, Cacheable, Configurable
-{
+ implements Recyclable, Disposable, Cacheable, Configurable {
/**
* The sitemap-defined server pages program generator
*/
@@ -134,7 +128,7 @@
if (programGenerator == null) {
this.programGenerator =
- (ProgramGenerator) manager.lookup(ProgramGenerator.ROLE);
+ (ProgramGenerator) manager.lookup(ProgramGenerator.ROLE);
}
}
@@ -145,13 +139,9 @@
this.completionPipe = new CompletionPipe();
this.completionPipe.setLogger(getLogger());
}
- }
- public void parameterize (Parameters parameters) {
- this.markupLanguage = parameters.getParameter(
- "markup-language", DEFAULT_MARKUP_LANGUAGE);
- this.programmingLanguage = parameters.getParameter(
- "programming-language", DEFAULT_PROGRAMMING_LANGUAGE);
+ this.markupLanguage =
config.getChild("markup-language").getValue(DEFAULT_MARKUP_LANGUAGE);
+ this.programmingLanguage =
config.getChild("programming-language").getValue(DEFAULT_PROGRAMMING_LANGUAGE);
}
/**
@@ -175,7 +165,7 @@
public CacheValidity generateValidity() {
CacheValidity genValidity = generator.generateValidity();
if (genValidity != null) {
- HashMap map = new HashMap (1);
+ HashMap map = new HashMap(1);
map.put("source", this.inputSource.getSystemId());
ParametersCacheValidity pcv = new ParametersCacheValidity(map);
return new CompositeCacheValidity(genValidity, pcv);
@@ -204,15 +194,19 @@
public final static String DEFAULT_PROGRAMMING_LANGUAGE = "java";
public void setup(SourceResolver resolver, Map objectModel, String src,
Parameters par)
- throws ProcessingException, SAXException, IOException {
+ throws ProcessingException, SAXException, IOException {
super.setup(resolver, objectModel, src, par);
- this.inputSource = this.resolver.resolve(super.source);
+ String markupLanguage = this.parameters.getParameter(
+ "markup-language", this.markupLanguage);
+ String programmingLanguage = this.parameters.getParameter(
+ "programming-language", this.programmingLanguage);
+
+ this.inputSource = this.resolver.resolve(super.source);
try {
- generator = (AbstractServerPage) programGenerator.load(
- this.manager, super.source, this.markupLanguage,
- this.programmingLanguage, this.resolver);
+ generator = (AbstractServerPage) programGenerator.load(super.manager,
+ super.source, markupLanguage, programmingLanguage,
super.resolver);
} catch (ProcessingException e) {
throw e;
} catch (Exception e) {
@@ -225,10 +219,10 @@
// Give our own logger to the generator so that logs go in the correct
category
if (generator instanceof Loggable) {
- ((Loggable)generator).setLogger(getLogger());
+ ((Loggable) generator).setLogger(getLogger());
}
- generator.setup(this.resolver, this.objectModel, super.source,
this.parameters);
+ generator.setup(super.resolver, super.objectModel, super.source,
super.parameters);
}
/**
@@ -269,20 +263,20 @@
// log exception and ensure that generator is released.
try {
generator.generate();
- } catch (IOException e){
+ } catch (IOException e) {
getLogger().debug("IOException in generate()", e);
throw e;
- } catch (SAXException e){
+ } catch (SAXException e) {
getLogger().debug("SAXException in generate()", e);
throw e;
- } catch (ProcessingException e){
+ } catch (ProcessingException e) {
getLogger().debug("ProcessingException in generate()", e);
throw e;
- } catch (Exception e){
+ } catch (Exception e) {
getLogger().debug("Exception in generate()", e);
throw new ProcessingException("Exception in
ServerPagesGenerator.generate()", e);
} finally {
- if(generator != null)
+ if (generator != null)
programGenerator.release(generator);
generator = null;
}
@@ -365,7 +359,7 @@
* Receive notification of the beginning of an element.
*/
public void startElement(String namespaceURI, String localName, String
rawName, Attributes atts)
- throws SAXException {
+ throws SAXException {
super.startElement(namespaceURI, localName, rawName, atts);
this.eventStack.push(rawName);
this.eventStack.push(localName);
@@ -377,7 +371,7 @@
* Receive notification of the end of an element.
*/
public void endElement(String namespaceURI, String localName, String
rawName)
- throws SAXException {
+ throws SAXException {
this.eventStack.pop(); // ELEMENT_OBJ
this.eventStack.pop(); // namespaceURI
this.eventStack.pop(); // localName
@@ -414,8 +408,7 @@
}
public void startDTD(String name, String publicId, String systemId)
- throws SAXException
- {
+ throws SAXException {
super.startDTD(name, publicId, systemId);
this.eventStack.push(DTD_OBJ);
}
@@ -447,22 +440,22 @@
// End any started events in case of premature return
while (this.eventStack.size() != 0) {
- int event = ((Integer)eventStack.pop()).intValue();
+ int event = ((Integer) eventStack.pop()).intValue();
- switch(event) {
- case DOCUMENT :
+ switch (event) {
+ case DOCUMENT:
super.endDocument();
break;
- case ELEMENT :
- String namespaceURI = (String)eventStack.pop();
- String localName = (String)eventStack.pop();
- String rawName = (String)eventStack.pop();
+ case ELEMENT:
+ String namespaceURI = (String) eventStack.pop();
+ String localName = (String) eventStack.pop();
+ String rawName = (String) eventStack.pop();
super.endElement(namespaceURI, localName, rawName);
break;
- case PREFIX_MAPPING :
- super.endPrefixMapping((String)eventStack.pop());
+ case PREFIX_MAPPING:
+ super.endPrefixMapping((String) eventStack.pop());
break;
case CDATA:
@@ -474,7 +467,7 @@
break;
case ENTITY:
- super.endEntity((String)eventStack.pop());
+ super.endEntity((String) eventStack.pop());
break;
}
}
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]