• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ResponseBodyEmitter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter的典型用法代码示例。如果您正苦于以下问题:Java ResponseBodyEmitter类的具体用法?Java ResponseBodyEmitter怎么用?Java ResponseBodyEmitter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ResponseBodyEmitter类属于org.springframework.web.servlet.mvc.method.annotation包,在下文中一共展示了ResponseBodyEmitter类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getJobLogStream

import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; //导入依赖的package包/类
@RequestMapping(value = "/{job:.*}/logStream", method = GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseBodyEmitter getJobLogStream(@PathVariable("job") String job) {
    JobInstance ji = jobsManager.getJob(job);
    ExtendedAssert.notFound(ji, "Job was not found by id: " + job);
    ResponseBodyEmitter emitter = new ResponseBodyEmitter(TimeUnit.MINUTES.toMillis(10L));
    JobEventConsumer consumer = new JobEventConsumer(this.jobsManager, emitter, ji);
    ji.atEnd().addListener(() -> {
        // it need for job which finish before request
        emitter.complete();
    }, ExecutorUtils.DIRECT);
    // TODO  we may want to consume history, also.
    Subscription subs = jobsManager.getSubscriptions().openSubscriptionOnKey(consumer, ji.getInfo());
    emitter.onCompletion(() -> {
        // Emitter not invoke this at client disconnect,
        //  may be it will be fix in future versions
        subs.close();
    });
    return emitter;
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:20,代码来源:JobApi.java


示例2: fillEmitterByBamTrack

import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; //导入依赖的package包/类
private void fillEmitterByBamTrack(final Track<Read> track, final BamQueryOption options,
                                             ResponseBodyEmitter emitter) throws IOException {
    final BamTrackEmitter bamTrackEmitter = new BamTrackEmitter(emitter);

    // TODO: track.getEndIndex() - track.getStartIndex() > maxCoverageRange
    if (options.getMode() == BamTrackMode.REGIONS) {
        taskExecutorService.executeTrackTask(
            bamTrackEmitter, SEQUENTIAL,
            () -> bamTrackEmitter.writeTrackAndFinish(bamHelper.getRegionsFromFile(track))
        );
    } else {
        taskExecutorService.executeTrackTask(
            bamTrackEmitter, ASYNC,
            () -> bamHelper.getReadsFromFile(track, options, bamTrackEmitter)
        );
    }
}
 
开发者ID:epam,项目名称:NGB,代码行数:18,代码来源:BamManager.java


示例3: fillEmitterByBamTrackFromURL

import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; //导入依赖的package包/类
private void fillEmitterByBamTrackFromURL(final Track<Read> track, String bamUrl, String indexUrl,
                                                    final BamQueryOption options, ResponseBodyEmitter emitter)
        throws IOException {
    final BamTrackEmitter bamTrackEmitter = new BamTrackEmitter(emitter);

    if (track.getEndIndex() - track.getStartIndex() > maxCoverageRange) {
        taskExecutorService.executeTrackTask(
            bamTrackEmitter, SEQUENTIAL,
            () -> bamTrackEmitter.writeTrackAndFinish(bamHelper.getRegionsFromUrl(track, bamUrl, indexUrl))
        );
    } else {
        taskExecutorService.executeTrackTask(
            bamTrackEmitter, ASYNC,
            () -> bamHelper.fillEmitterByReadsFromUrl(track, bamUrl, indexUrl, options, bamTrackEmitter)
        );
    }
}
 
开发者ID:epam,项目名称:NGB,代码行数:18,代码来源:BamManager.java


示例4: handle

import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; //导入依赖的package包/类
@RequestMapping(value = "/ws/event")
@ResponseBody
public ResponseEntity<ResponseBodyEmitter> handle() {
    ResponseBodyEmitter emitter = new ResponseBodyEmitter();

    executorService.execute(() -> {
        try {
            for (int i = 0 ; i<10 ;i++) {
                emitter.send("event: datetime\n");
                emitter.send("data: " + LocalDateTime.now().toString() + "\n\n");
                Thread.sleep(1000);
            }

            emitter.complete();
        } catch (Exception e) {
            LOG.error(e.getMessage(), e);
        }
    });

    return ResponseEntity.ok().contentType(MediaType.parseMediaType("text/event-stream")).body(emitter);
}
 
开发者ID:victorbuckservices,项目名称:workshop-spring-4.0-to-4.2,代码行数:22,代码来源:EventController.java


示例5: ResponseBodyEmitterObserver

import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; //导入依赖的package包/类
public ResponseBodyEmitterObserver(MediaType mediaType, Observable<T> observable, ResponseBodyEmitter responseBodyEmitter) {

        this.mediaType = mediaType;
        this.responseBodyEmitter = responseBodyEmitter;
        this.responseBodyEmitter.onTimeout(this);
        this.responseBodyEmitter.onCompletion(this);
        observable.subscribe(this);
    }
 
开发者ID:jmnarloch,项目名称:rxjava-spring-boot-starter,代码行数:9,代码来源:ResponseBodyEmitterObserver.java


示例6: update

import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; //导入依赖的package包/类
@RequestMapping(value = "/clusters/{cluster}/containers/update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseBodyEmitter update(@PathVariable("cluster") String cluster,
                                  @RequestBody UiUpdateContainers req) {
    log.info("got scale update request: {}", req);
    JobParameters params = createParametersString(cluster, req);

    ResponseBodyEmitter emitter = new ResponseBodyEmitter(TimeUnit.MINUTES.toMillis(10L));
    JobInstance jobInstance = jobsManager.create(params);
    JobApi.JobEventConsumer consumer = new JobApi.JobEventConsumer(this.jobsManager, emitter, jobInstance);
    jobsManager.getSubscriptions().subscribeOnKey(consumer, jobInstance.getInfo());
    log.info("Try start job: {}", params);
    jobInstance.start();
    return emitter;
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:15,代码来源:UiUpdateContainersController.java


示例7: sendBamTrackToEmitter

import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; //导入依赖的package包/类
/**
 * Returns {@code Track} filled with BAM data from a specified BAM file in the server's file system
 * @param track input track
 * @param option BAM track options
 * @param emitter where to write data
 * @throws IOException on resource reading errors
 */
public void sendBamTrackToEmitter(final Track<Read> track, BamQueryOption option, ResponseBodyEmitter emitter)
        throws IOException {
    final Chromosome chromosome = trackHelper.validateTrack(track);
    BamQueryOption currentOptions = option == null ? new BamQueryOption() : option;
    BamUtil.validateOptions(currentOptions, chromosome);
    fillEmitterByBamTrack(track, currentOptions, emitter);
}
 
开发者ID:epam,项目名称:NGB,代码行数:15,代码来源:BamManager.java


示例8: BamTrackEmitter

import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; //导入依赖的package包/类
public BamTrackEmitter(ResponseBodyEmitter emitter) throws IOException {
    this.emitter = emitter;
    this.stringBuffer = new StringBuilder(BUFFER_SIZE);
    this.jsonMapper = new JsonMapper();

    writeHeader();
}
 
开发者ID:epam,项目名称:NGB,代码行数:8,代码来源:BamTrackEmitter.java


示例9: ResponseBodyEmitterSubscriber

import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; //导入依赖的package包/类
public ResponseBodyEmitterSubscriber(HttpHeaders request, MediaType mediaType,
		Publisher<?> observable, ResponseBodyEmitter responseBodyEmitter,
		boolean json) {

	this.request = request;
	this.mediaType = mediaType;
	this.responseBodyEmitter = responseBodyEmitter;
	this.json = json;
	this.responseBodyEmitter.onTimeout(new Timeout());
	this.responseBodyEmitter.onCompletion(new Complete());
	this.single = observable instanceof Mono;
	observable.subscribe(this);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-function,代码行数:14,代码来源:ResponseBodyEmitterSubscriber.java


示例10: getEmitter

import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; //导入依赖的package包/类
private ResponseBodyEmitter getEmitter(Long timeout, Publisher<?> flux,
		MediaType mediaType, HttpHeaders request) {
	Publisher<?> exported = flux instanceof Mono ? Mono.from(flux)
			: Flux.from(flux).timeout(Duration.ofMillis(timeout), Flux.empty());
	if (!MediaType.ALL.equals(mediaType)
			&& EVENT_STREAM.isCompatibleWith(mediaType)) {
		// TODO: more subtle content negotiation
		return new FluxResponseSseEmitter(request, MediaType.APPLICATION_JSON,
				exported);
	}
	return new FluxResponseBodyEmitter(request, mediaType, exported);
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-function,代码行数:13,代码来源:FluxReturnValueHandler.java


示例11: JobEventConsumer

import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; //导入依赖的package包/类
public JobEventConsumer(JobsManager jobsManager, ResponseBodyEmitter emitter, JobInstance jobInstance) {
    this.jobsManager = jobsManager;
    this.emitter = emitter;
    this.jobInstance = jobInstance;
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:6,代码来源:JobApi.java


示例12: data

import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; //导入依赖的package包/类
@RequestMapping(value = "/bam/track/get", method = RequestMethod.POST)
@ApiOperation(
        value = "Returns data (chunked) matching the given query to fill in a bam track. Returns all information " +
                "about reads.",
        notes = NOTES +
                "<br/>option:<br/>" +
                "all the following params are <b>optional</b>, if any of the params is incorrect, " +
                "it will be set to default value:<br/><br/>" +
                "1) <b>trackDirection</b> - can be 'LEFT', 'MIDDLE' or 'RIGHT', responsible for direction <br/>" +
                "default - MIDDLE" +
                "2) <b>showClipping</b> - if true handles the track with soft clipping, default is false;<br/>" +
                "3) <b>showSpliceJunction</b> - return a information about splice junction, " +
                "default is false;<br/>" +
                "4) <b>frame</b> - size of frame for downsampling,  default is null;<br/>" +
                "5) <b>count</b> - count of read in frame, default is null ;<br/>" +
                "if frame or count default or incorrect, return track without downsampling<br/>" +
                "6) <b>mode</b> controls BAM display mode: REGIONS - return only regions of possible read " +
                "location; <br/>" +
                "COVERAGE - return only BAM coverage;<br/>" +
                "FULL - return both reads and coverage",
        produces = MediaType.APPLICATION_JSON_VALUE)
@ApiResponses(
        value = {@ApiResponse(code = HTTP_STATUS_OK, message = API_STATUS_DESCRIPTION)
        })
public final ResponseEntity<ResponseBodyEmitter> loadTrackStream(
        @RequestBody final TrackQuery query,
        @RequestParam(required = false) final String fileUrl,
        @RequestParam(required = false) final String indexUrl)
        throws IOException {

    final ResponseBodyEmitter emitter = new ResponseBodyEmitter(EMITTER_TIMEOUT);
    if (fileUrl == null) {
        bamManager.sendBamTrackToEmitter(convertToTrack(query), query.getOption(), emitter);
    } else {
        bamManager.sendBamTrackToEmitterFromUrl(convertToTrack(query), query.getOption(), fileUrl,
                indexUrl, emitter);
    }

    HttpHeaders responseHeaders = new HttpHeaders();
    responseHeaders.setContentType(MediaType.APPLICATION_JSON_UTF8);
    return new ResponseEntity<>(emitter, responseHeaders, HttpStatus.OK);
}
 
开发者ID:epam,项目名称:NGB,代码行数:43,代码来源:BamController.java


示例13: sendBamTrackToEmitterFromUrl

import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter; //导入依赖的package包/类
/**
 * Returns {@code Track} filled with BAM data from a specified URL
 * @param track input track
 * @param option BAM track options
 * @param bamUrl path to BAM file
 * @param indexUrl path to Bam index file
 * @param emitter where to write data
 * @throws IOException on resource reading errors
 */
public void sendBamTrackToEmitterFromUrl(final Track<Read> track, BamQueryOption option, String bamUrl,
                                                   String indexUrl, ResponseBodyEmitter emitter)
        throws IOException {
    final Chromosome chromosome = trackHelper.validateUrlTrack(track, bamUrl, indexUrl);
    BamQueryOption currentOptions = option == null ? new BamQueryOption() : option;
    BamUtil.validateOptions(currentOptions, chromosome);
    fillEmitterByBamTrackFromURL(track, bamUrl, indexUrl, currentOptions, emitter);
}
 
开发者ID:epam,项目名称:NGB,代码行数:18,代码来源:BamManager.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DateProperty类代码示例发布时间:2022-05-22
下一篇:
Java DefaultAttribute类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap