我试图将自定义Ant侦听器连接到CometD,但是我得到了一个NPE,我期待一个通道句柄。这是一个代码段:
@Service
public class CometListener implements BuildListener {
@Inject
private BayeuxServer bayeuxServer;
@Session
private LocalSession sender;
private String _channelName;
private ServerChannel _channel = null;
public CometListener() {
_channelName = "/my/test";
}
@PostConstruct
private void initChannel() {
_channel = bayeuxServer.createChannelIfAbsent(_channelName).getReference();
}
public final void buildFinished(final BuildEvent finish) {
// Convert the Update business object to a CometD-friendly format
Map<String, Object> data = new HashMap<String, Object>(4);
data.put("status", 1);
_channel.publish(sender, data);
finish.getProject().log("buildFinished() called.", Project.MSG_ERR);
}
}
我以Using cometd in dropwizard为例,但建议的答案并没有解决问题。
提前感谢您的任何反馈。
答案 0 :(得分:0)
没关系,我需要一个Bayeux客户端,而不是服务器。