
it.nergrid.got.edc.TopicThread Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of edc-connector Show documentation
Show all versions of edc-connector Show documentation
Bauer's stand-alone connector to the Everywhare Cloud
package it.nergrid.got.edc;
import javax.inject.Inject;
import it.netgrid.bauer.EventHandler;
import it.netgrid.bauer.Topic;
import it.netgrid.got.edc.events.ErrorEvent;
import it.netgrid.got.edc.events.MessageFromBauer;
import it.netgrid.got.edc.events.MessageToBauer;
public class TopicThread implements Runnable {
private ECTopic ecTopic;
private Topic sendTopic;
private Topic receiveTopic;
private Topic errorTopic;
private String topic;
@Inject
public TopicThread(String topic, Topic sendTopic, Topic receiveTopic,
Topic errorTopic, ECTopic ecTopic) {
this.sendTopic = sendTopic;
this.receiveTopic = receiveTopic;
this.errorTopic = errorTopic;
this.topic = topic;
this.ecTopic = ecTopic;
}
@Override
public void run() {
// aggiunge l'handler per bauer
if(receiveTopic.getName()!=null){
receiveTopic.addHandler(new EventHandler() {
@Override
public Class getEventClass() {
return MessageFromBauer.class;
}
@Override
public String getName() {
return receiveTopic.getName();
}
@Override
public boolean handle(MessageFromBauer event) {
if (ecTopic.publish(topic, event)) {
return true;
} else {
errorTopic.post(new ErrorEvent(topic, "publish failed"));
}
return true;
}
});
}
}
// metodo per aggiungere il riferimento a Topic nella
// Map di ECTopic
public Topic getSendTopic() {
return sendTopic;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy