001/* 002 * GWTEventService 003 * Copyright (c) 2011 and beyond, strawbill UG (haftungsbeschr?nkt) 004 * 005 * This is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU Lesser General Public License as 007 * published by the Free Software Foundation; either version 3 of 008 * the License, or (at your option) any later version. 009 * Other licensing for GWTEventService may also be possible on request. 010 * Please view the license.txt of the project for more information. 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 */ 022package de.novanic.eventservice.client.logger; 023 024import java.util.Collection; 025import java.util.ArrayList; 026 027/** 028 * @author sstrohschein 029 * <br>Date: 21.10.2008 030 * <br>Time: 23:13:12 031 */ 032public abstract class AbstractClientLogger implements ClientLogger 033{ 034 private final Collection<ClientLogger> myAttachedLoggers; 035 036 protected AbstractClientLogger() { 037 myAttachedLoggers = new ArrayList<ClientLogger>(); 038 } 039 040 public void log(String aMessage) { 041 log_internal(aMessage); 042 for(ClientLogger theLogger: myAttachedLoggers) { 043 theLogger.log(aMessage); 044 } 045 } 046 047 public void error(String aMessage) { 048 error_internal(aMessage); 049 for(ClientLogger theLogger: myAttachedLoggers) { 050 theLogger.error(aMessage); 051 } 052 } 053 054 public void error(String aMessage, Throwable aThrowable) { 055 error_internal(aMessage, aThrowable); 056 for(ClientLogger theLogger: myAttachedLoggers) { 057 theLogger.error(aMessage, aThrowable); 058 } 059 } 060 061 public void attach(ClientLogger aClientLogger) { 062 myAttachedLoggers.add(aClientLogger); 063 } 064 065 public void detach(ClientLogger aClientLogger) { 066 myAttachedLoggers.remove(aClientLogger); 067 } 068 069 protected abstract void log_internal(String aMessage); 070 071 protected abstract void error_internal(String aMessage); 072 073 protected abstract void error_internal(String aMessage, Throwable aThrowable); 074}