001    /* 
002     * Copyright 2008-2009 the original author or authors.
003     * The contents of this file are subject to the Mozilla Public License
004     * Version 1.1 (the "License"); you may not use this file except in
005     * compliance with the License. You may obtain a copy of the License at
006     * http://www.mozilla.org/MPL/
007     *
008     * Software distributed under the License is distributed on an "AS IS"
009     * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
010     * License for the specific language governing rights and limitations
011     * under the License.
012     */
013     
014    package com.mtgi.analytics;
015    
016    import java.util.Queue;
017    
018    import org.apache.commons.logging.Log;
019    import org.apache.commons.logging.LogFactory;
020    
021    /**
022     * An event persister which discards all incoming events.  Intended for testing
023     * and diagnostic purposes only.
024     */
025    public class NullBehaviorEventPersisterImpl implements BehaviorEventPersister {
026    
027            private static final Log log = LogFactory.getLog(NullBehaviorEventPersisterImpl.class);
028            
029            public int persist(Queue<BehaviorEvent> events) {
030                    int count = events.size();
031                    events.clear();
032                    log.info("Discarded " + count + " events");
033                    return count;
034            }
035    
036    }