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

it.netgrid.bauer.helpers.EventRecordingTopic Maven / Gradle / Ivy

There is a newer version: 1.1.6
Show newest version
package it.netgrid.bauer.helpers;

import java.util.Queue;

import it.netgrid.bauer.EventHandler;
import it.netgrid.bauer.Topic;
import it.netgrid.bauer.helpers.SubstituteTopicEvent.Action;

public class EventRecordingTopic implements Topic {
	
    String name;
    SubstituteTopic topic;
    Queue eventQueue;

    public EventRecordingTopic(SubstituteTopic topic, Queue eventQueue) {
        this.topic = topic;
        this.name = topic.getName();
        this.eventQueue = eventQueue;
    }

    public String getName() {
        return name;
    }

	@Override
	public void addHandler(EventHandler handler) {
		SubstituteTopicEvent qEvent = new SubstituteTopicEvent(topic, Action.ADD_HANDLER, null, handler);
		this.eventQueue.add(qEvent);
	}

	@Override
	public void post(E event) {
		SubstituteTopicEvent qEvent = new SubstituteTopicEvent(topic, Action.POST, event, null);
		this.eventQueue.add(qEvent);
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy