001: /*
002: * JBoss, Home of Professional Open Source
003: * Copyright 2005, JBoss Inc., and individual contributors as indicated
004: * by the @authors tag. See the copyright.txt in the distribution for a
005: * full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jbpm.persistence.db;
023:
024: import java.io.Serializable;
025:
026: import org.apache.commons.logging.Log;
027: import org.apache.commons.logging.LogFactory;
028:
029: public abstract class StaleObjectLogConfigurer {
030:
031: private static Log log = LogFactory
032: .getLog(StaleObjectLogConfigurer.class);
033: public static Log staleObjectExceptionsLog = LogFactory
034: .getLog(StaleObjectLogConfigurer.class.getName()
035: + ".staleObjectExceptions");
036:
037: public static void hideStaleObjectExceptions() {
038: try {
039: staleObjectExceptionsLog = wrap(staleObjectExceptionsLog);
040: log
041: .info("stale object exceptions will be hidden from logging");
042: } catch (Exception e) {
043: log
044: .info("couldn't hide stale object exceptions from logging");
045: }
046: }
047:
048: private static Log wrap(Log log) {
049: return new LogWrapper(log);
050: }
051:
052: public static class LogWrapper implements Log, Serializable {
053: private static final long serialVersionUID = 1L;
054: Log delegate;
055:
056: public LogWrapper(Log delegate) {
057: this .delegate = delegate;
058: }
059:
060: public void debug(Object arg0, Throwable arg1) {
061: }
062:
063: public void debug(Object arg0) {
064: }
065:
066: public void error(Object arg0, Throwable arg1) {
067: }
068:
069: public void error(Object arg0) {
070: }
071:
072: public void info(Object arg0, Throwable arg1) {
073: }
074:
075: public void info(Object arg0) {
076: }
077:
078: public void trace(Object arg0, Throwable arg1) {
079: }
080:
081: public void trace(Object arg0) {
082: }
083:
084: public void warn(Object arg0, Throwable arg1) {
085: }
086:
087: public void warn(Object arg0) {
088: }
089:
090: public void fatal(Object arg0, Throwable arg1) {
091: delegate.fatal(arg0, arg1);
092: }
093:
094: public void fatal(Object arg0) {
095: delegate.fatal(arg0);
096: }
097:
098: public boolean isDebugEnabled() {
099: return delegate.isDebugEnabled();
100: }
101:
102: public boolean isErrorEnabled() {
103: return false;
104: }
105:
106: public boolean isFatalEnabled() {
107: return delegate.isFatalEnabled();
108: }
109:
110: public boolean isInfoEnabled() {
111: return false;
112: }
113:
114: public boolean isTraceEnabled() {
115: return false;
116: }
117:
118: public boolean isWarnEnabled() {
119: return false;
120: }
121: }
122: }
|