Moved inner classes out to top level classes for easier testing

This commit is contained in:
Trustin Lee 2008-08-25 10:16:56 +00:00
parent b4d84ce73b
commit 4f276cf52e
10 changed files with 482 additions and 273 deletions

View File

@ -0,0 +1,94 @@
/*
* JBoss, Home of Professional Open Source
*
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
* by the @author tags. See the COPYRIGHT.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.netty.logging;
import org.apache.commons.logging.Log;
/**
* @author The Netty Project (netty-dev@lists.jboss.org)
* @author Trustin Lee (tlee@redhat.com)
*
* @version $Rev$, $Date$
*
*/
class CommonsLogger implements InternalLogger {
private final Log logger;
CommonsLogger(Log logger) {
this.logger = logger;
}
public void debug(String msg) {
logger.debug(msg);
}
public void debug(String msg, Throwable cause) {
logger.debug(msg, cause);
}
public void error(String msg) {
logger.error(msg);
}
public void error(String msg, Throwable cause) {
logger.error(msg, cause);
}
public void info(String msg) {
logger.info(msg);
}
public void info(String msg, Throwable cause) {
logger.info(msg, cause);
}
public boolean isDebugEnabled() {
return logger.isDebugEnabled();
}
public boolean isErrorEnabled() {
return logger.isErrorEnabled();
}
public boolean isInfoEnabled() {
return logger.isInfoEnabled();
}
public boolean isWarnEnabled() {
return logger.isWarnEnabled();
}
public void warn(String msg) {
logger.warn(msg);
}
public void warn(String msg, Throwable cause) {
logger.warn(msg, cause);
}
@Override
public String toString() {
return logger.toString();
}
}

View File

@ -23,6 +23,7 @@
package org.jboss.netty.logging;
/**
* Logger factory which creates an
* <a href="http://commons.apache.org/logging/">Apache Commons Logging</a>
@ -40,59 +41,6 @@ public class CommonsLoggerFactory extends InternalLoggerFactory {
public InternalLogger newInstance(String name) {
final org.apache.commons.logging.Log logger =
org.apache.commons.logging.LogFactory.getLog(name);
return new InternalLogger() {
public void debug(String msg) {
logger.debug(msg);
}
public void debug(String msg, Throwable cause) {
logger.debug(msg, cause);
}
public void error(String msg) {
logger.error(msg);
}
public void error(String msg, Throwable cause) {
logger.error(msg, cause);
}
public void info(String msg) {
logger.info(msg);
}
public void info(String msg, Throwable cause) {
logger.info(msg, cause);
}
public boolean isDebugEnabled() {
return logger.isDebugEnabled();
}
public boolean isErrorEnabled() {
return logger.isErrorEnabled();
}
public boolean isInfoEnabled() {
return logger.isInfoEnabled();
}
public boolean isWarnEnabled() {
return logger.isWarnEnabled();
}
public void warn(String msg) {
logger.warn(msg);
}
public void warn(String msg, Throwable cause) {
logger.warn(msg, cause);
}
@Override
public String toString() {
return logger.toString();
}
};
return new CommonsLogger(logger);
}
}

View File

@ -0,0 +1,96 @@
/*
* JBoss, Home of Professional Open Source
*
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
* by the @author tags. See the COPYRIGHT.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.netty.logging;
import org.jboss.logging.Logger;
/**
* @author The Netty Project (netty-dev@lists.jboss.org)
* @author Trustin Lee (tlee@redhat.com)
*
* @version $Rev$, $Date$
*
*/
class JBossLogger implements InternalLogger {
private final Logger logger;
JBossLogger(Logger logger) {
this.logger = logger;
}
public void debug(String msg) {
logger.debug(msg);
}
public void debug(String msg, Throwable cause) {
logger.debug(msg, cause);
}
public void error(String msg) {
logger.error(msg);
}
public void error(String msg, Throwable cause) {
logger.error(msg, cause);
}
public void info(String msg) {
logger.info(msg);
}
public void info(String msg, Throwable cause) {
logger.info(msg, cause);
}
@SuppressWarnings("deprecation")
public boolean isDebugEnabled() {
return logger.isDebugEnabled();
}
public boolean isErrorEnabled() {
return true;
}
@SuppressWarnings("deprecation")
public boolean isInfoEnabled() {
return logger.isInfoEnabled();
}
public boolean isWarnEnabled() {
return true;
}
public void warn(String msg) {
logger.warn(msg);
}
public void warn(String msg, Throwable cause) {
logger.warn(msg, cause);
}
@Override
public String toString() {
return String.valueOf(logger.getName());
}
}

View File

