All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.yestech.event.guice.MulticasterBinder Maven / Gradle / Ivy

Go to download

Java Based Event framework that can be used with a Dependency Injection system or without. Currently Spring and Guice are supported. The Framework is pluggable with implementation that support direct routing and integration of apache camel to handle the routing of events.

The newest version!
/*
 * Copyright LGPL3
 * YES Technology Association
 * http://yestech.org
 *
 * http://www.opensource.org/licenses/lgpl-3.0.html
 */
package org.yestech.event.guice;

import com.google.inject.Binder;
import org.yestech.event.multicaster.IEventMulticaster;
import org.yestech.event.listener.IListener;
import org.yestech.event.multicaster.DefaultEventMulticaster;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 */
public class MulticasterBinder
{
    private DefaultEventMulticaster multicasterClass;
    private List list = new ArrayList();

    public MulticasterBinder(DefaultEventMulticaster multicasterClass) {

        this.multicasterClass = multicasterClass;
    }


    public void addListener(IListener listener) {
        list.add(listener);
    }

    @SuppressWarnings({"unchecked"})
    public void bind(Binder binder) {
        for (IListener listener : list)
        {
            binder.bind((Class) listener.getClass()).toInstance(listener);
        }
        binder.bind(IEventMulticaster.class).toInstance(multicasterClass);
        multicasterClass.setListeners(list);
        multicasterClass.init();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy