本文整理汇总了Java中org.omg.dds.sub.DataReader类的典型用法代码示例。如果您正苦于以下问题:Java DataReader类的具体用法?Java DataReader怎么用?Java DataReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataReader类属于org.omg.dds.sub包,在下文中一共展示了DataReader类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.omg.dds.sub.DataReader; //导入依赖的package包/类
public static void main(String[] args) {
final Topic<TopTenHashtagsType> topic = VConfig.DefaultEntities.defaultDomainParticipant().createTopic("TopTenHashtags", TopTenHashtagsType.class);
final DataReader<TopTenHashtagsType> reader = VConfig.DefaultEntities.defaultSub().createDataReader(topic);
reader.setListener(new DataReaderListener<TopTenHashtagsType>() {
@Override
public void onRequestedDeadlineMissed(RequestedDeadlineMissedEvent<TopTenHashtagsType> requestedDeadlineMissedEvent) {
}
@Override
public void onRequestedIncompatibleQos(RequestedIncompatibleQosEvent<TopTenHashtagsType> requestedIncompatibleQosEvent) {
}
@Override
public void onSampleRejected(SampleRejectedEvent<TopTenHashtagsType> sampleRejectedEvent) {
}
@Override
public void onLivelinessChanged(LivelinessChangedEvent<TopTenHashtagsType> livelinessChangedEvent) {
}
@Override
public void onDataAvailable(DataAvailableEvent<TopTenHashtagsType> data) {
final Sample.Iterator<TopTenHashtagsType> samples = reader.take();
if (samples != null) {
while (samples.hasNext()) {
final Sample<TopTenHashtagsType> next = samples.next();
final TopTenHashtagsType hashtags = next.getData();
if (hashtags != null) {
StringBuilder sb = new StringBuilder("\nTop 10 hashtags: ");
sb.append(hashtags.filter).append("\n");
for (int i = 0; i < hashtags.hashtag.length; i++) {
sb.append(i).append(". (");
sb.append(hashtags.count[i]).append(", ").append(hashtags.hashtag[i]);
sb.append(")\n");
}
System.out.println(sb.toString());
}
}
}
}
@Override
public void onSubscriptionMatched(SubscriptionMatchedEvent<TopTenHashtagsType> subscriptionMatchedEvent) {
}
@Override
public void onSampleLost(SampleLostEvent<TopTenHashtagsType> sampleLostEvent) {
}
});
}
示例2: onStart
import org.omg.dds.sub.DataReader; //导入依赖的package包/类
@Override
public void onStart() {
final TypeSupport<TYPE> typeSupport = TypeSupport.newTypeSupport(topicType, topicRegType, VConfig.ENV);
final Durability durability = defaultPolicyFactory().Durability().withPersistent();
final DurabilityService durabilityService = defaultPolicyFactory().DurabilityService()
.withHistoryDepth(DS_HISTORY)
.withServiceCleanupDelay(DS_CLEAN_UP_DELAY, TimeUnit.SECONDS)
.withHistoryKind(History.Kind.KEEP_LAST)
.withMaxInstances(DS_MAX_INSTANCES)
.withMaxSamples(DS_MAX_SAMPLES)
.withMaxSamplesPerInstance(DS_MAX_SAMPLES_X_INSTANCE);
final TopicQos topicQos = defaultDomainParticipant().getDefaultTopicQos()
.withPolicy(durability)
.withPolicy(durabilityService);
final History history = defaultPolicyFactory().History().withKeepLast(100 * 2);
final DataReaderQos drQos = defaultSub().getDefaultDataReaderQos().withPolicy(history);
final Topic<TYPE> topic =
defaultDomainParticipant().createTopic(topicName, typeSupport, topicQos, null, (Collection<Class<? extends Status>>) null);
dr = defaultSub().createDataReader(topic, drQos);
dr.setListener(new BaseDataReaderListener<TYPE>() {
@Override
public void onDataAvailable(DataAvailableEvent<TYPE> dataAvailableEvent) {
final DataReader.Selector<TYPE> selector = dr.select();
selector.dataState(selector.getDataState().with(SampleState.NOT_READ));
final Sample.Iterator<TYPE> samples = dr.take(selector);
try {
while (samples.hasNext()) {
final Sample<TYPE> sample = samples.next();
TYPE data = sample.getData();
if (data != null) {
VortexReceiver.this.store(data);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
示例3: SubscriptionMatchedEvent
import org.omg.dds.sub.DataReader; //导入依赖的package包/类
protected SubscriptionMatchedEvent(DataReader<TYPE> source) {
super(source);
}
示例4: SampleRejectedEvent
import org.omg.dds.sub.DataReader; //导入依赖的package包/类
protected SampleRejectedEvent(DataReader<TYPE> source) {
super(source);
}
示例5: RequestedDeadlineMissedEvent
import org.omg.dds.sub.DataReader; //导入依赖的package包/类
protected RequestedDeadlineMissedEvent(DataReader<TYPE> source) {
super(source);
}
示例6: LivelinessChangedEvent
import org.omg.dds.sub.DataReader; //导入依赖的package包/类
protected LivelinessChangedEvent(DataReader<TYPE> source) {
super(source);
}
示例7: RequestedIncompatibleQosEvent
import org.omg.dds.sub.DataReader; //导入依赖的package包/类
protected RequestedIncompatibleQosEvent(DataReader<TYPE> source) {
super(source);
}
示例8: SampleLostEvent
import org.omg.dds.sub.DataReader; //导入依赖的package包/类
protected SampleLostEvent(DataReader<TYPE> source) {
super(source);
}
示例9: DataAvailableEvent
import org.omg.dds.sub.DataReader; //导入依赖的package包/类
protected DataAvailableEvent(DataReader<TYPE> source) {
super(source);
}
示例10: getRequestDataReader
import org.omg.dds.sub.DataReader; //导入依赖的package包/类
public DataReader<TReq> getRequestDataReader();
示例11: getReplyDataReader
import org.omg.dds.sub.DataReader; //导入依赖的package包/类
public <TRep> DataReader<TRep> getReplyDataReader(Class<?> replyType);
示例12: getReplyDataReader
import org.omg.dds.sub.DataReader; //导入依赖的package包/类
public DataReader<TRep> getReplyDataReader();
示例13: getRequestDataReader
import org.omg.dds.sub.DataReader; //导入依赖的package包/类
public <TReq> DataReader<TReq> getRequestDataReader(Class<?> requestType);