com.github.jy2.commandline.picocli.topic.TopicEchoCommand Maven / Gradle / Ivy
package com.github.jy2.commandline.picocli.topic;
import java.util.function.Consumer;
import com.github.jy2.Subscriber;
import com.github.jy2.commandline.picocli.Main;
import com.github.jy2.commandline.picocli.topic.completion.TopicNameCompletionCandidates;
import com.github.jy2.introspection.TopicInfo;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.Parameters;
import picocli.CommandLine.ParentCommand;
@Command(name = "echo", description = "Print list of topics")
public class TopicEchoCommand implements Runnable {
@ParentCommand
TopicCommand parent;
@Parameters(index = "0", description = "Name of the topic", completionCandidates = TopicNameCompletionCandidates.class)
String topicName;
@Option(names = { "--grep" }, description = "Character sequence to be expected in serialized message content")
String grep;
public static Subscriber subscriber = null;
public void run() {
System.out.println("Subscribed to topic: " + topicName);
System.out.println("Press Crtl-C to stop");
// Class type = Main.introspector.getTopicType(topicName);
// TopicInfo ti = Main.introspector.getTopicInfo(topicName);
// if (ti.reportedJavaType != null) {
// try {
// ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
// if (classLoader != null) {
// type = Class.forName(ti.reportedJavaType, false, classLoader);
// } else {
// type = Class.forName(ti.reportedJavaType);
// }
// } catch (ClassNotFoundException e) {
// e.printStackTrace();
// }
// }
// subscriber = Main.di.createSubscriber(topicName, type, 5, 50);
subscriber = Main.di.createSubscriber(topicName, null, 5, 50);
subscriber.addMessageListener(new Consumer
© 2015 - 2024 Weber Informatics LLC | Privacy Policy