mwomack     2005/02/21 21:24:54

  Modified:    src/java/org/apache/log4j/joran/action Action.java
                        RepositoryPropertyAction.java
  Log:
  Moved getLoggerRepository to base Action class so it can be used by all 
subclasses.  Centralizes logic for locating the LoggerRepository being acted 
upon.
  
  Revision  Changes    Path
  1.3       +20 -0     
logging-log4j/src/java/org/apache/log4j/joran/action/Action.java
  
  Index: Action.java
  ===================================================================
  RCS file: 
/home/cvs/logging-log4j/src/java/org/apache/log4j/joran/action/Action.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Action.java       13 Jan 2005 16:12:26 -0000      1.2
  +++ Action.java       22 Feb 2005 05:24:54 -0000      1.3
  @@ -20,6 +20,8 @@
   import org.apache.log4j.joran.spi.ExecutionContext;
   import org.apache.log4j.joran.spi.Interpreter;
   import org.apache.log4j.spi.ComponentBase;
  +import org.apache.log4j.spi.LoggerRepository;
  +import org.apache.log4j.spi.ErrorItem;
   
   import org.xml.sax.Attributes;
   import org.xml.sax.Locator;
  @@ -79,4 +81,22 @@
       }
       return -1;
     }
  +  
  +  /**
  +   * Helper method to return the LoggerRepository of the  execution context.
  +   *
  +   * @param ec The ExecutionContext that contains the reference to the
  +   *   LoggerRepository
  +   * @return The LoggerRepository
  +   */
  +  protected LoggerRepository getLoggerRepository(ExecutionContext ec) {
  +    Object o = ec.getObject(0);
  +    if(o instanceof LoggerRepository) {
  +      return (LoggerRepository) o;
  +    } else {
  +      String errMsg = "There is no LoggerRepository at the top of the object 
stack.";
  +      ec.addError(new ErrorItem(errMsg));
  +      throw new IllegalStateException(errMsg);
  +    }
  +  }
   }
  
  
  
  1.5       +0 -11     
logging-log4j/src/java/org/apache/log4j/joran/action/RepositoryPropertyAction.java
  
  Index: RepositoryPropertyAction.java
  ===================================================================
  RCS file: 
/home/cvs/logging-log4j/src/java/org/apache/log4j/joran/action/RepositoryPropertyAction.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RepositoryPropertyAction.java     12 Jan 2005 15:04:18 -0000      1.4
  +++ RepositoryPropertyAction.java     22 Feb 2005 05:24:54 -0000      1.5
  @@ -28,17 +28,6 @@
    * Window>Preferences>Java>Code Generation>Code and Comments
    */
   public class RepositoryPropertyAction extends PropertyAction {
  -
  -  LoggerRepository getLoggerRepository(ExecutionContext ec) {
  -    Object o = ec.getObjectStack().get(0);
  -    if(o instanceof LoggerRepository) {
  -      return (LoggerRepository) o;
  -    } else {
  -      String errMsg = "There is no LoggerRepository at the top of the object 
stack.";
  -      ec.addError(new ErrorItem(errMsg));
  -      throw new IllegalStateException(errMsg);
  -    }
  -  }
     
     public void setProperties(ExecutionContext ec, Properties props) {
       LoggerRepository repository = getLoggerRepository(ec);
  
  
  

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

Reply via email to