You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by di...@apache.org on 2001/03/02 13:21:08 UTC
cvs commit: xml-cocoon/src/org/apache/cocoon/generation ServerPagesGenerator.java
dims 01/03/02 04:21:07
Modified: src/org/apache/cocoon/components/language/generator Tag:
xml-cocoon2 ProgramGeneratorImpl.java
src/org/apache/cocoon/generation Tag: xml-cocoon2
ServerPagesGenerator.java
Log:
Changes to speedup the XSP Engine.
Revision Changes Path
No revision
No revision
1.1.2.39 +29 -12 xml-cocoon/src/org/apache/cocoon/components/language/generator/Attic/ProgramGeneratorImpl.java
Index: ProgramGeneratorImpl.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/components/language/generator/Attic/ProgramGeneratorImpl.java,v
retrieving revision 1.1.2.38
retrieving revision 1.1.2.39
diff -u -r1.1.2.38 -r1.1.2.39
--- ProgramGeneratorImpl.java 2001/03/01 15:45:33 1.1.2.38
+++ ProgramGeneratorImpl.java 2001/03/02 12:21:00 1.1.2.39
@@ -46,7 +46,7 @@
/**
* The default implementation of <code>ProgramGenerator</code>
* @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
- * @version CVS $Revision: 1.1.2.38 $ $Date: 2001/03/01 15:45:33 $
+ * @version CVS $Revision: 1.1.2.39 $ $Date: 2001/03/02 12:21:00 $
*/
public class ProgramGeneratorImpl extends AbstractLoggable implements ProgramGenerator, Contextualizable, Composer, Configurable, ThreadSafe {
@@ -133,12 +133,7 @@
String programmingLanguageName,
EntityResolver resolver)
throws Exception {
- // Get markup and programming languages
- MarkupLanguage markupLanguage = (MarkupLanguage)this.markupSelector.select(markupLanguageName);
- ProgrammingLanguage programmingLanguage =
- (ProgrammingLanguage)this.languageSelector.select(programmingLanguageName);
- programmingLanguage.setLanguageName(programmingLanguageName);
// Create filesystem store
// Set filenames
String filename = IOUtils.getFullFilename(file);
@@ -158,22 +153,32 @@
}
if (programInstance == null) {
+ MarkupLanguage markupLanguage = null;
+ ProgrammingLanguage programmingLanguage = null;
try {
+ // Get markup and programming languages
+ markupLanguage = (MarkupLanguage)this.markupSelector.select(markupLanguageName);
+ programmingLanguage = (ProgrammingLanguage)this.languageSelector.select(programmingLanguageName);
+ programmingLanguage.setLanguageName(programmingLanguageName);
program = generateResource(file, normalizedName, markupLanguage, programmingLanguage, resolver);
} catch (LanguageException le) {
getLogger().debug("Language Exception", le);
+ } finally {
+ this.markupSelector.release((Component) markupLanguage);
+ this.languageSelector.release((Component) programmingLanguage);
}
try {
programInstance = (CompiledComponent) select(normalizedName);
} catch (Exception cme) {
getLogger().debug("Can't load ServerPage", cme);
+ } finally {
+ this.markupSelector.release((Component) markupLanguage);
+ this.languageSelector.release((Component) programmingLanguage);
}
}
if (this.autoReload == false) {
- this.markupSelector.release((Component) markupLanguage);
- this.languageSelector.release((Component) programmingLanguage);
return programInstance;
}
@@ -187,6 +192,8 @@
release(programInstance);
// Unload program
+ ProgrammingLanguage programmingLanguage = (ProgrammingLanguage)this.languageSelector.select(programmingLanguageName);
+ programmingLanguage.setLanguageName(programmingLanguageName);
programmingLanguage.unload(program, normalizedName, this.workDir);
// Invalidate previous program/instance pair
@@ -196,14 +203,24 @@
if (programInstance == null) {
if (program == null) {
- program = generateResource(file, normalizedName, markupLanguage, programmingLanguage, resolver);
+ MarkupLanguage markupLanguage = null;
+ ProgrammingLanguage programmingLanguage = null;
+ try {
+ // Get markup and programming languages
+ markupLanguage = (MarkupLanguage)this.markupSelector.select(markupLanguageName);
+ programmingLanguage = (ProgrammingLanguage)this.languageSelector.select(programmingLanguageName);
+ programmingLanguage.setLanguageName(programmingLanguageName);
+ program = generateResource(file, normalizedName, markupLanguage, programmingLanguage, resolver);
+ } catch (LanguageException le) {
+ getLogger().debug("Language Exception", le);
+ } finally {
+ this.markupSelector.release((Component) markupLanguage);
+ this.languageSelector.release((Component) programmingLanguage);
+ }
}
// Instantiate
programInstance = (CompiledComponent) select(normalizedName);
}
-
- this.markupSelector.release((Component) markupLanguage);
- this.languageSelector.release((Component) programmingLanguage);
return programInstance;
}
No revision
No revision
1.1.2.21 +17 -17 xml-cocoon/src/org/apache/cocoon/generation/Attic/ServerPagesGenerator.java
Index: ServerPagesGenerator.java
===================================================================
RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/generation/Attic/ServerPagesGenerator.java,v
retrieving revision 1.1.2.20
retrieving revision 1.1.2.21
diff -u -r1.1.2.20 -r1.1.2.21
--- ServerPagesGenerator.java 2001/02/22 17:10:35 1.1.2.20
+++ ServerPagesGenerator.java 2001/03/02 12:21:05 1.1.2.21
@@ -13,7 +13,7 @@
import org.xml.sax.InputSource;
import org.xml.sax.EntityResolver;
-import java.util.Stack;
+import java.util.LinkedList;
import org.xml.sax.Locator;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
@@ -41,7 +41,7 @@
* delegating actual SAX event generation.
*
* @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
- * @version CVS $Revision: 1.1.2.20 $ $Date: 2001/02/22 17:10:35 $
+ * @version CVS $Revision: 1.1.2.21 $ $Date: 2001/03/02 12:21:05 $
*/
public class ServerPagesGenerator
extends ServletGenerator
@@ -150,8 +150,8 @@
generator.generate();
// End any started events in case of premature return
- while (!this.eventStack.empty()) {
- EventData eventData = (EventData) this.eventStack.pop();
+ while (this.eventStack.size()!=0) {
+ EventData eventData = (EventData) this.eventStack.removeFirst();
switch (eventData.eventType) {
case DOCUMENT:
@@ -188,7 +188,7 @@
* The SAX event stack. Used for "completing" pendind SAX events left "open"
* by prematurely returning server pages generators
*/
- protected Stack eventStack = new Stack();
+ protected LinkedList eventStack = new LinkedList();
/**
* Receive notification of character data.
@@ -201,7 +201,7 @@
* Receive notification of the end of a document.
*/
public void endDocument() throws SAXException {
- this.eventStack.pop();
+ this.eventStack.removeFirst();
this.contentHandler.endDocument();
}
@@ -211,7 +211,7 @@
public void endElement(String namespaceURI, String localName, String rawName)
throws SAXException
{
- this.eventStack.pop();
+ this.eventStack.removeFirst();
this.contentHandler.endElement(namespaceURI, localName, rawName);
}
@@ -219,7 +219,7 @@
* End the scope of a prefix-URI mapping.
*/
public void endPrefixMapping(String prefix) throws SAXException {
- this.eventStack.pop();
+ this.eventStack.removeFirst();
this.contentHandler.endPrefixMapping(prefix);
}
@@ -262,7 +262,7 @@
*/
public void startDocument() throws SAXException {
this.contentHandler.startDocument();
- this.eventStack.push(new EventData(DOCUMENT));
+ this.eventStack.addFirst(new EventData(DOCUMENT));
}
/**
@@ -274,7 +274,7 @@
throws SAXException
{
this.contentHandler.startElement(namespaceURI, localName, rawName, atts);
- this.eventStack.push(new EventData(ELEMENT, namespaceURI, localName, rawName));
+ this.eventStack.addFirst(new EventData(ELEMENT, namespaceURI, localName, rawName));
}
/**
@@ -283,7 +283,7 @@
public void startPrefixMapping(String prefix, String uri) throws SAXException
{
this.contentHandler.startPrefixMapping(prefix, uri);
- this.eventStack.push(new EventData(PREFIX_MAPPING, prefix, uri));
+ this.eventStack.addFirst(new EventData(PREFIX_MAPPING, prefix, uri));
}
public void comment(char[] ch, int start, int length) throws SAXException {
@@ -292,34 +292,34 @@
public void endCDATA() throws SAXException {
this.lexicalHandler.endCDATA();
- this.eventStack.pop();
+ this.eventStack.removeFirst();
}
public void endDTD() throws SAXException {
this.lexicalHandler.endDTD();
- this.eventStack.pop();
+ this.eventStack.removeFirst();
}
public void endEntity(String name) throws SAXException {
this.lexicalHandler.endEntity(name);
- this.eventStack.pop();
+ this.eventStack.removeFirst();
}
public void startCDATA() throws SAXException {
this.lexicalHandler.startCDATA();
- this.eventStack.push(new EventData(CDATA));
+ this.eventStack.addFirst(new EventData(CDATA));
}
public void startDTD(String name, String publicId, String systemId)
throws SAXException
{
this.lexicalHandler.startDTD(name, publicId, systemId);
- this.eventStack.push(new EventData(DTD, name, publicId, systemId));
+ this.eventStack.addFirst(new EventData(DTD, name, publicId, systemId));
}
public void startEntity(String name) throws SAXException {
this.lexicalHandler.startEntity(name);
- this.eventStack.push(new EventData(ENTITY, name));
+ this.eventStack.addFirst(new EventData(ENTITY, name));
}
protected final static int DOCUMENT = 0;