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    /**
019     * Stores instances of {@link BehaviorEvent} to a behavior tracking database.
020     */
021    public interface BehaviorEventPersister {
022            /**
023             * Drain the given event queue, persisting all instances to the
024             * database.  Persisters must support the persisting of child events
025             * before their parents, since this is generally the natural order
026             * in which events are completed.  This method returns when the queue 
027             * is empty.
028             * @return the number of persisted events
029             */
030            public int persist(Queue<BehaviorEvent> events);
031    }