MvnForumEventManager.java :  » Forum » mvnforum-1.1 » com » mvnforum » event » Java Open Source

Java Open Source » Forum » mvnforum 1.1 
mvnforum 1.1 » com » mvnforum » event » MvnForumEventManager.java
/*
 * $Header: /cvsroot/mvnforum/mvnforum/src/com/mvnforum/event/MvnForumEventManager.java,v 1.3 2007/12/17 09:09:41 minhnn Exp $
 * $Author: minhnn $
 * $Revision: 1.3 $
 * $Date: 2007/12/17 09:09:41 $
 *
 * ====================================================================
 *
 * Copyright (C) 2002-2007 by MyVietnam.net
 *
 * All copyright notices regarding mvnForum MUST remain
 * intact in the scripts and in the outputted HTML.
 * The "powered by" text/logo with a link back to
 * http://www.mvnForum.com and http://www.MyVietnam.net in
 * the footer of the pages MUST remain visible when the pages
 * are viewed on the internet or intranet.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Support can be obtained from support forums at:
 * http://www.mvnForum.com/mvnforum/index
 *
 * Correspondence and Marketing Questions can be sent to:
 * info at MyVietnam net
 *
 * @author: Minh Nguyen
 * @author: Mai  Nguyen
 */
package com.mvnforum.event;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class MvnForumEventManager {

    //static variable
    private static MvnForumEventManager instance = new MvnForumEventManager();

    private transient Collection eventListeners;

    private MvnForumEventManager() {
        eventListeners = new ArrayList();
    }

    public static MvnForumEventManager getInstance() {
        return instance;
    }

    /************************************************************************
     * Event method
     ************************************************************************/
    public synchronized void removeMvnForumEventListener(MvnForumEventListener listener) {
        eventListeners.remove(listener);
    }

    public synchronized void addMvnForumEventListener(MvnForumEventListener listener) {
        System.out.println("MvnForumEventManager.addMvnForumEventListener()");
        eventListeners.add(listener);
    }

    public void firePreLogin(MvnForumEvent e) {
        for (Iterator iterator = eventListeners.iterator(); iterator.hasNext(); ) {
            ((MvnForumEventListener) iterator.next()).onPreLogin(e);
        }
    }

    public void firePostLogin(MvnForumEvent e) {
        for (Iterator iterator = eventListeners.iterator(); iterator.hasNext(); ) {
            ((MvnForumEventListener) iterator.next()).onPostLogin(e);
        }
    }

    public void firePreLogout(MvnForumEvent e) {
        System.out.println("MvnForumEventManager.firePreLogout() " + eventListeners.size());
        for (Iterator iterator = eventListeners.iterator(); iterator.hasNext(); ) {
            ((MvnForumEventListener) iterator.next()).onPreLogout(e);
        }
    }

    public void firePostLogout(MvnForumEvent e) {
        for (Iterator iterator = eventListeners.iterator(); iterator.hasNext(); ) {
            ((MvnForumEventListener) iterator.next()).onPostLogout(e);
        }
    }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.