Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Logback: the reliable, generic, fast and flexible logging framework. Copyright (C) 1999-2011, QOS.ch. All rights reserved. This program and the accompanying materials are dual-licensed under either the terms of the Eclipse Public License v1.0 as published by the Eclipse Foundation or (per the licensee's choosing) under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation.
 
 package ch.qos.logback.core.spi;
 
A helper class that implements ContextAware methods. Use this class to implement the ContextAware interface by composition.

Author(s):
Ceki Gülcü
 
 public class ContextAwareImpl implements ContextAware {
 
   private int noContextWarning = 0;
   protected Context context;
   final Object origin;
   
   public ContextAwareImpl(Object origin) {
     this. = origin;
   }
   
   protected Object getOrigin() {
     return ;
   }
   
   public void setContext(Context context) {
     if (this. == null) {
       this. = context;
     } else if (this. != context) {
       throw new IllegalStateException("Context has been already set");
     }
   }
 
   public Context getContext() {
     return this.;
   }
 
   public StatusManager getStatusManager() {
     if ( == null) {
       return null;
     }
     return .getStatusManager();
   }
 
   public void addStatus(Status status) {
     if ( == null) {
       if (++ == 0) {
         ..println("LOGBACK: No context given for " + this);
       }
       return;
     }
     if (sm != null) {
       sm.add(status);
     }
   }
 
   public void addInfo(String msg) {
     addStatus(new InfoStatus(msggetOrigin()));
   }
 
   public void addInfo(String msgThrowable ex) {
     addStatus(new InfoStatus(msggetOrigin(), ex));
   }
 
   public void addWarn(String msg) {
     addStatus(new WarnStatus(msggetOrigin()));
   }
 
   public void addWarn(String msgThrowable ex) {
     addStatus(new WarnStatus(msggetOrigin(), ex));
   }
 
   public void addError(String msg) {
     addStatus(new ErrorStatus(msggetOrigin()));
   }
 
   public void addError(String msgThrowable ex) {
     addStatus(new ErrorStatus(msggetOrigin(), ex));
   }
 
New to GrepCode? Check out our FAQ X