@ -23,6 +23,7 @@
package org.jboss.netty.logging;
/**
* Logger factory which creates a
* <a href="http://anonsvn.jboss.org/repos/common/common-logging-spi/">JBoss Logging</a>
@ -40,61 +41,6 @@ public class JBossLoggerFactory extends InternalLoggerFactory {
public InternalLogger newInstance(String name) {
final org.jboss.logging.Logger logger =
org.jboss.logging.Logger.getLogger(name);
return new InternalLogger() {
public void debug(String msg) {
logger.debug(msg);
}
public void debug(String msg, Throwable cause) {
logger.debug(msg, cause);
}
public void error(String msg) {
logger.error(msg);
}
public void error(String msg, Throwable cause) {
logger.error(msg, cause);
}
public void info(String msg) {
logger.info(msg);
}
public void info(String msg, Throwable cause) {
logger.info(msg, cause);
}
@SuppressWarnings("deprecation")
public boolean isDebugEnabled() {
return logger.isDebugEnabled();
}
public boolean isErrorEnabled() {
return true;
}
@SuppressWarnings("deprecation")
public boolean isInfoEnabled() {
return logger.isInfoEnabled();
}
public boolean isWarnEnabled() {
return true;
}
public void warn(String msg) {
logger.warn(msg);
}
public void warn(String msg, Throwable cause) {
logger.warn(msg, cause);
}
@Override
public String toString() {
return String.valueOf(logger.getName());
}
};
return new JBossLogger(logger);
}
}

View File

@ -0,0 +1,95 @@
/*
* JBoss, Home of Professional Open Source
*
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
* by the @author tags. See the COPYRIGHT.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.netty.logging;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* @author The Netty Project (netty-dev@lists.jboss.org)
* @author Trustin Lee (tlee@redhat.com)
*
* @version $Rev$, $Date$
*
*/
class JdkLogger implements InternalLogger {
private final Logger logger;
JdkLogger(Logger logger) {
this.logger = logger;
}
public void debug(String msg) {
logger.log(Level.FINE, msg);
}
public void debug(String msg, Throwable cause) {
logger.log(Level.FINE, msg, cause);
}
public void error(String msg) {
logger.log(Level.SEVERE, msg);
}
public void error(String msg, Throwable cause) {
logger.log(Level.SEVERE, msg, cause);
}
public void info(String msg) {
logger.log(Level.INFO, msg);
}
public void info(String msg, Throwable cause) {
logger.log(Level.INFO, msg, cause);
}
public boolean isDebugEnabled() {
return logger.isLoggable(Level.FINE);
}
public boolean isErrorEnabled() {
return logger.isLoggable(Level.SEVERE);
}
public boolean isInfoEnabled() {
return logger.isLoggable(Level.INFO);
}
public boolean isWarnEnabled() {
return logger.isLoggable(Level.WARNING);
}
public void warn(String msg) {
logger.log(Level.WARNING, msg);
}
public void warn(String msg, Throwable cause) {
logger.log(Level.WARNING, msg, cause);
}
@Override
public String toString() {
return String.valueOf(logger.getName());
}
}

View File

@ -22,7 +22,6 @@
*/
package org.jboss.netty.logging;
import java.util.logging.Level;
/**
* Logger factory which creates a
@ -41,59 +40,6 @@ public class JdkLoggerFactory extends InternalLoggerFactory {
public InternalLogger newInstance(String name) {
final java.util.logging.Logger logger =
java.util.logging.Logger.getLogger(name);
return new InternalLogger() {
public void debug(String msg) {
logger.log(Level.FINE, msg);
}
public void debug(String msg, Throwable cause) {
logger.log(Level.FINE, msg, cause);
}
public void error(String msg) {
logger.log(Level.SEVERE, msg);
}
public void error(String msg, Throwable cause) {
logger.log(Level.SEVERE, msg, cause);
}
public void info(String msg) {
logger.log(Level.INFO, msg);
}
public void info(String msg, Throwable cause) {
logger.log(Level.INFO, msg, cause);
}
public boolean isDebugEnabled() {
return logger.isLoggable(Level.FINE);
}
public boolean isErrorEnabled() {
return logger.isLoggable(Level.SEVERE);
}
public boolean isInfoEnabled() {
return logger.isLoggable(Level.INFO);
}
public boolean isWarnEnabled() {
return logger.isLoggable(Level.WARNING);
}
public void warn(String msg) {
logger.log(Level.WARNING, msg);
}
public void warn(String msg, Throwable cause) {
logger.log(Level.WARNING, msg, cause);
}
@Override
public String toString() {
return String.valueOf(logger.getName());
}
};
return new JdkLogger(logger);
}
}

View File

@ -0,0 +1,94 @@
/*
* JBoss, Home of Professional Open Source
*
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
* by the @author tags. See the COPYRIGHT.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.netty.logging;
import org.apache.log4j.Logger;
/**
* @author The Netty Project (netty-dev@lists.jboss.org)
* @author Trustin Lee (tlee@redhat.com)
*
* @version $Rev$, $Date$
*
*/
class Log4JLogger implements InternalLogger {
private final Logger logger;
Log4JLogger(Logger logger) {
this.logger = logger;
}
public void debug(String msg) {
logger.debug(msg);
}
public void debug(String msg, Throwable cause) {
logger.debug(msg, cause);
}
public void error(String msg) {
logger.error(msg);
}
public void error(String msg, Throwable cause) {
logger.error(msg, cause);
}
public void info(String msg) {
logger.info(msg);
}
public void info(String msg, Throwable cause) {
logger.info(msg, cause);
}
public boolean isDebugEnabled() {
return logger.isDebugEnabled();
}
public boolean isErrorEnabled() {
return true;
}
public boolean isInfoEnabled() {
return logger.isInfoEnabled();
}
public boolean isWarnEnabled() {
return true;
}
public void warn(String msg) {
logger.warn(msg);
}
public void warn(String msg, Throwable cause) {
logger.warn(msg, cause);
}
@Override
public String toString() {
return String.valueOf(logger.getName());
}
}

