You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2005/02/11 16:20:53 UTC
svn commit: r153410 - in cocoon/trunk/src:
core/java/org/apache/cocoon/configuration/Settings.java
java/org/apache/cocoon/generation/StatusGenerator.java
Author: cziegeler
Date: Fri Feb 11 07:20:52 2005
New Revision: 153410
URL: http://svn.apache.org/viewcvs?view=rev&rev=153410
Log:
Start adding settings to status generator
Modified:
cocoon/trunk/src/core/java/org/apache/cocoon/configuration/Settings.java
cocoon/trunk/src/java/org/apache/cocoon/generation/StatusGenerator.java
Modified: cocoon/trunk/src/core/java/org/apache/cocoon/configuration/Settings.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/core/java/org/apache/cocoon/configuration/Settings.java?view=diff&r1=153409&r2=153410
==============================================================================
--- cocoon/trunk/src/core/java/org/apache/cocoon/configuration/Settings.java (original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/configuration/Settings.java Fri Feb 11 07:20:52 2005
@@ -70,14 +70,14 @@
* try setting this parameter to "true".
*/
protected boolean initClassloader = INIT_CLASSLOADER;
- protected static final String KEY_INIT_CLASSLOADER = "init.classloader";
+ public static final String KEY_INIT_CLASSLOADER = "init.classloader";
/**
* This parameter allows to set system properties
*/
protected Map forceProperties = new HashMap();
/** FIXME - implement the support for this key: */
- protected static final String KEY_FORCE_PROPERTIES = "force.properties";
+ public static final String KEY_FORCE_PROPERTIES = "force.properties";
/**
* This parameter points to the main configuration file for Cocoon.
@@ -85,20 +85,20 @@
* resolved relative to the application context path.
*/
protected String configuration;
- protected static final String KEY_CONFIGURATION = "configuration";
+ public static final String KEY_CONFIGURATION = "configuration";
/**
* This parameter indicates the configuration file of the LogKit management
*/
protected String loggingConfiguration;
- protected static final String KEY_LOGGING_CONFIGURATION = "logging.configuration";
+ public static final String KEY_LOGGING_CONFIGURATION = "logging.configuration";
/**
* This parameter indicates the category id of the logger from the LogKit
* configuration used by the environment.
*/
protected String accessLogger;
- protected static final String KEY_LOGGING_ACCESS_LOGGER = "logging.logger.access";
+ public static final String KEY_LOGGING_ACCESS_LOGGER = "logging.logger.access";
/**
* This parameter indicates the category id of the logger from the LogKit
@@ -108,7 +108,7 @@
* logger="..." attribute in the component configuration file.
*/
protected String cocoonLogger;
- protected static final String KEY_LOGGING_COCOON_LOGGER = "logging.logger.cocoon";
+ public static final String KEY_LOGGING_COCOON_LOGGER = "logging.logger.cocoon";
/**
* This parameter indicates the log level to use throughout startup of the
@@ -117,14 +117,14 @@
* not readable/available this log level is of importance.
*/
protected String bootstrapLogLevel;
- protected static final String KEY_LOGGING_BOOTSTRAP_LOGLEVEL = "logging.bootstrap.level";
+ public static final String KEY_LOGGING_BOOTSTRAP_LOGLEVEL = "logging.bootstrap.level";
/**
* This parameter switches the logging system from LogKit to Log4J for Cocoon.
* Log4J has to be configured already.
*/
protected String loggerClassName;
- protected static final String KEY_LOGGING_MANAGER_CLASS = "logging.manager.class";
+ public static final String KEY_LOGGING_MANAGER_CLASS = "logging.manager.class";
/**
* If you want to configure log4j using Cocoon, then you can define
@@ -136,7 +136,7 @@
* for example.
*/
protected String log4jConfiguration;
- protected static final String KEY_LOGGING_LOG4J_CONFIGURATION = "logging.log4j.configuration";
+ public static final String KEY_LOGGING_LOG4J_CONFIGURATION = "logging.log4j.configuration";
/**
* Allow reinstantiating (reloading) of the cocoon instance. If this is
@@ -145,7 +145,7 @@
* reloaded when cocoon.xconf changes. Default is no for security reasons.
*/
protected boolean allowReload = ALLOW_RELOAD;
- protected static final String KEY_ALLOW_RELOAD = "allow.reload";
+ public static final String KEY_ALLOW_RELOAD = "allow.reload";
/**
* This parameter is used to list classes that should be loaded at
@@ -155,14 +155,14 @@
*/
protected List loadClasses = new ArrayList();
/** FIXME: Implement support for this: */
- protected static final String KEY_LOAD_CLASSES = "load.classes";
+ public static final String KEY_LOAD_CLASSES = "load.classes";
/**
* Causes all files in multipart requests to be processed.
* Default is false for security reasons.
*/
protected boolean enableUploads = ENABLE_UPLOADS;
- protected static final String KEY_UPLOADS_ENABLE = "uploads.enable";
+ public static final String KEY_UPLOADS_ENABLE = "uploads.enable";
/**
* This parameter allows to specify where Cocoon should put uploaded files.
@@ -171,14 +171,14 @@
* with volume: C:\Path\To\Upload\Directory.
*/
protected String uploadDirectory;
- protected static final String KEY_UPLOADS_DIRECTORY = "uploads.directory";
+ public static final String KEY_UPLOADS_DIRECTORY = "uploads.directory";
/**
* Causes all files in multipart requests to be saved to upload-dir.
* Default is true for security reasons.
*/
protected boolean autosaveUploads = SAVE_UPLOADS_TO_DISK;
- protected static final String KEY_UPLOADS_AUTOSAVE = "uploads.autosave";
+ public static final String KEY_UPLOADS_AUTOSAVE = "uploads.autosave";
/**
* Specify handling of name conflicts when saving uploaded files to disk.
@@ -187,13 +187,13 @@
* filename unique.
*/
protected String overwriteUploads;
- protected static final String KEY_UPLOADS_OVERWRITE = "uploads.overwrite";
+ public static final String KEY_UPLOADS_OVERWRITE = "uploads.overwrite";
/**
* Specify maximum allowed size of the upload. Defaults to 10 Mb.
*/
protected int maxUploadSize = MAX_UPLOAD_SIZE;
- protected static final String KEY_UPLOADS_MAXSIZE = "uploads.maxsize";
+ public static final String KEY_UPLOADS_MAXSIZE = "uploads.maxsize";
/**
* This parameter allows to specify where Cocoon should create its page
@@ -202,7 +202,7 @@
* absolute directory must start with volume: C:\Path\To\Cache\Directory.
*/
protected String cacheDirectory;
- protected static final String KEY_CACHE_DIRECTORY = "cache.directory";
+ public static final String KEY_CACHE_DIRECTORY = "cache.directory";
/**
* This parameter allows to specify where Cocoon should put it's
@@ -211,7 +211,7 @@
* absolute directory must start with volume: C:\Path\To\Work\Directory.
*/
protected String workDirectory;
- protected static final String KEY_WORK_DIRECTORY = "work.directory";
+ public static final String KEY_WORK_DIRECTORY = "work.directory";
/**
* This parameter allows to specify additional directories or jars
@@ -221,7 +221,7 @@
*/
protected List extraClasspaths = new ArrayList();
/** FIXME: Implement support for this: */
- protected static final String KEY_EXTRA_CLASSPATHS = "extra.classpaths";
+ public static final String KEY_EXTRA_CLASSPATHS = "extra.classpaths";
/**
* This parameter allows you to select the parent service manager.
@@ -232,33 +232,33 @@
* this class, if it implements them.
*/
protected String parentServiceManagerClassName;
- protected static final String KEY_PARENT_SERVICE_MANAGER = "parentservicemanager";
+ public static final String KEY_PARENT_SERVICE_MANAGER = "parentservicemanager";
/**
* Allow adding processing time to the response
*/
protected boolean showTime = SHOW_TIME;
- protected static final String KEY_SHOWTIME = "showtime";
+ public static final String KEY_SHOWTIME = "showtime";
/**
* If true, processing time will be added as an HTML comment
*/
protected boolean hideShowTime = HIDE_SHOW_TIME;
- protected static final String KEY_HIDE_SHOWTIME = "hideshowtime";
+ public static final String KEY_HIDE_SHOWTIME = "hideshowtime";
/**
* If true or not set, this class will try to catch and handle all Cocoon exceptions.
* If false, it will rethrow them to the servlet container.
*/
protected boolean manageExceptions = MANAGE_EXCEPTIONS;
- protected static final String KEY_MANAGE_EXCEPTIONS = "manageexceptions";
+ public static final String KEY_MANAGE_EXCEPTIONS = "manageexceptions";
/**
* Set form encoding. This will be the character set used to decode request
* parameters. If not set the ISO-8859-1 encoding will be assumed.
*/
protected String formEncoding;
- protected static final String KEY_FORM_ENCODING = "formencoding";
+ public static final String KEY_FORM_ENCODING = "formencoding";
/**
* If this value is specified, it will be interpreted as a log level and
@@ -266,13 +266,13 @@
* definition in the logging configuration.
*/
protected String overrideLogLevel;
- protected static final String KEY_LOGGING_OVERRIDE_LOGLEVEL = "override.loglevel";
+ public static final String KEY_LOGGING_OVERRIDE_LOGLEVEL = "override.loglevel";
/**
* Delay between reload checks for the configuration
*/
protected long configurationReloadDelay = 1000;
- protected static final String KEY_CONFIGURATION_RELOAD_DELAY = "configuration.reloaddelay";
+ public static final String KEY_CONFIGURATION_RELOAD_DELAY = "configuration.reloaddelay";
/**
* Create a new settings object
Modified: cocoon/trunk/src/java/org/apache/cocoon/generation/StatusGenerator.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/generation/StatusGenerator.java?view=diff&r1=153409&r2=153410
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/generation/StatusGenerator.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/generation/StatusGenerator.java Fri Feb 11 07:20:52 2005
@@ -25,14 +25,18 @@
import java.util.List;
import java.util.StringTokenizer;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.cocoon.Constants;
+import org.apache.cocoon.configuration.Settings;
+import org.apache.cocoon.core.Core;
import org.apache.commons.lang.SystemUtils;
import org.apache.excalibur.store.Store;
import org.apache.excalibur.store.StoreJanitor;
import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
@@ -76,7 +80,9 @@
* @author <a href="mailto:g-froehlich@gmx.de">Gerhard Froehlich</a>
* @version CVS $Id$
*/
-public class StatusGenerator extends ServiceableGenerator {
+public class StatusGenerator
+ extends ServiceableGenerator
+ implements Contextualizable {
/**
* The StoreJanitor used to get cache statistics
@@ -84,6 +90,16 @@
protected StoreJanitor storejanitor;
protected Store store_persistent;
+ /** The context */
+ protected Context context;
+
+ /* (non-Javadoc)
+ * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
+ */
+ public void contextualize(Context context) throws ContextException {
+ this.context = context;
+ }
+
/**
* The XML namespace for the output document.
*/
@@ -120,6 +136,9 @@
}
}
+ /* (non-Javadoc)
+ * @see org.apache.avalon.framework.activity.Disposable#dispose()
+ */
public void dispose() {
if (this.manager != null) {
this.manager.release(this.store_persistent);
@@ -141,7 +160,7 @@
this.contentHandler.startPrefixMapping("", namespace);
this.contentHandler.startPrefixMapping(xlinkPrefix, xlinkNamespace);
- genStatus(this.contentHandler);
+ genStatus();
// End the document.
this.contentHandler.endPrefixMapping(xlinkPrefix);
@@ -151,7 +170,7 @@
/** Generate the main status document.
*/
- private void genStatus(ContentHandler ch) throws SAXException {
+ private void genStatus() throws SAXException {
// Root element.
// The current date and time.
@@ -173,42 +192,43 @@
atts.addAttribute(namespace, "date", "date", "CDATA", dateTime);
atts.addAttribute(namespace, "host", "host", "CDATA", localHost);
atts.addAttribute(namespace, "cocoon-version", "cocoon-version", "CDATA", Constants.VERSION);
- ch.startElement(namespace, "statusinfo", "statusinfo", atts);
+ this.xmlConsumer.startElement(namespace, "statusinfo", "statusinfo", atts);
- genVMStatus(ch);
+ genSettings();
+ genVMStatus();
// End root element.
- ch.endElement(namespace, "statusinfo", "statusinfo");
+ this.xmlConsumer.endElement(namespace, "statusinfo", "statusinfo");
}
- private void genVMStatus(ContentHandler ch) throws SAXException {
+ private void genVMStatus() throws SAXException {
AttributesImpl atts = new AttributesImpl();
- startGroup(ch, "vm");
+ startGroup("vm");
// BEGIN Memory status
- startGroup(ch, "memory");
- addValue(ch, "total", String.valueOf(Runtime.getRuntime().totalMemory()));
- addValue(ch, "free", String.valueOf(Runtime.getRuntime().freeMemory()));
- endGroup(ch);
+ startGroup("memory");
+ addValue("total", String.valueOf(Runtime.getRuntime().totalMemory()));
+ addValue("free", String.valueOf(Runtime.getRuntime().freeMemory()));
+ endGroup();
// END Memory status
// BEGIN JRE
- startGroup(ch, "jre");
- addValue(ch, "version", SystemUtils.JAVA_VERSION);
+ startGroup("jre");
+ addValue("version", SystemUtils.JAVA_VERSION);
atts.clear();
// qName = prefix + ':' + localName
atts.addAttribute(xlinkNamespace, "type", xlinkPrefix + ":type", "CDATA", "simple");
atts.addAttribute(xlinkNamespace, "href", xlinkPrefix + ":href", "CDATA", SystemUtils.JAVA_VENDOR_URL);
- addValue(ch, "java-vendor", SystemUtils.JAVA_VENDOR, atts);
- endGroup(ch);
+ addValue("java-vendor", SystemUtils.JAVA_VENDOR, atts);
+ endGroup();
// END JRE
// BEGIN Operating system
- startGroup(ch, "operating-system");
- addValue(ch, "name", SystemUtils.OS_NAME);
- addValue(ch, "architecture", SystemUtils.OS_ARCH);
- addValue(ch, "version", SystemUtils.OS_VERSION);
- endGroup(ch);
+ startGroup("operating-system");
+ addValue("name", SystemUtils.OS_NAME);
+ addValue("architecture", SystemUtils.OS_ARCH);
+ addValue("version", SystemUtils.OS_VERSION);
+ endGroup();
// END operating system
String classpath = SystemUtils.JAVA_CLASS_PATH;
@@ -217,23 +237,23 @@
while (tokenizer.hasMoreTokens()) {
paths.add(tokenizer.nextToken());
}
- addMultilineValue(ch, "classpath", paths);
+ addMultilineValue("classpath", paths);
// END ClassPath
// BEGIN Cache
if ( this.storejanitor != null ) {
- startGroup(ch, "Store-Janitor");
+ startGroup("Store-Janitor");
// For each element in StoreJanitor
Iterator i = this.storejanitor.iterator();
while (i.hasNext()) {
Store store = (Store) i.next();
- startGroup(ch, store.getClass().getName() + " (hash = 0x" + Integer.toHexString(store.hashCode()) + ")" );
+ startGroup(store.getClass().getName() + " (hash = 0x" + Integer.toHexString(store.hashCode()) + ")" );
int size = 0;
int empty = 0;
atts.clear();
atts.addAttribute(namespace, "name", "name", "CDATA", "cached");
- ch.startElement(namespace, "value", "value", atts);
+ this.xmlConsumer.startElement(namespace, "value", "value", atts);
// For each element in Store
Enumeration e = store.keys();
atts.clear();
@@ -246,32 +266,32 @@
empty++;
} else {
line = key + " (class: " + val.getClass().getName() + ")";
- ch.startElement(namespace, "line", "line", atts);
- ch.characters(line.toCharArray(), 0, line.length());
- ch.endElement(namespace, "line", "line");
+ this.xmlConsumer.startElement(namespace, "line", "line", atts);
+ this.xmlConsumer.characters(line.toCharArray(), 0, line.length());
+ this.xmlConsumer.endElement(namespace, "line", "line");
}
}
if (size == 0) {
- ch.startElement(namespace, "line", "line", atts);
+ this.xmlConsumer.startElement(namespace, "line", "line", atts);
String value = "[empty]";
- ch.characters(value.toCharArray(), 0, value.length());
- ch.endElement(namespace, "line", "line");
+ this.xmlConsumer.characters(value.toCharArray(), 0, value.length());
+ this.xmlConsumer.endElement(namespace, "line", "line");
}
- ch.endElement(namespace, "value", "value");
+ this.xmlConsumer.endElement(namespace, "value", "value");
- addValue(ch, "size", String.valueOf(size) + " items in cache (" + empty + " are empty)");
- endGroup(ch);
+ addValue("size", String.valueOf(size) + " items in cache (" + empty + " are empty)");
+ endGroup();
}
- endGroup(ch);
+ endGroup();
}
if (this.store_persistent != null) {
- startGroup(ch, store_persistent.getClass().getName()+" (hash = 0x"+Integer.toHexString(store_persistent.hashCode())+")");
+ startGroup( store_persistent.getClass().getName()+" (hash = 0x"+Integer.toHexString(store_persistent.hashCode())+")");
int size = 0;
int empty = 0;
atts.clear();
atts.addAttribute(namespace, "name", "name", "CDATA", "cached");
- ch.startElement(namespace, "value", "value", atts);
+ this.xmlConsumer.startElement(namespace, "value", "value", atts);
Enumeration enumer = this.store_persistent.keys();
while (enumer.hasMoreElements()) {
size++;
@@ -283,84 +303,94 @@
empty++;
} else {
line = key + " (class: " + val.getClass().getName() + ")";
- ch.startElement(namespace, "line", "line", atts);
- ch.characters(line.toCharArray(), 0, line.length());
- ch.endElement(namespace, "line", "line");
+ this.xmlConsumer.startElement(namespace, "line", "line", atts);
+ this.xmlConsumer.characters(line.toCharArray(), 0, line.length());
+ this.xmlConsumer.endElement(namespace, "line", "line");
}
}
if (size == 0) {
- ch.startElement(namespace, "line", "line", atts);
+ this.xmlConsumer.startElement(namespace, "line", "line", atts);
String value = "[empty]";
- ch.characters(value.toCharArray(), 0, value.length());
- ch.endElement(namespace, "line", "line");
+ this.xmlConsumer.characters(value.toCharArray(), 0, value.length());
+ this.xmlConsumer.endElement(namespace, "line", "line");
}
- ch.endElement(namespace, "value", "value");
+ this.xmlConsumer.endElement(namespace, "value", "value");
- addValue(ch, "size", String.valueOf(size) + " items in cache (" + empty + " are empty)");
- endGroup(ch);
+ addValue("size", String.valueOf(size) + " items in cache (" + empty + " are empty)");
+ endGroup();
}
// END Cache
// BEGIN OS info
- endGroup(ch);
+ endGroup();
+ }
+
+ private void genSettings() throws SAXException {
+ final Settings s = Core.getSettings(this.context);
+ this.startGroup("settings");
+
+ // FIXME add all
+ this.addValue(Settings.KEY_CONFIGURATION, s.getConfiguration());
+ this.addValue(Settings.KEY_CONFIGURATION_RELOAD_DELAY, String.valueOf(s.getConfigurationReloadDelay()));
+ this.endGroup();
}
/** Utility function to begin a <code>group</code> tag pair. */
- private void startGroup(ContentHandler ch, String name) throws SAXException {
- startGroup(ch, name, null);
+ private void startGroup(String name) throws SAXException {
+ startGroup(name, null);
}
/** Utility function to begin a <code>group</code> tag pair with added attributes. */
- private void startGroup(ContentHandler ch, String name, Attributes atts) throws SAXException {
+ private void startGroup(String name, Attributes atts) throws SAXException {
AttributesImpl ai = (atts == null) ? new AttributesImpl() : new AttributesImpl(atts);
ai.addAttribute(namespace, "name", "name", "CDATA", name);
- ch.startElement(namespace, "group", "group", ai);
+ this.xmlConsumer.startElement(namespace, "group", "group", ai);
}
/** Utility function to end a <code>group</code> tag pair. */
- private void endGroup(ContentHandler ch) throws SAXException {
- ch.endElement(namespace, "group", "group");
+ private void endGroup() throws SAXException {
+ this.xmlConsumer.endElement(namespace, "group", "group");
}
/** Utility function to begin and end a <code>value</code> tag pair. */
- private void addValue(ContentHandler ch, String name, String value) throws SAXException {
- addValue(ch, name, value, null);
+ private void addValue(String name, String value) throws SAXException {
+ addValue(name, value, null);
}
/** Utility function to begin and end a <code>value</code> tag pair with added attributes. */
- private void addValue(ContentHandler ch, String name, String value, Attributes atts) throws SAXException {
+ private void addValue(String name, String value, Attributes atts) throws SAXException {
AttributesImpl ai = (atts == null) ? new AttributesImpl() : new AttributesImpl(atts);
ai.addAttribute(namespace, "name", "name", "CDATA", name);
- ch.startElement(namespace, "value", "value", ai);
- ch.startElement(namespace, "line", "line", new AttributesImpl());
+ this.xmlConsumer.startElement(namespace, "value", "value", ai);
+ this.xmlConsumer.startElement(namespace, "line", "line", new AttributesImpl());
if (value != null) {
- ch.characters(value.toCharArray(), 0, value.length());
+ this.xmlConsumer.characters(value.toCharArray(), 0, value.length());
}
- ch.endElement(namespace, "line", "line");
- ch.endElement(namespace, "value", "value");
+ this.xmlConsumer.endElement(namespace, "line", "line");
+ this.xmlConsumer.endElement(namespace, "value", "value");
}
/** Utility function to begin and end a <code>value</code> tag pair. */
- private void addMultilineValue(ContentHandler ch, String name, List values) throws SAXException {
- addMultilineValue(ch, name, values, null);
+ private void addMultilineValue(String name, List values) throws SAXException {
+ addMultilineValue(name, values, null);
}
/** Utility function to begin and end a <code>value</code> tag pair with added attributes. */
- private void addMultilineValue(ContentHandler ch, String name, List values, Attributes atts) throws SAXException {
+ private void addMultilineValue(String name, List values, Attributes atts) throws SAXException {
AttributesImpl ai = (atts == null) ? new AttributesImpl() : new AttributesImpl(atts);
ai.addAttribute(namespace, "name", "name", "CDATA", name);
- ch.startElement(namespace, "value", "value", ai);
+ this.xmlConsumer.startElement(namespace, "value", "value", ai);
for (int i = 0; i < values.size(); i++) {
String value = (String) values.get(i);
if (value != null) {
- ch.startElement(namespace, "line", "line", new AttributesImpl());
- ch.characters(value.toCharArray(), 0, value.length());
- ch.endElement(namespace, "line", "line");
+ this.xmlConsumer.startElement(namespace, "line", "line", new AttributesImpl());
+ this.xmlConsumer.characters(value.toCharArray(), 0, value.length());
+ this.xmlConsumer.endElement(namespace, "line", "line");
}
}
- ch.endElement(namespace, "value", "value");
+ this.xmlConsumer.endElement(namespace, "value", "value");
}
}