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


Java Flux.fromIterable方法代码示例

本文整理汇总了Java中reactor.core.publisher.Flux.fromIterable方法的典型用法代码示例。如果您正苦于以下问题:Java Flux.fromIterable方法的具体用法?Java Flux.fromIterable怎么用?Java Flux.fromIterable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在reactor.core.publisher.Flux的用法示例。


在下文中一共展示了Flux.fromIterable方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readEmployeesByDescAge

import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Override
public Flux<Employee> readEmployeesByDescAge() {
	Scheduler subWorker = Schedulers.newSingle("sub-thread");
	Scheduler pubWorker = Schedulers.newSingle("pub-thread");
	Supplier<Flux<Employee>> deferredTask = ()->{
		System.out.println("flux:defer task executor: "+ Thread.currentThread().getName());
		System.out.println("flux:defer task executor login: " + SecurityContextHolder.getContext().getAuthentication().getPrincipal());
		return Flux.fromIterable(employeeDaoImpl.getEmployees());
	};
	Comparator<Employee> descAge = (e1, e2) -> {
		System.out.println("flux:sort task executor: " + Thread.currentThread().getName());
		System.out.println("flux:sort task executor login: " + SecurityContextHolder.getContext().getAuthentication().getPrincipal());
		if(e1.getAge().compareTo(e2.getAge()) == 0){
			return 0;
		} else if(e1.getAge().compareTo(e2.getAge()) > 0){
			return -1;
		} else return 1;
	};
	Flux<Employee> deferred = Flux.defer(deferredTask).sort(descAge).subscribeOn(subWorker).publishOn(pubWorker);
	return deferred;
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:22,代码来源:EmployeeServiceImpl.java

示例2: readEmployeesFlux

import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Override
public Flux<Employee> readEmployeesFlux(int age) {
	Scheduler subWorker = Schedulers.newSingle("sub-thread");
	Scheduler pubWorker = Schedulers.newSingle("pub-thread");
	Predicate<Employee> validAge = (e) -> {
		System.out.println("flux:filter task executor: " + Thread.currentThread().getName());
		System.out.println("flux:filter task executor login: " + SecurityContextHolder.getContext().getAuthentication().getPrincipal());
		return e.getAge() > age;
	};
	Supplier<Flux<Employee>> deferredTask = ()->{
		System.out.println("flux:defer task executor: " + Thread.currentThread().getName());
		System.out.println("flux:defer task executor login: " + SecurityContextHolder.getContext().getAuthentication().getPrincipal());
		return Flux.fromIterable(employeeDaoImpl.getEmployees());
	};
	Flux<Employee> deferred = Flux.defer(deferredTask).filter(validAge).subscribeOn(subWorker).publishOn(pubWorker);
	return deferred;
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:18,代码来源:EmployeeServiceImpl.java

示例3: createPubAndMain

import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Override
public Flux<Employee> createPubAndMain() {
	Scheduler pubWorker = Schedulers.newSingle("pub-thread");
	Predicate<Employee> validAge = (e) -> {
		System.out.println("filter thread " +Thread.currentThread().getName());
		return e.getAge() > 25;
	};
	Supplier<Flux<Employee>> deferredTask = ()->{
		System.out.println("defer thread "+Thread.currentThread().getName());
		return Flux.fromIterable(employeeDaoImpl.getEmployees());
	};
	Flux<Employee> deferred = Flux.defer(deferredTask).publishOn(pubWorker).filter(validAge);
	return deferred;
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:15,代码来源:EmployeeScheduledStreamServiceImpl.java

示例4: createPublisherThread

import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@Override
public Flux<Employee> createPublisherThread() {
	Scheduler pubWorker = Schedulers.newSingle("pub-thread");
	Predicate<Employee> validAge = (e) -> {
		System.out.println("filter thread " +Thread.currentThread().getName());
		return e.getAge() > 25;
	};
	Supplier<Flux<Employee>> deferredTask = ()->{
		System.out.println("defer thread "+Thread.currentThread().getName());
		return Flux.fromIterable(employeeDaoImpl.getEmployees());
	};
	Flux<Employee> deferred = Flux.defer(deferredTask).filter(validAge).publishOn(pubWorker);
	return deferred;
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:15,代码来源:EmployeeScheduledStreamServiceImpl.java

示例5: fooBarFluxFromValues

import reactor.core.publisher.Flux; //导入方法依赖的package包/类
Flux<String> fooBarFluxFromValues() {
    return Flux.fromIterable(Arrays.asList("foo", "bar"));
}
 
开发者ID:aliaksei-lithium,项目名称:spring5demo,代码行数:4,代码来源:FluxSampleTest.java

示例6: findAll

import reactor.core.publisher.Flux; //导入方法依赖的package包/类
Flux<Post> findAll() {
    return Flux.fromIterable(data.values());
}
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:4,代码来源:PostRepository.java

示例7: selectReactDepts

import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@GetMapping("/selectReactDepts")
public Flux<Department> selectReactDepts() {
	return Flux.fromIterable(departmentServiceImpl.findAllDepts());
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:5,代码来源:DeptReactiveController.java

示例8: exposeJpaUsers

import reactor.core.publisher.Flux; //导入方法依赖的package包/类
@GetMapping("/fluxJpaUsers")
public Flux<UserDetails> exposeJpaUsers() {
	return Flux.fromIterable(userdetailsServiceImpl.findAllUserdetails());
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:5,代码来源:LoginReactController.java

示例9: findAll

import reactor.core.publisher.Flux; //导入方法依赖的package包/类
Flux<Post> findAll() {
    return Flux.fromIterable(DATA);
}
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:4,代码来源:PostRepository.java

示例10: loginDetailsList

import reactor.core.publisher.Flux; //导入方法依赖的package包/类
public Mono<ServerResponse> loginDetailsList(ServerRequest req) {
	Flux<LoginDetails> flux = Flux.fromIterable(logindetailsServiceImpl.findAllLogindetails());
	return ok().contentType(MediaType.APPLICATION_STREAM_JSON).body(flux, LoginDetails.class);
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:5,代码来源:LoginHandler.java

示例11: empList

import reactor.core.publisher.Flux; //导入方法依赖的package包/类
public Mono<ServerResponse> empList(ServerRequest req) {
	Flux<Employee> flux = Flux.fromIterable(employeeServiceImpl.findAllEmps());
	return ok().contentType(MediaType.APPLICATION_STREAM_JSON).body(flux, Employee.class);
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:5,代码来源:EmpDataHandler.java

示例12: deptList

import reactor.core.publisher.Flux; //导入方法依赖的package包/类
public Mono<ServerResponse> deptList(ServerRequest req) {
	Flux<Department> flux = Flux.fromIterable(departmentServiceImpl.findAllDepts());
	return ok().contentType(MediaType.APPLICATION_STREAM_JSON).body(flux, Department.class);
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:5,代码来源:DeptDataHandler.java

示例13: userDetailsList

import reactor.core.publisher.Flux; //导入方法依赖的package包/类
public Mono<ServerResponse> userDetailsList(ServerRequest req) {
	Flux<UserDetails> flux = Flux.fromIterable(userdetailsServiceImpl.findAllUserdetails());
	return ok().contentType(MediaType.APPLICATION_STREAM_JSON).body(flux, UserDetails.class);
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:5,代码来源:LoginHandler.java

示例14: chooseUserByLastName

import reactor.core.publisher.Flux; //导入方法依赖的package包/类
public Mono<ServerResponse> chooseUserByLastName(ServerRequest req) {
	Flux<UserDetails> flux = Flux.fromIterable(userdetailsServiceImpl.findUserByLastname(req.pathVariable("lname")));
	return ok().contentType(MediaType.APPLICATION_STREAM_JSON).body(flux, UserDetails.class)
			.switchIfEmpty(ServerResponse.notFound().build());
}
 
开发者ID:PacktPublishing,项目名称:Spring-5.0-Cookbook,代码行数:6,代码来源:LoginHandler.java


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