ovidiu 02/03/17 13:53:37
Modified: src/scratchpad/schecoon/src/org/apache/cocoon/components/flow
InterpreterSelector.java
Log:
Maintain the logger separate from the Cocoon sitemap one. Initialize
the created interpreters with the values obtained from the
Configuration object.
Revision Changes Path
1.4 +29 -1
xml-cocoon2/src/scratchpad/schecoon/src/org/apache/cocoon/components/flow/InterpreterSelector.java
Index: InterpreterSelector.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/scratchpad/schecoon/src/org/apache/cocoon/components/flow/InterpreterSelector.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- InterpreterSelector.java 15 Mar 2002 23:35:47 -0000 1.3
+++ InterpreterSelector.java 17 Mar 2002 21:53:37 -0000 1.4
@@ -1,28 +1,45 @@
package org.apache.cocoon.components.flow;
import org.apache.avalon.excalibur.component.ExcaliburComponentSelector;
+import org.apache.avalon.excalibur.logger.LogKitManageable;
+import org.apache.avalon.excalibur.logger.LogKitManager;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.Composable;
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.ParameterException;
import org.apache.avalon.framework.parameters.Parameterizable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.log.Logger;
public class InterpreterSelector extends ExcaliburComponentSelector
- implements Configurable, ThreadSafe, Composable
+ implements Configurable, ThreadSafe, Composable, LogKitManageable
{
+ LogKitManager logkit;
ComponentManager manager;
String defaultLanguage;
ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ public void setLogKitManager(LogKitManager logkit)
+ {
+ this.logkit = logkit;
+ }
+
public void configure(Configuration config)
throws ConfigurationException
{
defaultLanguage = config.getAttribute("default", null);
+ boolean reloadScripts = config.getAttributeAsBoolean("reload-scripts", false);
+ long checkTime = config.getAttributeAsLong("check-time", 1000L);
+ String loggerName = config.getAttribute("logger", null);
+ Logger loggerUsed = getLogger();
+ if (loggerName != null) {
+ loggerUsed = logkit.getLogger(loggerName);
+ }
Configuration[] components = config.getChildren("component-instance");
if (components.length == 0)
@@ -36,6 +53,17 @@
try {
clazz = loader.loadClass(className);
addComponent(name, clazz, component);
+
+ // Setup various configuration options on the scripting
+ // language Cocoon component
+ Interpreter interp = (Interpreter)this.select(name);
+ if (interp instanceof AbstractInterpreter) {
+ ((AbstractInterpreter)interp).setReloadScripts(reloadScripts);
+ ((AbstractInterpreter)interp).setCheckTime(checkTime);
+ }
+
+ if (interp instanceof Loggable)
+ ((Loggable)interp).setLogger(loggerUsed);
}
catch (Exception ex) {
throw new ConfigurationException("Cannot load class " + className);
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]