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/03/03 19:13:25 UTC
svn commit: r156063 - in cocoon/trunk/src:
blocks/databases/java/org/apache/cocoon/acting/
core/java/org/apache/cocoon/components/
core/java/org/apache/cocoon/core/container/
Author: cziegeler
Date: Thu Mar 3 10:13:23 2005
New Revision: 156063
URL: http://svn.apache.org/viewcvs?view=rev&rev=156063
Log:
Add logging configuration to ComponentInfo
Modified:
cocoon/trunk/src/blocks/databases/java/org/apache/cocoon/acting/DatabaseCookieAuthenticatorAction.java
cocoon/trunk/src/core/java/org/apache/cocoon/components/ComponentInfo.java
cocoon/trunk/src/core/java/org/apache/cocoon/core/container/ComponentFactory.java
cocoon/trunk/src/core/java/org/apache/cocoon/core/container/RoleManager.java
Modified: cocoon/trunk/src/blocks/databases/java/org/apache/cocoon/acting/DatabaseCookieAuthenticatorAction.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/databases/java/org/apache/cocoon/acting/DatabaseCookieAuthenticatorAction.java?view=diff&r1=156062&r2=156063
==============================================================================
--- cocoon/trunk/src/blocks/databases/java/org/apache/cocoon/acting/DatabaseCookieAuthenticatorAction.java (original)
+++ cocoon/trunk/src/blocks/databases/java/org/apache/cocoon/acting/DatabaseCookieAuthenticatorAction.java Thu Mar 3 10:13:23 2005
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.cocoon.environment.Cookie;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.Request;
Modified: cocoon/trunk/src/core/java/org/apache/cocoon/components/ComponentInfo.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/core/java/org/apache/cocoon/components/ComponentInfo.java?view=diff&r1=156062&r2=156063
==============================================================================
--- cocoon/trunk/src/core/java/org/apache/cocoon/components/ComponentInfo.java (original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/components/ComponentInfo.java Thu Mar 3 10:13:23 2005
@@ -29,131 +29,142 @@
public static final int MODEL_SINGLETON = 1;
public static final int MODEL_POOLED = 2;
public static final int MODEL_NON_THREAD_SAFE_POOLED = 3;
-
+
public static final String TYPE_SINGLETON = "singleton";
public static final String TYPE_POOLED = "pooled";
public static final String TYPE_NON_THREAD_SAFE_POOLED = "non-thread-safe-pooled";
+ public static final int LOGGING_SYSTEM_LOGKIT = 0;
+ public static final int LOGGING_SYSTEM_LOG4J = 1;
+ public static final int LOGGING_SYSTEM_COMMONSLOGGING = 2;
+
+ public static final String LOGGING_LOGKIT = "logkit";
+ public static final String LOGGING_LOG4J = "log4j";
+ public static final String LOGGING_COMMONSLOGGING = "commons";
+
private int model;
+ private int loggingSystem;
private String initMethodName;
private String destroyMethodName;
private String poolInMethodName;
private String poolOutMethodName;
private String serviceClassName;
private Configuration configuration;
-
+ private String loggerCategory;
+
public ComponentInfo() {
this.model = MODEL_PRIMITIVE;
}
-
+
/**
* @return Returns the model.
*/
public int getModel() {
return model;
}
-
+
/**
* @param model The model to set.
*/
public void setModel(int model) {
this.model = model;
}
-
+
/**
* @return Returns the destroyMethod.
*/
public String getDestroyMethodName() {
return destroyMethodName;
}
-
+
/**
* @param destroyMethod The destroyMethod to set.
*/
public void setDestroyMethodName(String destroyMethod) {
this.destroyMethodName = destroyMethod;
}
-
+
/**
* @return Returns the initMethod.
*/
public String getInitMethodName() {
return initMethodName;
}
-
+
/**
* @param initMethod The initMethod to set.
*/
public void setInitMethodName(String initMethod) {
this.initMethodName = initMethod;
}
-
+
/**
* @return Returns the poolInMethodName
*/
public String getPoolInMethodName() {
return this.poolInMethodName;
}
-
+
/**
* @param poolMethod The poolInMethod name to set.
*/
public void setPoolInMethodName(String poolMethod) {
this.poolInMethodName = poolMethod;
}
-
+
/**
* @return Returns the poolOutMethodName
*/
public String getPoolOutMethodName() {
return this.poolOutMethodName;
}
-
+
/**
* @param poolMethod The poolOutMethod name to set.
*/
public void setPoolOutMethodName(String poolMethod) {
this.poolOutMethodName = poolMethod;
}
-
+
/**
* @return Returns the serviceClassName.
*/
public String getServiceClassName() {
return serviceClassName;
}
-
+
/**
* @param serviceClassName The serviceClassName to set.
*/
public void setServiceClassName(String serviceClassName) {
this.serviceClassName = serviceClassName;
}
-
+
/**
* @return Returns the configuration.
*/
public Configuration getConfiguration() {
return configuration;
}
+
/**
* @param configuration The configuration to set.
*/
public void setConfiguration(Configuration configuration) {
this.configuration = configuration;
}
-
+
public String getLocation() {
return this.configuration.getLocation();
}
-
+
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString() {
return "ServiceInfo: {class=" + this.getServiceClassName()+"}";
}
-
+
public void fill(Configuration attr) {
// test model
final String model = attr.getAttribute("model", null);
@@ -168,10 +179,21 @@
} else if ( TYPE_SINGLETON.equals(model) ) {
this.setModel(ComponentInfo.MODEL_SINGLETON);
}
+ // init/destroy methods
this.setInitMethodName(attr.getAttribute("init", null));
this.setDestroyMethodName(attr.getAttribute("destroy", null));
+ // logging
+ this.setLoggerCategory(attr.getAttribute("logger", null));
+ final String logSystem = attr.getAttribute("logging", LOGGING_LOGKIT);
+ if ( LOGGING_LOG4J.equals(logSystem) ) {
+ this.setLoggingSystem(LOGGING_SYSTEM_LOG4J);
+ } else if (LOGGING_COMMONSLOGGING.equals(logSystem)) {
+ this.setLoggingSystem(LOGGING_SYSTEM_LOGKIT);
+ } else if ( LOGGING_LOGKIT.equals(logSystem) ) {
+ this.setLoggingSystem(LOGGING_SYSTEM_COMMONSLOGGING);
+ }
}
-
+
public ComponentInfo duplicate() {
ComponentInfo info = new ComponentInfo();
info.model = this.model;
@@ -181,7 +203,37 @@
info.poolOutMethodName = this.poolOutMethodName;
info.serviceClassName = this.serviceClassName;
info.configuration = this.configuration;
+ info.loggerCategory = this.loggerCategory;
+ info.loggingSystem = this.loggingSystem;
return info;
+ }
+
+ /**
+ * @return Returns the loggerCategory.
+ */
+ public String getLoggerCategory() {
+ return this.loggerCategory;
+ }
+
+ /**
+ * @param loggerCategory The loggerCategory to set.
+ */
+ public void setLoggerCategory(String loggerCategory) {
+ this.loggerCategory = loggerCategory;
+ }
+
+ /**
+ * @return Returns the loggingSystem.
+ */
+ public int getLoggingSystem() {
+ return this.loggingSystem;
+ }
+
+ /**
+ * @param loggingSystem The loggingSystem to set.
+ */
+ public void setLoggingSystem(int loggingSystem) {
+ this.loggingSystem = loggingSystem;
}
}
Modified: cocoon/trunk/src/core/java/org/apache/cocoon/core/container/ComponentFactory.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/core/java/org/apache/cocoon/core/container/ComponentFactory.java?view=diff&r1=156062&r2=156063
==============================================================================
--- cocoon/trunk/src/core/java/org/apache/cocoon/core/container/ComponentFactory.java (original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/core/container/ComponentFactory.java Thu Mar 3 10:13:23 2005
@@ -43,7 +43,7 @@
/** The parameters for this component
*/
- protected Parameters parameters;
+ protected final Parameters parameters;
protected final Class serviceClass;
protected final Method initMethod;
@@ -54,10 +54,8 @@
/**
* Construct a new component factory for the specified component.
*
- * @param componentClass the class to instantiate (must have a default constructor).
- * @param configuration the <code>Configuration</code> object to pass to new instances.
- * @param seerviceManager the service manager to pass to <code>Serviceable</code>s.
- * @param context the <code>Context</code> to pass to <code>Contexutalizable</code>s.
+ * @param environment Describes the environment for the component.
+ * @param info Describes the configuration/settings for the component.
*
*/
public ComponentFactory( final ComponentEnvironment environment,
@@ -66,17 +64,30 @@
this.environment = environment;
this.serviceInfo = info;
+ // this is our default logger:
Logger actualLogger = this.environment.logger;
- // If the handler is created "manually" (e.g. XSP engine), loggerManager can be null
- if( this.environment.loggerManager != null && this.serviceInfo.getConfiguration() != null) {
- final String category = this.serviceInfo.getConfiguration().getAttribute("logger", null);
- if (category != null) {
- actualLogger = this.environment.loggerManager.getLoggerForCategory(category);
+ final String category = this.serviceInfo.getLoggerCategory();
+ if ( category != null ) {
+ if ( info.getLoggingSystem() == ComponentInfo.LOGGING_SYSTEM_LOGKIT ) {
+ // If the handler is created "manually" (e.g. XSP engine), loggerManager can be null
+ if( this.environment.loggerManager != null ) {
+ actualLogger = this.environment.loggerManager.getLoggerForCategory(category);
+ }
+ } else if ( info.getLoggingSystem() == ComponentInfo.LOGGING_SYSTEM_LOG4J ) {
+ // FIXME - activate me
+ // actualLogger = new Log4JLogger(org.apache.log4j.Logger.getLogger(category));
+ } else if ( info.getLoggingSystem() == ComponentInfo.LOGGING_SYSTEM_COMMONSLOGGING ) {
+ // FIXME - we don't have a wrapper for this
}
}
this.componentLogger = actualLogger;
this.serviceClass = this.environment.loadClass(this.serviceInfo.getServiceClassName());
+ if ( Parameterizable.class.isAssignableFrom(this.serviceClass) ) {
+ this.parameters = Parameters.fromConfiguration( this.serviceInfo.getConfiguration() );
+ } else {
+ this.parameters = null;
+ }
if ( this.serviceInfo.getDestroyMethodName() != null ) {
this.destroyMethod = this.serviceClass.getMethod(this.serviceInfo.getDestroyMethodName(), null);
} else {
@@ -127,9 +138,6 @@
ContainerUtil.configure( component, this.serviceInfo.getConfiguration() );
if( component instanceof Parameterizable ) {
- if ( this.parameters == null ) {
- this.parameters = Parameters.fromConfiguration( this.serviceInfo.getConfiguration() );
- }
ContainerUtil.parameterize( component, this.parameters );
}
Modified: cocoon/trunk/src/core/java/org/apache/cocoon/core/container/RoleManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/core/java/org/apache/cocoon/core/container/RoleManager.java?view=diff&r1=156062&r2=156063
==============================================================================
--- cocoon/trunk/src/core/java/org/apache/cocoon/core/container/RoleManager.java (original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/core/container/RoleManager.java Thu Mar 3 10:13:23 2005
@@ -36,13 +36,13 @@
implements Configurable {
/** Map for shorthand to role mapping */
- private Map shorthands = new HashMap();
+ private final Map shorthands = new HashMap();
/** Map for role to default classname mapping */
- private Map classNames = new HashMap();
+ private final Map classNames = new HashMap();
/** Map for role->key to classname mapping */
- private Map keyClassNames = new HashMap();
+ private final Map keyClassNames = new HashMap();
/** Parent role manager for nested resolution */
private final RoleManager parent;
@@ -200,7 +200,7 @@
throw new ConfigurationException("Invalid redeclaration: default class already set to " + info.getServiceClassName() +
" for role " + roleName + " at " + role.getLocation());
}
- //FIXME: should check also other ServiceInfo members, but they're currently not used
+ //FIXME: should check also other ServiceInfo members
}
}
@@ -236,7 +236,7 @@
throw new ConfigurationException("Invalid redeclaration: class already set to " + info.getServiceClassName() +
" for hint " + shortHand + " at " + key.getLocation());
}
- //FIXME: should check also other ServiceInfo members, but they're currently not used
+ //FIXME: should check also other ServiceInfo members
}
}
}