logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ceki Gülcü <c...@qos.ch>
Subject Re: cvs commit: logging-log4j/src/java/org/apache/joran/action NestComponentIA.java
Date Wed, 05 Jan 2005 19:54:17 GMT
At 08:28 PM 1/5/2005, you wrote:
>Instead of
>>          actionData.nestedComponent = 
>> Loader.loadClass(className).newInstance();
>>   -
>>   +      if(actionData.nestedComponent instanceof Component) {
>>   +        ((Component) 
>> actionData.nestedComponent).setLoggerRepository(this.repository);
>>   +      }
>Could you do something like:
>actionData.nestedComponent = this.repository.createComponent(className);

that does not look too difficult:

public class Hierarchy implements LoggerRepository {

   public Object createComponent(String className) {

     Object o  = Loader.loadClass(className).newInstance();

      if(o instanceof Component) {
        ((Component) o).setLoggerRepository(this);


The only major issue with this approach occurs when the repository is
null, the repository.createComponent(className) call would bomb while
ActionBase.getLogger() would return valid ULogger even when the
repository is not set (i.e. null).

My basic working assumption has been that owning repository is allowed
to be left blank. To be honest, I am quite happy with the current
approach. It is well aligned with the current component initialization
pattern prevalent in log4j code, that is:

   Component c = new Component();

This pattern has the advantage of malleability. It has proven to be
highly tolerant of future extensions. Having said that, I welcome any
suggestions for objective improvements.

Ceki Gülcü

   The complete log4j manual: http://www.qos.ch/log4j/

To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org

View raw message