1 package org.jmux.app.component; 2 3 import org.jmux.app.App; 4 import org.jmux.app.component.config.Config; 5 import org.jmux.app.component.jmx.Access; 6 import org.jmux.app.component.jmx.JMX; 7 import org.slf4j.Logger; 8 import org.slf4j.LoggerFactory; 9 10 /****************************************************************************** 11 jmux - Java Modules Using XML 12 Copyright © 2006 jmux.org 13 14 This library is free software; you can redistribute it and/or 15 modify it under the terms of the GNU Lesser General Public 16 License as published by the Free Software Foundation; either 17 version 2.1 of the License, or (at your option) any later version. 18 19 This library is distributed in the hope that it will be useful, 20 but WITHOUT ANY WARRANTY; without even the implied warranty of 21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 Lesser General Public License for more details. 23 24 You should have received a copy of the GNU Lesser General Public 25 License along with this library; if not, write to the Free Software 26 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 27 *****************************************************************************/ 28 29 /*** 30 * @author donaldw 31 */ 32 public abstract class AbstractComponent implements Component { 33 @JMX(Access.READ) 34 private final String className = this.getClass().getName(); 35 private final Logger logger = LoggerFactory.getLogger(className); 36 37 private Config config; 38 39 public void configure(Config config, App app) { 40 this.config = config; 41 } 42 43 protected Config getConfig() { 44 return this.config; 45 } 46 47 protected void logDebug(String message) { 48 logger.debug(message); 49 } 50 51 protected void logDebug(String message, Throwable throwable) { 52 logger.debug(message, throwable); 53 } 54 55 protected void log(String message) { 56 logger.info(message); 57 } 58 59 protected void logError(String message, Throwable throwable) { 60 logger.error(message, throwable); 61 } 62 63 protected void logError(String message) { 64 logger.error(message); 65 } 66 }