ceki        2004/11/17 09:28:00

  Modified:    src/java/org/apache/joran ExecutionContext.java
                        Interpreter.java ErrorItem.java
               src/java/org/apache/joran/helper SimpleRuleStore.java
               src/java/org/apache/joran/action ParamAction.java
                        NestComponentIA.java ImplicitAction.java
                        Action.java
  Removed:     src/java/org/apache/joran joran-specs.html
  Log:
  LogLog to Logger
  
  Revision  Changes    Path
  1.11      +13 -21    
logging-log4j/src/java/org/apache/joran/ExecutionContext.java
  
  Index: ExecutionContext.java
  ===================================================================
  RCS file: 
/home/cvs/logging-log4j/src/java/org/apache/joran/ExecutionContext.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ExecutionContext.java     20 May 2004 11:49:07 -0000      1.10
  +++ ExecutionContext.java     17 Nov 2004 17:28:00 -0000      1.11
  @@ -16,10 +16,9 @@
   
   package org.apache.joran;
   
  -import org.apache.log4j.Logger;
  -import org.apache.log4j.helpers.LogLog;
  -import org.apache.log4j.helpers.OptionConverter;
  +//import org.apache.log4j.helpers.OptionConverter;
   
  +import org.apache.log4j.helpers.OptionConverter;
   import org.xml.sax.Locator;
   
   import java.util.HashMap;
  @@ -32,11 +31,13 @@
   
   /**
    *
  - * Joran is designed to parse DOM trees
  - *
  + * The ExecutionContext contains the contextual state of a Joran parsing 
  + * session. [EMAIL PROTECTED] Action Actions} depend on this context to 
exchange and
  + * storeinformation.
  + *  
  + * @author Ceki Gülcü
    */
   public class ExecutionContext {
  -  static final Logger logger = Logger.getLogger(ExecutionContext.class);
     Stack objectStack;
     HashMap objectMap;
     Vector errorList;
  @@ -117,11 +118,11 @@
       if(key == null || value == null) {
         return;
       }
  -    if (substitutionProperties.contains(key)) {
  -      LogLog.warn(
  -        "key [" + key
  -        + "] already contained in the EC properties. Overwriting.");
  -    }
  +//    if (substitutionProperties.contains(key)) {
  +//      LogLog.warn(
  +//        "key [" + key
  +//        + "] already contained in the EC properties. Overwriting.");
  +//    }
   
       // values with leading or trailing spaces are bad. We remove them now.
       value = value.trim();
  @@ -135,7 +136,6 @@
       Iterator i = props.keySet().iterator();
       while(i.hasNext()) {
         String key = (String) i.next();
  -      LogLog.debug("Adding property ["+key+"="+props.getProperty(key)+"]");
         addProperty(key, props.getProperty(key));
       }
     }
  @@ -148,14 +148,6 @@
       if(value == null) {
         return null;
       }
  -    try {
  -      return OptionConverter.substVars(value, substitutionProperties);
  -    } catch (IllegalArgumentException e) {
  -      logger.warn(
  -        "Could not perform variable substitution for variable [" + value + 
"]",
  -        e);
  -
  -      return value;
  -    }
  +    return OptionConverter.substVars(value, substitutionProperties);
     }
   }
  
  
  
  1.15      +0 -3      logging-log4j/src/java/org/apache/joran/Interpreter.java
  
  Index: Interpreter.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/joran/Interpreter.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Interpreter.java  16 Nov 2004 20:29:44 -0000      1.14
  +++ Interpreter.java  17 Nov 2004 17:28:00 -0000      1.15
  @@ -17,8 +17,6 @@
   package org.apache.joran;
   
   import org.apache.joran.action.*;
  -//import org.apache.log4j.Logger;
  -//mport org.apache.log4j.helpers.LogLog;
   
   import org.xml.sax.Attributes;
   import org.xml.sax.EntityResolver;
  @@ -66,7 +64,6 @@
    *
    */
   public class Interpreter extends DefaultHandler {
  -  //static final Logger logger = Logger.getLogger(Interpreter.class);
     private static List EMPTY_LIST = new Vector(0);
     private RuleStore ruleStore;
     private ExecutionContext ec;
  
  
  
  1.3       +0 -3      logging-log4j/src/java/org/apache/joran/ErrorItem.java
  
  Index: ErrorItem.java
  ===================================================================
  RCS file: /home/cvs/logging-log4j/src/java/org/apache/joran/ErrorItem.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ErrorItem.java    9 Apr 2004 14:03:48 -0000       1.2
  +++ ErrorItem.java    17 Nov 2004 17:28:00 -0000      1.3
  @@ -18,9 +18,6 @@
   
   /**
    * @author ceki
  - *
  - * To change the template for this generated type comment go to
  - * Window>Preferences>Java>Code Generation>Code and Comments
    */
   public class ErrorItem {
     String message;
  
  
  
  1.3       +3 -7      
logging-log4j/src/java/org/apache/joran/helper/SimpleRuleStore.java
  
  Index: SimpleRuleStore.java
  ===================================================================
  RCS file: 
/home/cvs/logging-log4j/src/java/org/apache/joran/helper/SimpleRuleStore.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SimpleRuleStore.java      28 May 2004 14:49:38 -0000      1.2
  +++ SimpleRuleStore.java      17 Nov 2004 17:28:00 -0000      1.3
  @@ -20,7 +20,6 @@
   import org.apache.joran.RuleStore;
   import org.apache.joran.action.*;
   
  -import org.apache.log4j.Logger;
   import org.apache.log4j.helpers.OptionConverter;
   
   import java.util.ArrayList;
  @@ -30,7 +29,6 @@
   
   
   public class SimpleRuleStore implements RuleStore {
  -  final static Logger logger = Logger.getLogger(SimpleRuleStore.class);
   
     // key: Pattern instance, value: ArrayList containing actions
     HashMap rules = new HashMap();
  @@ -52,11 +50,9 @@
         (Action) OptionConverter.instantiateByClassName(
           actionClassName, Action.class, null);
   
  -    if (action != null) {
  -      addRule(pattern, action);
  -    } else {
  -      logger.warn("Could not intantiate Action of class 
["+actionClassName+"].");
  -    }
  +      if(action != null) {
  +        addRule(pattern, action);
  +      }
     }
   
     public List matchActions(Pattern pattern) {
  
  
  
  1.12      +47 -31    
logging-log4j/src/java/org/apache/joran/action/ParamAction.java
  
  Index: ParamAction.java
  ===================================================================
  RCS file: 
/home/cvs/logging-log4j/src/java/org/apache/joran/action/ParamAction.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- ParamAction.java  6 Jun 2004 12:06:03 -0000       1.11
  +++ ParamAction.java  17 Nov 2004 17:28:00 -0000      1.12
  @@ -1,3 +1,19 @@
  +/*
  + * Copyright 1999,2004 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.
  + * You may obtain a copy of the License at
  + *
  + *      http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
   package org.apache.joran.action;
   
   import org.apache.joran.ErrorItem;
  @@ -5,49 +21,49 @@
   
   import org.apache.log4j.Logger;
   import org.apache.log4j.config.PropertySetter;
  -import org.apache.log4j.helpers.LogLog;
   import org.apache.log4j.helpers.OptionConverter;
  +
   import org.xml.sax.Attributes;
   
  +
   public class ParamAction extends Action {
  +  static final Logger logger = Logger.getLogger(ParamAction.class);
  +  static String NO_NAME = "No name attribute in <param> element";
  +  static String NO_VALUE = "No name attribute in <param> element";
  +  boolean inError = false;
   
  -  final static Logger logger = Logger.getLogger(ParamAction.class);
  +  public void begin(
  +    ExecutionContext ec, String localName, Attributes attributes) {
  +    String name = attributes.getValue(NAME_ATTRIBUTE);
  +    String value = attributes.getValue(VALUE_ATTRIBUTE);
  +
  +    if (name == null) {
  +      inError = true;
  +      logger.error(NO_NAME);
  +      ec.addError(new ErrorItem(NO_NAME));
  +      return;
  +    }
   
  -     static String NO_NAME = "No name attribute in <param> element";
  -     static String NO_VALUE = "No name attribute in <param> element";
  -  
  -  boolean inError = false;
  -  
  -  public void begin(ExecutionContext ec, String localName, Attributes 
attributes) {
  -             String name = attributes.getValue(NAME_ATTRIBUTE);
  -             String value = attributes.getValue(VALUE_ATTRIBUTE);
  -
  -    if(name==null) {
  -                     inError = true;
  -                     logger.error(NO_NAME);
  -                     ec.addError(new ErrorItem(NO_NAME));    
  -     return;
  +    if (value == null) {
  +      inError = true;
  +      logger.error(NO_VALUE);
  +      ec.addError(new ErrorItem(NO_VALUE));
  +      return;
       }
   
  -             if(value==null) {
  -                     inError = true;
  -                     logger.error(NO_VALUE);
  -                     ec.addError(new ErrorItem(NO_VALUE));   
  -                     return;
  -             }
  -    
       // remove both leading and trailing spaces
       value = value.trim();
  -    
  -             Object o = ec.peekObject();
  -             PropertySetter propSetter = new PropertySetter(o);              
  -             value = ec.subst(OptionConverter.convertSpecialChars(value));
  -    
  +
  +    Object o = ec.peekObject();
  +    PropertySetter propSetter = new PropertySetter(o);
  +    value = ec.subst(OptionConverter.convertSpecialChars(value));
  +
       // allow for variable substitution for name as well
       name = ec.subst(name);
  -    
  -    LogLog.debug("In ParamAction setting parameter ["+name+"] to value 
["+value+"].");
  -             propSetter.setProperty(name, value);
  +
  +    getLogger().debug(
  +      "In ParamAction setting parameter [{}] to value [{}].", name, value);
  +    propSetter.setProperty(name, value);
     }
   
     public void end(ExecutionContext ec, String localName) {
  
  
  
  1.12      +12 -19    
logging-log4j/src/java/org/apache/joran/action/NestComponentIA.java
  
  Index: NestComponentIA.java
  ===================================================================
  RCS file: 
/home/cvs/logging-log4j/src/java/org/apache/joran/action/NestComponentIA.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- NestComponentIA.java      18 May 2004 16:50:43 -0000      1.11
  +++ NestComponentIA.java      17 Nov 2004 17:28:00 -0000      1.12
  @@ -24,7 +24,6 @@
   import org.apache.log4j.Logger;
   import org.apache.log4j.config.PropertySetter;
   import org.apache.log4j.helpers.Loader;
  -import org.apache.log4j.helpers.LogLog;
   import org.apache.log4j.spi.OptionHandler;
   
   import org.xml.sax.Attributes;
  @@ -51,7 +50,6 @@
     public boolean isApplicable(
       Pattern pattern, Attributes attributes, ExecutionContext ec) {
       //LogLog.debug("in NestComponentIA.isApplicable <" + pattern + ">");
  -
       String nestedElementTagName = pattern.peekLast();
   
       Object o = ec.peekObject();
  @@ -66,17 +64,14 @@
       // we only push action data if NestComponentIA is applicable
       case PropertySetter.AS_COLLECTION:
       case PropertySetter.AS_PROPERTY:
  -
         ActionData ad = new ActionData(parentBean, containmentType);
         actionDataStack.push(ad);
   
         return true;
  -
       default:
         ec.addError(
           new ErrorItem(
             "PropertySetter.canContainComponent returned " + containmentType));
  -
         return false;
       }
     }
  @@ -84,7 +79,6 @@
     public void begin(
       ExecutionContext ec, String localName, Attributes attributes) {
       //LogLog.debug("in NestComponentIA begin method");
  -
       // get the action data object pushed in isApplicable() method call
       ActionData actionData = (ActionData) actionDataStack.peek();
   
  @@ -104,20 +98,20 @@
       }
   
       try {
  -      LogLog.debug(
  -        "About to instantiate component <" + localName + "> of type ["
  -        + className + "]");
  +      getLogger().debug(
  +        "About to instantiate component <{}> of type [{}]", localName,
  +        className);
   
         actionData.nestedComponent = Loader.loadClass(className).newInstance();
   
  -      LogLog.debug(
  -        "Pushing component <" + localName + "> on top of the object stack.");
  +      getLogger().debug(
  +        "Pushing component <{}> on top of the object stack.", localName);
         ec.pushObject(actionData.nestedComponent);
       } catch (Exception oops) {
         actionData.inError = true;
   
         String msg = "Could not create component <" + localName + ">.";
  -      LogLog.error(msg, oops);
  +      getLogger().error(msg, oops);
         ec.addError(new ErrorItem(msg));
       }
     }
  @@ -149,18 +143,17 @@
         // Now let us attach the component
         switch (actionData.containmentType) {
         case PropertySetter.AS_PROPERTY:
  -        LogLog.debug(
  -          "Setting [" + tagName + "] to parent of type ["
  -          + actionData.parentBean.getObjClass() + "]");
  +        getLogger().debug(
  +          "Setting [{}] to parent of type [{}]", tagName,
  +          actionData.parentBean.getObjClass());
           actionData.parentBean.setComponent(
             tagName, actionData.nestedComponent);
   
           break;
  -
         case PropertySetter.AS_COLLECTION:
  -        LogLog.debug(
  -          "Adding [" + tagName + "] to parent of type ["
  -          + actionData.parentBean.getObjClass() + "]");
  +        getLogger().debug(
  +          "Adding [{}] to parent of type [{}]", tagName,
  +          actionData.parentBean.getObjClass());
           actionData.parentBean.addComponent(
             tagName, actionData.nestedComponent);
   
  
  
  
  1.5       +2 -0      
logging-log4j/src/java/org/apache/joran/action/ImplicitAction.java
  
  Index: ImplicitAction.java
  ===================================================================
  RCS file: 
/home/cvs/logging-log4j/src/java/org/apache/joran/action/ImplicitAction.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ImplicitAction.java       10 Apr 2004 13:49:00 -0000      1.4
  +++ ImplicitAction.java       17 Nov 2004 17:28:00 -0000      1.5
  @@ -45,4 +45,6 @@
      */
     public abstract boolean isApplicable(
       Pattern currentPattern, Attributes attributes, ExecutionContext ec);
  +  
  +  
   }
  
  
  
  1.16      +26 -5     
logging-log4j/src/java/org/apache/joran/action/Action.java
  
  Index: Action.java
  ===================================================================
  RCS file: 
/home/cvs/logging-log4j/src/java/org/apache/joran/action/Action.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Action.java       18 May 2004 16:50:43 -0000      1.15
  +++ Action.java       17 Nov 2004 17:28:00 -0000      1.16
  @@ -18,6 +18,9 @@
   
   import org.apache.joran.ExecutionContext;
   import org.apache.joran.Interpreter;
  +import org.apache.log4j.LogManager;
  +import org.apache.log4j.Logger;
  +
   import org.xml.sax.Attributes;
   import org.xml.sax.Locator;
   
  @@ -44,6 +47,11 @@
     public static final String PATTERN_ATTRIBUTE = "pattern";
     public static final String ACTION_CLASS_ATTRIBUTE = "actionClass";
   
  +  /*
  +   * An inststance specific logger. 
  +   */
  +  private Logger logger;
  +  
     /**
      * Called when the parser first encounters an element.
      *
  @@ -56,26 +64,39 @@
     public abstract void end(ExecutionContext ec, String name);
   
     //public abstract void finish(ExecutionContext ec);
  -
     public String toString() {
       return this.getClass().getName();
     }
  -  
  +
     protected int getColumnNumber(ExecutionContext ec) {
       Interpreter jp = ec.getJoranInterpreter();
       Locator locator = jp.getLocator();
  -    if(locator != null) {
  +    if (locator != null) {
         return locator.getColumnNumber();
       }
       return -1;
     }
  -  
  +
     protected int getLineNumber(ExecutionContext ec) {
       Interpreter jp = ec.getJoranInterpreter();
       Locator locator = jp.getLocator();
  -    if(locator != null) {
  +    if (locator != null) {
         return locator.getLineNumber();
       }
       return -1;
  +  }
  +  
  +  /**
  +   * Return an instance specifi logger to be used by the Action itself.
  +   * This logger is not intended to be used by Mrs. Piggy, our proverbial 
user,
  +   * hence the protected keyword.
  +   * 
  +   * @return instance specific logger
  +   */
  +  protected Logger getLogger() {
  +    if(logger == null) {
  +      logger = LogManager.getLogger(this.getClass().getName());
  +    }
  +    return logger;
     }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to