当前位置: 首页>>代码示例>>Java>>正文


Java DataReader类代码示例

本文整理汇总了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) {

        }
    });
}
 
开发者ID:ADLINK-IST,项目名称:vortex-spark,代码行数:61,代码来源:VortexHashtagReporter.java

示例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();
            }
        }
    });
}
 
开发者ID:ADLINK-IST,项目名称:vortex-spark,代码行数:44,代码来源:VortexReceiver.java

示例3: SubscriptionMatchedEvent

import org.omg.dds.sub.DataReader; //导入依赖的package包/类
protected SubscriptionMatchedEvent(DataReader<TYPE> source) {
    super(source);
}
 
开发者ID:davnoe,项目名称:dds-psm-java,代码行数:4,代码来源:SubscriptionMatchedEvent.java

示例4: SampleRejectedEvent

import org.omg.dds.sub.DataReader; //导入依赖的package包/类
protected SampleRejectedEvent(DataReader<TYPE> source) {
    super(source);
}
 
开发者ID:davnoe,项目名称:dds-psm-java,代码行数:4,代码来源:SampleRejectedEvent.java

示例5: RequestedDeadlineMissedEvent

import org.omg.dds.sub.DataReader; //导入依赖的package包/类
protected RequestedDeadlineMissedEvent(DataReader<TYPE> source) {
    super(source);
}
 
开发者ID:davnoe,项目名称:dds-psm-java,代码行数:4,代码来源:RequestedDeadlineMissedEvent.java

示例6: LivelinessChangedEvent

import org.omg.dds.sub.DataReader; //导入依赖的package包/类
protected LivelinessChangedEvent(DataReader<TYPE> source) {
    super(source);
}
 
开发者ID:davnoe,项目名称:dds-psm-java,代码行数:4,代码来源:LivelinessChangedEvent.java

示例7: RequestedIncompatibleQosEvent

import org.omg.dds.sub.DataReader; //导入依赖的package包/类
protected RequestedIncompatibleQosEvent(DataReader<TYPE> source) {
    super(source);
}
 
开发者ID:davnoe,项目名称:dds-psm-java,代码行数:4,代码来源:RequestedIncompatibleQosEvent.java

示例8: SampleLostEvent

import org.omg.dds.sub.DataReader; //导入依赖的package包/类
protected SampleLostEvent(DataReader<TYPE> source) {
    super(source);
}
 
开发者ID:davnoe,项目名称:dds-psm-java,代码行数:4,代码来源:SampleLostEvent.java

示例9: DataAvailableEvent

import org.omg.dds.sub.DataReader; //导入依赖的package包/类
protected DataAvailableEvent(DataReader<TYPE> source) {
    super(source);
}
 
开发者ID:davnoe,项目名称:dds-psm-java,代码行数:4,代码来源:DataAvailableEvent.java

示例10: getRequestDataReader

import org.omg.dds.sub.DataReader; //导入依赖的package包/类
public DataReader<TReq> getRequestDataReader(); 
开发者ID:rticommunity,项目名称:dds-rpc-java,代码行数:2,代码来源:Replier.java

示例11: getReplyDataReader

import org.omg.dds.sub.DataReader; //导入依赖的package包/类
public <TRep> DataReader<TRep> getReplyDataReader(Class<?> replyType); 
开发者ID:rticommunity,项目名称:dds-rpc-java,代码行数:2,代码来源:ClientEndpoint.java

示例12: getReplyDataReader

import org.omg.dds.sub.DataReader; //导入依赖的package包/类
public DataReader<TRep> getReplyDataReader(); 
开发者ID:rticommunity,项目名称:dds-rpc-java,代码行数:2,代码来源:Requester.java

示例13: getRequestDataReader

import org.omg.dds.sub.DataReader; //导入依赖的package包/类
public <TReq> DataReader<TReq> getRequestDataReader(Class<?> requestType); 
开发者ID:rticommunity,项目名称:dds-rpc-java,代码行数:2,代码来源:ServiceEndpoint.java


注:本文中的org.omg.dds.sub.DataReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。