001    /*
002     * Version: $Revision: $
003     *
004     * Date: $Date: $
005     *
006     * Copyright (c) 2002-2009, The DSpace Foundation.  All rights reserved.
007     *
008     * Redistribution and use in source and binary forms, with or without
009     * modification, are permitted provided that the following conditions are
010     * met:
011     *
012     * - Redistributions of source code must retain the above copyright
013     * notice, this list of conditions and the following disclaimer.
014     *
015     * - Redistributions in binary form must reproduce the above copyright
016     * notice, this list of conditions and the following disclaimer in the
017     * documentation and/or other materials provided with the distribution.
018     *
019     * - Neither the name of the DSpace Foundation nor the names of its
020     * contributors may be used to endorse or promote products derived from
021     * this software without specific prior written permission.
022     *
023     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
024     * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
025     * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
026     * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
027     * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
028     * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
029     * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
030     * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
031     * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
032     * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
033     * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
034     * DAMAGE.
035     */
036    
037    package org.dspace.usage;
038    
039    import org.dspace.services.EventService;
040    import org.dspace.services.model.EventListener;
041    
042    /**
043     * AbstractUsageEventListener is used as the base class for listening events running
044     * in the EventService.
045     * 
046     * @author Mark Diggory (mdiggory at atmire.com)
047     * @version $Revision: $
048     */
049    public abstract class AbstractUsageEventListener implements EventListener {
050    
051            public AbstractUsageEventListener() {
052                    super();
053            }
054    
055            /**
056             * Empty String[] flags to have Listener 
057             * consume any event name prefixes.
058             */
059            public String[] getEventNamePrefixes() {
060                    return new String[0];
061            }
062    
063            /**
064             * Currently consumes events generated for
065             * all resources.
066             */
067            public String getResourcePrefix() {
068                    return null;
069            }
070    
071            public void setEventService(EventService service) throws Exception {
072                    if(service != null)
073                            service.registerEventListener(this);
074                    else
075                            throw new RuntimeException("EventService handed to Listener cannot be null");
076            
077            }
078            
079    }