本文整理汇总了Java中dk.dma.ais.bus.consumer.DistributerConsumer类的典型用法代码示例。如果您正苦于以下问题:Java DistributerConsumer类的具体用法?Java DistributerConsumer怎么用?Java DistributerConsumer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DistributerConsumer类属于dk.dma.ais.bus.consumer包,在下文中一共展示了DistributerConsumer类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startAisBus
import dk.dma.ais.bus.consumer.DistributerConsumer; //导入依赖的package包/类
private void startAisBus(Consumer<AisPacket> packetConsumer) {
LOG.debug("Starting AisBus");
try {
DistributerConsumer distributor = new DistributerConsumer();
distributor.getConsumers().add(packetConsumer);
distributor.init();
aisBus.registerConsumer(distributor);
aisBus.start();
aisBus.startConsumers();
aisBus.startProviders();
} catch (Exception e) {
LOG.error("Failed to start AisBus", e);
exit(-1);
}
LOG.debug("AisBus started");
}
示例2: AisView
import dk.dma.ais.bus.consumer.DistributerConsumer; //导入依赖的package包/类
private AisView(AisViewConfiguration conf) {
this.conf = conf;
// Create and start handler
handler = new AisViewHandler(conf);
handler.start();
// Create AisBus
aisBus = conf.getAisbusConfiguration().getInstance();
// Create web server
if (conf.getServerConfiguration() != null) {
webServer = new WebServer(conf.getServerConfiguration());
} else {
webServer = null;
}
// Create distributor consumer and add to aisBus
DistributerConsumer distributer = new DistributerConsumer();
distributer.getConsumers().add(handler);
distributer.init();
aisBus.registerConsumer(distributer);
}
示例3: AisCoverage
import dk.dma.ais.bus.consumer.DistributerConsumer; //导入依赖的package包/类
private AisCoverage(AisCoverageConfiguration conf) {
this.conf = conf;
// Create handler
handler = new CoverageHandler(conf);
// Create AisBus
aisBus = conf.getAisbusConfiguration().getInstance();
// Create web server
if (conf.getServerConfiguration() != null) {
webServer = new WebServer(conf.getServerConfiguration());
} else {
webServer = null;
}
final DistributerConsumer unfilteredConsumer = new DistributerConsumer(true);
unfilteredConsumer.init();
// Delegate unfiltered packets to handler
unfilteredConsumer.getConsumers().add(new Consumer<AisPacket>() {
@Override
public void accept(AisPacket packet) {
handler.receiveUnfiltered(packet);
}
});
aisBus.registerConsumer(unfilteredConsumer);
}
示例4: makeConfiguration
import dk.dma.ais.bus.consumer.DistributerConsumer; //导入依赖的package包/类
@Test
public void makeConfiguration() throws FileNotFoundException, JAXBException {
String filename = "src/main/resources/coverage-test.xml";
AisCoverageConfiguration conf = new AisCoverageConfiguration();
AisBusConfiguration aisBusConf = new AisBusConfiguration();
// Provider
TcpClientProviderConfiguration reader = new TcpClientProviderConfiguration();
reader.getHostPort().add("ais163.sealan.dk:65262");
aisBusConf.getProviders().add(reader);
// Unfiltered consumer
DistributerConsumerConfiguration unfilteredDist = new DistributerConsumerConfiguration();
unfilteredDist.setName("UNFILTERED");
aisBusConf.getConsumers().add(unfilteredDist);
// Filtered consumer
DistributerConsumerConfiguration filteredDist = new DistributerConsumerConfiguration();
filteredDist.setName("FILTERED");
DuplicateFilterConfiguration duplicateFilter = new DuplicateFilterConfiguration();
filteredDist.getFilters().add(duplicateFilter);
aisBusConf.getConsumers().add(filteredDist);
conf.setAisbusConfiguration(aisBusConf);
conf.setLatSize(1.5);
conf.setLonSize(1.5);
DatabaseConfiguration dbConf = new DatabaseConfiguration();
conf.setDatabaseConfiguration(dbConf);
// dbConf.set
// dbConf.setName("MongoDB");
// dbConf.setAddr("localhost");
// dbConf.setPort(9999);
// conf.setDatabase("MemoryOnly");
AisCoverageConfiguration.save(filename, conf);
conf = AisCoverageConfiguration.load(filename);
AisBus aisBus = conf.getAisbusConfiguration().getInstance();
DistributerConsumer filtered = (DistributerConsumer) aisBus.getConsumer("FILTERED");
Assert.assertNotNull(filtered);
DistributerConsumer unfiltered = (DistributerConsumer) aisBus.getConsumer("UNFILTERED");
Assert.assertNotNull(unfiltered);
}