View File

@ -23,6 +23,7 @@
package org.jboss.netty.logging;
/**
* Logger factory which creates an
* <a href="http://logging.apache.org/log4j/1.2/index.html">Apache Log4J</a>
@ -40,59 +41,6 @@ public class Log4JLoggerFactory extends InternalLoggerFactory {
public InternalLogger newInstance(String name) {
final org.apache.log4j.Logger logger =
org.apache.log4j.Logger.getLogger(name);
return new InternalLogger() {
public void debug(String msg) {
logger.debug(msg);
}
public void debug(String msg, Throwable cause) {
logger.debug(msg, cause);
}
public void error(String msg) {
logger.error(msg);
}
public void error(String msg, Throwable cause) {
logger.error(msg, cause);
}
public void info(String msg) {
logger.info(msg);
}
public void info(String msg, Throwable cause) {
logger.info(msg, cause);
}
public boolean isDebugEnabled() {
return logger.isDebugEnabled();
}
public boolean isErrorEnabled() {
return true;
}
public boolean isInfoEnabled() {
return logger.isInfoEnabled();
}
public boolean isWarnEnabled() {
return true;
}
public void warn(String msg) {
logger.warn(msg);
}
public void warn(String msg, Throwable cause) {
logger.warn(msg, cause);
}
@Override
public String toString() {
return String.valueOf(logger.getName());
}
};
return new Log4JLogger(logger);
}
}

View File

@ -0,0 +1,94 @@
/*
* JBoss, Home of Professional Open Source
*
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
* by the @author tags. See the COPYRIGHT.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.netty.logging;
import org.slf4j.Logger;
/**
* @author The Netty Project (netty-dev@lists.jboss.org)
* @author Trustin Lee (tlee@redhat.com)
*
* @version $Rev$, $Date$
*
*/
class Slf4JLogger implements InternalLogger {
private final Logger logger;
Slf4JLogger(Logger logger) {
this.logger = logger;
}
public void debug(String msg) {
logger.debug(msg);
}
public void debug(String msg, Throwable cause) {
logger.debug(msg, cause);
}
public void error(String msg) {
logger.error(msg);
}
public void error(String msg, Throwable cause) {
logger.error(msg, cause);
}
public void info(String msg) {
logger.info(msg);
}
public void info(String msg, Throwable cause) {
logger.info(msg, cause);
}
public boolean isDebugEnabled() {
return logger.isDebugEnabled();
}
public boolean isErrorEnabled() {
return logger.isErrorEnabled();
}
public boolean isInfoEnabled() {
return logger.isInfoEnabled();
}
public boolean isWarnEnabled() {
return logger.isWarnEnabled();
}
public void warn(String msg) {
logger.warn(msg);
}
public void warn(String msg, Throwable cause) {
logger.warn(msg, cause);
}
@Override
public String toString() {
return String.valueOf(logger.getName());
}
}

View File

@ -23,6 +23,7 @@
package org.jboss.netty.logging;
/**
* Logger factory which creates a <a href="http://www.slf4j.org/">SLF4J</a>
* logger.
@ -39,59 +40,6 @@ public class Slf4JLoggerFactory extends InternalLoggerFactory {
public InternalLogger newInstance(String name) {
final org.slf4j.Logger logger =
org.slf4j.LoggerFactory.getLogger(name);
return new InternalLogger() {
public void debug(String msg) {
logger.debug(msg);
}
public void debug(String msg, Throwable cause) {
logger.debug(msg, cause);
}
public void error(String msg) {
logger.error(msg);
}
public void error(String msg, Throwable cause) {
logger.error(msg, cause);
}
public void info(String msg) {
logger.info(msg);
}
public void info(String msg, Throwable cause) {
logger.info(msg, cause);
}
public boolean isDebugEnabled() {
return logger.isDebugEnabled();
}
public boolean isErrorEnabled() {
return logger.isErrorEnabled();
}
public boolean isInfoEnabled() {
return logger.isInfoEnabled();
}
public boolean isWarnEnabled() {
return logger.isWarnEnabled();
}
public void warn(String msg) {
logger.warn(msg);
}
public void warn(String msg, Throwable cause) {
logger.warn(msg, cause);
}
@Override
public String toString() {
return String.valueOf(logger.getName());
}
};
return new Slf4JLogger(logger);
}
}