001 package com.agilejava.blammo; 002 003 /* 004 * Copyright (C) 2006, Wilfred Springer 005 * 006 * This library is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 2.1 of the License, or (at your option) any later version. 010 * 011 * This library is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public 017 * License along with this library; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 019 */ 020 021 /** 022 * The interface to be implemented by Blammo loggers, allowing us to plug in a 023 * certain kind of {@link LoggingKitAdapter} to facilitate a particular way of 024 * logging. 025 * 026 * @author Wilfred Springer 027 * 028 */ 029 public interface BlammoLogger { 030 031 /** 032 * Sets the {@link LoggingKitAdapter} to be used by this logger. 033 * 034 * @param log 035 */ 036 void setLoggingKitAdapter(LoggingKitAdapter log); 037 038 /** 039 * Sets an interceptor for the events. Whereas {@link LoggingKitAdapter}s 040 * are expected to <em>always</em> log the event, interceptors can decide 041 * wether the event should be logged at all. Events are identified by id. 042 */ 043 void setInterceptor(Interceptor interceptor); 044 045 public interface Interceptor { 046 047 /** 048 * Intercepts the event, and decides if it should be processed any 049 * further. 050 * 051 * @param eventId The identifier of the event, if it exists. (Could be 052 * <code>null</code>.) 053 * @param cl The class generating the event. 054 * @param method The method generating the event. 055 * @return A boolean indicating if this event should be accepted for 056 * further processing. 057 */ 058 boolean accepts(String eventId, Class cl, String method); 059 060 } 061 062 public class DefaultInterceptor implements Interceptor { 063 064 public boolean accepts(String eventId, Class cl, String method) { 065 return true; 066 } 067 068 } 069 070 }